mapdisp.py 23 KB

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