GwyDataView — Data field displaying area
char * | data-prefix | Read / Write |
double | zoom | Read / Write |
void | layer-plugged | Run First |
void | layer-unplugged | Run First |
void | redrawn | Run First |
void | resized | Run First |
struct | GwyDataView |
struct | GwyDataViewClass |
GObject ╰── GInitiallyUnowned ╰── GtkObject ╰── GtkWidget ╰── GwyDataView
GwyDataView implements AtkImplementorIface and GtkBuildable.
#include <libgwydgets/gwydgets.h>
GwyDataView is a basic two-dimensional data display widget. The actual
rendering is performed by one or more GwyDataViewLayer's, pluggable into
the data view. Each layer generally displays different data field from
the container supplied to gwy_data_view_new()
.
A base layer (set with gwy_data_view_set_base_layer()
) must be always
present, and normally it is always a GwyLayerBasic.
Other layers are optional. Middle, or alpha, layer (set with
gwy_data_view_set_alpha_layer()
) used to display masks is normally always
a GwyLayerMask. Top layer, if present, is a GwyVectorLayer allowing to
draw selections with mouse and otherwise interace with the view, it is set
with gwy_data_view_set_top_layer()
.
The size of a data view is affected by two factors: zoom and outer
constraints. If an explicit size set by window manager or by Gtk+ means, the
view scales the displayed data to fit into this size (while keeping x/y
ratio). Zoom controlls the size a data view requests, and can be set with
gwy_data_view_set_zoom()
.
Several helper functions are available for transformation between screen
coordinates in the view and physical coordinates in the displayed data
field: gwy_data_view_coords_xy_to_real()
, gwy_data_view_get_xmeasure()
,
gwy_data_view_get_hexcess()
, and others. Physical coordinates are always
taken from data field displayed by base layer.
GtkWidget *
gwy_data_view_new (GwyContainer *data
);
Creates a new data-displaying widget for data
.
A newly created GwyDataView doesn't display anything. You have to add
some layers to it, at least a base layer with
gwy_data_view_set_base_layer()
, and possibly others with
gwy_data_view_set_alpha_layer()
and gwy_data_view_set_top_layer()
.
The top layer is special. It must be a vector layer and can receive mouse and keyboard events.
The base layer it also special. It must be always present, and must not be transparent or vector.
data |
A GwyContainer containing the data to display. |
A newly created data view as a GtkWidget.
GwyPixmapLayer *
gwy_data_view_get_base_layer (GwyDataView *data_view
);
Returns the base layer this data view currently uses.
A base layer should be always present.
data_view |
A data view. |
The currently used base layer.
void gwy_data_view_set_base_layer (GwyDataView *data_view
,GwyPixmapLayer *layer
);
Plugs layer
to data_view
as the base layer.
If another base layer is present, it's unplugged.
The layer must not be a vector layer. Theoretically, it can be NULL
to
use no base layer, but then data_view
will probably display garbage.
data_view |
A data view. |
|
layer |
A layer to be used as the base layer for |
GwyPixmapLayer *
gwy_data_view_get_alpha_layer (GwyDataView *data_view
);
Returns the alpha layer this data view currently uses, or NULL
if none
is present.
data_view |
A data view. |
The currently used alpha layer.
void gwy_data_view_set_alpha_layer (GwyDataView *data_view
,GwyPixmapLayer *layer
);
Plugs layer
to data_view
as the alpha layer.
If another alpha layer is present, it's unplugged.
The layer must not be a vector layer. It can be NULL
, meaning no alpha
layer is to be used.
data_view |
A data view. |
|
layer |
A layer to be used as the alpha layer for |
GwyVectorLayer *
gwy_data_view_get_top_layer (GwyDataView *data_view
);
Returns the top layer this data view currently uses, or NULL
if none
is present.
data_view |
A data view. |
The currently used top layer.
void gwy_data_view_set_top_layer (GwyDataView *data_view
,GwyVectorLayer *layer
);
Plugs layer
to data_view
as the top layer.
If another top layer is present, it's unplugged.
The layer must be a vector layer. It can be NULL
, meaning no top
layer is to be used.
data_view |
A data view. |
|
layer |
A layer to be used as the top layer for |
const gchar *
gwy_data_view_get_data_prefix (GwyDataView *data_view
);
Gets the prefix for the container data channel that the data view is currently set to display.
data_view |
A data view. |
The container data prefix (eg. "/0/data").
void gwy_data_view_set_data_prefix (GwyDataView *data_view
,const gchar *prefix
);
Sets the prefix for the container data channel to display in a data view.
This function only affects where the data view itself takes parameters from, it does not affect layer keys.
data_view |
A data view. |
|
prefix |
Container prefix for data (eg. "/0/data"). |
gdouble
gwy_data_view_get_hexcess (GwyDataView *data_view
);
Return the horizontal excess of widget size to data size.
Do not use. Only useful for GwyDataWindow implementation.
data_view |
A data view. |
The execess.
gdouble
gwy_data_view_get_vexcess (GwyDataView *data_view
);
Return the vertical excess of widget size to data size.
Do not use. Only useful for GwyDataWindow implementation.
data_view |
A data view. |
The execess.
void gwy_data_view_set_zoom (GwyDataView *data_view
,gdouble zoom
);
Sets zoom of data_view
to zoom
.
Zoom greater than 1 means larger image on screen and vice versa.
Note window manager can prevent the window from resize and thus the zoom from change.
data_view |
A data view. |
|
zoom |
A new zoom value. |
gdouble
gwy_data_view_get_zoom (GwyDataView *data_view
);
Returns current ideal zoom of a data view.
More precisely the zoom value requested by gwy_data_view_set_zoom()
, if
it's in use (real zoom may differ a bit due to pixel rounding). If zoom
was set by explicite widget size change, real and requested zoom are
considered to be the same.
When a resize is queued, the new zoom value is returned.
In other words, this is the zoom data_view
would like to have. Use
gwy_data_view_get_real_zoom()
to get the real zoom.
data_view |
A data view. |
The zoom as a ratio between ideal displayed size and base data field size.
gdouble
gwy_data_view_get_real_zoom (GwyDataView *data_view
);
Returns current real zoom of a data view.
This is the zoom value a data view may not wish to have, but was imposed
by window manager or other constraints. Unlike ideal zoom set by
gwy_data_view_set_zoom()
, this value cannot be set.
When a resize is queued, the current (old) value is returned.
data_view |
A data view. |
The zoom as a ratio between real displayed size and base data field size.
GwyContainer *
gwy_data_view_get_data (GwyDataView *data_view
);
Returns the data container used by data_view
.
data_view |
A data view. |
The data as a GwyContainer.
void gwy_data_view_coords_xy_clamp (GwyDataView *data_view
,gint *xscr
,gint *yscr
);
Fixes screen coordinates xscr
and yscr
to be inside the data-displaying
area (which can be smaller than widget size).
data_view |
A data view. |
|
xscr |
A screen x-coordinate relative to widget origin. |
|
yscr |
A screen y-coordinate relative to widget origin. |
void gwy_data_view_coords_xy_cut_line (GwyDataView *data_view
,gint *x0scr
,gint *y0scr
,gint *x1scr
,gint *y1scr
);
Fixes screen coordinates of line endpoints to be inside the data-displaying area (which can be smaller than widget size).
data_view |
A data view. |
|
x0scr |
First point screen x-coordinate relative to widget origin. |
|
y0scr |
First point screen y-coordinate relative to widget origin. |
|
x1scr |
Second point screen x-coordinate relative to widget origin. |
|
y1scr |
Second point screen y-coordinate relative to widget origin. |
Since: 2.11
void gwy_data_view_coords_xy_to_real (GwyDataView *data_view
,gint xscr
,gint yscr
,gdouble *xreal
,gdouble *yreal
);
Recomputes screen coordinates relative to widget origin to physical coordinates in the sample.
Note that data fields offsets are not taken into
account. Coordinates xreal
, yreal
are just relative coordinates to the
top left field corner.
data_view |
A data view. |
|
xscr |
A screen x-coordinate relative to widget origin. |
|
yscr |
A screen y-coordinate relative to widget origin. |
|
xreal |
Where the physical x-coordinate in the data sample should be stored. |
|
yreal |
Where the physical y-coordinate in the data sample should be stored. |
void gwy_data_view_coords_real_to_xy (GwyDataView *data_view
,gdouble xreal
,gdouble yreal
,gint *xscr
,gint *yscr
);
Recomputes physical coordinate in the sample to screen coordinate relative to widget origin.
Note that data fields offsets are not taken into
account. Coordinates xreal
, yreal
are just relative coordinates to the
top left field corner.
data_view |
A data view. |
|
xreal |
A physical x-coordinate in the data sample. |
|
yreal |
A physical y-coordinate in the data sample. |
|
xscr |
Where the screen x-coordinate relative to widget origin should be stored. |
|
yscr |
Where the screen y-coordinate relative to widget origin should be stored. |
void gwy_data_view_coords_real_to_xy_float (GwyDataView *data_view
,gdouble xreal
,gdouble yreal
,gdouble *xscr
,gdouble *yscr
);
Recomputes physical coordinate in the sample to screen coordinate relative to widget origin, keeping them as floating point values.
Note that data fields offsets are not taken into
account. Coordinates xreal
, yreal
are just relative coordinates to the
top left field corner.
data_view |
A data view. |
|
xreal |
A physical x-coordinate in the data sample. |
|
yreal |
A physical y-coordinate in the data sample. |
|
xscr |
Where the screen x-coordinate relative to widget origin should be stored. |
|
yscr |
Where the screen y-coordinate relative to widget origin should be stored. |
Since: 2.45
gdouble
gwy_data_view_get_xmeasure (GwyDataView *data_view
);
Returns the ratio between horizontal physical lengths and horizontal screen lengths in pixels.
data_view |
A data view. |
The horizontal measure.
gdouble
gwy_data_view_get_ymeasure (GwyDataView *data_view
);
Returns the ratio between vertical physical lengths and horizontal screen lengths in pixels.
data_view |
A data view. |
The vertical measure.
void gwy_data_view_get_pixel_data_sizes (GwyDataView *data_view
,gint *xres
,gint *yres
);
Obtains pixel dimensions of data displayed by a data view.
This is a convenience method, the same values could be obtained
by gwy_data_field_get_xres()
and gwy_data_field_get_yres()
of the data
field displayed by the base layer.
data_view |
A data view. |
|
xres |
Location to store x-resolution of displayed data (or |
|
yres |
Location to store y-resolution of displayed data (or |
void gwy_data_view_get_real_data_sizes (GwyDataView *data_view
,gdouble *xreal
,gdouble *yreal
);
Obtains physical dimensions of data displayed by a data view.
Physical coordinates are always taken from data field displayed by the base
layer. This is a convenience method, the same values could be obtained
by gwy_data_field_get_xreal()
and gwy_data_field_get_yreal()
of the data
field displayed by the base layer.
data_view |
A data view. |
|
xreal |
Location to store physical x-dimension of the displayed data
without excess (or |
|
yreal |
Location to store physical y-dimension of the displayed data
without excess (or |
void gwy_data_view_get_real_data_offsets (GwyDataView *data_view
,gdouble *xoffset
,gdouble *yoffset
);
Obtains physical offsets of data displayed by a data view.
Physical coordinates are always taken from data field displayed by the base
layer. This is a convenience method, the same values could be obtained
by gwy_data_field_get_xoffset()
and gwy_data_field_get_yoffset()
of the data
field displayed by the base layer.
data_view |
A data view. |
|
xoffset |
Location to store physical x-offset of the top corner of
displayed data without excess (or |
|
yoffset |
Location to store physical y-offset of the top corner of
displayed data without excess (or |
Since: 2.16
void gwy_data_view_get_metric (GwyDataView *data_view
,gdouble *metric
);
Fills metric matrix for a data view.
The metric matrix essentially transforms distances in physical coordinates
to screen distances. It is to be used with functions like
gwy_math_find_nearest_point()
and gwy_math_find_nearest_line()
when the
distance should be screen-Euclidean.
data_view |
A data view. |
|
metric |
Metric matrix 2x2 (stored in sequentially by rows: m11, m12, m12, m22). |
GdkPixbuf * gwy_data_view_get_pixbuf (GwyDataView *data_view
,gint max_width
,gint max_height
);
Creates and returns a pixbuf from the data view.
If the data is not square, the resulting pixbuf is also nonsquare. The returned pixbuf also never has an alpha channel.
data_view |
A data view. |
|
max_width |
Pixbuf width that should not be exceeeded. Value smaller than 1 means unlimited size. |
|
max_height |
Pixbuf height that should not be exceeeded. Value smaller than 1 means unlimited size. |
The pixbuf as a newly created GdkPixbuf, it should be freed
when no longer needed. It is never larger than the actual data
size, as max_width
and max_height
are only upper limits.
GdkPixbuf * gwy_data_view_export_pixbuf (GwyDataView *data_view
,gdouble zoom
,gboolean draw_alpha
,gboolean draw_top
);
Exports data view to a pixbuf.
data_view |
A data view. |
|
zoom |
Zoom to export data with (unrelated to data view zoom). |
|
draw_alpha |
|
|
draw_top |
|
A newly created pixbuf, it must be freed by caller.
struct GwyDataView;
struct GwyDataViewClass { GtkWidgetClass parent_class; /* Signals */ void (*redrawn)(GwyDataView *data_view); void (*resized)(GwyDataView *data_view); void (*layer_plugged)(GwyDataView *data_view, GwyDataViewLayerType layer); void (*layer_unplugged)(GwyDataView *data_view, GwyDataViewLayerType layer); void (*reserved1)(void); void (*reserved2)(void); };
“data-prefix”
property“data-prefix” char *
The :data-prefix property is the container prefix the data displayed by this view lies under.
Note it is only used for items used by GwyDataView itself, layers have their own keys.
Owner: GwyDataView
Flags: Read / Write
Default value: NULL
“zoom”
property“zoom” double
The :zoom property is the ratio between displayed and real data size.
Owner: GwyDataView
Flags: Read / Write
Allowed values: [0.0625,16]
Default value: 1
“layer-plugged”
signalvoid user_function (GwyDataView *arg1, GwyDataViewLayerType gwydataview, gpointer user_data)
The ::layer-plugged signal is emitted when a layer is plugged into a GwyDataView.
When a layer replaces an existing layer, ::layer-unplugged is emitted once the old layer is unplugged, then ::layer-plugged when the new is plugged.
arg1 |
Which layer was plugged (a GwyDataViewLayerType value). |
|
gwydataview |
The GwyDataView which received the signal. |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“layer-unplugged”
signalvoid user_function (GwyDataView *arg1, GwyDataViewLayerType gwydataview, gpointer user_data)
The ::layer-unplugged signal is emitted when a layer is unplugged from a GwyDataView.
When a layer replaces an existing layer, ::layer-unplugged is emitted once the old layer is unplugged, then ::layer-plugged when the new is plugged.
arg1 |
Which layer was unplugged (a GwyDataViewLayerType value). |
|
gwydataview |
The GwyDataView which received the signal. |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“redrawn”
signalvoid user_function (GwyDataView *gwydataview, gpointer user_data)
The ::redrawn signal is emitted when GwyDataView redraws pixbufs after
an update. That is, when it's the right time to get a new pixbuf from
gwy_data_view_get_pixbuf()
.
gwydataview |
The GwyDataView which received the signal. |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“resized”
signalvoid user_function (GwyDataView *gwydataview, gpointer user_data)
The ::resized signal is emitted when GwyDataView wants to be resized, that is when the dimensions of base data field changes or square mode is changed. Its purpose is to subvert the normal resizing logic of GwyDataWindow (due to geometry hints, its size requests are generally ignored, so an explicit resize is needed). You should usually ignore it.
gwydataview |
The GwyDataView which received the signal. |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
GwyDataWindow -- window combining data view with other controls, GwyDataViewLayer -- layers a data view is composed of,
gwypixfield --low level functions for painting data fields, Gwy3DView -- OpenGL 3D data display