File: wx.lib.floatcanvas.FloatCanvas.FloatCanvas.txt

package info (click to toggle)
wxpython4.0 4.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 211,112 kB
  • sloc: cpp: 888,355; python: 223,130; makefile: 52,087; ansic: 45,780; sh: 3,012; xml: 1,534; perl: 264
file content (482 lines) | stat: -rw-r--r-- 18,675 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2018 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc

.. currentmodule:: wx.lib.floatcanvas.FloatCanvas

.. highlight:: python



.. _wx.lib.floatcanvas.FloatCanvas.FloatCanvas:

==========================================================================================================================================
|phoenix_title|  **wx.lib.floatcanvas.FloatCanvas.FloatCanvas**
==========================================================================================================================================

The main class of the floatcanvas package :class:`~lib.floatcanvas.FloatCanvas`.



|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>FloatCanvas</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.lib.floatcanvas.FloatCanvas.FloatCanvas_inheritance.png" alt="Inheritance diagram of FloatCanvas" usemap="#dummy" class="inheritance"/></center>
   </div>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Panel.html" title="wx.Panel" alt="" coords="115,315,191,344"/> <area shape="rect" id="node7" href="wx.lib.floatcanvas.FloatCanvas.FloatCanvas.html" title="wx.lib.floatcanvas.FloatCanvas.FloatCanvas" alt="" coords="5,392,301,421"/> <area shape="rect" id="node2" href="wx.Window.html" title="wx.Window" alt="" coords="109,237,197,267"/> <area shape="rect" id="node3" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="45,5,147,35"/> <area shape="rect" id="node4" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="97,83,208,112"/> <area shape="rect" id="node6" href="wx.WindowBase.html" title="wx.WindowBase" alt="" coords="93,160,213,189"/> <area shape="rect" id="node5" href="wx.Object.html" title="wx.Object" alt="" coords="171,5,252,35"/> </map> 
   </p>

|


|super_classes| Known Superclasses
==================================

