| |
- Drawable_2D
class Drawable_2D |
|
2D Graphics displaying widget interface definition
Application Level Interface:
===========================
This class has some methods that can be called at application level. They refer to adding
and changing graphical elements over the graphic displaying. They are called through
View.GetDrawable() object:
PutLine
PutRectangle
SetObjectCoords
EraseObject
This class generates the following callbacks to parent (a View object):
_RightButtonPress
_ButtonPress
_DoubleClick
_ButtonRelease
_Motion
_ButtonPressMotion
_KeyPress |
|
- Destroy(self)
- Cleanup
- DrawImage(self, image_string, image_size, depth, colormap_table, reset_zoom=0)
- Parameters:
image_string: String with the image data
image_size: tuple, size of the image (x,y).
depth: either 32 (image_string has RGBX representation of image) or
8 (image has 256 levels of colors, 1 byte per pixel)
colormap_table: only considered if depth equals to 8. In this case,
it is a list of 256 int numbers corresponding to
the RGB value for each color number.
reset_zoom: if non-zero, resets zoom and scroll state.
- EraseImage(self)
- EraseObject(self, obj)
- Erases graphical object
Parameters:
obj: reference to the object
- GetHeight(self)
- Returns height of the displayed image (image coords)
- GetWidth(self)
- Returns width of the displayed image (image coords)
- GetWindowHeight(self)
- Returns the height of visible window
- GetWindowPosition(self)
- Returns image coordinates of the visible upper left corner
- GetWindowWidth(self)
- Returns the width of visible window
- GetZoomFactor(self)
- Returns zoom factor:
- equals to 1. if no zoom
- greater than 1. if zoomed in
- less than 1. if zoomed out
- ImageCoord2ViewCoord(self, image_coord)
- Tranforms image coordinates (referenced to original image) into
view coordinates (as generated by the events)
- MoveTo(self, position)
- Parameters:
position: tuple (x,y), position (image coords) to scroll to
- PutLine(self, X0, Y0, X1, Y1, pen=<PyDVT.GUIBinding.Binding.Pen instance>)
- Parameters:
X0,Y0: First point (image coords)
X1,Y1: Second point (image coords)
pen: Pen object
Returns a reference to the object
- PutRectangle(self, X0, Y0, X1, Y1, pen=<PyDVT.GUIBinding.Binding.Pen instance>, brush=<PyDVT.GUIBinding.Binding.Brush instance>)
- Parameters:
X0,Y0: upper-left corner (image coords)
X1,Y1: lower-right corner (image coords)
pen: Pen object to the contour
brush: Brush object for the filling
Returns a reference to the object
- Save(self, filename, format)
- Parameters:
filename: name of the output file.
format: format to be saved ("PS","PNG","BMP" or "JPG")
- SetObjectCoords(self, obj, *args)
- Changes the coordinates of an graphical object
Parameters:
obj: reference to the object
*args: X0,Y0,X1,Y1,... in image coords
- SetZoom(self, val=None, rect=None, com=None)
- Sets zoom state
Parameters: (only one must be set)
val: a float, sets directly a value to the zoom factor
rect: a tuple in the format (x0,y0,x1,y1), that defines the coordinates of
the upper-left and the lower-right points of a zoomed area, in
image coordinates.
com: can be "fit", "normal", "in" and "out"
- Show(self)
- Displays widget
- ViewCoord2ImageCoord(self, view_coord)
- Tranforms view coordinates (as generated by the events) into
image coordinates (referenced to original image)
- __init__(self, parent, zoom_mode='ON', scroll_mode='ON')
- Parameters:
parent: parent widget (a View object)
zoom_mode: "ON", "OFF" or "FIT_TO_SCREEN"
scroll_mode: "ON" or "OFF"
| |