mapdisplay.py 23 KB

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