The main class of the floatcanvas package FloatCanvas
.
__init__ |
Default class constructor. |
AddObject |
Add an object to the canvas |
AddObjects |
Add objects to the canvas |
addshape |
Creates Group and adds its reference to the canvas. |
ClearAll |
ClearAll(ResetBB=True) |
Draw |
Canvas.Draw(Force=False) |
FlatEarthProjection |
Compute the scaling array for the flat-earth projection |
GetHitTestColor |
Get the hit test colour |
HitTest |
Check if any objects in the dict for this event. |
InitAll |
Sets everything in the Canvas to default state. |
InitializePanel |
Intialize the panel. |
KeyDownEvent |
Key down event. |
KeyUpEvent |
Key up event. |
LeftDoubleClickEvent |
Left double click event. |
LeftDownEvent |
Left down event. |
LeftUpEvent |
Left up event. |
MakeHitDict |
Initialize the Hit dictonary. |
MakeNewBuffers |
Make a new buffer. |
MakeNewForegroundHTBitmap |
Off screen Bitmap used for Hit tests on foreground objects |
MakeNewHTBitmap |
Off screen Bitmap used for Hit tests on background objects |
MiddleDoubleClickEvent |
Middle double click event. |
MiddleDownEvent |
Middle down event. |
MiddleUpEvent |
Middle up event. |
MotionEvent |
Motion event. |
MouseOverTest |
Check if mouse is over an object. |
MoveImage |
Move the image in the window. |
OnPaint |
On paint handler. |
OnSize |
On size handler. |
OnSizeTimer |
On size timer handler. |
PixelToWorld |
Converts coordinates from Pixel coordinates to world coordinates. |
RemoveObject |
“ |
RemoveObjects |
“ |
RightDoubleCLickEvent |
Right double click event. |
RightDownEvent |
Right down event. |
RightUpEvent |
Right up event. |
SaveAsImage |
Saves the current image as an image file. |
ScalePixelToWorld |
This function computes a pair of x.y lengths, |
ScaleWorldToPixel |
This function will get passed to the drawing functions of the objects, |
SetMode |
Set the GUImode to any of the available mode. |
SetProjectionFun |
Set a custom projection function |
SetToNewScale |
Set to the new scale |
UnBindAll |
Removes all bindings to Objects. |
WheelEvent |
Wheel event. |
WorldToPixel |
This function will get passed to the drawing functions of the objects, |
Zoom |
Zoom(factor, center) changes the amount of zoom of the image by factor. |
ZoomToBB |
Zooms the image to the bounding box given, or to the bounding |
FloatCanvas
(wx.Panel)¶The main class of the floatcanvas package FloatCanvas
.
__init__
(self, parent, id = -1, size = wx.DefaultSize, ProjectionFun = None, BackgroundColor = "WHITE", Debug = False, **kwargs)¶Default class constructor.
Parameters: |
|
---|
AddObject
(self, obj)¶Add an object to the canvas
Parameters: | obj (DrawObject) – the object to add |
---|---|
Returns: | DrawObject |
AddObjects
(self, Objects)¶Add objects to the canvas
Parameters: | Objects (list) – a list of DrawObject |
---|
addshape
(self, *args, **kwargs)¶Creates Group and adds its reference to the canvas. Argument protocol same as Group class, whose docstring is:
A group of other FloatCanvas Objects
Not all DrawObject methods may apply here.
Note that if an object is in more than one group, it will get drawn more than once.
ClearAll
(self, ResetBB=True)¶ClearAll(ResetBB=True)
Removes all DrawObjects from the Canvas
If ResetBB is set to False, the original bounding box will remain
Draw
(self, Force=False)¶Canvas.Draw(Force=False)
Re-draws the canvas.
Note that the buffer will not be re-drawn unless something has
changed. If you change a DrawObject directly, then the canvas
will not know anything has changed. In this case, you can force
a re-draw by passing int True
for the Force flag:
Canvas.Draw(Force=True)
There is a main buffer set up to double buffer the screen, so you can get quick re-draws when the window gets uncovered.
If there are any objects in self._ForeDrawList, then the background gets drawn to a new buffer, and the foreground objects get drawn on top of it. The final result if blitted to the screen, and stored for future Paint events. This is done so that you can have a complicated background, but have something changing on the foreground, without having to wait for the background to get re-drawn. This can be used to support simple animation, for instance.
FlatEarthProjection
(self, CenterPoint)¶Compute the scaling array for the flat-earth projection
Parameters: | CenterPoint – center point of viewport (lon, lat) – the
longitude is scaled to the latitude of this point. a 2-tuple, or a
(2,) NumPy array of point coordinates
|
---|
GetHitTestColor
(self, xy)¶Get the hit test colour
Parameters: | xy – the position to get the hit test colour for |
---|
HitTest
(self, event, HitEvent)¶Check if any objects in the dict for this event.
InitAll
(self)¶Sets everything in the Canvas to default state.
It can be used to reset the Canvas
InitializePanel
(self)¶Intialize the panel.
KeyDownEvent
(self, event)¶Key down event.
KeyUpEvent
(self, event)¶Key up event.
LeftDoubleClickEvent
(self, event)¶Left double click event.
LeftDownEvent
(self, event)¶Left down event.
LeftUpEvent
(self, event)¶Left up event.
MakeHitDict
(self)¶Initialize the Hit dictonary.
MakeNewBuffers
(self)¶Make a new buffer.
MakeNewForegroundHTBitmap
(self)¶Off screen Bitmap used for Hit tests on foreground objects
MakeNewHTBitmap
(self)¶Off screen Bitmap used for Hit tests on background objects
MiddleDoubleClickEvent
(self, event)¶Middle double click event.
MiddleDownEvent
(self, event)¶Middle down event.
MiddleUpEvent
(self, event)¶Middle up event.
MotionEvent
(self, event)¶Motion event.
MouseOverTest
(self, event)¶Check if mouse is over an object.
MoveImage
(self, shift, CoordType, ReDraw=True)¶Move the image in the window.
Parameters: |
|
---|
OnPaint
(self, event)¶On paint handler.
OnSize
(self, event=None)¶On size handler.
OnSizeTimer
(self, event=None)¶On size timer handler.
PixelToWorld
(self, Points)¶Converts coordinates from Pixel coordinates to world coordinates.
Points is a tuple of (x,y) coordinates, or a list of such tuples, or a NX2 Numpy array of x,y coordinates.
RemoveObject
(self, Object, ResetBB=True)¶” Remove object from canvas
Parameters: |
|
---|
RemoveObjects
(self, Objects)¶” Remove objects from canvas
Parameters: | Objects (list) – a list of DrawObjects to remove |
---|
RightDoubleCLickEvent
(self, event)¶Right double click event.
RightDownEvent
(self, event)¶Right down event.
RightUpEvent
(self, event)¶Right up event.
SaveAsImage
(self, filename, ImageType=wx.BITMAP_TYPE_PNG)¶Saves the current image as an image file.
Parameters: |
|
---|
ScalePixelToWorld
(self, Lengths)¶This function computes a pair of x.y lengths, to change then from pixel to world coordinates.
Lengths should be a NX2 array of (x,y) coordinates, or a 2-tuple, or sequence of 2-tuples.
ScaleWorldToPixel
(self, Lengths)¶This function will get passed to the drawing functions of the objects, to Change a length from world to pixel coordinates.
Lengths should be a NX2 array of (x,y) coordinates, or a 2-tuple, or sequence of 2-tuples.
SetMode
(self, Mode)¶Set the GUImode to any of the available mode.
Parameters: | Mode – a valid GUI Mode, out of the box valid modes
are subclassed from GUIBase or a mode
can also be user defined. |
---|
SetProjectionFun
(self, ProjectionFun)¶Set a custom projection function
Parameters: | ProjectionFun – valid entries are FlatEarth , None
or a callable object that takes the ViewPortCenter and returns
MapProjectionVector |
---|
SetToNewScale
(self, DrawFlag=True)¶Set to the new scale
Parameters: | DrawFlag (boolean) – draw the canvas |
---|
UnBindAll
(self)¶Removes all bindings to Objects.
WheelEvent
(self, event)¶Wheel event.
WorldToPixel
(self, Coordinates)¶This function will get passed to the drawing functions of the objects, to transform from world to pixel coordinates. Coordinates should be a NX2 array of (x,y) coordinates, or a 2-tuple, or sequence of 2-tuples.
Zoom
(self, factor, center = None, centerCoords="World", keepPointInPlace=False)¶Zoom(factor, center) changes the amount of zoom of the image by factor. If factor is greater than one, the image gets larger. If factor is less than one, the image gets smaller. :param factor: amount to zoom in or out If factor is greater than one,
the image gets larger. If factor is less than one, the image gets smaller.
Parameters: |
|
---|
ZoomToBB
(self, NewBB=None, DrawFlag=True)¶Zooms the image to the bounding box given, or to the bounding box of all the objects on the canvas, if none is given.