mapdisplay.py 22 KB

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