mapdisp.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. """!
  2. @package gui_core.mapdisp
  3. @brief Base classes for Map display window
  4. Classes:
  5. - mapdisp::MapFrameBase
  6. - mapdisp::SingleMapFrame
  7. - mapdisp::DoubleMapFrame
  8. (C) 2009-2012 by the GRASS Development Team
  9. This program is free software under the GNU General Public License
  10. (>=v2). Read the file COPYING that comes with GRASS for details.
  11. @author Martin Landa <landa.martin gmail.com>
  12. @author Michael Barton <michael.barton@asu.edu>
  13. @author Vaclav Petras <wenzeslaus gmail.com>
  14. @author Anna Kratochvilova <kratochanna gmail.com>
  15. """
  16. import os
  17. import sys
  18. import wx
  19. import wx.aui
  20. from core import globalvar
  21. from core.debug import Debug
  22. from core.utils import _
  23. from grass.script import core as grass
  24. class MapFrameBase(wx.Frame):
  25. """!Base class for map display window
  26. Derived class must use (create and initialize) \c statusbarManager
  27. or override
  28. GetProperty(), SetProperty() and HasProperty() methods.
  29. Several methods has to be overriden or
  30. \c NotImplementedError("MethodName") will be raised.
  31. If derived class enables and disables auto-rendering,
  32. it should override IsAutoRendered method.
  33. It is expected that derived class will call _setUpMapWindow().
  34. Derived class can has one or more map windows (and map renderes)
  35. but implementation of MapFrameBase expects that one window and
  36. one map will be current.
  37. Current instances of map window and map renderer should be returned
  38. by methods GetWindow() and GetMap() respectively.
  39. AUI manager is stored in \c self._mgr.
  40. """
  41. def __init__(self, parent = None, id = wx.ID_ANY, title = None,
  42. style = wx.DEFAULT_FRAME_STYLE,
  43. auimgr = None, name = None, **kwargs):
  44. """!
  45. @warning Use \a auimgr parameter only if you know what you are doing.
  46. @param parent gui parent
  47. @param id wx id
  48. @param title window title
  49. @param style \c wx.Frame style
  50. @param toolbars array of activated toolbars, e.g. ['map', 'digit']
  51. @param auimgr AUI manager (if \c None, wx.aui.AuiManager is used)
  52. @param name frame name
  53. @param kwargs arguments passed to \c wx.Frame
  54. """
  55. self.parent = parent
  56. wx.Frame.__init__(self, parent, id, title, style = style, name = name, **kwargs)
  57. #
  58. # set the size & system icon
  59. #
  60. self.SetClientSize(self.GetSize())
  61. self.iconsize = (16, 16)
  62. self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass_map.ico'), wx.BITMAP_TYPE_ICO))
  63. # toolbars
  64. self.toolbars = {}
  65. #
  66. # Fancy gui
  67. #
  68. if auimgr == None:
  69. self._mgr = wx.aui.AuiManager(self)
  70. else:
  71. self._mgr = auimgr
  72. def _initMap(self, Map):
  73. """!Initialize map display, set dimensions and map region
  74. """
  75. if not grass.find_program('g.region', '--help'):
  76. sys.exit(_("GRASS module '%s' not found. Unable to start map "
  77. "display window.") % 'g.region')
  78. self.width, self.height = self.GetClientSize()
  79. Debug.msg(2, "MapFrame._initMap():")
  80. Map.ChangeMapSize(self.GetClientSize())
  81. Map.region = Map.GetRegion() # g.region -upgc
  82. # self.Map.SetRegion() # adjust region to match display window
  83. def OnSize(self, event):
  84. """!Adjust statusbar on changing size"""
  85. # reposition checkbox in statusbar
  86. self.StatusbarReposition()
  87. # update statusbar
  88. self.StatusbarUpdate()
  89. def SetProperty(self, name, value):
  90. """!Sets property"""
  91. self.statusbarManager.SetProperty(name, value)
  92. def GetProperty(self, name):
  93. """!Returns property"""
  94. return self.statusbarManager.GetProperty(name)
  95. def HasProperty(self, name):
  96. """!Checks whether object has property"""
  97. return self.statusbarManager.HasProperty(name)
  98. def GetPPM(self):
  99. """! Get pixel per meter
  100. @todo now computed every time, is it necessary?
  101. @todo enable user to specify ppm (and store it in UserSettings)
  102. """
  103. # TODO: need to be fixed...
  104. ### screen X region problem
  105. ### user should specify ppm
  106. dc = wx.ScreenDC()
  107. dpSizePx = wx.DisplaySize() # display size in pixels
  108. dpSizeMM = wx.DisplaySizeMM() # display size in mm (system)
  109. dpSizeIn = (dpSizeMM[0] / 25.4, dpSizeMM[1] / 25.4) # inches
  110. sysPpi = dc.GetPPI()
  111. comPpi = (dpSizePx[0] / dpSizeIn[0],
  112. dpSizePx[1] / dpSizeIn[1])
  113. ppi = comPpi # pixel per inch
  114. ppm = ((ppi[0] / 2.54) * 100, # pixel per meter
  115. (ppi[1] / 2.54) * 100)
  116. Debug.msg(4, "MapFrameBase.GetPPM(): size: px=%d,%d mm=%f,%f "
  117. "in=%f,%f ppi: sys=%d,%d com=%d,%d; ppm=%f,%f" % \
  118. (dpSizePx[0], dpSizePx[1], dpSizeMM[0], dpSizeMM[1],
  119. dpSizeIn[0], dpSizeIn[1],
  120. sysPpi[0], sysPpi[1], comPpi[0], comPpi[1],
  121. ppm[0], ppm[1]))
  122. return ppm
  123. def SetMapScale(self, value, map = None):
  124. """! Set current map scale
  125. @param value scale value (n if scale is 1:n)
  126. @param map Map instance (if none self.Map is used)
  127. """
  128. if not map:
  129. map = self.Map
  130. region = self.Map.region
  131. dEW = value * (region['cols'] / self.GetPPM()[0])
  132. dNS = value * (region['rows'] / self.GetPPM()[1])
  133. region['n'] = region['center_northing'] + dNS / 2.
  134. region['s'] = region['center_northing'] - dNS / 2.
  135. region['w'] = region['center_easting'] - dEW / 2.
  136. region['e'] = region['center_easting'] + dEW / 2.
  137. # add to zoom history
  138. self.GetWindow().ZoomHistory(region['n'], region['s'],
  139. region['e'], region['w'])
  140. def GetMapScale(self, map = None):
  141. """! Get current map scale
  142. @param map Map instance (if none self.Map is used)
  143. """
  144. if not map:
  145. map = self.GetMap()
  146. region = map.region
  147. ppm = self.GetPPM()
  148. heightCm = region['rows'] / ppm[1] * 100
  149. widthCm = region['cols'] / ppm[0] * 100
  150. Debug.msg(4, "MapFrame.GetMapScale(): width_cm=%f, height_cm=%f" %
  151. (widthCm, heightCm))
  152. xscale = (region['e'] - region['w']) / (region['cols'] / ppm[0])
  153. yscale = (region['n'] - region['s']) / (region['rows'] / ppm[1])
  154. scale = (xscale + yscale) / 2.
  155. Debug.msg(3, "MapFrame.GetMapScale(): xscale=%f, yscale=%f -> scale=%f" % \
  156. (xscale, yscale, scale))
  157. return scale
  158. def GetProgressBar(self):
  159. """!Returns progress bar
  160. Progress bar can be used by other classes.
  161. """
  162. return self.statusbarManager.GetProgressBar()
  163. def GetMap(self):
  164. """!Returns current map (renderer) instance"""
  165. raise NotImplementedError("GetMap")
  166. def GetWindow(self):
  167. """!Returns current map window"""
  168. raise NotImplementedError("GetWindow")
  169. def GetWindows(self):
  170. """!Returns list of map windows"""
  171. raise NotImplementedError("GetWindows")
  172. def GetMapToolbar(self):
  173. """!Returns toolbar with zooming tools"""
  174. raise NotImplementedError("GetMapToolbar")
  175. def GetToolbar(self, name):
  176. """!Returns toolbar if exists else None.
  177. Toolbars dictionary contains currently used toolbars only.
  178. """
  179. if name in self.toolbars:
  180. return self.toolbars[name]
  181. return None
  182. def StatusbarUpdate(self):
  183. """!Update statusbar content"""
  184. Debug.msg(5, "MapFrameBase.StatusbarUpdate()")
  185. self.statusbarManager.Update()
  186. def IsAutoRendered(self):
  187. """!Check if auto-rendering is enabled"""
  188. # TODO: this is now not the right place to access this attribute
  189. # TODO: add mapWindowProperties to init parameters
  190. # and pass the right object in the init of derived class?
  191. # or do not use this method at all, let mapwindow decide
  192. return self.mapWindowProperties.autoRender
  193. def CoordinatesChanged(self):
  194. """!Shows current coordinates on statusbar.
  195. """
  196. # assuming that the first mode is coordinates
  197. # probably shold not be here but good solution is not available now
  198. if self.statusbarManager.GetMode() == 0:
  199. self.statusbarManager.ShowItem('coordinates')
  200. def StatusbarReposition(self):
  201. """!Reposition items in statusbar"""
  202. self.statusbarManager.Reposition()
  203. def StatusbarEnableLongHelp(self, enable = True):
  204. """!Enable/disable toolbars long help"""
  205. for toolbar in self.toolbars.itervalues():
  206. toolbar.EnableLongHelp(enable)
  207. def IsStandalone(self):
  208. """!Check if map frame is standalone"""
  209. raise NotImplementedError("IsStandalone")
  210. def OnRender(self, event):
  211. """!Re-render map composition (each map layer)
  212. """
  213. raise NotImplementedError("OnRender")
  214. def OnDraw(self, event):
  215. """!Re-display current map composition
  216. """
  217. self.MapWindow.UpdateMap(render = False)
  218. def OnErase(self, event):
  219. """!Erase the canvas
  220. """
  221. self.MapWindow.EraseMap()
  222. def OnZoomIn(self, event):
  223. """!Zoom in the map.
  224. Set mouse cursor, zoombox attributes, and zoom direction
  225. """
  226. toolbar = self.GetMapToolbar()
  227. self.SwitchTool(toolbar, event)
  228. win = self.GetWindow()
  229. self._prepareZoom(mapWindow = win, zoomType = 1)
  230. def OnZoomOut(self, event):
  231. """!Zoom out the map.
  232. Set mouse cursor, zoombox attributes, and zoom direction
  233. """
  234. toolbar = self.GetMapToolbar()
  235. self.SwitchTool(toolbar, event)
  236. win = self.GetWindow()
  237. self._prepareZoom(mapWindow = win, zoomType = -1)
  238. def _setUpMapWindow(self, mapWindow):
  239. """Binds map windows' zoom history signals to map toolbar."""
  240. # enable or disable zoom history tool
  241. mapWindow.zoomHistoryAvailable.connect(
  242. lambda:
  243. self.GetMapToolbar().Enable('zoomBack', enable=True))
  244. mapWindow.zoomHistoryUnavailable.connect(
  245. lambda:
  246. self.GetMapToolbar().Enable('zoomBack', enable=False))
  247. mapWindow.mouseMoving.connect(self.CoordinatesChanged)
  248. def _prepareZoom(self, mapWindow, zoomType):
  249. """!Prepares MapWindow for zoom, toggles toolbar
  250. @param mapWindow MapWindow to prepare
  251. @param zoomType 1 for zoom in, -1 for zoom out
  252. """
  253. mapWindow.mouse['use'] = "zoom"
  254. mapWindow.mouse['box'] = "box"
  255. mapWindow.zoomtype = zoomType
  256. mapWindow.pen = wx.Pen(colour = 'Red', width = 2, style = wx.SHORT_DASH)
  257. # change the cursor
  258. mapWindow.SetNamedCursor('cross')
  259. def SwitchTool(self, toolbar, event):
  260. """!Helper function to switch tools"""
  261. # unregistration of all registered mouse event handlers of
  262. # Mapwindow
  263. self.MapWindow.UnregisterAllHandlers()
  264. if toolbar:
  265. toolbar.OnTool(event)
  266. toolbar.action['desc'] = ''
  267. def OnPointer(self, event):
  268. """!Sets mouse mode to pointer."""
  269. self.MapWindow.mouse['use'] = 'pointer'
  270. def OnPan(self, event):
  271. """!Panning, set mouse to drag
  272. """
  273. toolbar = self.GetMapToolbar()
  274. self.SwitchTool(toolbar, event)
  275. win = self.GetWindow()
  276. self._preparePan(mapWindow = win)
  277. def _preparePan(self, mapWindow):
  278. """!Prepares MapWindow for pan, toggles toolbar
  279. @param mapWindow MapWindow to prepare
  280. """
  281. mapWindow.mouse['use'] = "pan"
  282. mapWindow.mouse['box'] = "pan"
  283. mapWindow.zoomtype = 0
  284. # change the cursor
  285. mapWindow.SetNamedCursor('hand')
  286. def OnZoomBack(self, event):
  287. """!Zoom last (previously stored position)
  288. """
  289. self.MapWindow.ZoomBack()
  290. def OnZoomToMap(self, event):
  291. """!
  292. Set display extents to match selected raster (including NULLs)
  293. or vector map.
  294. """
  295. self.MapWindow.ZoomToMap(layers = self.Map.GetListOfLayers())
  296. def OnZoomToWind(self, event):
  297. """!Set display geometry to match computational region
  298. settings (set with g.region)
  299. """
  300. self.MapWindow.ZoomToWind()
  301. def OnZoomToDefault(self, event):
  302. """!Set display geometry to match default region settings
  303. """
  304. self.MapWindow.ZoomToDefault()
  305. class SingleMapFrame(MapFrameBase):
  306. """! Frame with one map window.
  307. It is base class for frames which needs only one map.
  308. Derived class should have \c self.MapWindow or
  309. it has to override GetWindow() methods.
  310. @note To access maps use getters only
  311. (when using class or when writing class itself).
  312. """
  313. def __init__(self, parent = None, giface = None, id = wx.ID_ANY, title = None,
  314. style = wx.DEFAULT_FRAME_STYLE,
  315. Map = None,
  316. auimgr = None, name = None, **kwargs):
  317. """!
  318. @param parent gui parent
  319. @param id wx id
  320. @param title window title
  321. @param style \c wx.Frame style
  322. @param Map instance of render.Map
  323. @param name frame name
  324. @param kwargs arguments passed to MapFrameBase
  325. """
  326. MapFrameBase.__init__(self, parent = parent, id = id, title = title,
  327. style = style,
  328. auimgr = auimgr, name = name, **kwargs)
  329. self.Map = Map # instance of render.Map
  330. #
  331. # initialize region values
  332. #
  333. self._initMap(Map = self.Map)
  334. def GetMap(self):
  335. """!Returns map (renderer) instance"""
  336. return self.Map
  337. def GetWindow(self):
  338. """!Returns map window"""
  339. return self.MapWindow
  340. def GetWindows(self):
  341. """!Returns list of map windows"""
  342. return [self.MapWindow]
  343. def OnRender(self, event):
  344. """!Re-render map composition (each map layer)
  345. """
  346. self.GetWindow().UpdateMap(render = True, renderVector = True)
  347. # update statusbar
  348. self.StatusbarUpdate()
  349. class DoubleMapFrame(MapFrameBase):
  350. """! Frame with two map windows.
  351. It is base class for frames which needs two maps.
  352. There is no primary and secondary map. Both maps are equal.
  353. However, one map is current.
  354. It is expected that derived class will call _bindWindowsActivation()
  355. when both map windows will be initialized.
  356. Drived class should have method GetMapToolbar() returns toolbar
  357. which has methods SetActiveMap() and Enable().
  358. @note To access maps use getters only
  359. (when using class or when writing class itself).
  360. @todo Use it in GCP manager
  361. (probably changes to both DoubleMapFrame and GCP MapFrame will be neccessary).
  362. """
  363. def __init__(self, parent = None, id = wx.ID_ANY, title = None,
  364. style = wx.DEFAULT_FRAME_STYLE,
  365. firstMap = None, secondMap = None,
  366. auimgr = None, name = None, **kwargs):
  367. """!
  368. \a firstMap is set as active (by assign it to \c self.Map).
  369. Derived class should assging to \c self.MapWindow to make one
  370. map window current by dafault.
  371. @param parent gui parent
  372. @param id wx id
  373. @param title window title
  374. @param style \c wx.Frame style
  375. @param name frame name
  376. @param kwargs arguments passed to MapFrameBase
  377. """
  378. MapFrameBase.__init__(self, parent = parent, id = id, title = title,
  379. style = style,
  380. auimgr = auimgr, name = name, **kwargs)
  381. self.firstMap = firstMap
  382. self.secondMap = secondMap
  383. self.Map = firstMap
  384. #
  385. # initialize region values
  386. #
  387. self._initMap(Map = self.firstMap)
  388. self._initMap(Map = self.secondMap)
  389. self._bindRegions = False
  390. def _bindWindowsActivation(self):
  391. self.GetFirstWindow().Bind(wx.EVT_ENTER_WINDOW, self.ActivateFirstMap)
  392. self.GetSecondWindow().Bind(wx.EVT_ENTER_WINDOW, self.ActivateSecondMap)
  393. def GetFirstMap(self):
  394. """!Returns first Map instance
  395. """
  396. return self.firstMap
  397. def GetSecondMap(self):
  398. """!Returns second Map instance
  399. """
  400. return self.secondMap
  401. def GetFirstWindow(self):
  402. """!Get first map window"""
  403. return self.firstMapWindow
  404. def GetSecondWindow(self):
  405. """!Get second map window"""
  406. return self.secondMapWindow
  407. def GetMap(self):
  408. """!Returns current map (renderer) instance
  409. @note Use this method to access current map renderer.
  410. (It is not guarented that current map will be stored in
  411. \c self.Map in future versions.)
  412. """
  413. return self.Map
  414. def GetWindow(self):
  415. """!Returns current map window
  416. @see GetMap()
  417. """
  418. return self.MapWindow
  419. def GetWindows(self):
  420. """!Return list of all windows"""
  421. return [self.firstMapWindow, self.secondMapWindow]
  422. def ActivateFirstMap(self, event = None):
  423. """!Make first Map and MapWindow active and (un)bind regions of the two Maps."""
  424. if self.MapWindow == self.firstMapWindow:
  425. return
  426. self.Map = self.firstMap
  427. self.MapWindow = self.firstMapWindow
  428. self.GetMapToolbar().SetActiveMap(0)
  429. # bind/unbind regions
  430. if self._bindRegions:
  431. self.firstMapWindow.zoomChanged.connect(self.OnZoomChangedFirstMap)
  432. self.secondMapWindow.zoomChanged.disconnect(self.OnZoomChangedSecondMap)
  433. def ActivateSecondMap(self, event = None):
  434. """!Make second Map and MapWindow active and (un)bind regions of the two Maps."""
  435. if self.MapWindow == self.secondMapWindow:
  436. return
  437. self.Map = self.secondMap
  438. self.MapWindow = self.secondMapWindow
  439. self.GetMapToolbar().SetActiveMap(1)
  440. if self._bindRegions:
  441. self.secondMapWindow.zoomChanged.connect(self.OnZoomChangedSecondMap)
  442. self.firstMapWindow.zoomChanged.disconnect(self.OnZoomChangedFirstMap)
  443. def SetBindRegions(self, on):
  444. """!Set or unset binding display regions."""
  445. self._bindRegions = on
  446. if on:
  447. if self.MapWindow == self.firstMapWindow:
  448. self.firstMapWindow.zoomChanged.connect(self.OnZoomChangedFirstMap)
  449. else:
  450. self.secondMapWindow.zoomChanged.connect(self.OnZoomChangedSecondMap)
  451. else:
  452. if self.MapWindow == self.firstMapWindow:
  453. self.firstMapWindow.zoomChanged.disconnect(self.OnZoomChangedFirstMap)
  454. else:
  455. self.secondMapWindow.zoomChanged.disconnect(self.OnZoomChangedSecondMap)
  456. def OnZoomChangedFirstMap(self):
  457. """!Display region of the first window (Map) changed.
  458. Synchronize the region of the second map and re-render it.
  459. This is the default implementation which can be overridden.
  460. """
  461. region = self.GetFirstMap().GetCurrentRegion()
  462. self.GetSecondMap().region.update(region)
  463. self.Render(mapToRender = self.GetSecondWindow())
  464. def OnZoomChangedSecondMap(self):
  465. """!Display region of the second window (Map) changed.
  466. Synchronize the region of the second map and re-render it.
  467. This is the default implementation which can be overridden.
  468. """
  469. region = self.GetSecondMap().GetCurrentRegion()
  470. self.GetFirstMap().region.update(region)
  471. self.Render(mapToRender = self.GetFirstWindow())
  472. def OnZoomIn(self, event):
  473. """!Zoom in the map.
  474. Set mouse cursor, zoombox attributes, and zoom direction
  475. """
  476. toolbar = self.GetMapToolbar()
  477. self.SwitchTool(toolbar, event)
  478. win = self.GetFirstWindow()
  479. self._prepareZoom(mapWindow = win, zoomType = 1)
  480. win = self.GetSecondWindow()
  481. self._prepareZoom(mapWindow = win, zoomType = 1)
  482. def OnZoomOut(self, event):
  483. """!Zoom out the map.
  484. Set mouse cursor, zoombox attributes, and zoom direction
  485. """
  486. toolbar = self.GetMapToolbar()
  487. self.SwitchTool(toolbar, event)
  488. win = self.GetFirstWindow()
  489. self._prepareZoom(mapWindow = win, zoomType = -1)
  490. win = self.GetSecondWindow()
  491. self._prepareZoom(mapWindow = win, zoomType = -1)
  492. def OnPan(self, event):
  493. """!Panning, set mouse to drag
  494. """
  495. toolbar = self.GetMapToolbar()
  496. self.SwitchTool(toolbar, event)
  497. win = self.GetFirstWindow()
  498. self._preparePan(mapWindow = win)
  499. win = self.GetSecondWindow()
  500. self._preparePan(mapWindow = win)
  501. def OnPointer(self, event):
  502. """!Set pointer mode (dragging overlays)"""
  503. toolbar = self.GetMapToolbar()
  504. self.SwitchTool(toolbar, event)
  505. self.GetFirstWindow().mouse['use'] = 'pointer'
  506. self.GetFirstWindow().SetNamedCursor('default')
  507. self.GetSecondWindow().mouse['use'] = 'pointer'
  508. self.GetSecondWindow().SetNamedCursor('default')
  509. def OnRender(self, event):
  510. """!Re-render map composition (each map layer)
  511. """
  512. self.Render(mapToRender = self.GetFirstWindow())
  513. self.Render(mapToRender = self.GetSecondWindow())
  514. def Render(self, mapToRender):
  515. """!Re-render map composition"""
  516. mapToRender.UpdateMap(render = True,
  517. renderVector = mapToRender == self.GetFirstWindow())
  518. # update statusbar
  519. self.StatusbarUpdate()
  520. def OnErase(self, event):
  521. """!Erase the canvas
  522. """
  523. self.Erase(mapToErase = self.GetFirstWindow())
  524. self.Erase(mapToErase = self.GetSecondWindow())
  525. def Erase(self, mapToErase):
  526. """!Erase the canvas
  527. """
  528. mapToErase.EraseMap()
  529. def OnDraw(self, event):
  530. """!Re-display current map composition
  531. """
  532. self.Draw(mapToDraw = self.GetFirstWindow())
  533. self.Draw(mapToDraw = self.GetSecondWindow())
  534. def Draw(self, mapToDraw):
  535. """!Re-display current map composition
  536. """
  537. mapToDraw.UpdateMap(render = False)