mapdisplay.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. """!
  2. @package gcp.mapdisplay
  3. @brief Display to manage ground control points with two toolbars, one
  4. for various display management functions, one for manipulating GCPs.
  5. Classes:
  6. - mapdisplay::MapFrame
  7. (C) 2006-2011 by the GRASS Development Team
  8. This program is free software under the GNU General Public License
  9. (>=v2). Read the file COPYING that comes with GRASS for details.
  10. @author Markus Metz
  11. """
  12. import os
  13. import math
  14. import platform
  15. from core import globalvar
  16. import wx
  17. import wx.aui
  18. from mapdisp.toolbars import MapToolbar
  19. from gcp.toolbars import GCPDisplayToolbar, GCPManToolbar
  20. from mapdisp.gprint import PrintOptions
  21. from core.gcmd import GMessage
  22. from gui_core.dialogs import GetImageHandlers, ImageSizeDialog
  23. from gui_core.mapdisp import SingleMapFrame
  24. from core.settings import UserSettings
  25. from mapdisp.mapwindow import BufferedWindow
  26. import mapdisp.statusbar as sb
  27. # for standalone app
  28. cmdfilename = None
  29. class MapFrame(SingleMapFrame):
  30. """!Main frame for map display window. Drawing takes place in
  31. child double buffered drawing window.
  32. """
  33. def __init__(self, parent, giface, title=_("GRASS GIS Manage Ground Control Points"),
  34. toolbars=["gcpdisp"], tree=None, notebook=None, lmgr=None,
  35. page=None, Map=None, auimgr=None, name = 'GCPMapWindow', **kwargs):
  36. """!Main map display window with toolbars, statusbar and
  37. DrawWindow
  38. @param toolbars array of activated toolbars, e.g. ['map', 'digit']
  39. @param tree reference to layer tree
  40. @param notebook control book ID in Layer Manager
  41. @param lmgr Layer Manager
  42. @param page notebook page with layer tree
  43. @param Map instance of render.Map
  44. @param auimgs AUI manager
  45. @param kwargs wx.Frame attribures
  46. """
  47. SingleMapFrame.__init__(self, parent = parent, giface = giface, title = title,
  48. Map = Map, auimgr = auimgr, name = name, **kwargs)
  49. self._layerManager = lmgr # Layer Manager object
  50. self.tree = tree # Layer Manager layer tree object
  51. self.page = page # Notebook page holding the layer tree
  52. self.layerbook = notebook # Layer Manager layer tree notebook
  53. self._giface = giface
  54. #
  55. # Add toolbars
  56. #
  57. for toolb in toolbars:
  58. self.AddToolbar(toolb)
  59. self.activemap = self.toolbars['gcpdisp'].togglemap
  60. self.activemap.SetSelection(0)
  61. self.SrcMap = self.grwiz.SrcMap # instance of render.Map
  62. self.TgtMap = self.grwiz.TgtMap # instance of render.Map
  63. self._mgr.SetDockSizeConstraint(0.5, 0.5)
  64. #
  65. # Add statusbar
  66. #
  67. # items for choice
  68. self.statusbarItems = [sb.SbCoordinates,
  69. sb.SbRegionExtent,
  70. sb.SbCompRegionExtent,
  71. sb.SbShowRegion,
  72. sb.SbResolution,
  73. sb.SbDisplayGeometry,
  74. sb.SbMapScale,
  75. sb.SbProjection,
  76. sb.SbGoToGCP,
  77. sb.SbRMSError]
  78. # create statusbar and its manager
  79. statusbar = self.CreateStatusBar(number = 4, style = 0)
  80. statusbar.SetStatusWidths([-5, -2, -1, -1])
  81. self.statusbarManager = sb.SbManager(mapframe = self, statusbar = statusbar)
  82. # fill statusbar manager
  83. self.statusbarManager.AddStatusbarItemsByClass(self.statusbarItems, mapframe = self, statusbar = statusbar)
  84. self.statusbarManager.AddStatusbarItem(sb.SbMask(self, statusbar = statusbar, position = 2))
  85. self.statusbarManager.AddStatusbarItem(sb.SbRender(self, statusbar = statusbar, position = 3))
  86. self.statusbarManager.SetMode(8) # goto GCP
  87. self.statusbarManager.Update()
  88. #
  89. # Init map display (buffered DC & set default cursor)
  90. #
  91. self.grwiz.SwitchEnv('source')
  92. self.SrcMapWindow = BufferedWindow(parent=self, giface=self._giface, id=wx.ID_ANY,
  93. Map=self.SrcMap, frame = self, tree=self.tree, lmgr=self._layerManager)
  94. self.grwiz.SwitchEnv('target')
  95. self.TgtMapWindow = BufferedWindow(parent=self, giface=self._giface, id=wx.ID_ANY,
  96. Map=self.TgtMap, frame = self, tree=self.tree, lmgr=self._layerManager)
  97. self.MapWindow = self.SrcMapWindow
  98. self.Map = self.SrcMap
  99. self._setUpMapWindow(self.SrcMapWindow)
  100. self._setUpMapWindow(self.TgtMapWindow)
  101. self.SrcMapWindow.SetCursor(self.cursors["cross"])
  102. self.TgtMapWindow.SetCursor(self.cursors["cross"])
  103. self.SrcMapWindow.mouseEntered.connect(
  104. lambda:
  105. self._setActiveMapWindow(self.SrcMapWindow))
  106. self.TgtMapWindow.mouseEntered.connect(
  107. lambda:
  108. self._setActiveMapWindow(self.TgtMapWindow))
  109. #
  110. # initialize region values
  111. #
  112. self._initMap(Map = self.SrcMap)
  113. self._initMap(Map = self.TgtMap)
  114. #
  115. # Bind various events
  116. #
  117. self.activemap.Bind(wx.EVT_CHOICE, self.OnUpdateActive)
  118. #
  119. # Update fancy gui style
  120. #
  121. # AuiManager wants a CentrePane, workaround to get two equally sized windows
  122. self.list = self.CreateGCPList()
  123. #self.SrcMapWindow.SetSize((300, 300))
  124. #self.TgtMapWindow.SetSize((300, 300))
  125. self.list.SetSize((100, 150))
  126. self._mgr.AddPane(self.list, wx.aui.AuiPaneInfo().
  127. Name("gcplist").Caption(_("GCP List")).LeftDockable(False).
  128. RightDockable(False).PinButton().FloatingSize((600,200)).
  129. CloseButton(False).DestroyOnClose(True).
  130. Top().Layer(1).MinSize((200,100)))
  131. self._mgr.AddPane(self.SrcMapWindow, wx.aui.AuiPaneInfo().
  132. Name("source").Caption(_("Source Display")).Dockable(False).
  133. CloseButton(False).DestroyOnClose(True).Floatable(False).
  134. Centre())
  135. self._mgr.AddPane(self.TgtMapWindow, wx.aui.AuiPaneInfo().
  136. Name("target").Caption(_("Target Display")).Dockable(False).
  137. CloseButton(False).DestroyOnClose(True).Floatable(False).
  138. Right().Layer(0))
  139. srcwidth, srcheight = self.SrcMapWindow.GetSize()
  140. tgtwidth, tgtheight = self.TgtMapWindow.GetSize()
  141. srcwidth = (srcwidth + tgtwidth) / 2
  142. self._mgr.GetPane("target").Hide()
  143. self._mgr.Update()
  144. self._mgr.GetPane("source").BestSize((srcwidth, srcheight))
  145. self._mgr.GetPane("target").BestSize((srcwidth, srcheight))
  146. if self.show_target:
  147. self._mgr.GetPane("target").Show()
  148. else:
  149. self.activemap.Enable(False)
  150. # needed by Mac OS, does not harm on Linux, breaks display on Windows
  151. if platform.system() != 'Windows':
  152. self._mgr.Update()
  153. #
  154. # Init print module and classes
  155. #
  156. self.printopt = PrintOptions(self, self.MapWindow)
  157. #
  158. # Initialization of digitization tool
  159. #
  160. self.digit = None
  161. # set active map
  162. self.MapWindow = self.SrcMapWindow
  163. self.Map = self.SrcMap
  164. # do not init zoom history here, that happens when zooming to map(s)
  165. #
  166. # Re-use dialogs
  167. #
  168. self.dialogs = {}
  169. self.dialogs['attributes'] = None
  170. self.dialogs['category'] = None
  171. self.dialogs['barscale'] = None
  172. self.dialogs['legend'] = None
  173. self.decorationDialog = None # decoration/overlays
  174. def _setUpMapWindow(self, mapWindow):
  175. # enable or disable zoom history tool
  176. mapWindow.zoomHistoryAvailable.connect(
  177. lambda:
  178. self.GetMapToolbar().Enable('zoomback', enable=True))
  179. mapWindow.zoomHistoryUnavailable.connect(
  180. lambda:
  181. self.GetMapToolbar().Enable('zoomback', enable=False))
  182. def AddToolbar(self, name):
  183. """!Add defined toolbar to the window
  184. Currently known toolbars are:
  185. - 'map' - basic map toolbar
  186. - 'vdigit' - vector digitizer
  187. - 'gcpdisp' - GCP Manager, Display
  188. - 'gcpman' - GCP Manager, points management
  189. - 'nviz' - 3D view mode
  190. """
  191. # default toolbar
  192. if name == "map":
  193. self.toolbars['map'] = MapToolbar(self, self.Map)
  194. self._mgr.AddPane(self.toolbars['map'],
  195. wx.aui.AuiPaneInfo().
  196. Name("maptoolbar").Caption(_("Map Toolbar")).
  197. ToolbarPane().Top().
  198. LeftDockable(False).RightDockable(False).
  199. BottomDockable(False).TopDockable(True).
  200. CloseButton(False).Layer(2).
  201. BestSize((self.toolbars['map'].GetSize())))
  202. # GCP display
  203. elif name == "gcpdisp":
  204. self.toolbars['gcpdisp'] = GCPDisplayToolbar(self)
  205. self._mgr.AddPane(self.toolbars['gcpdisp'],
  206. wx.aui.AuiPaneInfo().
  207. Name("gcpdisplaytoolbar").Caption(_("GCP Display toolbar")).
  208. ToolbarPane().Top().
  209. LeftDockable(False).RightDockable(False).
  210. BottomDockable(False).TopDockable(True).
  211. CloseButton(False).Layer(2))
  212. if self.show_target == False:
  213. self.toolbars['gcpdisp'].Enable('zoommenu', enable = False)
  214. self.toolbars['gcpman'] = GCPManToolbar(self)
  215. self._mgr.AddPane(self.toolbars['gcpman'],
  216. wx.aui.AuiPaneInfo().
  217. Name("gcpmanagertoolbar").Caption(_("GCP Manager toolbar")).
  218. ToolbarPane().Top().Row(1).
  219. LeftDockable(False).RightDockable(False).
  220. BottomDockable(False).TopDockable(True).
  221. CloseButton(False).Layer(2))
  222. self._mgr.Update()
  223. def OnUpdateProgress(self, event):
  224. """
  225. Update progress bar info
  226. """
  227. self.GetProgressBar().UpdateProgress(event.layer, event.map)
  228. event.Skip()
  229. def OnFocus(self, event):
  230. """
  231. Change choicebook page to match display.
  232. Or set display for georectifying
  233. """
  234. if self._layerManager and \
  235. self._layerManager.gcpmanagement:
  236. # in GCP Management, set focus to current MapWindow for mouse actions
  237. self.OnPointer(event)
  238. self.MapWindow.SetFocus()
  239. else:
  240. # change bookcontrol page to page associated with display
  241. # GCP Manager: use bookcontrol?
  242. if self.page:
  243. pgnum = self.layerbook.GetPageIndex(self.page)
  244. if pgnum > -1:
  245. self.layerbook.SetSelection(pgnum)
  246. event.Skip()
  247. def OnDraw(self, event):
  248. """!Re-display current map composition
  249. """
  250. self.MapWindow.UpdateMap(render = False)
  251. def OnRender(self, event):
  252. """!Re-render map composition (each map layer)
  253. """
  254. # FIXME: remove qlayer code or use RemoveQueryLayer() now in mapdisp.frame
  255. # delete tmp map layers (queries)
  256. qlayer = self.Map.GetListOfLayers(name=globalvar.QUERYLAYER)
  257. for layer in qlayer:
  258. self.Map.DeleteLayer(layer)
  259. self.SrcMapWindow.UpdateMap(render=True)
  260. if self.show_target:
  261. self.TgtMapWindow.UpdateMap(render=True)
  262. # update statusbar
  263. self.StatusbarUpdate()
  264. def OnPointer(self, event):
  265. """!Pointer button clicked
  266. """
  267. self.toolbars['gcpdisp'].OnTool(event)
  268. self.toolbars['gcpdisp'].action['desc'] = ''
  269. # change the cursor
  270. self.SrcMapWindow.SetCursor(self.cursors["cross"])
  271. self.SrcMapWindow.mouse['use'] = "pointer"
  272. self.SrcMapWindow.mouse['box'] = "point"
  273. self.TgtMapWindow.SetCursor(self.cursors["cross"])
  274. self.TgtMapWindow.mouse['use'] = "pointer"
  275. self.TgtMapWindow.mouse['box'] = "point"
  276. def OnZoomIn(self, event):
  277. """
  278. Zoom in the map.
  279. Set mouse cursor, zoombox attributes, and zoom direction
  280. """
  281. self.toolbars['gcpdisp'].OnTool(event)
  282. self.toolbars['gcpdisp'].action['desc'] = ''
  283. self.MapWindow.mouse['use'] = "zoom"
  284. self.MapWindow.mouse['box'] = "box"
  285. self.MapWindow.zoomtype = 1
  286. self.MapWindow.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
  287. # change the cursor
  288. self.MapWindow.SetCursor(self.cursors["cross"])
  289. if self.MapWindow == self.SrcMapWindow:
  290. win = self.TgtMapWindow
  291. elif self.MapWindow == self.TgtMapWindow:
  292. win = self.SrcMapWindow
  293. win.mouse['use'] = "zoom"
  294. win.mouse['box'] = "box"
  295. win.zoomtype = 1
  296. win.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
  297. # change the cursor
  298. win.SetCursor(self.cursors["cross"])
  299. def OnZoomOut(self, event):
  300. """
  301. Zoom out the map.
  302. Set mouse cursor, zoombox attributes, and zoom direction
  303. """
  304. self.toolbars['gcpdisp'].OnTool(event)
  305. self.toolbars['gcpdisp'].action['desc'] = ''
  306. self.MapWindow.mouse['use'] = "zoom"
  307. self.MapWindow.mouse['box'] = "box"
  308. self.MapWindow.zoomtype = -1
  309. self.MapWindow.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
  310. # change the cursor
  311. self.MapWindow.SetCursor(self.cursors["cross"])
  312. if self.MapWindow == self.SrcMapWindow:
  313. win = self.TgtMapWindow
  314. elif self.MapWindow == self.TgtMapWindow:
  315. win = self.SrcMapWindow
  316. win.mouse['use'] = "zoom"
  317. win.mouse['box'] = "box"
  318. win.zoomtype = -1
  319. win.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
  320. # change the cursor
  321. win.SetCursor(self.cursors["cross"])
  322. def OnPan(self, event):
  323. """
  324. Panning, set mouse to drag
  325. """
  326. self.toolbars['gcpdisp'].OnTool(event)
  327. self.toolbars['gcpdisp'].action['desc'] = ''
  328. self.MapWindow.mouse['use'] = "pan"
  329. self.MapWindow.mouse['box'] = "pan"
  330. self.MapWindow.zoomtype = 0
  331. # change the cursor
  332. self.MapWindow.SetCursor(self.cursors["hand"])
  333. if self.MapWindow == self.SrcMapWindow:
  334. win = self.TgtMapWindow
  335. elif self.MapWindow == self.TgtMapWindow:
  336. win = self.SrcMapWindow
  337. win.mouse['use'] = "pan"
  338. win.mouse['box'] = "pan"
  339. win.zoomtype = 0
  340. # change the cursor
  341. win.SetCursor(self.cursors["hand"])
  342. def OnErase(self, event):
  343. """
  344. Erase the canvas
  345. """
  346. self.MapWindow.EraseMap()
  347. if self.MapWindow == self.SrcMapWindow:
  348. win = self.TgtMapWindow
  349. elif self.MapWindow == self.TgtMapWindow:
  350. win = self.SrcMapWindow
  351. win.EraseMap()
  352. def OnZoomRegion(self, event):
  353. """
  354. Zoom to region
  355. """
  356. self.Map.getRegion()
  357. self.Map.getResolution()
  358. self.UpdateMap()
  359. # event.Skip()
  360. def OnAlignRegion(self, event):
  361. """
  362. Align region
  363. """
  364. if not self.Map.alignRegion:
  365. self.Map.alignRegion = True
  366. else:
  367. self.Map.alignRegion = False
  368. # event.Skip()
  369. def SaveToFile(self, event):
  370. """!Save map to image
  371. """
  372. img = self.MapWindow.img
  373. if not img:
  374. GMessage(parent = self,
  375. message = _("Nothing to render (empty map). Operation canceled."))
  376. return
  377. filetype, ltype = GetImageHandlers(img)
  378. # get size
  379. dlg = ImageSizeDialog(self)
  380. dlg.CentreOnParent()
  381. if dlg.ShowModal() != wx.ID_OK:
  382. dlg.Destroy()
  383. return
  384. width, height = dlg.GetValues()
  385. dlg.Destroy()
  386. # get filename
  387. dlg = wx.FileDialog(parent = self,
  388. message = _("Choose a file name to save the image "
  389. "(no need to add extension)"),
  390. wildcard = filetype,
  391. style=wx.SAVE | wx.FD_OVERWRITE_PROMPT)
  392. if dlg.ShowModal() == wx.ID_OK:
  393. path = dlg.GetPath()
  394. if not path:
  395. dlg.Destroy()
  396. return
  397. base, ext = os.path.splitext(path)
  398. fileType = ltype[dlg.GetFilterIndex()]['type']
  399. extType = ltype[dlg.GetFilterIndex()]['ext']
  400. if ext != extType:
  401. path = base + '.' + extType
  402. self.MapWindow.SaveToFile(path, fileType,
  403. width, height)
  404. dlg.Destroy()
  405. def PrintMenu(self, event):
  406. """
  407. Print options and output menu for map display
  408. """
  409. point = wx.GetMousePosition()
  410. printmenu = wx.Menu()
  411. # Add items to the menu
  412. setup = wx.MenuItem(printmenu, wx.ID_ANY, _('Page setup'))
  413. printmenu.AppendItem(setup)
  414. self.Bind(wx.EVT_MENU, self.printopt.OnPageSetup, setup)
  415. preview = wx.MenuItem(printmenu, wx.ID_ANY, _('Print preview'))
  416. printmenu.AppendItem(preview)
  417. self.Bind(wx.EVT_MENU, self.printopt.OnPrintPreview, preview)
  418. doprint = wx.MenuItem(printmenu, wx.ID_ANY, _('Print display'))
  419. printmenu.AppendItem(doprint)
  420. self.Bind(wx.EVT_MENU, self.printopt.OnDoPrint, doprint)
  421. # Popup the menu. If an item is selected then its handler
  422. # will be called before PopupMenu returns.
  423. self.PopupMenu(printmenu)
  424. printmenu.Destroy()
  425. def FormatDist(self, dist):
  426. """!Format length numbers and units in a nice way,
  427. as a function of length. From code by Hamish Bowman
  428. Grass Development Team 2006"""
  429. mapunits = self.Map.projinfo['units']
  430. if mapunits == 'metres': mapunits = 'meters'
  431. outunits = mapunits
  432. dist = float(dist)
  433. divisor = 1.0
  434. # figure out which units to use
  435. if mapunits == 'meters':
  436. if dist > 2500.0:
  437. outunits = 'km'
  438. divisor = 1000.0
  439. else: outunits = 'm'
  440. elif mapunits == 'feet':
  441. # nano-bug: we match any "feet", but US Survey feet is really
  442. # 5279.9894 per statute mile, or 10.6' per 1000 miles. As >1000
  443. # miles the tick markers are rounded to the nearest 10th of a
  444. # mile (528'), the difference in foot flavours is ignored.
  445. if dist > 5280.0:
  446. outunits = 'miles'
  447. divisor = 5280.0
  448. else:
  449. outunits = 'ft'
  450. elif 'degree' in mapunits:
  451. if dist < 1:
  452. outunits = 'min'
  453. divisor = (1/60.0)
  454. else:
  455. outunits = 'deg'
  456. # format numbers in a nice way
  457. if (dist/divisor) >= 2500.0:
  458. outdist = round(dist/divisor)
  459. elif (dist/divisor) >= 1000.0:
  460. outdist = round(dist/divisor,1)
  461. elif (dist/divisor) > 0.0:
  462. outdist = round(dist/divisor,int(math.ceil(3-math.log10(dist/divisor))))
  463. else:
  464. outdist = float(dist/divisor)
  465. return (outdist, outunits)
  466. def OnZoomToRaster(self, event):
  467. """!
  468. Set display extents to match selected raster map (ignore NULLs)
  469. """
  470. self.MapWindow.ZoomToMap(ignoreNulls = True)
  471. def OnZoomToSaved(self, event):
  472. """!Set display geometry to match extents in
  473. saved region file
  474. """
  475. self.MapWindow.ZoomToSaved()
  476. def OnDisplayToWind(self, event):
  477. """!Set computational region (WIND file) to match display
  478. extents
  479. """
  480. self.MapWindow.DisplayToWind()
  481. def SaveDisplayRegion(self, event):
  482. """!Save display extents to named region file.
  483. """
  484. self.MapWindow.SaveDisplayRegion()
  485. def OnZoomMenu(self, event):
  486. """!Popup Zoom menu
  487. """
  488. point = wx.GetMousePosition()
  489. zoommenu = wx.Menu()
  490. # Add items to the menu
  491. zoomwind = wx.MenuItem(zoommenu, wx.ID_ANY, _('Zoom to computational region (set with g.region)'))
  492. zoommenu.AppendItem(zoomwind)
  493. self.Bind(wx.EVT_MENU, self.OnZoomToWind, zoomwind)
  494. zoomdefault = wx.MenuItem(zoommenu, wx.ID_ANY, _('Zoom to default region'))
  495. zoommenu.AppendItem(zoomdefault)
  496. self.Bind(wx.EVT_MENU, self.OnZoomToDefault, zoomdefault)
  497. zoomsaved = wx.MenuItem(zoommenu, wx.ID_ANY, _('Zoom to saved region'))
  498. zoommenu.AppendItem(zoomsaved)
  499. self.Bind(wx.EVT_MENU, self.OnZoomToSaved, zoomsaved)
  500. savewind = wx.MenuItem(zoommenu, wx.ID_ANY, _('Set computational region from display'))
  501. zoommenu.AppendItem(savewind)
  502. self.Bind(wx.EVT_MENU, self.OnDisplayToWind, savewind)
  503. savezoom = wx.MenuItem(zoommenu, wx.ID_ANY, _('Save display geometry to named region'))
  504. zoommenu.AppendItem(savezoom)
  505. self.Bind(wx.EVT_MENU, self.SaveDisplayRegion, savezoom)
  506. # Popup the menu. If an item is selected then its handler
  507. # will be called before PopupMenu returns.
  508. self.PopupMenu(zoommenu)
  509. zoommenu.Destroy()
  510. def IsStandalone(self):
  511. """!Check if Map display is standalone"""
  512. if self._layerManager:
  513. return False
  514. return True
  515. def GetLayerManager(self):
  516. """!Get reference to Layer Manager
  517. @return window reference
  518. @return None (if standalone)
  519. """
  520. return self._layerManager
  521. def GetSrcWindow(self):
  522. return self.SrcMapWindow
  523. def GetTgtWindow(self):
  524. return self.TgtMapWindow
  525. def GetShowTarget(self):
  526. return self.show_target
  527. def GetMapToolbar(self):
  528. """!Returns toolbar with zooming tools"""
  529. return self.toolbars['gcpdisp']
  530. def _setActiveMapWindow(self, mapWindow):
  531. if not self.MapWindow == mapWindow:
  532. self.MapWindow = mapWindow
  533. self.Map = mapWindow.Map
  534. self.UpdateActive(mapWindow)
  535. # needed for wingrass
  536. self.SetFocus()