gcpmapdisp.py 23 KB

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