GwyPlainTool — Base class for simple tools
enum | GwyPlainToolChanged |
enum | GwyHoldSelectionFlags |
GwyRectSelectionLabels | |
GwyToolHeldSelection | |
struct | GwyPlainTool |
struct | GwyPlainToolClass |
GObject ╰── GwyTool ╰── GwyPlainTool
#include <app/gwyapp.h>
GType gwy_plain_tool_check_layer_type (GwyPlainTool *plain_tool
,const gchar *name
);
Checks for a required layer type.
If the layer exists, its GType is returned. If it does not exist, zero is returned and a warning message is added
to the tool dialog. In addition, it sets init_failed
to TRUE
.
Therefore, this function should be called early in tool instance initialization and it should not be called again once it fails.
plain_tool |
A plain tool. |
|
name |
Layer type name (e.g. |
The type of the layer, or 0 on failure.
void gwy_plain_tool_connect_selection (GwyPlainTool *plain_tool
,GType layer_type
,const gchar *bname
);
Sets up a plain tool to automatically manage layer selection.
When layer_type
is 0 and bname
NULL
, plain tool stops automatically managing selection (hopefully).
This method performs gwy_plain_tool_ensure_layer()
and gwy_plain_tool_set_selection_key()
, connecting to the
selection and making sure the selection
field always points to the correct selection object (or is NULL
).
The selection_changed
method of GwyPlainToolClass is only invoked for a tool instance once this method was called
to set up the selection tracking.
plain_tool |
A plain tool. |
|
layer_type |
Layer type. Use |
|
bname |
Selection key base name, for example |
void gwy_plain_tool_ensure_layer (GwyPlainTool *plain_tool
,GType layer_type
);
Makes sure a plain tool's layer is of the correct type.
This is a low-level function, normally you would use gwy_plain_tool_connect_selection()
.
plain_tool |
A plain tool. |
|
layer_type |
Layer type. Use |
const gchar * gwy_plain_tool_set_selection_key (GwyPlainTool *plain_tool
,const gchar *bname
);
Constructs selection key from data key and sets it on the vector layer.
This is a low-level function, normally you would use
gwy_plain_tool_connect_selection()
.
plain_tool |
A plain tool. |
|
bname |
Selection key base name, for example |
The full key (as a layer-owned string).
GtkWidget *
gwy_plain_tool_add_clear_button (GwyPlainTool *plain_tool
);
Adds a `Clear' button to a plain tool.
This button works with automatically managed selection (see gwy_plain_tool_connect_selection()
). If you want to
manage selection yourself add the button with gtk_dialog_add_button()
.
plain_tool |
A plain tool. |
The button widget.
gdouble gwy_plain_tool_get_z_average (GwyDataField *data_field
,const gdouble *point
,gint radius
);
Computes average value over a part of data field dfield
.
It is not an error if part of it lies outside the data field borders (it is simply not counted in), however the intersection have to be nonempty.
data_field |
A data field. |
|
point |
Real X and Y-coordinate of area center in physical units. |
|
radius |
Area radius in pixels, 1 means a signle pixel. The actual radius passed to
|
The average value.
void gwy_plain_tool_enable_object_deletion (GwyPlainTool *plain_tool
,GtkTreeView *treeview
);
Enables deletion of selection objects by presssing Delete in a tree view diplaying them.
plain_tool |
A plain tool. |
|
treeview |
A tree view that displays selection objects in order, each row corresponding to one selection object. |
Since: 2.7
void gwy_plain_tool_hold_selection (GwyPlainTool *plain_tool
,GwyHoldSelectionFlags hold_flags
);
Possibly transfers the selection to a new image upon plain tool data switch.
This function should be called from data_switched()
class method in a tool after setting up the layer and
selection. If the selection should be transferred to the new image according to hold_flags
the previous (held)
selection will replace whatever selection might be there currently. Otherwise the new image's selection is
preserved (and in fact held itself).
Selection holding must be enabled in tool instance init function using gwy_plain_tool_enable_selection_holding()
.
plain_tool |
A plain tool. |
|
hold_flags |
Flags controlling when the selection is held (transferred to another image). |
Since: 2.63
void
gwy_plain_tool_enable_selection_holding
(GwyPlainTool *plain_tool
);
Enables selection holding for a plain tool.
Selection holding means that, if certain conditions are satisfied, upon data switch the tool transfers the current selection to the new image, replacing whatever selection might be there.
This function should be called from the instance init function.
Holding is currently unsupported for tools which use multiple selection types.
plain_tool |
A plain tool. |
Since: 2.63
GwyRectSelectionLabels * gwy_rect_selection_labels_new (gboolean none_is_full
,GCallback callback
,gpointer cbdata
);
Creates a table displaying rectangular selection information.
The returned object will destroy itself when the table is destroyed.
none_is_full |
|
|
callback |
Callback to call when the selection is edited. |
|
cbdata |
Data to pass to |
The newly created rectangular selection information, as an opaque pointer. The table widget can be
obtained with gwy_rect_selection_labels_get_table()
.
GtkWidget *
gwy_rect_selection_labels_get_table (GwyRectSelectionLabels *rlabels
);
Gets the table widget of a rectangular selection information.
rlabels |
Rectangular selection information table. |
The table as a GtkWidget.
void gwy_rect_selection_labels_select (GwyRectSelectionLabels *rlabels
,GwySelection *selection
,GwyDataField *dfield
);
Updates selection data using rectangular selection information table.
rlabels |
Rectangular selection information table. |
|
selection |
A rectangular selection to fill information into. |
|
dfield |
A data field to use for real/pixel coordinate transforms. |
gboolean gwy_rect_selection_labels_fill (GwyRectSelectionLabels *rlabels
,GwySelection *selection
,GwyDataField *dfield
,gdouble *selreal
,gint *selpix
);
Updates rectangular selection info display.
It is possible to pass NULL
dfield
but non-NULL
selection
. This can lead to TRUE
return value (if the
selection is non-empty), but the labels will be still cleared as there is no way to convert between real and pixel
coordinates.
rlabels |
Rectangular selection info table. |
|
selection |
A rectangular selection to fill information from. It can be |
|
dfield |
A data field to use for real/pixel coordinate transforms. It can be |
|
selreal |
If not |
|
selpix |
If not |
TRUE
if a selection is present, FALSE
otherwise.
void
gwy_plain_tool_log_add (GwyPlainTool *plain_tool
);
Logs a data modification operation of a plain tool.
This is a convenience wrapper for gwy_app_channel_log_add()
, setting automatically the container, data id and
function name from the tool. It can only be used for simple data modification operations in which the source and
target ids are the same. In more complex cases you have to use gwy_app_channel_log_add()
directly.
plain_tool |
A plain tool. |
Since: 2.35
void gwy_plain_tool_add_param_table (GwyPlainTool *plain_tool
,GwyParamTable *partable
);
Registers a parameter table with a data processing module dialog window.
See gwy_dialog_add_param_table()
for details.
plain_tool |
A plain tool. |
|
partable |
Parameter table to add. |
Since: 2.62
The type of pending changes that accumulated during tool inactivity.
Channel data field was changed. |
||
Mask data field was changed. |
||
Presentation data field was changed. |
||
Selection was changed. |
||
Selection was finished (that is emitted “finished”). |
Flags controlling the selection holding behaviour of tools.
Although any combination of flags is valid, this is mainly so that user's choice is not reset. For any holding to
be done at all the GWY_HOLD_SELECTION_HOLD
flag must be set. If it is unset then GWY_HOLD_SELECTION_OVERWRITE
and GWY_HOLD_SELECTION_CLEAR
do not matter. Similarly, for GWY_HOLD_SELECTION_CLEAR
has any effect only if
overwriting is enabled by setting GWY_HOLD_SELECTION_OVERWRITE
.
Selections are held (transferred to the new image). |
||
Existing selections on the new image is replaced. |
||
If the current image has no selection the selection on the new image is cleared. |
Since: 2.63
typedef struct _GwyRectSelectionLabels GwyRectSelectionLabels;
typedef struct _GwyToolHeldSelection GwyToolHeldSelection;
struct GwyPlainTool;
struct GwyPlainToolClass { GwyToolClass parent_class; void (*data_changed)(GwyPlainTool *plain_tool); void (*mask_changed)(GwyPlainTool *plain_tool); void (*show_changed)(GwyPlainTool *plain_tool); void (*selection_changed)(GwyPlainTool *plain_tool, gint hint); void (*selection_finished)(GwyPlainTool *plain_tool); void (*reserved1)(void); void (*reserved2)(void); void (*reserved3)(void); };