Module gwy :: Class DataView
[hide private]
[frames] | no frames]

Class DataView

source code

Instance Methods [hide private]
 
__init__(data)
Creates a new data-displaying widget for data.
source code
 
get_base_layer()
Returns the base layer this data view currently uses.
source code
 
set_base_layer(layer)
Plugs layer to data_view as the base layer.
source code
 
get_alpha_layer()
Returns the alpha layer this data view currently uses, or None if none is present.
source code
 
set_alpha_layer(layer)
Plugs layer to data_view as the alpha layer.
source code
 
get_top_layer()
Returns the top layer this data view currently uses, or None if none is present.
source code
 
set_top_layer(layer)
Plugs layer to data_view as the top layer.
source code
 
get_data_prefix()
Gets the prefix for the container data channel that the data view is currently set to display.
source code
 
set_data_prefix(prefix)
Sets the prefix for the container data channel to display in a data view.
source code
 
get_hexcess()
Return the horizontal excess of widget size to data size.
source code
 
get_vexcess()
Return the vertical excess of widget size to data size.
source code
 
set_zoom(zoom)
Sets zoom of data_view to zoom.
source code
 
get_zoom()
Returns current ideal zoom of a data view.
source code
 
get_real_zoom()
Returns current real zoom of a data view.
source code
 
get_data()
Returns the data container used by data_view.
source code
 
coords_xy_clamp()
Fixes screen coordinates xscr and yscr to be inside the data-displaying area (which can be smaller than widget size).
source code
 
coords_xy_cut_line()
Fixes screen coordinates of line endpoints to be inside the data-displaying area (which can be smaller than widget size).
source code
 
coords_xy_to_real(xscr, yscr)
Recomputes screen coordinates relative to widget origin to physical coordinates in the sample.
source code
 
coords_real_to_xy(xreal, yreal)
Recomputes physical coordinate in the sample to screen coordinate relative to widget origin.
source code
 
coords_real_to_xy_float(xreal, yreal)
Recomputes physical coordinate in the sample to screen coordinate relative to widget origin, keeping them as floating point values.
source code
 
get_xmeasure()
Returns the ratio between horizontal physical lengths and horizontal screen lengths in pixels.
source code
 
get_ymeasure()
Returns the ratio between vertical physical lengths and horizontal screen lengths in pixels.
source code
 
get_pixel_data_sizes()
Obtains pixel dimensions of data displayed by a data view.
source code
 
get_real_data_sizes()
Obtains physical dimensions of data displayed by a data view.
source code
 
get_real_data_offsets()
Obtains physical offsets of data displayed by a data view.
source code
 
get_pixbuf(max_width, max_height)
Creates and returns a pixbuf from the data view.
source code
 
export_pixbuf(zoom, draw_alpha, draw_top)
Exports data view to a pixbuf.
source code
 
get_metric()
Fills metric matrix for a data view.
source code
Method Details [hide private]

__init__(data)
(Constructor)

source code 

Creates a new data-displaying widget for data.

A newly created DataView doesn't display anything. You have to add some layers to it, at least a base layer with DataView.set_base_layer(), and possibly others with DataView.set_alpha_layer() and DataView.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.

Parameters:
  • data - A Container containing the data to display. (Container)
Returns:
A newly created data view as a GtkWidget. (gtk.Widget)

get_base_layer()

source code 

Returns the base layer this data view currently uses.

A base layer should be always present.

Returns:
The currently used base layer. (PixmapLayer)

set_base_layer(layer)

source code 

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 None to use no base layer, but then data_view will probably display garbage.

Parameters:
  • layer - A layer to be used as the base layer for data_view. (PixmapLayer)

get_alpha_layer()

source code 

Returns the alpha layer this data view currently uses, or None if none is present.

Returns:
The currently used alpha layer. (PixmapLayer)

set_alpha_layer(layer)

source code 

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 None, meaning no alpha layer is to be used.

Parameters:
  • layer - A layer to be used as the alpha layer for data_view. (PixmapLayer)

get_top_layer()

source code 

Returns the top layer this data view currently uses, or None if none is present.

Returns:
The currently used top layer. (VectorLayer)

set_top_layer(layer)

source code 

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 None, meaning no top layer is to be used.

Parameters:
  • layer - A layer to be used as the top layer for data_view. (VectorLayer)

get_data_prefix()

source code 

Gets the prefix for the container data channel that the data view is currently set to display.

Returns:
The container data prefix (eg. "/0/data"). (string)

set_data_prefix(prefix)

