toolbars.py 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046
  1. """
  2. MODULE: toolbar
  3. CLASSES:
  4. * AbstractToolbar
  5. * MapToolbar
  6. * GRToolbar
  7. * GCPToolbar
  8. * VDigitToolbar
  9. * ProfileToolbar
  10. * NvizToolbar
  11. PURPOSE: Toolbars for Map Display window
  12. AUTHORS: The GRASS Development Team
  13. Michael Barton, Martin Landa, Jachym Cepicky
  14. COPYRIGHT: (C) 2007-2008 by the GRASS Development Team
  15. This program is free software under the GNU General Public
  16. License (>=v2). Read the file COPYING that comes with GRASS
  17. for details.
  18. """
  19. import wx
  20. import os, sys
  21. import globalvar
  22. import gcmd
  23. import grassenv
  24. import gdialogs
  25. import vdigit
  26. from vdigit import VDigitSettingsDialog as VDigitSettingsDialog
  27. from debug import Debug as Debug
  28. from icon import Icons as Icons
  29. from preferences import globalSettings as UserSettings
  30. gmpath = os.path.join(globalvar.ETCWXDIR, "icons")
  31. sys.path.append(gmpath)
  32. class AbstractToolbar(object):
  33. """Abstract toolbar class"""
  34. def __init__():
  35. pass
  36. def InitToolbar(self, parent, toolbar, toolData):
  37. """Initialize toolbar, i.e. add tools to the toolbar
  38. @return list of ids (of added tools)
  39. """
  40. for tool in toolData:
  41. self.CreateTool(parent, toolbar, *tool)
  42. self._toolbar = toolbar
  43. self._data = toolData
  44. def ToolbarData(self):
  45. """Toolbar data"""
  46. return None
  47. def CreateTool(self, parent, toolbar, tool, label, bitmap, kind,
  48. shortHelp, longHelp, handler):
  49. """Add tool to the toolbar
  50. @return id of tool
  51. """
  52. bmpDisabled=wx.NullBitmap
  53. if label:
  54. toolWin = toolbar.AddLabelTool(tool, label, bitmap,
  55. bmpDisabled, kind,
  56. shortHelp, longHelp)
  57. parent.Bind(wx.EVT_TOOL, handler, toolWin)
  58. else: # add separator
  59. toolbar.AddSeparator()
  60. return tool
  61. def GetToolbar(self):
  62. """Get toolbar widget reference"""
  63. return self._toolbar
  64. def EnableLongHelp(self, enable=True):
  65. """Enable/disable long help
  66. @param enable True for enable otherwise disable
  67. """
  68. for tool in self._data:
  69. if tool[0] == '': # separator
  70. continue
  71. if enable:
  72. self._toolbar.SetToolLongHelp(tool[0], tool[5])
  73. else:
  74. self._toolbar.SetToolLongHelp(tool[0], "")
  75. class MapToolbar(AbstractToolbar):
  76. """
  77. Main Map Display toolbar
  78. """
  79. def __init__(self, mapdisplay, map):
  80. self.mapcontent = map
  81. self.mapdisplay = mapdisplay
  82. self.toolbar = wx.ToolBar(parent=self.mapdisplay, id=wx.ID_ANY)
  83. self.toolbar.SetToolBitmapSize(globalvar.toolbarSize)
  84. self.InitToolbar(self.mapdisplay, self.toolbar, self.ToolbarData())
  85. # optional tools
  86. self.combo = wx.ComboBox(parent=self.toolbar, id=wx.ID_ANY, value='Tools',
  87. choices=['Digitize', 'Nviz'], style=wx.CB_READONLY, size=(90, -1))
  88. self.comboid = self.toolbar.AddControl(self.combo)
  89. self.mapdisplay.Bind(wx.EVT_COMBOBOX, self.OnSelectTool, self.comboid)
  90. # realize the toolbar
  91. self.toolbar.Realize()
  92. def ToolbarData(self):
  93. """Toolbar data"""
  94. self.displaymap = wx.NewId()
  95. self.rendermap = wx.NewId()
  96. self.erase = wx.NewId()
  97. self.pointer = wx.NewId()
  98. self.query = wx.NewId()
  99. self.pan = wx.NewId()
  100. self.zoomin = wx.NewId()
  101. self.zoomout = wx.NewId()
  102. self.zoomback = wx.NewId()
  103. self.zoommenu = wx.NewId()
  104. self.analyze = wx.NewId()
  105. self.dec = wx.NewId()
  106. self.savefile = wx.NewId()
  107. self.printmap = wx.NewId()
  108. # tool, label, bitmap, kind, shortHelp, longHelp, handler
  109. return (
  110. (self.displaymap, "displaymap", Icons["displaymap"].GetBitmap(),
  111. wx.ITEM_NORMAL, Icons["displaymap"].GetLabel(), Icons["displaymap"].GetDesc(),
  112. self.mapdisplay.OnDraw),
  113. (self.rendermap, "rendermap", Icons["rendermap"].GetBitmap(),
  114. wx.ITEM_NORMAL, Icons["rendermap"].GetLabel(), Icons["rendermap"].GetDesc(),
  115. self.mapdisplay.OnRender),
  116. (self.erase, "erase", Icons["erase"].GetBitmap(),
  117. wx.ITEM_NORMAL, Icons["erase"].GetLabel(), Icons["erase"].GetDesc(),
  118. self.mapdisplay.OnErase),
  119. ("", "", "", "", "", "", ""),
  120. (self.pointer, "pointer", Icons["pointer"].GetBitmap(),
  121. wx.ITEM_RADIO, Icons["pointer"].GetLabel(), Icons["pointer"].GetDesc(),
  122. self.mapdisplay.OnPointer),
  123. (self.query, "queryDisplay", Icons["queryDisplay"].GetBitmap(),
  124. wx.ITEM_RADIO, Icons["queryDisplay"].GetLabel(), Icons["queryDisplay"].GetDesc(),
  125. self.mapdisplay.OnQuery),
  126. (self.pan, "pan", Icons["pan"].GetBitmap(),
  127. wx.ITEM_RADIO, Icons["pan"].GetLabel(), Icons["pan"].GetDesc(),
  128. self.mapdisplay.OnPan),
  129. (self.zoomin, "zoom_in", Icons["zoom_in"].GetBitmap(),
  130. wx.ITEM_RADIO, Icons["zoom_in"].GetLabel(), Icons["zoom_in"].GetDesc(),
  131. self.mapdisplay.OnZoomIn),
  132. (self.zoomout, "zoom_out", Icons["zoom_out"].GetBitmap(),
  133. wx.ITEM_RADIO, Icons["zoom_out"].GetLabel(), Icons["zoom_out"].GetDesc(),
  134. self.mapdisplay.OnZoomOut),
  135. (self.zoomback, "zoom_back", Icons["zoom_back"].GetBitmap(),
  136. wx.ITEM_NORMAL, Icons["zoom_back"].GetLabel(), Icons["zoom_back"].GetDesc(),
  137. self.mapdisplay.OnZoomBack),
  138. (self.zoommenu, "zoommenu", Icons["zoommenu"].GetBitmap(),
  139. wx.ITEM_NORMAL, Icons["zoommenu"].GetLabel(), Icons["zoommenu"].GetDesc(),
  140. self.mapdisplay.OnZoomMenu),
  141. ("", "", "", "", "", "", ""),
  142. (self.analyze, "analyze", Icons["analyze"].GetBitmap(),
  143. wx.ITEM_NORMAL, Icons["analyze"].GetLabel(), Icons["analyze"].GetDesc(),
  144. self.mapdisplay.OnAnalyze),
  145. ("", "", "", "", "", "", ""),
  146. (self.dec, "overlay", Icons["overlay"].GetBitmap(),
  147. wx.ITEM_NORMAL, Icons["overlay"].GetLabel(), Icons["overlay"].GetDesc(),
  148. self.mapdisplay.OnDecoration),
  149. ("", "", "", "", "", "", ""),
  150. (self.savefile, "savefile", Icons["savefile"].GetBitmap(),
  151. wx.ITEM_NORMAL, Icons["savefile"].GetLabel(), Icons["savefile"].GetDesc(),
  152. self.mapdisplay.SaveToFile),
  153. (self.printmap, "printmap", Icons["printmap"].GetBitmap(),
  154. wx.ITEM_NORMAL, Icons["printmap"].GetLabel(), Icons["printmap"].GetDesc(),
  155. self.mapdisplay.PrintMenu),
  156. ("", "", "", "", "", "", "")
  157. )
  158. def OnSelectTool(self, event):
  159. """
  160. Select / enable tool available in tools list
  161. """
  162. tool = event.GetString()
  163. if tool == "Digitize" and not self.mapdisplay.toolbars['vdigit']:
  164. self.mapdisplay.AddToolbar("vdigit")
  165. elif tool == "Nviz" and not self.mapdisplay.toolbars['nviz']:
  166. self.mapdisplay.AddToolbar("nviz")
  167. def Enable2D(self, enabled):
  168. """Enable/Disable 2D display mode specific tools"""
  169. for tool in (self.pointer,
  170. self.query,
  171. self.pan,
  172. self.zoomin,
  173. self.zoomout,
  174. self.zoomback,
  175. self.zoommenu,
  176. self.analyze,
  177. self.dec,
  178. self.savefile,
  179. self.printmap):
  180. self.toolbar.EnableTool(tool, enabled)
  181. class GRToolbar(AbstractToolbar):
  182. """
  183. Georectify Display toolbar
  184. """
  185. def __init__(self, mapdisplay, map):
  186. self.mapcontent = map
  187. self.mapdisplay = mapdisplay
  188. self.toolbar = wx.ToolBar(parent=self.mapdisplay, id=wx.ID_ANY)
  189. # self.SetToolBar(self.toolbar)
  190. self.toolbar.SetToolBitmapSize(globalvar.toolbarSize)
  191. self.InitToolbar(self.mapdisplay, self.toolbar, self.ToolbarData())
  192. # realize the toolbar
  193. self.toolbar.Realize()
  194. def ToolbarData(self):
  195. """Toolbar data"""
  196. self.displaymap = wx.NewId()
  197. self.rendermap = wx.NewId()
  198. self.erase = wx.NewId()
  199. self.gcpset = wx.NewId()
  200. self.pan = wx.NewId()
  201. self.zoomin = wx.NewId()
  202. self.zoomout = wx.NewId()
  203. self.zoomback = wx.NewId()
  204. self.zoommenu = wx.NewId()
  205. # tool, label, bitmap, kind, shortHelp, longHelp, handler
  206. return (
  207. (self.displaymap, "displaymap", Icons["displaymap"].GetBitmap(),
  208. wx.ITEM_NORMAL, Icons["displaymap"].GetLabel(), Icons["displaymap"].GetDesc(),
  209. self.mapdisplay.OnDraw),
  210. (self.rendermap, "rendermap", Icons["rendermap"].GetBitmap(),
  211. wx.ITEM_NORMAL, Icons["rendermap"].GetLabel(), Icons["rendermap"].GetDesc(),
  212. self.mapdisplay.OnRender),
  213. (self.erase, "erase", Icons["erase"].GetBitmap(),
  214. wx.ITEM_NORMAL, Icons["erase"].GetLabel(), Icons["erase"].GetDesc(),
  215. self.mapdisplay.OnErase),
  216. ("", "", "", "", "", "", ""),
  217. (self.gcpset, "grGcpSet", Icons["grGcpSet"].GetBitmap(),
  218. wx.ITEM_RADIO, Icons["grGcpSet"].GetLabel(), Icons["grGcpSet"].GetDesc(),
  219. self.mapdisplay.OnPointer),
  220. (self.pan, "pan", Icons["pan"].GetBitmap(),
  221. wx.ITEM_RADIO, Icons["pan"].GetLabel(), Icons["pan"].GetDesc(),
  222. self.mapdisplay.OnPan),
  223. (self.zoomin, "zoom_in", Icons["zoom_in"].GetBitmap(),
  224. wx.ITEM_RADIO, Icons["zoom_in"].GetLabel(), Icons["zoom_in"].GetDesc(),
  225. self.mapdisplay.OnZoomIn),
  226. (self.zoomout, "zoom_out", Icons["zoom_out"].GetBitmap(),
  227. wx.ITEM_RADIO, Icons["zoom_out"].GetLabel(), Icons["zoom_out"].GetDesc(),
  228. self.mapdisplay.OnZoomOut),
  229. (self.zoomback, "zoom_back", Icons["zoom_back"].GetBitmap(),
  230. wx.ITEM_NORMAL, Icons["zoom_back"].GetLabel(), Icons["zoom_back"].GetDesc(),
  231. self.mapdisplay.OnZoomBack),
  232. (self.zoommenu, "zoommenu", Icons["zoommenu"].GetBitmap(),
  233. wx.ITEM_NORMAL, Icons["zoommenu"].GetLabel(), Icons["zoommenu"].GetDesc(),
  234. self.mapdisplay.OnZoomMenu),
  235. )
  236. class GCPToolbar(AbstractToolbar):
  237. """
  238. Toolbar for digitization
  239. """
  240. def __init__(self, parent, mapdisplay, map):
  241. self.parent = parent # GCP
  242. self.mapcontent = map
  243. self.mapdisplay = mapdisplay
  244. self.toolbar = wx.ToolBar(parent=self.mapdisplay, id=wx.ID_ANY)
  245. # self.SetToolBar(self.toolbar)
  246. self.toolbar.SetToolBitmapSize(globalvar.toolbarSize)
  247. self.InitToolbar(self.mapdisplay, self.toolbar, self.ToolbarData())
  248. # realize the toolbar
  249. self.toolbar.Realize()
  250. def ToolbarData(self):
  251. self.gcpSave = wx.NewId()
  252. self.gcpAdd = wx.NewId()
  253. self.gcpDelete = wx.NewId()
  254. self.gcpClear = wx.NewId()
  255. self.gcpReload = wx.NewId()
  256. self.rms = wx.NewId()
  257. self.georect = wx.NewId()
  258. self.settings = wx.NewId()
  259. self.quit = wx.NewId()
  260. return (
  261. (self.gcpSave, 'grGcpSave', Icons["grGcpSave"].GetBitmap(),
  262. wx.ITEM_NORMAL, Icons["grGcpSave"].GetLabel(), Icons["grGcpSave"].GetDesc(),
  263. self.parent.SaveGCPs),
  264. (self.gcpAdd, 'grGrGcpAdd', Icons["grGcpAdd"].GetBitmap(),
  265. wx.ITEM_NORMAL, Icons["grGcpAdd"].GetLabel(), Icons["grGcpAdd"].GetDesc(),
  266. self.parent.AddGCP),
  267. (self.gcpDelete, 'grGrGcpDelete', Icons["grGcpDelete"].GetBitmap(),
  268. wx.ITEM_NORMAL, Icons["grGcpDelete"].GetLabel(), Icons["grGcpDelete"].GetDesc(),
  269. self.parent.DeleteGCP),
  270. (self.gcpClear, 'grGcpClear', Icons["grGcpClear"].GetBitmap(),
  271. wx.ITEM_NORMAL, Icons["grGcpClear"].GetLabel(), Icons["grGcpClear"].GetDesc(),
  272. self.parent.ClearGCP),
  273. (self.gcpReload, 'grGcpReload', Icons["grGcpReload"].GetBitmap(),
  274. wx.ITEM_NORMAL, Icons["grGcpReload"].GetLabel(), Icons["grGcpReload"].GetDesc(),
  275. self.parent.ReloadGCPs),
  276. ("", "", "", "", "", "", ""),
  277. (self.rms, 'grGcpRms', Icons["grGcpRms"].GetBitmap(),
  278. wx.ITEM_NORMAL, Icons["grGcpRms"].GetLabel(), Icons["grGcpRms"].GetDesc(),
  279. self.parent.OnRMS),
  280. (self.georect, 'grGeorect', Icons["grGeorect"].GetBitmap(),
  281. wx.ITEM_NORMAL, Icons["grGeorect"].GetLabel(), Icons["grGeorect"].GetDesc(),
  282. self.parent.OnGeorect),
  283. ("", "", "", "", "", "", ""),
  284. (self.settings, 'grSettings', Icons["grSettings"].GetBitmap(),
  285. wx.ITEM_NORMAL, Icons["grSettings"].GetLabel(), Icons["grSettings"].GetDesc(),
  286. self.parent.OnSettings),
  287. (self.quit, 'grGcpQuit', Icons["grGcpQuit"].GetBitmap(),
  288. wx.ITEM_NORMAL, Icons["grGcpQuit"].GetLabel(), Icons["grGcpQuit"].GetDesc(),
  289. self.parent.OnQuit)
  290. )
  291. class VDigitToolbar(AbstractToolbar):
  292. """
  293. Toolbar for digitization
  294. """
  295. def __init__(self, parent, map, layerTree=None):
  296. self.mapcontent = map # Map class instance
  297. self.parent = parent # MapFrame
  298. self.layerTree = layerTree # reference to layer tree associated to map display
  299. # selected map to digitize
  300. self.layerSelectedID = None
  301. self.layers = []
  302. # default action (digitize new point, line, etc.)
  303. self.action = "addLine"
  304. self.type = "point"
  305. self.addString = ""
  306. self.comboid = None
  307. # only one dialog can be open
  308. self.settingsDialog = None
  309. # create toolbars (two rows optionaly)
  310. self.toolbar = []
  311. self.numOfRows = 1 # number of rows for toolbar
  312. for row in range(0, self.numOfRows):
  313. self.toolbar.append(wx.ToolBar(parent=self.parent, id=wx.ID_ANY))
  314. self.toolbar[row].SetToolBitmapSize(globalvar.toolbarSize)
  315. self.toolbar[row].Bind(wx.EVT_TOOL, self.OnTool)
  316. # create toolbar
  317. if self.numOfRows == 1:
  318. rowdata=None
  319. else:
  320. rowdata = row
  321. self.InitToolbar(self.parent, self.toolbar[row], self.ToolbarData(rowdata))
  322. # list of available vector maps
  323. self.UpdateListOfLayers(updateTool=True)
  324. # realize toolbar
  325. for row in range(0, self.numOfRows):
  326. self.toolbar[row].Realize()
  327. # disable undo/redo
  328. self.toolbar[0].EnableTool(self.undo, False)
  329. # toogle to pointer by default
  330. self.OnTool(None)
  331. def ToolbarData(self, row=None):
  332. """
  333. Toolbar data
  334. """
  335. data = []
  336. if row is None or row == 0:
  337. self.addPoint = wx.NewId()
  338. self.addLine = wx.NewId()
  339. self.addBoundary = wx.NewId()
  340. self.addCentroid = wx.NewId()
  341. self.moveVertex = wx.NewId()
  342. self.addVertex = wx.NewId()
  343. self.removeVertex = wx.NewId()
  344. self.splitLine = wx.NewId()
  345. self.editLine = wx.NewId()
  346. self.moveLine = wx.NewId()
  347. self.deleteLine = wx.NewId()
  348. self.additionalTools = wx.NewId()
  349. self.displayCats = wx.NewId()
  350. self.displayAttr = wx.NewId()
  351. self.copyCats = wx.NewId()
  352. data = [("", "", "", "", "", "", ""),
  353. (self.addPoint, "digAddPoint", Icons["digAddPoint"].GetBitmap(),
  354. wx.ITEM_RADIO, Icons["digAddPoint"].GetLabel(), Icons["digAddPoint"].GetDesc(),
  355. self.OnAddPoint),
  356. (self.addLine, "digAddLine", Icons["digAddLine"].GetBitmap(),
  357. wx.ITEM_RADIO, Icons["digAddLine"].GetLabel(), Icons["digAddLine"].GetDesc(),
  358. self.OnAddLine),
  359. (self.addBoundary, "digAddBoundary", Icons["digAddBoundary"].GetBitmap(),
  360. wx.ITEM_RADIO, Icons["digAddBoundary"].GetLabel(), Icons["digAddBoundary"].GetDesc(),
  361. self.OnAddBoundary),
  362. (self.addCentroid, "digAddCentroid", Icons["digAddCentroid"].GetBitmap(),
  363. wx.ITEM_RADIO, Icons["digAddCentroid"].GetLabel(), Icons["digAddCentroid"].GetDesc(),
  364. self.OnAddCentroid),
  365. (self.moveVertex, "digMoveVertex", Icons["digMoveVertex"].GetBitmap(),
  366. wx.ITEM_RADIO, Icons["digMoveVertex"].GetLabel(), Icons["digMoveVertex"].GetDesc(),
  367. self.OnMoveVertex),
  368. (self.addVertex, "digAddVertex", Icons["digAddVertex"].GetBitmap(),
  369. wx.ITEM_RADIO, Icons["digAddVertex"].GetLabel(), Icons["digAddVertex"].GetDesc(),
  370. self.OnAddVertex),
  371. (self.removeVertex, "digRemoveVertex", Icons["digRemoveVertex"].GetBitmap(),
  372. wx.ITEM_RADIO, Icons["digRemoveVertex"].GetLabel(), Icons["digRemoveVertex"].GetDesc(),
  373. self.OnRemoveVertex),
  374. (self.splitLine, "digSplitLine", Icons["digSplitLine"].GetBitmap(),
  375. wx.ITEM_RADIO, Icons["digSplitLine"].GetLabel(), Icons["digSplitLine"].GetDesc(),
  376. self.OnSplitLine),
  377. (self.editLine, "digEditLine", Icons["digEditLine"].GetBitmap(),
  378. wx.ITEM_RADIO, Icons["digEditLine"].GetLabel(), Icons["digEditLine"].GetDesc(),
  379. self.OnEditLine),
  380. (self.moveLine, "digMoveLine", Icons["digMoveLine"].GetBitmap(),
  381. wx.ITEM_RADIO, Icons["digMoveLine"].GetLabel(), Icons["digMoveLine"].GetDesc(),
  382. self.OnMoveLine),
  383. (self.deleteLine, "digDeleteLine", Icons["digDeleteLine"].GetBitmap(),
  384. wx.ITEM_RADIO, Icons["digDeleteLine"].GetLabel(), Icons["digDeleteLine"].GetDesc(),
  385. self.OnDeleteLine),
  386. (self.displayCats, "digDispCats", Icons["digDispCats"].GetBitmap(),
  387. wx.ITEM_RADIO, Icons["digDispCats"].GetLabel(), Icons["digDispCats"].GetDesc(),
  388. self.OnDisplayCats),
  389. (self.copyCats, "digCopyCats", Icons["digCopyCats"].GetBitmap(),
  390. wx.ITEM_RADIO, Icons["digCopyCats"].GetLabel(), Icons["digCopyCats"].GetDesc(),
  391. self.OnCopyCats),
  392. (self.displayAttr, "digDispAttr", Icons["digDispAttr"].GetBitmap(),
  393. wx.ITEM_RADIO, Icons["digDispAttr"].GetLabel(), Icons["digDispAttr"].GetDesc(),
  394. self.OnDisplayAttr),
  395. (self.additionalTools, "digAdditionalTools", Icons["digAdditionalTools"].GetBitmap(),
  396. wx.ITEM_RADIO, Icons["digAdditionalTools"].GetLabel(),
  397. Icons["digAdditionalTools"].GetDesc(),
  398. self.OnAdditionalToolMenu)]
  399. if row is None or row == 1:
  400. self.undo = wx.NewId()
  401. self.settings = wx.NewId()
  402. self.exit = wx.NewId()
  403. data.append(("", "", "", "", "", "", ""))
  404. data.append((self.undo, "digUndo", Icons["digUndo"].GetBitmap(),
  405. wx.ITEM_NORMAL, Icons["digUndo"].GetLabel(), Icons["digUndo"].GetDesc(),
  406. self.OnUndo))
  407. # data.append((self.undo, "digRedo", Icons["digRedo"].GetBitmap(),
  408. # wx.ITEM_NORMAL, Icons["digRedo"].GetLabel(), Icons["digRedo"].GetDesc(),
  409. # self.OnRedo))
  410. data.append((self.settings, "digSettings", Icons["digSettings"].GetBitmap(),
  411. wx.ITEM_NORMAL, Icons["digSettings"].GetLabel(), Icons["digSettings"].GetDesc(),
  412. self.OnSettings))
  413. data.append((self.exit, "digExit", Icons["quit"].GetBitmap(),
  414. wx.ITEM_NORMAL, Icons["digExit"].GetLabel(), Icons["digExit"].GetDesc(),
  415. self.OnExit))
  416. return data
  417. def OnTool(self, event):
  418. """Tool selected -> toggle tool to pointer"""
  419. id = self.parent.toolbars['map'].pointer
  420. self.parent.toolbars['map'].toolbar.ToggleTool(id, True)
  421. self.parent.toolbars['map'].mapdisplay.OnPointer(event)
  422. if event:
  423. event.Skip()
  424. def OnAddPoint(self, event):
  425. """Add point to the vector map Laier"""
  426. Debug.msg (2, "VDigitToolbar.OnAddPoint()")
  427. self.action = "addLine"
  428. self.type = "point"
  429. self.parent.MapWindow.mouse['box'] = 'point'
  430. def OnAddLine(self, event):
  431. """Add line to the vector map layer"""
  432. Debug.msg (2, "VDigitToolbar.OnAddLine()")
  433. self.action = "addLine"
  434. self.type = "line"
  435. self.parent.MapWindow.mouse['box'] = 'line'
  436. self.parent.MapWindow.polycoords = [] # reset temp line
  437. def OnAddBoundary(self, event):
  438. """Add boundary to the vector map layer"""
  439. Debug.msg (2, "VDigitToolbar.OnAddBoundary()")
  440. self.action = "addLine"
  441. self.type = "boundary"
  442. self.parent.MapWindow.mouse['box'] = 'line'
  443. self.parent.MapWindow.polycoords = [] # reset temp line
  444. def OnAddCentroid(self, event):
  445. """Add centroid to the vector map layer"""
  446. Debug.msg (2, "VDigitToolbar.OnAddCentroid()")
  447. self.action = "addLine"
  448. self.type = "centroid"
  449. self.parent.MapWindow.mouse['box'] = 'point'
  450. def OnExit (self, event=None):
  451. """Quit digitization tool"""
  452. # stop editing of the currently selected map layer
  453. try:
  454. self.StopEditing(self.layers[self.layerSelectedID])
  455. except:
  456. pass
  457. # close dialogs if still open
  458. if self.settingsDialog:
  459. self.settingsDialog.OnCancel(None)
  460. if self.parent.dialogs['category']:
  461. self.parent.dialogs['category'].OnCancel(None)
  462. if self.parent.dialogs['attributes']:
  463. self.parent.dialogs['attributes'].OnCancel(None)
  464. # disable the toolbar
  465. self.parent.RemoveToolbar ("vdigit")
  466. def OnMoveVertex(self, event):
  467. """Move line vertex"""
  468. Debug.msg(2, "Digittoolbar.OnMoveVertex():")
  469. self.action = "moveVertex"
  470. self.parent.MapWindow.mouse['box'] = 'point'
  471. def OnAddVertex(self, event):
  472. """Add line vertex"""
  473. Debug.msg(2, "Digittoolbar.OnAddVertex():")
  474. self.action = "addVertex"
  475. self.parent.MapWindow.mouse['box'] = 'point'
  476. def OnRemoveVertex(self, event):
  477. """Remove line vertex"""
  478. Debug.msg(2, "Digittoolbar.OnRemoveVertex():")
  479. self.action = "removeVertex"
  480. self.parent.MapWindow.mouse['box'] = 'point'
  481. def OnSplitLine(self, event):
  482. """Split line"""
  483. Debug.msg(2, "Digittoolbar.OnSplitLine():")
  484. self.action = "splitLine"
  485. self.parent.MapWindow.mouse['box'] = 'point'
  486. def OnEditLine(self, event):
  487. """Edit line"""
  488. Debug.msg(2, "Digittoolbar.OnEditLine():")
  489. self.action="editLine"
  490. self.parent.MapWindow.mouse['box'] = 'line'
  491. def OnMoveLine(self, event):
  492. """Move line"""
  493. Debug.msg(2, "Digittoolbar.OnMoveLine():")
  494. self.action = "moveLine"
  495. self.parent.MapWindow.mouse['box'] = 'box'
  496. def OnDeleteLine(self, event):
  497. """Delete line"""
  498. Debug.msg(2, "Digittoolbar.OnDeleteLine():")
  499. self.action = "deleteLine"
  500. self.parent.MapWindow.mouse['box'] = 'box'
  501. def OnDisplayCats(self, event):
  502. """Display/update categories"""
  503. Debug.msg(2, "Digittoolbar.OnDisplayCats():")
  504. self.action="displayCats"
  505. self.parent.MapWindow.mouse['box'] = 'point'
  506. def OnDisplayAttr(self, event):
  507. """Display/update attributes"""
  508. Debug.msg(2, "Digittoolbar.OnDisplayAttr():")
  509. self.action="displayAttrs"
  510. self.parent.MapWindow.mouse['box'] = 'point'
  511. def OnCopyCats(self, event):
  512. """Copy categories"""
  513. Debug.msg(2, "Digittoolbar.OnCopyCats():")
  514. self.action="copyCats"
  515. self.parent.MapWindow.mouse['box'] = 'point'
  516. def OnUndo(self, event):
  517. """Undo previous changes"""
  518. self.parent.digit.Undo()
  519. event.Skip()
  520. def EnableUndo(self, enable=True):
  521. """Enable 'Undo' in toolbar
  522. @param enable False for disable
  523. """
  524. if enable:
  525. if self.toolbar[0].GetToolEnabled(self.undo) is False:
  526. self.toolbar[0].EnableTool(self.undo, True)
  527. else:
  528. if self.toolbar[0].GetToolEnabled(self.undo) is True:
  529. self.toolbar[0].EnableTool(self.undo, False)
  530. def OnSettings(self, event):
  531. """Show settings dialog"""
  532. if self.parent.digit is None:
  533. reload(vdigit)
  534. from vdigit import Digit as Digit
  535. self.parent.digit = Digit(mapwindow=self.parent.MapWindow)
  536. if not self.settingsDialog:
  537. self.settingsDialog = VDigitSettingsDialog(parent=self.parent, title=_("Digitization settings"),
  538. style=wx.DEFAULT_DIALOG_STYLE)
  539. self.settingsDialog.Show()
  540. def OnAdditionalToolMenu(self, event):
  541. """Menu for additional tools"""
  542. point = wx.GetMousePosition()
  543. toolMenu = wx.Menu()
  544. # Add items to the menu
  545. copy = wx.MenuItem(toolMenu, wx.ID_ANY, _('Copy features from (background) vector map'))
  546. toolMenu.AppendItem(copy)
  547. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnCopy, copy)
  548. flip = wx.MenuItem(toolMenu, wx.ID_ANY, _('Flip selected lines/boundaries'))
  549. toolMenu.AppendItem(flip)
  550. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnFlip, flip)
  551. merge = wx.MenuItem(toolMenu, wx.ID_ANY, _('Merge selected lines/boundaries'))
  552. toolMenu.AppendItem(merge)
  553. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnMerge, merge)
  554. breakL = wx.MenuItem(toolMenu, wx.ID_ANY, _('Break selected lines/boundaries at intersection'))
  555. toolMenu.AppendItem(breakL)
  556. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnBreak, breakL)
  557. snap = wx.MenuItem(toolMenu, wx.ID_ANY, _('Snap selected lines/boundaries (only to nodes)'))
  558. toolMenu.AppendItem(snap)
  559. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnSnap, snap)
  560. connect = wx.MenuItem(toolMenu, wx.ID_ANY, _('Connect two selected lines/boundaries'))
  561. toolMenu.AppendItem(connect)
  562. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnConnect, connect)
  563. query = wx.MenuItem(toolMenu, wx.ID_ANY, _('Query tool'))
  564. toolMenu.AppendItem(query)
  565. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnQuery, query)
  566. zbulk = wx.MenuItem(toolMenu, wx.ID_ANY, _('Z bulk-labeling of 3D lines'))
  567. toolMenu.AppendItem(zbulk)
  568. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnZBulk, zbulk)
  569. typeconv = wx.MenuItem(toolMenu, wx.ID_ANY, _('Feature type conversion'))
  570. toolMenu.AppendItem(typeconv)
  571. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnTypeConversion, typeconv)
  572. # Popup the menu. If an item is selected then its handler
  573. # will be called before PopupMenu returns.
  574. self.parent.MapWindow.PopupMenu(toolMenu)
  575. toolMenu.Destroy()
  576. def OnCopy(self, event):
  577. """Copy selected features from (background) vector map"""
  578. Debug.msg(2, "Digittoolbar.OnCopy():")
  579. self.action="copyLine"
  580. self.parent.MapWindow.mouse['box'] = 'box'
  581. def OnFlip(self, event):
  582. """Flip selected lines/boundaries"""
  583. Debug.msg(2, "Digittoolbar.OnFlip():")
  584. self.action="flipLine"
  585. self.parent.MapWindow.mouse['box'] = 'box'
  586. def OnMerge(self, event):
  587. """Merge selected lines/boundaries"""
  588. Debug.msg(2, "Digittoolbar.OnMerge():")
  589. self.action="mergeLine"
  590. self.parent.MapWindow.mouse['box'] = 'box'
  591. def OnBreak(self, event):
  592. """Break selected lines/boundaries"""
  593. Debug.msg(2, "Digittoolbar.OnBreak():")
  594. self.action="breakLine"
  595. self.parent.MapWindow.mouse['box'] = 'box'
  596. def OnSnap(self, event):
  597. """Snap selected features"""
  598. Debug.msg(2, "Digittoolbar.OnSnap():")
  599. self.action="snapLine"
  600. self.parent.MapWindow.mouse['box'] = 'box'
  601. def OnConnect(self, event):
  602. """Connect selected lines/boundaries"""
  603. Debug.msg(2, "Digittoolbar.OnConnect():")
  604. self.action="connectLine"
  605. self.parent.MapWindow.mouse['box'] = 'point'
  606. def OnQuery(self, event):
  607. """Query selected lines/boundaries"""
  608. Debug.msg(2, "Digittoolbar.OnQuery(): %s" % \
  609. UserSettings.Get(group='vdigit', key='query', subkey='type'))
  610. self.action="queryLine"
  611. self.parent.MapWindow.mouse['box'] = 'box'
  612. def OnZBulk(self, event):
  613. """Z bulk-labeling selected lines/boundaries"""
  614. Debug.msg(2, "Digittoolbar.OnZBulk():")
  615. self.action="zbulkLine"
  616. self.parent.MapWindow.mouse['box'] = 'line'
  617. def OnTypeConversion(self, event):
  618. """Feature type conversion
  619. Supported conversions:
  620. - point <-> centroid
  621. - line <-> boundary
  622. """
  623. Debug.msg(2, "Digittoolbar.OnTypeConversion():")
  624. self.action="typeConv"
  625. self.parent.MapWindow.mouse['box'] = 'box'
  626. def OnSelectMap (self, event):
  627. """
  628. Select vector map layer for editing
  629. If there is a vector map layer already edited, this action is
  630. firstly terminated. The map layer is closed. After this the
  631. selected map layer activated for editing.
  632. """
  633. if event.GetSelection() == 0: # create new vector map layer
  634. if self.layerSelectedID is not None:
  635. openVectorMap = self.layers[self.layerSelectedID].name.split('@')[0]
  636. else:
  637. openVectorMap = None
  638. mapName = gdialogs.CreateNewVector(self.parent,
  639. exceptMap=openVectorMap)
  640. if mapName:
  641. # add layer to map layer tree
  642. if self.layerTree:
  643. self.layerTree.AddLayer(ltype='vector',
  644. lname=mapName,
  645. lchecked=True,
  646. lopacity=1.0,
  647. lcmd=['d.vect', 'map=%s' % mapName])
  648. vectLayers = self.UpdateListOfLayers(updateTool=True)
  649. selection = vectLayers.index(mapName)
  650. else:
  651. pass # TODO (no Layer Manager)
  652. else:
  653. self.combo.SetValue(_('Select vector map'))
  654. return
  655. else:
  656. selection = event.GetSelection() - 1 # first option is 'New vector map'
  657. if self.layerSelectedID == selection:
  658. return False
  659. if self.layerSelectedID != None: # deactive map layer for editing
  660. self.StopEditing(self.layers[self.layerSelectedID])
  661. # select the given map layer for editing
  662. self.layerSelectedID = selection
  663. self.StartEditing(self.layers[self.layerSelectedID])
  664. event.Skip()
  665. return True
  666. def StartEditing (self, layerSelected):
  667. """
  668. Start editing of selected vector map layer.
  669. @param layerSelectedId id of layer to be edited
  670. @return True on success
  671. @return False on error
  672. """
  673. reload(vdigit)
  674. from vdigit import Digit as Digit
  675. self.parent.digit = Digit(mapwindow=self.parent.MapWindow)
  676. try:
  677. self.layerSelectedID = self.layers.index(layerSelected)
  678. mapLayer = self.layers[self.layerSelectedID]
  679. except:
  680. return False
  681. try:
  682. self.parent.digit.SetMapName(mapLayer.name)
  683. except gcmd.DigitError, e:
  684. self.layerSelectedID = None
  685. print >> sys.stderr, e # wxMessageBox
  686. return False
  687. # update toolbar
  688. self.combo.SetValue (layerSelected.name)
  689. self.parent.toolbars['map'].combo.SetValue ('Digitize')
  690. # set initial category number for new features (layer=1), etc.
  691. Debug.msg (4, "VDigitToolbar.StartEditing(): layerSelectedID=%d layer=%s" % \
  692. (self.layerSelectedID, mapLayer.name))
  693. # deactive layer
  694. self.mapcontent.ChangeLayerActive(mapLayer, False)
  695. # change cursor
  696. if self.parent.MapWindow.mouse['use'] == 'pointer':
  697. self.parent.MapWindow.SetCursor(self.parent.cursors["cross"])
  698. # create pseudoDC for drawing the map
  699. self.parent.MapWindow.pdcVector = wx.PseudoDC()
  700. self.parent.digit.driver.SetDevice(self.parent.MapWindow.pdcVector)
  701. # self.parent.MapWindow.UpdateMap()
  702. if not self.parent.MapWindow.resize:
  703. self.parent.MapWindow.UpdateMap(render=True)
  704. return True
  705. def StopEditing (self, layerSelected):
  706. """
  707. Stop editing of selected vector map layer.
  708. """
  709. if self.layers[self.layerSelectedID] == layerSelected:
  710. self.layerSelectedID = None
  711. Debug.msg (4, "VDigitToolbar.StopEditing(): layer=%s" % \
  712. (layerSelected.name))
  713. self.combo.SetValue (_('Select vector map'))
  714. # save changes (only for vdigit)
  715. if UserSettings.Get(group='advanced', key='digitInterface', subkey='type') == 'vdigit':
  716. if UserSettings.Get(group='vdigit', key='saveOnExit', subkey='enabled') is False:
  717. dlg = wx.MessageDialog(parent=self.parent, message=_("Do you want to save changes "
  718. "in vector map <%s>?") % layerSelected.name,
  719. caption=_("Save changes?"),
  720. style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
  721. if dlg.ShowModal() == wx.ID_NO:
  722. # revert changes
  723. self.parent.digit.Undo(0)
  724. dlg.Destroy()
  725. self.parent.digit.SetMapName(None) # -> close map
  726. # re-active layer
  727. item = self.parent.tree.FindItemByData('maplayer', layerSelected)
  728. if item and self.parent.tree.IsItemChecked(item):
  729. self.mapcontent.ChangeLayerActive(layerSelected, True)
  730. # change cursor
  731. self.parent.MapWindow.SetCursor(self.parent.cursors["default"])
  732. # disable pseudodc for vector map layer
  733. self.parent.MapWindow.pdcVector = None
  734. self.parent.digit.driver.SetDevice(None)
  735. self.parent.digit.__del__() # FIXME: destructor is not called here (del)
  736. self.parent.digit = None
  737. return True
  738. return False
  739. def UpdateListOfLayers (self, updateTool=False):
  740. """
  741. Update list of available vector map layers.
  742. This list consists only editable layers (in the current mapset)
  743. Optionaly also update toolbar
  744. """
  745. Debug.msg (4, "VDigitToolbar.UpdateListOfLayers(): updateTool=%d" % \
  746. updateTool)
  747. layerNameSelected = None
  748. if self.layerSelectedID != None: # name of currently selected layer
  749. layerNameSelected = self.layers[self.layerSelectedID].name
  750. # select vector map layer in the current mapset
  751. layerNameList = []
  752. self.layers = self.mapcontent.GetListOfLayers(l_type="vector",
  753. l_mapset=grassenv.GetGRASSVariable('MAPSET'))
  754. for layer in self.layers:
  755. if not layer.name in layerNameList: # do not duplicate layer
  756. layerNameList.append (layer.name)
  757. if updateTool: # update toolbar
  758. if self.layerSelectedID == None:
  759. value = _('Select vector map')
  760. else:
  761. value = layerNameSelected
  762. if not self.comboid:
  763. self.combo = wx.ComboBox(self.toolbar[self.numOfRows-1], id=wx.ID_ANY, value=value,
  764. choices=[_('New vector map'), ] + layerNameList, size=(105, -1),
  765. style=wx.CB_READONLY)
  766. self.comboid = self.toolbar[self.numOfRows-1].InsertControl(0, self.combo)
  767. self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectMap, self.comboid)
  768. else:
  769. self.combo.SetItems([_('New vector map'), ] + layerNameList)
  770. # update layer index
  771. try:
  772. self.layerSelectedID = layerNameList.index(value)
  773. except ValueError:
  774. self.layerSelectedID = None
  775. self.toolbar[self.numOfRows-1].Realize()
  776. return layerNameList
  777. class ProfileToolbar(AbstractToolbar):
  778. """
  779. Toolbar for digitization
  780. """
  781. def __init__(self, parent, mapdisplay, map):
  782. self.parent = parent
  783. self.mapcontent = map
  784. self.mapdisplay = mapdisplay
  785. self.toolbar = wx.ToolBar(parent=self.mapdisplay, id=wx.ID_ANY)
  786. # self.SetToolBar(self.toolbar)
  787. self.toolbar.SetToolBitmapSize(globalvar.toolbarSize)
  788. self.InitToolbar(self.mapdisplay, self.toolbar, self.ToolbarData())
  789. # realize the toolbar
  790. self.toolbar.Realize()
  791. def ToolbarData(self):
  792. """Toolbar data"""
  793. self.transect = wx.NewId()
  794. self.addraster = wx.NewId()
  795. self.draw = wx.NewId()
  796. self.options = wx.NewId()
  797. self.drag = wx.NewId()
  798. self.zoom = wx.NewId()
  799. self.unzoom = wx.NewId()
  800. self.erase = wx.NewId()
  801. self.save = wx.NewId()
  802. self.printer = wx.NewId()
  803. self.quit = wx.NewId()
  804. # tool, label, bitmap, kind, shortHelp, longHelp, handler
  805. return (
  806. (self.transect, 'transect', Icons["transect"].GetBitmap(),
  807. wx.ITEM_NORMAL, Icons["transect"].GetLabel(), Icons["transect"].GetDesc(),
  808. self.parent.OnDrawTransect),
  809. (self.addraster, 'raster', Icons["addrast"].GetBitmap(),
  810. wx.ITEM_NORMAL, Icons["addrast"].GetLabel(), Icons["addrast"].GetDesc(),
  811. self.parent.OnSelectRaster),
  812. (self.draw, 'profiledraw', Icons["profiledraw"].GetBitmap(),
  813. wx.ITEM_NORMAL, Icons["profiledraw"].GetLabel(), Icons["profiledraw"].GetDesc(),
  814. self.parent.OnCreateProfile),
  815. (self.options, 'options', Icons["profileopt"].GetBitmap(),
  816. wx.ITEM_NORMAL, Icons["profileopt"].GetLabel(), Icons["profileopt"].GetDesc(),
  817. self.parent.ProfileOptionsMenu),
  818. (self.drag, 'drag', Icons['pan'].GetBitmap(),
  819. wx.ITEM_NORMAL, Icons["pan"].GetLabel(), Icons["pan"].GetDesc(),
  820. self.parent.OnDrag),
  821. (self.zoom, 'zoom', Icons['zoom_in'].GetBitmap(),
  822. wx.ITEM_NORMAL, Icons["zoom_in"].GetLabel(), Icons["zoom_in"].GetDesc(),
  823. self.parent.OnZoom),
  824. (self.unzoom, 'unzoom', Icons['zoom_back'].GetBitmap(),
  825. wx.ITEM_NORMAL, Icons["zoom_back"].GetLabel(), Icons["zoom_back"].GetDesc(),
  826. self.parent.OnRedraw),
  827. (self.erase, 'erase', Icons["erase"].GetBitmap(),
  828. wx.ITEM_NORMAL, Icons["erase"].GetLabel(), Icons["erase"].GetDesc(),
  829. self.parent.OnErase),
  830. ("", "", "", "", "", "", ""),
  831. (self.save, 'save', Icons["savefile"].GetBitmap(),
  832. wx.ITEM_NORMAL, Icons["savefile"].GetLabel(), Icons["savefile"].GetDesc(),
  833. self.parent.SaveToFile),
  834. (self.printer, 'print', Icons["printmap"].GetBitmap(),
  835. wx.ITEM_NORMAL, Icons["printmap"].GetLabel(), Icons["printmap"].GetDesc(),
  836. self.parent.PrintMenu),
  837. (self.quit, 'quit', Icons["quit"].GetBitmap(),
  838. wx.ITEM_NORMAL, Icons["quit"].GetLabel(), Icons["quit"].GetDesc(),
  839. self.parent.OnQuit),
  840. )
  841. class NvizToolbar(AbstractToolbar):
  842. """
  843. Nviz toolbar
  844. """
  845. def __init__(self, parent, map):
  846. self.parent = parent
  847. self.mapcontent = map
  848. self.toolbar = wx.ToolBar(parent=self.parent, id=wx.ID_ANY)
  849. # self.SetToolBar(self.toolbar)
  850. self.toolbar.SetToolBitmapSize(globalvar.toolbarSize)
  851. self.InitToolbar(self.parent, self.toolbar, self.ToolbarData())
  852. # realize the toolbar
  853. self.toolbar.Realize()
  854. def ToolbarData(self):
  855. """Toolbar data"""
  856. self.quit = wx.NewId()
  857. # tool, label, bitmap, kind, shortHelp, longHelp, handler
  858. return (
  859. (self.quit, 'quit', Icons["quit"].GetBitmap(),
  860. wx.ITEM_NORMAL, Icons["quit"].GetLabel(), Icons["quit"].GetDesc(),
  861. self.OnExit),
  862. )
  863. def OnExit (self, event=None):
  864. """Quit nviz tool (swith to 2D mode)"""
  865. # disable the toolbar
  866. self.parent.RemoveToolbar ("nviz")