mapdisp.py 22 KB

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