:class:`wx.Panel`

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.__init__`                     Default class constructor.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.AddObject`                    Add an object to the canvas
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.AddObjects`                   Add objects to the canvas
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.addshape`                     Creates Group and adds its reference to the canvas.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.ClearAll`                     ClearAll(ResetBB=True)
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.Draw`                         Canvas.Draw(Force=False)
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.FlatEarthProjection`          Compute the scaling array for the flat-earth projection
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.GetHitTestColor`              Get the hit test colour
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.HitTest`                      Check if any objects in the dict for this event.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.InitAll`                      Sets everything in the Canvas to default state.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.InitializePanel`              Intialize the panel.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.KeyDownEvent`                 Key down event.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.KeyUpEvent`                   Key up event.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.LeftDoubleClickEvent`         Left double click event.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.LeftDownEvent`                Left down event.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.LeftUpEvent`                  Left up event.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.MakeHitDict`                  Initialize the Hit dictonary.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.MakeNewBuffers`               Make a new buffer.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.MakeNewForegroundHTBitmap`    Off screen Bitmap used for Hit tests on foreground objects
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.MakeNewHTBitmap`              Off screen Bitmap used for Hit tests on background objects
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.MiddleDoubleClickEvent`       Middle double click event.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.MiddleDownEvent`              Middle down event.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.MiddleUpEvent`                Middle up event.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.MotionEvent`                  Motion event.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.MouseOverTest`                Check if mouse is over an object.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.MoveImage`                    Move the image in the window.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.OnPaint`                      On paint handler.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.OnSize`                       On size handler.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.OnSizeTimer`                  On size timer handler.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.PixelToWorld`                 Converts coordinates from Pixel coordinates to world coordinates.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.RemoveObject`                 "
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.RemoveObjects`                "
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.RightDoubleCLickEvent`        Right double click event.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.RightDownEvent`               Right down event.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.RightUpEvent`                 Right up event.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.SaveAsImage`                  Saves the current image as an image file.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.ScalePixelToWorld`            This function computes a pair of x.y lengths,
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.ScaleWorldToPixel`            This function will get passed to the drawing functions of the objects,
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.SetMode`                      Set the GUImode to any of the available mode.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.SetProjectionFun`             Set a custom projection function
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.SetToNewScale`                Set to the new scale
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.UnBindAll`                    Removes all bindings to Objects.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.WheelEvent`                   Wheel event.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.WorldToPixel`                 This function will get passed to the drawing functions of the objects,
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.Zoom`                         Zoom(factor, center) changes the amount of zoom of the image by factor.
:meth:`~wx.lib.floatcanvas.FloatCanvas.FloatCanvas.ZoomToBB`                     Zooms the image to the bounding box given, or to the bounding
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: FloatCanvas(wx.Panel)

   The main class of the floatcanvas package :class:`~lib.floatcanvas.FloatCanvas`.

   .. method:: __init__(self, parent, id = -1, size = wx.DefaultSize, ProjectionFun = None, BackgroundColor = "WHITE", Debug = False, \*\*kwargs)

      Default class constructor.
      
      :param wx.Window `parent`: parent window. Must not be ``None``;
      :param integer `id`: window identifier. A value of -1 indicates a default value;
      :param `size`: a tuple or :class:`wx.Size`
      :param `ProjectionFun`: This allows you to change the transform from
       world to pixel coordinates. We can point to :meth:`~lib.floatcanvas.FloatCanvas.FloatCanvas.FlatEarthProjection`
       for an example -- though that should really be a class method, or even
       better, simply a function in the module. There is a tiny bit on info
       in the error message in FloatCanvas.SetProjectionFun()
      
       (Note: this really should get re-factored to allow more generic
       projections...)
      :param string `BackgroundColor`: any value accepted by :class:`wx.Brush`
      :param `Debug`: activate debug, currently it prints some debugging
       information, could be improved.


   .. method:: AddObject(self, obj)

      Add an object to the canvas
      
      :param DrawObject `obj`: the object to add
      
      :return: DrawObject


   .. method:: AddObjects(self, Objects)

      Add objects to the canvas
      
      :param list `Objects`: a list of :class:`DrawObject`


   .. method:: 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.
      
          


   .. method:: 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


   .. method:: 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.


   .. method:: FlatEarthProjection(self, CenterPoint)

      Compute the scaling array for the flat-earth projection
      
      :param `CenterPoint`: center point of viewport (lon, lat) -- the
       longitude is scaled to the latitude of this point. a 2-tuple, or a
       (2,) `NumPy <http://www.numpy.org/>`_ array of point coordinates
      
       :returns : a (2,) numpy array that scales world coordinates. This
        scaling is applied when converting to-from world to pixel coordinates.


   .. method:: GetHitTestColor(self, xy)

      Get the hit test colour
      
      :param `xy`: the position to get the hit test colour for


   .. method:: HitTest(self, event, HitEvent)

      Check if any objects in the dict for this event.


   .. method:: InitAll(self)

      Sets everything in the Canvas to default state.
      
      It can be used to reset the Canvas


   .. method:: InitializePanel(self)

      Intialize the panel.


   .. method:: KeyDownEvent(self, event)

      Key down event.


   .. method:: KeyUpEvent(self, event)

      Key up event.


   .. method:: LeftDoubleClickEvent(self, event)

      Left double click event.


   .. method:: LeftDownEvent(self, event)

      Left down event.


   .. method:: LeftUpEvent(self, event)

      Left up event.


   .. method:: MakeHitDict(self)

      Initialize the Hit dictonary.


   .. method:: MakeNewBuffers(self)

      Make a new buffer.


   .. method:: MakeNewForegroundHTBitmap(self)

      Off screen Bitmap used for Hit tests on foreground objects


   .. method:: MakeNewHTBitmap(self)

      Off screen Bitmap used for Hit tests on background objects


   .. method:: MiddleDoubleClickEvent(self, event)

      Middle double click event.


   .. method:: MiddleDownEvent(self, event)

      Middle down event.


   .. method:: MiddleUpEvent(self, event)

      Middle up event.


   .. method:: MotionEvent(self, event)

      Motion event.


   .. method:: MouseOverTest(self, event)

      Check if mouse is over an object.


   .. method:: MoveImage(self, shift, CoordType, ReDraw=True)

      Move the image in the window.
      
      :param tuple `shift`: is an (x, y) tuple defining amount to shift in
       each direction
      :param string `CoordType`: defines what coordinates to use, valid entries
       are:
      
       ============== ======================================================
       Coordtype      Description
       ============== ======================================================
       `Panel`        shift the image by some fraction of the size of the
                      displayed image
       `Pixel`        shift the image by some number of pixels
       `World`        shift the image by an amount of floating point world
                      coordinates
       ============== ======================================================


   .. method:: OnPaint(self, event)

      On paint handler.


   .. method:: OnSize(self, event=None)

      On size handler.


   .. method:: OnSizeTimer(self, event=None)

      On size timer handler.


   .. method:: 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.


   .. method:: RemoveObject(self, Object, ResetBB=True)

      "
      Remove object from canvas
      
      :param DrawObject `Object`: a :class:`DrawObjects` to remove
      :param boolean `ResetBB`: reset the bounding box


   .. method:: RemoveObjects(self, Objects)

      "
      Remove objects from canvas
      
      :param list `Objects`: a list of :class:`DrawObjects` to remove


   .. method:: RightDoubleCLickEvent(self, event)

      Right double click event.


   .. method:: RightDownEvent(self, event)

      Right down event.


   .. method:: RightUpEvent(self, event)

      Right up event.


   .. method:: SaveAsImage(self, filename, ImageType=wx.BITMAP_TYPE_PNG)

      Saves the current image as an image file.
      
      :param string `filename`: the name of the image file
      :param `ImageType`: format to use, see :ref:`wx.BitmapType` and the note in
       :meth:`wx.Bitmap.SaveFile`


   .. method:: 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.


   .. method:: 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.


   .. method:: SetMode(self, Mode)

      Set the GUImode to any of the available mode.
      
      :param `Mode`: a valid GUI Mode, out of the box valid modes
       are subclassed from :class:`~lib.floatcanvas.GUIMode.GUIBase` or a mode
       can also be user defined.


   .. method:: SetProjectionFun(self, ProjectionFun)

      Set a custom projection function
      
      :param `ProjectionFun`: valid entries are ``FlatEarth``, ``None``
        or a callable object that takes the ``ViewPortCenter`` and returns
        ``MapProjectionVector``


   .. method:: SetToNewScale(self, DrawFlag=True)

      Set to the new scale
      
      :param boolean `DrawFlag`: draw the canvas


   .. method:: UnBindAll(self)

      Removes all bindings to Objects.


   .. method:: WheelEvent(self, event)

      Wheel event.


   .. method:: 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.


   .. method:: 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.
      :param center: a tuple of (x,y) coordinates of the center of the viewport,
                     after zooming. If center is not given, the center will stay the same.
      
      :param centerCoords: flag indicating whether the center given is in pixel or world
                           coords. Options are: "world" or "pixel"
      :param keepPointInPlace: boolean flag. If False, the center point is what's given.
                               If True, the image is shifted so that the given center point
                               is kept in the same pixel space. This facilitates keeping the
                               same point under the mouse when zooming with the scroll wheel.


   .. method:: 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.