gcpmapdisp.py 23 KB

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