source code 

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.

Parameters:
  • prefix - Container prefix for data (eg. "/0/data"). (string)

get_hexcess()

source code 

Return the horizontal excess of widget size to data size.

Do not use. Only useful for DataWindow implementation.

Returns:
The execess. (float)

get_vexcess()

source code 

Return the vertical excess of widget size to data size.

Do not use. Only useful for DataWindow implementation.

Returns:
The execess. (float)

set_zoom(zoom)

source code 

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.

Parameters:
  • zoom - A new zoom value. (float)

get_zoom()

source code 

Returns current ideal zoom of a data view.

More precisely the zoom value requested by DataView.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 DataView.get_real_zoom() to get the real zoom.

Returns:
The zoom as a ratio between ideal displayed size and base data field size. (float)

get_real_zoom()

source code 

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 DataView.set_zoom(), this value cannot be set.

When a resize is queued, the current (old) value is returned.

Returns:
The zoom as a ratio between real displayed size and base data field size. (float)

get_data()

source code 

Returns the data container used by data_view.

Returns:
The data as a Container. (Container)

coords_xy_clamp()

source code 

Fixes screen coordinates xscr and yscr to be inside the data-displaying area (which can be smaller than widget size).

Returns:
Tuple consisting of 2 values (xscr, yscr). ((IntInOutArg), (IntInOutArg))

coords_xy_cut_line()

source code 

Fixes screen coordinates of line endpoints to be inside the data-displaying area (which can be smaller than widget size).

Returns:
Tuple consisting of 4 values (x0scr, y0scr, x1scr, y1scr). ((IntInOutArg), (IntInOutArg), (IntInOutArg), (IntInOutArg))

Since: 2.11

coords_xy_to_real(xscr, yscr)

source code 

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.

Parameters:
  • xscr - A screen x-coordinate relative to widget origin. (int)
  • yscr - A screen y-coordinate relative to widget origin. (int)
Returns:
Tuple consisting of 2 values (xreal, yreal). ((float), (float))

coords_real_to_xy(xreal, yreal)

source code 

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.

Parameters:
  • xreal - A physical x-coordinate in the data sample. (float)
  • yreal - A physical y-coordinate in the data sample. (float)
Returns:
Tuple consisting of 2 values (xscr, yscr). ((int), (int))

coords_real_to_xy_float(xreal, yreal)

source code 

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.

Parameters:
  • xreal - A physical x-coordinate in the data sample. (float)
  • yreal - A physical y-coordinate in the data sample. (float)
Returns:
Tuple consisting of 2 values (xscr, yscr). ((float), (float))

Since: 2.45

get_xmeasure()

source code 

Returns the ratio between horizontal physical lengths and horizontal screen lengths in pixels.

Returns:
The horizontal measure. (float)

get_ymeasure()

source code 

Returns the ratio between vertical physical lengths and horizontal screen lengths in pixels.

Returns:
The vertical measure. (float)

get_pixel_data_sizes()

source code 

Obtains pixel dimensions of data displayed by a data view.

This is a convenience method, the same values could be obtained by DataField.get_xres() and DataField.get_yres() of the data field displayed by the base layer.

Returns:
Tuple consisting of 2 values (xres, yres). ((int), (int))

get_real_data_sizes()

source code 

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 DataField.get_xreal() and DataField.get_yreal() of the data field displayed by the base layer.

Returns:
Tuple consisting of 2 values (xreal, yreal). ((float), (float))

get_real_data_offsets()

source code 

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 DataField.get_xoffset() and DataField.get_yoffset() of the data field displayed by the base layer.

Returns:
Tuple consisting of 2 values (xoffset, yoffset). ((float), (float))

Since: 2.16

get_pixbuf(max_width, max_height)

source code 

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.

Parameters:
  • max_width - Pixbuf width that should not be exceeeded. Value smaller than 1 means unlimited size. (int)
  • max_height - Pixbuf height that should not be exceeeded. Value smaller than 1 means unlimited size. (int)
Returns:
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. (gdk.Pixbuf)

export_pixbuf(zoom, draw_alpha, draw_top)

source code 

Exports data view to a pixbuf.

Parameters:
  • zoom - Zoom to export data with (unrelated to data view zoom). (float)
  • draw_alpha - True to draw alpha layer (mask). (bool)
  • draw_top - True to draw top layer (selection). (bool)
Returns:
A newly created pixbuf, it must be freed by caller. (gdk.Pixbuf)

get_metric()

source code 

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.

Returns:
(list)