toolbars.py 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579
  1. """!
  2. @package toolbar
  3. @brief wxGUI toolbar widgets
  4. Classes:
  5. - AbstractToolbar
  6. - MapToolbar
  7. - GRToolbar
  8. - GCPToolbar
  9. - VDigitToolbar
  10. - ProfileToolbar
  11. - NvizToolbar
  12. - ModelToolbar
  13. - HistogramToolbar
  14. - LayerManagerToolbar
  15. (C) 2007-2010 by the GRASS Development Team
  16. This program is free software under the GNU General Public License
  17. (>=v2). Read the file COPYING that comes with GRASS for details.
  18. @author Michael Barton
  19. @author Jachym Cepicky
  20. @author Martin Landa <landa.martin gmail.com>
  21. """
  22. import os
  23. import sys
  24. import platform
  25. from grass.script import core as grass
  26. import wx
  27. import globalvar
  28. import gcmd
  29. import gdialogs
  30. import vdigit
  31. from vdigit import VDigitSettingsDialog as VDigitSettingsDialog
  32. from debug import Debug as Debug
  33. from preferences import globalSettings as UserSettings
  34. from nviz_preferences import NvizPreferencesDialog
  35. gmpath = os.path.join(globalvar.ETCWXDIR, "icons")
  36. sys.path.append(gmpath)
  37. from icon import Icons as Icons
  38. class AbstractToolbar(wx.ToolBar):
  39. """!Abstract toolbar class"""
  40. def __init__(self, parent):
  41. self.parent = parent
  42. wx.ToolBar.__init__(self, parent = self.parent, id = wx.ID_ANY)
  43. self.action = dict()
  44. self.Bind(wx.EVT_TOOL, self.OnTool)
  45. self.SetToolBitmapSize(globalvar.toolbarSize)
  46. def InitToolbar(self, toolData):
  47. """!Initialize toolbar, add tools to the toolbar
  48. """
  49. for tool in toolData:
  50. self.CreateTool(*tool)
  51. self._data = toolData
  52. def ToolbarData(self):
  53. """!Toolbar data (virtual)"""
  54. return None
  55. def CreateTool(self, tool, label, bitmap, kind,
  56. shortHelp, longHelp, handler):
  57. """!Add tool to the toolbar
  58. @return id of tool
  59. """
  60. bmpDisabled=wx.NullBitmap
  61. if label:
  62. Debug.msg(3, "CreateTool(): tool=%d, label=%s bitmap=%s" % \
  63. (tool, label, bitmap))
  64. toolWin = self.AddLabelTool(tool, label, bitmap,
  65. bmpDisabled, kind,
  66. shortHelp, longHelp)
  67. self.Bind(wx.EVT_TOOL, handler, toolWin)
  68. else: # separator
  69. self.AddSeparator()
  70. return tool
  71. def EnableLongHelp(self, enable=True):
  72. """!Enable/disable long help
  73. @param enable True for enable otherwise disable
  74. """
  75. for tool in self._data:
  76. if tool[0] == '': # separator
  77. continue
  78. if enable:
  79. self.SetToolLongHelp(tool[0], tool[5])
  80. else:
  81. self.SetToolLongHelp(tool[0], "")
  82. def OnTool(self, event):
  83. """!Tool selected"""
  84. if self.parent.GetName() == "GCPFrame":
  85. return
  86. if self.parent.toolbars['vdigit']:
  87. # update vdigit toolbar (unselect currently selected tool)
  88. id = self.parent.toolbars['vdigit'].GetAction(type='id')
  89. self.parent.toolbars['vdigit'].ToggleTool(id, False)
  90. if event:
  91. # deselect previously selected tool
  92. id = self.action.get('id', -1)
  93. if id != event.GetId():
  94. self.ToggleTool(self.action['id'], False)
  95. else:
  96. self.ToggleTool(self.action['id'], True)
  97. self.action['id'] = event.GetId()
  98. event.Skip()
  99. else:
  100. # initialize toolbar
  101. self.ToggleTool(self.action['id'], True)
  102. def GetAction(self, type='desc'):
  103. """!Get current action info"""
  104. return self.action.get(type, '')
  105. def SelectDefault(self, event):
  106. """!Select default tool"""
  107. self.ToggleTool(self.defaultAction['id'], True)
  108. self.defaultAction['bind'](event)
  109. self.action = { 'id' : self.defaultAction['id'],
  110. 'desc' : self.defaultAction.get('desc', '') }
  111. def FixSize(self, width):
  112. """!Fix toolbar width on Windows
  113. @todo Determine why combobox causes problems here
  114. """
  115. if platform.system() == 'Windows':
  116. size = self.GetBestSize()
  117. self.SetSize((size[0] + width, size[1]))
  118. def Enable(self, tool, enable = True):
  119. """!Enable defined tool
  120. @param tool name
  121. @param enable True to enable otherwise disable tool
  122. """
  123. try:
  124. id = getattr(self, tool)
  125. except AttributeError:
  126. return
  127. self.EnableTool(id, enable)
  128. class MapToolbar(AbstractToolbar):
  129. """!Map Display toolbar
  130. """
  131. def __init__(self, parent, mapcontent):
  132. """!Map Display constructor
  133. @param parent reference to MapFrame
  134. @param mapcontent reference to render.Map (registred by MapFrame)
  135. """
  136. self.mapcontent = mapcontent # render.Map
  137. AbstractToolbar.__init__(self, parent = parent) # MapFrame
  138. self.InitToolbar(self.ToolbarData())
  139. # optional tools
  140. self.combo = wx.ComboBox(parent=self, id=wx.ID_ANY, value=_('2D view'),
  141. choices=[_('2D view'), _('3D view'), _('Digitize')],
  142. style=wx.CB_READONLY, size=(90, -1))
  143. self.comboid = self.AddControl(self.combo)
  144. self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectTool, self.comboid)
  145. # realize the toolbar
  146. self.Realize()
  147. # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
  148. self.combo.Hide()
  149. self.combo.Show()
  150. self.action = { 'id' : self.pointer }
  151. self.defaultAction = { 'id' : self.pointer,
  152. 'bind' : self.parent.OnPointer }
  153. self.OnTool(None)
  154. self.EnableTool(self.zoomback, False)
  155. self.FixSize(width = 90)
  156. def ToolbarData(self):
  157. """!Toolbar data"""
  158. self.displaymap = wx.NewId()
  159. self.rendermap = wx.NewId()
  160. self.erase = wx.NewId()
  161. self.pointer = wx.NewId()
  162. self.query = wx.NewId()
  163. self.pan = wx.NewId()
  164. self.zoomin = wx.NewId()
  165. self.zoomout = wx.NewId()
  166. self.zoomback = wx.NewId()
  167. self.zoommenu = wx.NewId()
  168. self.zoomextent = wx.NewId()
  169. self.analyze = wx.NewId()
  170. self.dec = wx.NewId()
  171. self.savefile = wx.NewId()
  172. self.printmap = wx.NewId()
  173. # tool, label, bitmap, kind, shortHelp, longHelp, handler
  174. return (
  175. (self.displaymap, "displaymap", Icons["displaymap"].GetBitmap(),
  176. wx.ITEM_NORMAL, Icons["displaymap"].GetLabel(), Icons["displaymap"].GetDesc(),
  177. self.parent.OnDraw),
  178. (self.rendermap, "rendermap", Icons["rendermap"].GetBitmap(),
  179. wx.ITEM_NORMAL, Icons["rendermap"].GetLabel(), Icons["rendermap"].GetDesc(),
  180. self.parent.OnRender),
  181. (self.erase, "erase", Icons["erase"].GetBitmap(),
  182. wx.ITEM_NORMAL, Icons["erase"].GetLabel(), Icons["erase"].GetDesc(),
  183. self.parent.OnErase),
  184. ("", "", "", "", "", "", ""),
  185. (self.pointer, "pointer", Icons["pointer"].GetBitmap(),
  186. wx.ITEM_CHECK, Icons["pointer"].GetLabel(), Icons["pointer"].GetDesc(),
  187. self.parent.OnPointer),
  188. (self.query, "query", Icons["query"].GetBitmap(),
  189. wx.ITEM_CHECK, Icons["query"].GetLabel(), Icons["query"].GetDesc(),
  190. self.parent.OnQuery),
  191. (self.pan, "pan", Icons["pan"].GetBitmap(),
  192. wx.ITEM_CHECK, Icons["pan"].GetLabel(), Icons["pan"].GetDesc(),
  193. self.parent.OnPan),
  194. (self.zoomin, "zoom_in", Icons["zoom_in"].GetBitmap(),
  195. wx.ITEM_CHECK, Icons["zoom_in"].GetLabel(), Icons["zoom_in"].GetDesc(),
  196. self.parent.OnZoomIn),
  197. (self.zoomout, "zoom_out", Icons["zoom_out"].GetBitmap(),
  198. wx.ITEM_CHECK, Icons["zoom_out"].GetLabel(), Icons["zoom_out"].GetDesc(),
  199. self.parent.OnZoomOut),
  200. (self.zoomextent, "zoom_extent", Icons["zoom_extent"].GetBitmap(),
  201. wx.ITEM_NORMAL, Icons["zoom_extent"].GetLabel(), Icons["zoom_extent"].GetDesc(),
  202. self.parent.OnZoomToMap),
  203. (self.zoomback, "zoom_back", Icons["zoom_back"].GetBitmap(),
  204. wx.ITEM_NORMAL, Icons["zoom_back"].GetLabel(), Icons["zoom_back"].GetDesc(),
  205. self.parent.OnZoomBack),
  206. (self.zoommenu, "zoommenu", Icons["zoommenu"].GetBitmap(),
  207. wx.ITEM_NORMAL, Icons["zoommenu"].GetLabel(), Icons["zoommenu"].GetDesc(),
  208. self.parent.OnZoomMenu),
  209. ("", "", "", "", "", "", ""),
  210. (self.analyze, "analyze", Icons["analyze"].GetBitmap(),
  211. wx.ITEM_NORMAL, Icons["analyze"].GetLabel(), Icons["analyze"].GetDesc(),
  212. self.parent.OnAnalyze),
  213. ("", "", "", "", "", "", ""),
  214. (self.dec, "overlay", Icons["overlay"].GetBitmap(),
  215. wx.ITEM_NORMAL, Icons["overlay"].GetLabel(), Icons["overlay"].GetDesc(),
  216. self.parent.OnDecoration),
  217. ("", "", "", "", "", "", ""),
  218. (self.savefile, "savefile", Icons["savefile"].GetBitmap(),
  219. wx.ITEM_NORMAL, Icons["savefile"].GetLabel(), Icons["savefile"].GetDesc(),
  220. self.parent.SaveToFile),
  221. (self.printmap, "printmap", Icons["printmap"].GetBitmap(),
  222. wx.ITEM_NORMAL, Icons["printmap"].GetLabel(), Icons["printmap"].GetDesc(),
  223. self.parent.PrintMenu),
  224. ("", "", "", "", "", "", "")
  225. )
  226. def OnSelectTool(self, event):
  227. """!
  228. Select / enable tool available in tools list
  229. """
  230. tool = event.GetSelection()
  231. if tool == 0:
  232. self.ExitToolbars()
  233. self.Enable2D(True)
  234. elif tool == 1 and not self.parent.toolbars['nviz']:
  235. self.ExitToolbars()
  236. self.parent.AddToolbar("nviz")
  237. elif tool == 2 and not self.parent.toolbars['vdigit']:
  238. self.ExitToolbars()
  239. self.parent.AddToolbar("vdigit")
  240. self.parent.MapWindow.SetFocus()
  241. def ExitToolbars(self):
  242. if self.parent.toolbars['vdigit']:
  243. self.parent.toolbars['vdigit'].OnExit()
  244. if self.parent.toolbars['nviz']:
  245. self.parent.toolbars['nviz'].OnExit()
  246. def Enable2D(self, enabled):
  247. """!Enable/Disable 2D display mode specific tools"""
  248. for tool in (self.pointer,
  249. self.pan,
  250. self.zoomin,
  251. self.zoomout,
  252. self.zoomback,
  253. self.zoommenu,
  254. self.analyze,
  255. self.dec,
  256. self.printmap):
  257. self.EnableTool(tool, enabled)
  258. class GRToolbar(AbstractToolbar):
  259. """
  260. Georectification toolbar
  261. """
  262. def __init__(self, parent, mapcontent):
  263. """!
  264. Georectification toolbar constructor
  265. @param parent reference to MapFrame
  266. @param mapcontent reference to render.Map (registred by MapFrame)
  267. """
  268. self.mapcontent = mapcontent
  269. AbstractToolbar.__init__(self, parent)
  270. self.InitToolbar(self.ToolbarData())
  271. # realize the toolbar
  272. self.Realize()
  273. self.action = { 'id' : self.gcpset }
  274. self.defaultAction = { 'id' : self.gcpset,
  275. 'bind' : self.parent.OnPointer }
  276. self.OnTool(None)
  277. self.EnableTool(self.zoomback, False)
  278. def ToolbarData(self):
  279. """!Toolbar data"""
  280. self.displaymap = wx.NewId()
  281. self.rendermap = wx.NewId()
  282. self.erase = wx.NewId()
  283. self.gcpset = wx.NewId()
  284. self.pan = wx.NewId()
  285. self.zoomin = wx.NewId()
  286. self.zoomout = wx.NewId()
  287. self.zoomback = wx.NewId()
  288. self.zoomtomap = wx.NewId()
  289. # tool, label, bitmap, kind, shortHelp, longHelp, handler
  290. return (
  291. (self.displaymap, "displaymap", Icons["displaymap"].GetBitmap(),
  292. wx.ITEM_NORMAL, Icons["displaymap"].GetLabel(), Icons["displaymap"].GetDesc(),
  293. self.parent.OnDraw),
  294. (self.rendermap, "rendermap", Icons["rendermap"].GetBitmap(),
  295. wx.ITEM_NORMAL, Icons["rendermap"].GetLabel(), Icons["rendermap"].GetDesc(),
  296. self.parent.OnRender),
  297. (self.erase, "erase", Icons["erase"].GetBitmap(),
  298. wx.ITEM_NORMAL, Icons["erase"].GetLabel(), Icons["erase"].GetDesc(),
  299. self.parent.OnErase),
  300. ("", "", "", "", "", "", ""),
  301. (self.gcpset, "grGcpSet", Icons["grGcpSet"].GetBitmap(),
  302. wx.ITEM_RADIO, Icons["grGcpSet"].GetLabel(), Icons["grGcpSet"].GetDesc(),
  303. self.parent.OnPointer),
  304. (self.pan, "pan", Icons["pan"].GetBitmap(),
  305. wx.ITEM_RADIO, Icons["pan"].GetLabel(), Icons["pan"].GetDesc(),
  306. self.parent.OnPan),
  307. (self.zoomin, "zoom_in", Icons["zoom_in"].GetBitmap(),
  308. wx.ITEM_RADIO, Icons["zoom_in"].GetLabel(), Icons["zoom_in"].GetDesc(),
  309. self.parent.OnZoomIn),
  310. (self.zoomout, "zoom_out", Icons["zoom_out"].GetBitmap(),
  311. wx.ITEM_RADIO, Icons["zoom_out"].GetLabel(), Icons["zoom_out"].GetDesc(),
  312. self.parent.OnZoomOut),
  313. (self.zoomback, "zoom_back", Icons["zoom_back"].GetBitmap(),
  314. wx.ITEM_NORMAL, Icons["zoom_back"].GetLabel(), Icons["zoom_back"].GetDesc(),
  315. self.parent.OnZoomBack),
  316. (self.zoomtomap, "zoomtomap", Icons["zoommenu"].GetBitmap(),
  317. wx.ITEM_NORMAL, _("Zoom to map"), _("Zoom to displayed map"),
  318. self.OnZoomMap),
  319. )
  320. def OnZoomMap(self, event):
  321. """!Zoom to selected map"""
  322. self.parent.MapWindow.ZoomToMap(layers = self.mapcontent.GetListOfLayers())
  323. if event:
  324. event.Skip()
  325. class GCPToolbar(AbstractToolbar):
  326. """!
  327. Toolbar for managing ground control points during georectification
  328. @param parent reference to GCP widget
  329. """
  330. def __init__(self, parent):
  331. AbstractToolbar.__init__(self, parent)
  332. self.InitToolbar(self.ToolbarData())
  333. # realize the toolbar
  334. self.Realize()
  335. def ToolbarData(self):
  336. self.gcpSave = wx.NewId()
  337. self.gcpAdd = wx.NewId()
  338. self.gcpDelete = wx.NewId()
  339. self.gcpClear = wx.NewId()
  340. self.gcpReload = wx.NewId()
  341. self.rms = wx.NewId()
  342. self.georect = wx.NewId()
  343. self.settings = wx.NewId()
  344. self.quit = wx.NewId()
  345. return (
  346. (self.gcpSave, 'grGcpSave', Icons["grGcpSave"].GetBitmap(),
  347. wx.ITEM_NORMAL, Icons["grGcpSave"].GetLabel(), Icons["grGcpSave"].GetDesc(),
  348. self.parent.SaveGCPs),
  349. (self.gcpAdd, 'grGrGcpAdd', Icons["grGcpAdd"].GetBitmap(),
  350. wx.ITEM_NORMAL, Icons["grGcpAdd"].GetLabel(), Icons["grGcpAdd"].GetDesc(),
  351. self.parent.AddGCP),
  352. (self.gcpDelete, 'grGrGcpDelete', Icons["grGcpDelete"].GetBitmap(),
  353. wx.ITEM_NORMAL, Icons["grGcpDelete"].GetLabel(), Icons["grGcpDelete"].GetDesc(),
  354. self.parent.DeleteGCP),
  355. (self.gcpClear, 'grGcpClear', Icons["grGcpClear"].GetBitmap(),
  356. wx.ITEM_NORMAL, Icons["grGcpClear"].GetLabel(), Icons["grGcpClear"].GetDesc(),
  357. self.parent.ClearGCP),
  358. (self.gcpReload, 'grGcpReload', Icons["grGcpReload"].GetBitmap(),
  359. wx.ITEM_NORMAL, Icons["grGcpReload"].GetLabel(), Icons["grGcpReload"].GetDesc(),
  360. self.parent.ReloadGCPs),
  361. ("", "", "", "", "", "", ""),
  362. (self.rms, 'grGcpRms', Icons["grGcpRms"].GetBitmap(),
  363. wx.ITEM_NORMAL, Icons["grGcpRms"].GetLabel(), Icons["grGcpRms"].GetDesc(),
  364. self.parent.OnRMS),
  365. (self.georect, 'grGeorect', Icons["grGeorect"].GetBitmap(),
  366. wx.ITEM_NORMAL, Icons["grGeorect"].GetLabel(), Icons["grGeorect"].GetDesc(),
  367. self.parent.OnGeorect),
  368. ("", "", "", "", "", "", ""),
  369. (self.settings, 'grSettings', Icons["grSettings"].GetBitmap(),
  370. wx.ITEM_NORMAL, Icons["grSettings"].GetLabel(), Icons["grSettings"].GetDesc(),
  371. self.parent.OnSettings),
  372. (self.quit, 'grGcpQuit', Icons["grGcpQuit"].GetBitmap(),
  373. wx.ITEM_NORMAL, Icons["grGcpQuit"].GetLabel(), Icons["grGcpQuit"].GetDesc(),
  374. self.parent.OnQuit)
  375. )
  376. class VDigitToolbar(AbstractToolbar):
  377. """
  378. Toolbar for digitization
  379. """
  380. def __init__(self, parent, mapcontent, layerTree=None, log=None):
  381. self.mapcontent = mapcontent # Map class instance
  382. self.layerTree = layerTree # reference to layer tree associated to map display
  383. self.log = log # log area
  384. AbstractToolbar.__init__(self, parent)
  385. # currently selected map layer for editing (reference to MapLayer instance)
  386. self.mapLayer = None
  387. # list of vector layers from Layer Manager (only in the current mapset)
  388. self.layers = []
  389. self.comboid = None
  390. # only one dialog can be open
  391. self.settingsDialog = None
  392. # create toolbars (two rows optionally)
  393. self.InitToolbar(self.ToolbarData())
  394. self.Bind(wx.EVT_TOOL, self.OnTool)
  395. # default action (digitize new point, line, etc.)
  396. self.action = { 'desc' : 'addLine',
  397. 'type' : 'point',
  398. 'id' : self.addPoint }
  399. # list of available vector maps
  400. self.UpdateListOfLayers(updateTool=True)
  401. # realize toolbar
  402. self.Realize()
  403. # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
  404. self.combo.Hide()
  405. self.combo.Show()
  406. # disable undo/redo
  407. self.EnableTool(self.undo, False)
  408. # toogle to pointer by default
  409. self.OnTool(None)
  410. self.FixSize(width = 105)
  411. def ToolbarData(self):
  412. """!
  413. Toolbar data
  414. """
  415. data = []
  416. self.addPoint = wx.NewId()
  417. self.addLine = wx.NewId()
  418. self.addBoundary = wx.NewId()
  419. self.addCentroid = wx.NewId()
  420. self.moveVertex = wx.NewId()
  421. self.addVertex = wx.NewId()
  422. self.removeVertex = wx.NewId()
  423. self.splitLine = wx.NewId()
  424. self.editLine = wx.NewId()
  425. self.moveLine = wx.NewId()
  426. self.deleteLine = wx.NewId()
  427. self.additionalTools = wx.NewId()
  428. self.displayCats = wx.NewId()
  429. self.displayAttr = wx.NewId()
  430. self.copyCats = wx.NewId()
  431. self.undo = wx.NewId()
  432. self.settings = wx.NewId()
  433. self.exit = wx.NewId()
  434. data = [("", "", "", "", "", "", ""),
  435. (self.addPoint, "digAddPoint", Icons["digAddPoint"].GetBitmap(),
  436. wx.ITEM_CHECK, Icons["digAddPoint"].GetLabel(), Icons["digAddPoint"].GetDesc(),
  437. self.OnAddPoint),
  438. (self.addLine, "digAddLine", Icons["digAddLine"].GetBitmap(),
  439. wx.ITEM_CHECK, Icons["digAddLine"].GetLabel(), Icons["digAddLine"].GetDesc(),
  440. self.OnAddLine),
  441. (self.addBoundary, "digAddBoundary", Icons["digAddBoundary"].GetBitmap(),
  442. wx.ITEM_CHECK, Icons["digAddBoundary"].GetLabel(), Icons["digAddBoundary"].GetDesc(),
  443. self.OnAddBoundary),
  444. (self.addCentroid, "digAddCentroid", Icons["digAddCentroid"].GetBitmap(),
  445. wx.ITEM_CHECK, Icons["digAddCentroid"].GetLabel(), Icons["digAddCentroid"].GetDesc(),
  446. self.OnAddCentroid),
  447. (self.moveVertex, "digMoveVertex", Icons["digMoveVertex"].GetBitmap(),
  448. wx.ITEM_CHECK, Icons["digMoveVertex"].GetLabel(), Icons["digMoveVertex"].GetDesc(),
  449. self.OnMoveVertex),
  450. (self.addVertex, "digAddVertex", Icons["digAddVertex"].GetBitmap(),
  451. wx.ITEM_CHECK, Icons["digAddVertex"].GetLabel(), Icons["digAddVertex"].GetDesc(),
  452. self.OnAddVertex),
  453. (self.removeVertex, "digRemoveVertex", Icons["digRemoveVertex"].GetBitmap(),
  454. wx.ITEM_CHECK, Icons["digRemoveVertex"].GetLabel(), Icons["digRemoveVertex"].GetDesc(),
  455. self.OnRemoveVertex),
  456. (self.splitLine, "digSplitLine", Icons["digSplitLine"].GetBitmap(),
  457. wx.ITEM_CHECK, Icons["digSplitLine"].GetLabel(), Icons["digSplitLine"].GetDesc(),
  458. self.OnSplitLine),
  459. (self.editLine, "digEditLine", Icons["digEditLine"].GetBitmap(),
  460. wx.ITEM_CHECK, Icons["digEditLine"].GetLabel(), Icons["digEditLine"].GetDesc(),
  461. self.OnEditLine),
  462. (self.moveLine, "digMoveLine", Icons["digMoveLine"].GetBitmap(),
  463. wx.ITEM_CHECK, Icons["digMoveLine"].GetLabel(), Icons["digMoveLine"].GetDesc(),
  464. self.OnMoveLine),
  465. (self.deleteLine, "digDeleteLine", Icons["digDeleteLine"].GetBitmap(),
  466. wx.ITEM_CHECK, Icons["digDeleteLine"].GetLabel(), Icons["digDeleteLine"].GetDesc(),
  467. self.OnDeleteLine),
  468. (self.displayCats, "digDispCats", Icons["digDispCats"].GetBitmap(),
  469. wx.ITEM_CHECK, Icons["digDispCats"].GetLabel(), Icons["digDispCats"].GetDesc(),
  470. self.OnDisplayCats),
  471. (self.copyCats, "digCopyCats", Icons["digCopyCats"].GetBitmap(),
  472. wx.ITEM_CHECK, Icons["digCopyCats"].GetLabel(), Icons["digCopyCats"].GetDesc(),
  473. self.OnCopyCA),
  474. (self.displayAttr, "digDispAttr", Icons["digDispAttr"].GetBitmap(),
  475. wx.ITEM_CHECK, Icons["digDispAttr"].GetLabel(), Icons["digDispAttr"].GetDesc(),
  476. self.OnDisplayAttr),
  477. (self.additionalTools, "digAdditionalTools", Icons["digAdditionalTools"].GetBitmap(),
  478. wx.ITEM_CHECK, Icons["digAdditionalTools"].GetLabel(),
  479. Icons["digAdditionalTools"].GetDesc(),
  480. self.OnAdditionalToolMenu),
  481. ("", "", "", "", "", "", ""),
  482. (self.undo, "digUndo", Icons["digUndo"].GetBitmap(),
  483. wx.ITEM_NORMAL, Icons["digUndo"].GetLabel(), Icons["digUndo"].GetDesc(),
  484. self.OnUndo),
  485. # data.append((self.undo, "digRedo", Icons["digRedo"].GetBitmap(),
  486. # wx.ITEM_NORMAL, Icons["digRedo"].GetLabel(), Icons["digRedo"].GetDesc(),
  487. # self.OnRedo))
  488. (self.settings, "digSettings", Icons["digSettings"].GetBitmap(),
  489. wx.ITEM_NORMAL, Icons["digSettings"].GetLabel(), Icons["digSettings"].GetDesc(),
  490. self.OnSettings),
  491. (self.exit, "digExit", Icons["quit"].GetBitmap(),
  492. wx.ITEM_NORMAL, Icons["digExit"].GetLabel(), Icons["digExit"].GetDesc(),
  493. self.OnExit)]
  494. return data
  495. def OnTool(self, event):
  496. """!Tool selected -> disable selected tool in map toolbar"""
  497. id = self.parent.toolbars['map'].GetAction(type='id')
  498. self.parent.toolbars['map'].ToggleTool(id, False)
  499. # set cursor
  500. cursor = self.parent.cursors["cross"]
  501. self.parent.MapWindow.SetCursor(cursor)
  502. # pointer
  503. self.parent.OnPointer(None)
  504. if event:
  505. # deselect previously selected tool
  506. id = self.action.get('id', -1)
  507. if id != event.GetId():
  508. self.ToggleTool(self.action['id'], False)
  509. else:
  510. self.ToggleTool(self.action['id'], True)
  511. self.action['id'] = event.GetId()
  512. event.Skip()
  513. self.ToggleTool(self.action['id'], True)
  514. # clear tmp canvas
  515. if self.action['id'] != id:
  516. self.parent.MapWindow.ClearLines(pdc=self.parent.MapWindow.pdcTmp)
  517. if self.parent.digit and \
  518. len(self.parent.digit.driver.GetSelected()) > 0:
  519. # cancel action
  520. self.parent.MapWindow.OnMiddleDown(None)
  521. # set focus
  522. self.parent.MapWindow.SetFocus()
  523. def OnAddPoint(self, event):
  524. """!Add point to the vector map Laier"""
  525. Debug.msg (2, "VDigitToolbar.OnAddPoint()")
  526. self.action = { 'desc' : "addLine",
  527. 'type' : "point",
  528. 'id' : self.addPoint }
  529. self.parent.MapWindow.mouse['box'] = 'point'
  530. def OnAddLine(self, event):
  531. """!Add line to the vector map layer"""
  532. Debug.msg (2, "VDigitToolbar.OnAddLine()")
  533. self.action = { 'desc' : "addLine",
  534. 'type' : "line",
  535. 'id' : self.addLine }
  536. self.parent.MapWindow.mouse['box'] = 'line'
  537. ### self.parent.MapWindow.polycoords = [] # reset temp line
  538. def OnAddBoundary(self, event):
  539. """!Add boundary to the vector map layer"""
  540. Debug.msg (2, "VDigitToolbar.OnAddBoundary()")
  541. if self.action['desc'] != 'addLine' or \
  542. self.action['type'] != 'boundary':
  543. self.parent.MapWindow.polycoords = [] # reset temp line
  544. self.action = { 'desc' : "addLine",
  545. 'type' : "boundary",
  546. 'id' : self.addBoundary }
  547. self.parent.MapWindow.mouse['box'] = 'line'
  548. def OnAddCentroid(self, event):
  549. """!Add centroid to the vector map layer"""
  550. Debug.msg (2, "VDigitToolbar.OnAddCentroid()")
  551. self.action = { 'desc' : "addLine",
  552. 'type' : "centroid",
  553. 'id' : self.addCentroid }
  554. self.parent.MapWindow.mouse['box'] = 'point'
  555. def OnExit (self, event=None):
  556. """!Quit digitization tool"""
  557. # stop editing of the currently selected map layer
  558. if self.mapLayer:
  559. self.StopEditing()
  560. # close dialogs if still open
  561. if self.settingsDialog:
  562. self.settingsDialog.OnCancel(None)
  563. # set default mouse settings
  564. self.parent.MapWindow.mouse['use'] = "pointer"
  565. self.parent.MapWindow.mouse['box'] = "point"
  566. self.parent.MapWindow.polycoords = []
  567. # disable the toolbar
  568. self.parent.RemoveToolbar("vdigit")
  569. def OnMoveVertex(self, event):
  570. """!Move line vertex"""
  571. Debug.msg(2, "Digittoolbar.OnMoveVertex():")
  572. self.action = { 'desc' : "moveVertex",
  573. 'id' : self.moveVertex }
  574. self.parent.MapWindow.mouse['box'] = 'point'
  575. def OnAddVertex(self, event):
  576. """!Add line vertex"""
  577. Debug.msg(2, "Digittoolbar.OnAddVertex():")
  578. self.action = { 'desc' : "addVertex",
  579. 'id' : self.addVertex }
  580. self.parent.MapWindow.mouse['box'] = 'point'
  581. def OnRemoveVertex(self, event):
  582. """!Remove line vertex"""
  583. Debug.msg(2, "Digittoolbar.OnRemoveVertex():")
  584. self.action = { 'desc' : "removeVertex",
  585. 'id' : self.removeVertex }
  586. self.parent.MapWindow.mouse['box'] = 'point'
  587. def OnSplitLine(self, event):
  588. """!Split line"""
  589. Debug.msg(2, "Digittoolbar.OnSplitLine():")
  590. self.action = { 'desc' : "splitLine",
  591. 'id' : self.splitLine }
  592. self.parent.MapWindow.mouse['box'] = 'point'
  593. def OnEditLine(self, event):
  594. """!Edit line"""
  595. Debug.msg(2, "Digittoolbar.OnEditLine():")
  596. self.action = { 'desc' : "editLine",
  597. 'id' : self.editLine }
  598. self.parent.MapWindow.mouse['box'] = 'line'
  599. def OnMoveLine(self, event):
  600. """!Move line"""
  601. Debug.msg(2, "Digittoolbar.OnMoveLine():")
  602. self.action = { 'desc' : "moveLine",
  603. 'id' : self.moveLine }
  604. self.parent.MapWindow.mouse['box'] = 'box'
  605. def OnDeleteLine(self, event):
  606. """!Delete line"""
  607. Debug.msg(2, "Digittoolbar.OnDeleteLine():")
  608. self.action = { 'desc' : "deleteLine",
  609. 'id' : self.deleteLine }
  610. self.parent.MapWindow.mouse['box'] = 'box'
  611. def OnDisplayCats(self, event):
  612. """!Display/update categories"""
  613. Debug.msg(2, "Digittoolbar.OnDisplayCats():")
  614. self.action = { 'desc' : "displayCats",
  615. 'id' : self.displayCats }
  616. self.parent.MapWindow.mouse['box'] = 'point'
  617. def OnDisplayAttr(self, event):
  618. """!Display/update attributes"""
  619. Debug.msg(2, "Digittoolbar.OnDisplayAttr():")
  620. self.action = { 'desc' : "displayAttrs",
  621. 'id' : self.displayAttr }
  622. self.parent.MapWindow.mouse['box'] = 'point'
  623. def OnCopyCA(self, event):
  624. """!Copy categories/attributes menu"""
  625. point = wx.GetMousePosition()
  626. toolMenu = wx.Menu()
  627. # Add items to the menu
  628. cats = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
  629. text=_('Copy categories'),
  630. kind=wx.ITEM_CHECK)
  631. toolMenu.AppendItem(cats)
  632. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnCopyCats, cats)
  633. if self.action['desc'] == "copyCats":
  634. cats.Check(True)
  635. attrb = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
  636. text=_('Duplicate attributes'),
  637. kind=wx.ITEM_CHECK)
  638. toolMenu.AppendItem(attrb)
  639. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnCopyAttrb, attrb)
  640. if self.action['desc'] == "copyAttrs":
  641. attrb.Check(True)
  642. # Popup the menu. If an item is selected then its handler
  643. # will be called before PopupMenu returns.
  644. self.parent.MapWindow.PopupMenu(toolMenu)
  645. toolMenu.Destroy()
  646. if self.action['desc'] == "addPoint":
  647. self.ToggleTool(self.copyCats, False)
  648. def OnCopyCats(self, event):
  649. """!Copy categories"""
  650. if self.action['desc'] == 'copyCats': # select previous action
  651. self.ToggleTool(self.addPoint, True)
  652. self.ToggleTool(self.copyCats, False)
  653. self.OnAddPoint(event)
  654. return
  655. Debug.msg(2, "Digittoolbar.OnCopyCats():")
  656. self.action = { 'desc' : "copyCats",
  657. 'id' : self.copyCats }
  658. self.parent.MapWindow.mouse['box'] = 'point'
  659. def OnCopyAttrb(self, event):
  660. if self.action['desc'] == 'copyAttrs': # select previous action
  661. self.ToggleTool(self.addPoint, True)
  662. self.ToggleTool(self.copyCats, False)
  663. self.OnAddPoint(event)
  664. return
  665. Debug.msg(2, "Digittoolbar.OnCopyAttrb():")
  666. self.action = { 'desc' : "copyAttrs",
  667. 'id' : self.copyCats }
  668. self.parent.MapWindow.mouse['box'] = 'point'
  669. def OnUndo(self, event):
  670. """!Undo previous changes"""
  671. self.parent.digit.Undo()
  672. event.Skip()
  673. def EnableUndo(self, enable=True):
  674. """!Enable 'Undo' in toolbar
  675. @param enable False for disable
  676. """
  677. if enable:
  678. if self.GetToolEnabled(self.undo) is False:
  679. self.EnableTool(self.undo, True)
  680. else:
  681. if self.GetToolEnabled(self.undo) is True:
  682. self.EnableTool(self.undo, False)
  683. def OnSettings(self, event):
  684. """!Show settings dialog"""
  685. if self.parent.digit is None:
  686. reload(vdigit)
  687. from vdigit import VDigit as VDigit
  688. try:
  689. self.parent.digit = VDigit(mapwindow=self.parent.MapWindow)
  690. except SystemExit:
  691. self.parent.digit = None
  692. if not self.settingsDialog:
  693. self.settingsDialog = VDigitSettingsDialog(parent=self.parent, title=_("Digitization settings"),
  694. style=wx.DEFAULT_DIALOG_STYLE)
  695. self.settingsDialog.Show()
  696. def OnAdditionalToolMenu(self, event):
  697. """!Menu for additional tools"""
  698. point = wx.GetMousePosition()
  699. toolMenu = wx.Menu()
  700. # Add items to the menu
  701. copy = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
  702. text=_('Copy features from (background) vector map'),
  703. kind=wx.ITEM_CHECK)
  704. toolMenu.AppendItem(copy)
  705. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnCopy, copy)
  706. if self.action['desc'] == "copyLine":
  707. copy.Check(True)
  708. flip = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
  709. text=_('Flip selected lines/boundaries'),
  710. kind=wx.ITEM_CHECK)
  711. toolMenu.AppendItem(flip)
  712. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnFlip, flip)
  713. if self.action['desc'] == "flipLine":
  714. flip.Check(True)
  715. merge = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
  716. text=_('Merge selected lines/boundaries'),
  717. kind=wx.ITEM_CHECK)
  718. toolMenu.AppendItem(merge)
  719. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnMerge, merge)
  720. if self.action['desc'] == "mergeLine":
  721. merge.Check(True)
  722. breakL = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
  723. text=_('Break selected lines/boundaries at intersection'),
  724. kind=wx.ITEM_CHECK)
  725. toolMenu.AppendItem(breakL)
  726. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnBreak, breakL)
  727. if self.action['desc'] == "breakLine":
  728. breakL.Check(True)
  729. snap = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
  730. text=_('Snap selected lines/boundaries (only to nodes)'),
  731. kind=wx.ITEM_CHECK)
  732. toolMenu.AppendItem(snap)
  733. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnSnap, snap)
  734. if self.action['desc'] == "snapLine":
  735. snap.Check(True)
  736. connect = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
  737. text=_('Connect selected lines/boundaries'),
  738. kind=wx.ITEM_CHECK)
  739. toolMenu.AppendItem(connect)
  740. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnConnect, connect)
  741. if self.action['desc'] == "connectLine":
  742. connect.Check(True)
  743. query = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
  744. text=_('Query features'),
  745. kind=wx.ITEM_CHECK)
  746. toolMenu.AppendItem(query)
  747. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnQuery, query)
  748. if self.action['desc'] == "queryLine":
  749. query.Check(True)
  750. zbulk = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
  751. text=_('Z bulk-labeling of 3D lines'),
  752. kind=wx.ITEM_CHECK)
  753. toolMenu.AppendItem(zbulk)
  754. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnZBulk, zbulk)
  755. if self.action['desc'] == "zbulkLine":
  756. zbulk.Check(True)
  757. typeconv = wx.MenuItem(parentMenu=toolMenu, id=wx.ID_ANY,
  758. text=_('Feature type conversion'),
  759. kind=wx.ITEM_CHECK)
  760. toolMenu.AppendItem(typeconv)
  761. self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnTypeConversion, typeconv)
  762. if self.action['desc'] == "typeConv":
  763. typeconv.Check(True)
  764. # Popup the menu. If an item is selected then its handler
  765. # will be called before PopupMenu returns.
  766. self.parent.MapWindow.PopupMenu(toolMenu)
  767. toolMenu.Destroy()
  768. if self.action['desc'] == 'addPoint':
  769. self.ToggleTool(self.additionalTools, False)
  770. def OnCopy(self, event):
  771. """!Copy selected features from (background) vector map"""
  772. if self.action['desc'] == 'copyLine': # select previous action
  773. self.ToggleTool(self.addPoint, True)
  774. self.ToggleTool(self.additionalTools, False)
  775. self.OnAddPoint(event)
  776. return
  777. Debug.msg(2, "Digittoolbar.OnCopy():")
  778. self.action = { 'desc' : "copyLine",
  779. 'id' : self.additionalTools }
  780. self.parent.MapWindow.mouse['box'] = 'box'
  781. def OnFlip(self, event):
  782. """!Flip selected lines/boundaries"""
  783. if self.action['desc'] == 'flipLine': # select previous action
  784. self.ToggleTool(self.addPoint, True)
  785. self.ToggleTool(self.additionalTools, False)
  786. self.OnAddPoint(event)
  787. return
  788. Debug.msg(2, "Digittoolbar.OnFlip():")
  789. self.action = { 'desc' : "flipLine",
  790. 'id' : self.additionalTools }
  791. self.parent.MapWindow.mouse['box'] = 'box'
  792. def OnMerge(self, event):
  793. """!Merge selected lines/boundaries"""
  794. if self.action['desc'] == 'mergeLine': # select previous action
  795. self.ToggleTool(self.addPoint, True)
  796. self.ToggleTool(self.additionalTools, False)
  797. self.OnAddPoint(event)
  798. return
  799. Debug.msg(2, "Digittoolbar.OnMerge():")
  800. self.action = { 'desc' : "mergeLine",
  801. 'id' : self.additionalTools }
  802. self.parent.MapWindow.mouse['box'] = 'box'
  803. def OnBreak(self, event):
  804. """!Break selected lines/boundaries"""
  805. if self.action['desc'] == 'breakLine': # select previous action
  806. self.ToggleTool(self.addPoint, True)
  807. self.ToggleTool(self.additionalTools, False)
  808. self.OnAddPoint(event)
  809. return
  810. Debug.msg(2, "Digittoolbar.OnBreak():")
  811. self.action = { 'desc' : "breakLine",
  812. 'id' : self.additionalTools }
  813. self.parent.MapWindow.mouse['box'] = 'box'
  814. def OnSnap(self, event):
  815. """!Snap selected features"""
  816. if self.action['desc'] == 'snapLine': # select previous action
  817. self.ToggleTool(self.addPoint, True)
  818. self.ToggleTool(self.additionalTools, False)
  819. self.OnAddPoint(event)
  820. return
  821. Debug.msg(2, "Digittoolbar.OnSnap():")
  822. self.action = { 'desc' : "snapLine",
  823. 'id' : self.additionalTools }
  824. self.parent.MapWindow.mouse['box'] = 'box'
  825. def OnConnect(self, event):
  826. """!Connect selected lines/boundaries"""
  827. if self.action['desc'] == 'connectLine': # select previous action
  828. self.ToggleTool(self.addPoint, True)
  829. self.ToggleTool(self.additionalTools, False)
  830. self.OnAddPoint(event)
  831. return
  832. Debug.msg(2, "Digittoolbar.OnConnect():")
  833. self.action = { 'desc' : "connectLine",
  834. 'id' : self.additionalTools }
  835. self.parent.MapWindow.mouse['box'] = 'box'
  836. def OnQuery(self, event):
  837. """!Query selected lines/boundaries"""
  838. if self.action['desc'] == 'queryLine': # select previous action
  839. self.ToggleTool(self.addPoint, True)
  840. self.ToggleTool(self.additionalTools, False)
  841. self.OnAddPoint(event)
  842. return
  843. Debug.msg(2, "Digittoolbar.OnQuery(): %s" % \
  844. UserSettings.Get(group='vdigit', key='query', subkey='selection'))
  845. self.action = { 'desc' : "queryLine",
  846. 'id' : self.additionalTools }
  847. self.parent.MapWindow.mouse['box'] = 'box'
  848. def OnZBulk(self, event):
  849. """!Z bulk-labeling selected lines/boundaries"""
  850. if not self.parent.digit.driver.Is3D():
  851. wx.MessageBox(parent=self.parent,
  852. message=_("Vector map is not 3D. Operation canceled."),
  853. caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
  854. return
  855. if self.action['desc'] == 'zbulkLine': # select previous action
  856. self.ToggleTool(self.addPoint, True)
  857. self.ToggleTool(self.additionalTools, False)
  858. self.OnAddPoint(event)
  859. return
  860. Debug.msg(2, "Digittoolbar.OnZBulk():")
  861. self.action = { 'desc' : "zbulkLine",
  862. 'id' : self.additionalTools }
  863. self.parent.MapWindow.mouse['box'] = 'line'
  864. def OnTypeConversion(self, event):
  865. """!Feature type conversion
  866. Supported conversions:
  867. - point <-> centroid
  868. - line <-> boundary
  869. """
  870. if self.action['desc'] == 'typeConv': # select previous action
  871. self.ToggleTool(self.addPoint, True)
  872. self.ToggleTool(self.additionalTools, False)
  873. self.OnAddPoint(event)
  874. return
  875. Debug.msg(2, "Digittoolbar.OnTypeConversion():")
  876. self.action = { 'desc' : "typeConv",
  877. 'id' : self.additionalTools }
  878. self.parent.MapWindow.mouse['box'] = 'box'
  879. def OnSelectMap (self, event):
  880. """
  881. Select vector map layer for editing
  882. If there is a vector map layer already edited, this action is
  883. firstly terminated. The map layer is closed. After this the
  884. selected map layer activated for editing.
  885. """
  886. if event.GetSelection() == 0: # create new vector map layer
  887. if self.mapLayer:
  888. openVectorMap = self.mapLayer.GetName(fullyQualified=False)['name']
  889. else:
  890. openVectorMap = None
  891. mapName = gdialogs.CreateNewVector(self.parent,
  892. exceptMap = openVectorMap, log = self.log,
  893. cmd = (('v.edit',
  894. { 'tool' : 'create' },
  895. 'map')),
  896. disableAdd=True)[0]
  897. if mapName:
  898. # add layer to map layer tree
  899. if self.layerTree:
  900. self.layerTree.AddLayer(ltype='vector',
  901. lname=mapName,
  902. lchecked=True,
  903. lopacity=1.0,
  904. lcmd=['d.vect', 'map=%s' % mapName])
  905. vectLayers = self.UpdateListOfLayers(updateTool=True)
  906. selection = vectLayers.index(mapName)
  907. else:
  908. pass # TODO (no Layer Manager)
  909. else:
  910. self.combo.SetValue(_('Select vector map'))
  911. return
  912. else:
  913. selection = event.GetSelection() - 1 # first option is 'New vector map'
  914. # skip currently selected map
  915. if self.layers[selection] == self.mapLayer:
  916. return False
  917. if self.mapLayer:
  918. # deactive map layer for editing
  919. self.StopEditing()
  920. # select the given map layer for editing
  921. self.StartEditing(self.layers[selection])
  922. event.Skip()
  923. return True
  924. def StartEditing (self, mapLayer):
  925. """
  926. Start editing selected vector map layer.
  927. @param mapLayer reference to MapLayer instance
  928. """
  929. # deactive layer
  930. self.mapcontent.ChangeLayerActive(mapLayer, False)
  931. # clean map canvas
  932. ### self.parent.MapWindow.EraseMap()
  933. # unset background map if needed
  934. if mapLayer:
  935. if UserSettings.Get(group='vdigit', key='bgmap',
  936. subkey='value', internal=True) == mapLayer.GetName():
  937. UserSettings.Set(group='vdigit', key='bgmap',
  938. subkey='value', value='', internal=True)
  939. self.parent.statusbar.SetStatusText(_("Please wait, "
  940. "opening vector map <%s> for editing...") % \
  941. mapLayer.GetName(),
  942. 0)
  943. # reload vdigit module
  944. reload(vdigit)
  945. from vdigit import VDigit as VDigit
  946. # use vdigit's PseudoDC
  947. self.parent.MapWindow.DefinePseudoDC(vdigit = True)
  948. self.parent.digit = VDigit(mapwindow=self.parent.MapWindow)
  949. self.mapLayer = mapLayer
  950. # open vector map
  951. try:
  952. if not self.parent.MapWindow.CheckPseudoDC():
  953. raise gcmd.DigitError(parent=self.parent,
  954. message=_("Unable to initialize display driver of vector "
  955. "digitizer. See 'Command output' for details."))
  956. self.parent.digit.SetMapName(mapLayer.GetName())
  957. except gcmd.DigitError, e:
  958. self.mapLayer = None
  959. self.StopEditing()
  960. print >> sys.stderr, e # wxMessageBox
  961. return False
  962. # update toolbar
  963. self.combo.SetValue(mapLayer.GetName())
  964. self.parent.toolbars['map'].combo.SetValue (_('Digitize'))
  965. Debug.msg (4, "VDigitToolbar.StartEditing(): layer=%s" % mapLayer.GetName())
  966. # change cursor
  967. if self.parent.MapWindow.mouse['use'] == 'pointer':
  968. self.parent.MapWindow.SetCursor(self.parent.cursors["cross"])
  969. # create pseudoDC for drawing the map
  970. self.parent.MapWindow.pdcVector = vdigit.PseudoDC()
  971. self.parent.digit.driver.SetDevice(self.parent.MapWindow.pdcVector)
  972. if not self.parent.MapWindow.resize:
  973. self.parent.MapWindow.UpdateMap(render=True)
  974. opacity = mapLayer.GetOpacity(float=True)
  975. if opacity < 1.0:
  976. alpha = int(opacity * 255)
  977. self.parent.digit.driver.UpdateSettings(alpha)
  978. return True
  979. def StopEditing(self):
  980. """!Stop editing of selected vector map layer.
  981. @return True on success
  982. @return False on failure
  983. """
  984. # use wx's PseudoDC
  985. self.parent.MapWindow.DefinePseudoDC(vdigit = False)
  986. self.combo.SetValue (_('Select vector map'))
  987. # save changes
  988. if self.mapLayer:
  989. Debug.msg (4, "VDigitToolbar.StopEditing(): layer=%s" % self.mapLayer.GetName())
  990. if UserSettings.Get(group='vdigit', key='saveOnExit', subkey='enabled') is False:
  991. if self.parent.digit.GetUndoLevel() > -1:
  992. dlg = wx.MessageDialog(parent=self.parent,
  993. message=_("Do you want to save changes "
  994. "in vector map <%s>?") % self.mapLayer.GetName(),
  995. caption=_("Save changes?"),
  996. style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
  997. if dlg.ShowModal() == wx.ID_NO:
  998. # revert changes
  999. self.parent.digit.Undo(0)
  1000. dlg.Destroy()
  1001. self.parent.statusbar.SetStatusText(_("Please wait, "
  1002. "closing and rebuilding topology of "
  1003. "vector map <%s>...") % self.mapLayer.GetName(),
  1004. 0)
  1005. self.parent.digit.SetMapName(None) # -> close map
  1006. # re-active layer
  1007. item = self.parent.tree.FindItemByData('maplayer', self.mapLayer)
  1008. if item and self.parent.tree.IsItemChecked(item):
  1009. self.mapcontent.ChangeLayerActive(self.mapLayer, True)
  1010. # change cursor
  1011. self.parent.MapWindow.SetCursor(self.parent.cursors["default"])
  1012. # disable pseudodc for vector map layer
  1013. self.parent.MapWindow.pdcVector = None
  1014. self.parent.digit.driver.SetDevice(None)
  1015. # close dialogs
  1016. for dialog in ('attributes', 'category'):
  1017. if self.parent.dialogs[dialog]:
  1018. self.parent.dialogs[dialog].Close()
  1019. self.parent.dialogs[dialog] = None
  1020. self.parent.digit.__del__() # FIXME: destructor is not called here (del)
  1021. self.parent.digit = None
  1022. self.mapLayer = None
  1023. self.parent.MapWindow.redrawAll = True
  1024. return True
  1025. def UpdateListOfLayers (self, updateTool=False):
  1026. """!
  1027. Update list of available vector map layers.
  1028. This list consists only editable layers (in the current mapset)
  1029. Optionally also update toolbar
  1030. """
  1031. Debug.msg (4, "VDigitToolbar.UpdateListOfLayers(): updateTool=%d" % \
  1032. updateTool)
  1033. layerNameSelected = None
  1034. # name of currently selected layer
  1035. if self.mapLayer:
  1036. layerNameSelected = self.mapLayer.GetName()
  1037. # select vector map layer in the current mapset
  1038. layerNameList = []
  1039. self.layers = self.mapcontent.GetListOfLayers(l_type="vector",
  1040. l_mapset=grass.gisenv()['MAPSET'])
  1041. for layer in self.layers:
  1042. if not layer.name in layerNameList: # do not duplicate layer
  1043. layerNameList.append (layer.GetName())
  1044. if updateTool: # update toolbar
  1045. if not self.mapLayer:
  1046. value = _('Select vector map')
  1047. else:
  1048. value = layerNameSelected
  1049. if not self.comboid:
  1050. self.combo = wx.ComboBox(self, id=wx.ID_ANY, value=value,
  1051. choices=[_('New vector map'), ] + layerNameList, size=(115, -1),
  1052. style=wx.CB_READONLY)
  1053. self.comboid = self.InsertControl(0, self.combo)
  1054. self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectMap, self.comboid)
  1055. else:
  1056. self.combo.SetItems([_('New vector map'), ] + layerNameList)
  1057. self.Realize()
  1058. return layerNameList
  1059. def GetLayer(self):
  1060. """!Get selected layer for editing -- MapLayer instance"""
  1061. return self.mapLayer
  1062. class ProfileToolbar(AbstractToolbar):
  1063. """!Toolbar for profiling raster map
  1064. """
  1065. def __init__(self, parent):
  1066. AbstractToolbar.__init__(self, parent)
  1067. self.InitToolbar(self.ToolbarData())
  1068. # realize the toolbar
  1069. self.Realize()
  1070. def ToolbarData(self):
  1071. """!Toolbar data"""
  1072. self.transect = wx.NewId()
  1073. self.addraster = wx.NewId()
  1074. self.draw = wx.NewId()
  1075. self.options = wx.NewId()
  1076. self.drag = wx.NewId()
  1077. self.zoom = wx.NewId()
  1078. self.unzoom = wx.NewId()
  1079. self.erase = wx.NewId()
  1080. self.save = wx.NewId()
  1081. self.datasave = wx.NewId()
  1082. self.printer = wx.NewId()
  1083. self.quit = wx.NewId()
  1084. # tool, label, bitmap, kind, shortHelp, longHelp, handler
  1085. return (
  1086. (self.addraster, 'raster', Icons["addrast"].GetBitmap(),
  1087. wx.ITEM_NORMAL, Icons["addrast"].GetLabel(), Icons["addrast"].GetDesc(),
  1088. self.parent.OnSelectRaster),
  1089. (self.transect, 'transect', Icons["transect"].GetBitmap(),
  1090. wx.ITEM_NORMAL, Icons["transect"].GetLabel(), Icons["transect"].GetDesc(),
  1091. self.parent.OnDrawTransect),
  1092. ("", "", "", "", "", "", ""),
  1093. (self.draw, 'profiledraw', Icons["profiledraw"].GetBitmap(),
  1094. wx.ITEM_NORMAL, Icons["profiledraw"].GetLabel(), Icons["profiledraw"].GetDesc(),
  1095. self.parent.OnCreateProfile),
  1096. (self.erase, 'erase', Icons["erase"].GetBitmap(),
  1097. wx.ITEM_NORMAL, Icons["erase"].GetLabel(), Icons["erase"].GetDesc(),
  1098. self.parent.OnErase),
  1099. (self.drag, 'drag', Icons['pan'].GetBitmap(),
  1100. wx.ITEM_NORMAL, Icons["pan"].GetLabel(), Icons["pan"].GetDesc(),
  1101. self.parent.OnDrag),
  1102. (self.zoom, 'zoom', Icons['zoom_in'].GetBitmap(),
  1103. wx.ITEM_NORMAL, Icons["zoom_in"].GetLabel(), Icons["zoom_in"].GetDesc(),
  1104. self.parent.OnZoom),
  1105. (self.unzoom, 'unzoom', Icons['zoom_back'].GetBitmap(),
  1106. wx.ITEM_NORMAL, Icons["zoom_back"].GetLabel(), Icons["zoom_back"].GetDesc(),
  1107. self.parent.OnRedraw),
  1108. ("", "", "", "", "", "", ""),
  1109. (self.datasave, 'save data', Icons["datasave"].GetBitmap(),
  1110. wx.ITEM_NORMAL, Icons["datasave"].GetLabel(), Icons["datasave"].GetDesc(),
  1111. self.parent.SaveProfileToFile),
  1112. (self.save, 'save image', Icons["savefile"].GetBitmap(),
  1113. wx.ITEM_NORMAL, Icons["savefile"].GetLabel(), Icons["savefile"].GetDesc(),
  1114. self.parent.SaveToFile),
  1115. (self.printer, 'print', Icons["printmap"].GetBitmap(),
  1116. wx.ITEM_NORMAL, Icons["printmap"].GetLabel(), Icons["printmap"].GetDesc(),
  1117. self.parent.PrintMenu),
  1118. ("", "", "", "", "", "", ""),
  1119. (self.options, 'options', Icons["profileopt"].GetBitmap(),
  1120. wx.ITEM_NORMAL, Icons["profileopt"].GetLabel(), Icons["profileopt"].GetDesc(),
  1121. self.parent.ProfileOptionsMenu),
  1122. (self.quit, 'quit', Icons["quit"].GetBitmap(),
  1123. wx.ITEM_NORMAL, Icons["quit"].GetLabel(), Icons["quit"].GetDesc(),
  1124. self.parent.OnQuit),
  1125. )
  1126. class NvizToolbar(AbstractToolbar):
  1127. """!Nviz toolbar
  1128. """
  1129. def __init__(self, parent, mapcontent):
  1130. self.mapcontent = mapcontent
  1131. AbstractToolbar.__init__(self, parent)
  1132. # only one dialog can be open
  1133. self.settingsDialog = None
  1134. self.InitToolbar(self.ToolbarData())
  1135. # realize the toolbar
  1136. self.Realize()
  1137. def ToolbarData(self):
  1138. """!Toolbar data"""
  1139. self.settings = wx.NewId()
  1140. self.quit = wx.NewId()
  1141. # tool, label, bitmap, kind, shortHelp, longHelp, handler
  1142. return (
  1143. (self.settings, "settings", Icons["nvizSettings"].GetBitmap(),
  1144. wx.ITEM_NORMAL, Icons["nvizSettings"].GetLabel(), Icons["nvizSettings"].GetDesc(),
  1145. self.OnSettings),
  1146. (self.quit, 'quit', Icons["nvizQuit"].GetBitmap(),
  1147. wx.ITEM_NORMAL, Icons["nvizQuit"].GetLabel(), Icons["nvizQuit"].GetDesc(),
  1148. self.OnExit),
  1149. )
  1150. def OnSettings(self, event):
  1151. """!Show nviz notebook page"""
  1152. if not self.settingsDialog:
  1153. self.settingsDialog = NvizPreferencesDialog(parent = self.parent)
  1154. self.settingsDialog.Show()
  1155. def OnExit (self, event=None):
  1156. """!Quit nviz tool (swith to 2D mode)"""
  1157. # set default mouse settings
  1158. self.parent.MapWindow.mouse['use'] = "pointer"
  1159. self.parent.MapWindow.mouse['box'] = "point"
  1160. self.parent.MapWindow.polycoords = []
  1161. # disable the toolbar
  1162. self.parent.RemoveToolbar("nviz")
  1163. class ModelToolbar(AbstractToolbar):
  1164. """!Graphical modeler toolbar (see gmodeler.py)
  1165. """
  1166. def __init__(self, parent):
  1167. AbstractToolbar.__init__(self, parent)
  1168. self.InitToolbar(self.ToolbarData())
  1169. # realize the toolbar
  1170. self.Realize()
  1171. def ToolbarData(self):
  1172. """!Toolbar data"""
  1173. self.new = wx.NewId()
  1174. self.open = wx.NewId()
  1175. self.save = wx.NewId()
  1176. self.image = wx.NewId()
  1177. self.python = wx.NewId()
  1178. self.action = wx.NewId()
  1179. self.data = wx.NewId()
  1180. self.relation = wx.NewId()
  1181. self.run = wx.NewId()
  1182. self.validate = wx.NewId()
  1183. self.settings = wx.NewId()
  1184. # self.properties = wx.NewId()
  1185. self.variables = wx.NewId()
  1186. self.quit = wx.NewId()
  1187. # tool, label, bitmap, kind, shortHelp, longHelp, handler
  1188. return (
  1189. (self.new, 'new', Icons['modelNew'].GetBitmap(),
  1190. wx.ITEM_NORMAL, Icons['modelNew'].GetLabel(), Icons['modelNew'].GetDesc(),
  1191. self.parent.OnModelNew),
  1192. (self.open, 'open', Icons['modelOpen'].GetBitmap(),
  1193. wx.ITEM_NORMAL, Icons['modelOpen'].GetLabel(), Icons['modelOpen'].GetDesc(),
  1194. self.parent.OnModelOpen),
  1195. (self.save, 'save', Icons['modelSave'].GetBitmap(),
  1196. wx.ITEM_NORMAL, Icons['modelSave'].GetLabel(), Icons['modelSave'].GetDesc(),
  1197. self.parent.OnModelSave),
  1198. (self.image, 'image', Icons['modelToImage'].GetBitmap(),
  1199. wx.ITEM_NORMAL, Icons['modelToImage'].GetLabel(), Icons['modelToImage'].GetDesc(),
  1200. self.parent.OnExportImage),
  1201. (self.python, 'python', Icons['modelToPython'].GetBitmap(),
  1202. wx.ITEM_NORMAL, Icons['modelToPython'].GetLabel(), Icons['modelToPython'].GetDesc(),
  1203. self.parent.OnExportPython),
  1204. ('', '', '', '', '', '', ''),
  1205. (self.data, 'data', Icons['modelDataAdd'].GetBitmap(),
  1206. wx.ITEM_NORMAL, Icons['modelDataAdd'].GetLabel(), Icons['modelDataAdd'].GetDesc(),
  1207. self.parent.OnAddData),
  1208. (self.action, 'action', Icons['modelActionAdd'].GetBitmap(),
  1209. wx.ITEM_NORMAL, Icons['modelActionAdd'].GetLabel(), Icons['modelActionAdd'].GetDesc(),
  1210. self.parent.OnAddAction),
  1211. (self.relation, 'relation', Icons['modelRelation'].GetBitmap(),
  1212. wx.ITEM_NORMAL, Icons['modelRelation'].GetLabel(), Icons['modelRelation'].GetDesc(),
  1213. self.parent.OnDefineRelation),
  1214. ('', '', '', '', '', '', ''),
  1215. (self.run, 'run', Icons['modelRun'].GetBitmap(),
  1216. wx.ITEM_NORMAL, Icons['modelRun'].GetLabel(), Icons['modelRun'].GetDesc(),
  1217. self.parent.OnRunModel),
  1218. (self.validate, 'validate', Icons['modelValidate'].GetBitmap(),
  1219. wx.ITEM_NORMAL, Icons['modelValidate'].GetLabel(), Icons['modelValidate'].GetDesc(),
  1220. self.parent.OnValidateModel),
  1221. ('', '', '', '', '', '', ''),
  1222. (self.settings, "settings", Icons["modelSettings"].GetBitmap(),
  1223. wx.ITEM_NORMAL, Icons["modelSettings"].GetLabel(), Icons["modelSettings"].GetDesc(),
  1224. self.parent.OnPreferences),
  1225. (self.quit, 'quit', Icons['quit'].GetBitmap(),
  1226. wx.ITEM_NORMAL, Icons['quit'].GetLabel(), Icons['quit'].GetDesc(),
  1227. self.parent.OnCloseWindow),
  1228. )
  1229. class HistogramToolbar(AbstractToolbar):
  1230. """!Histogram toolbar (see histogram.py)
  1231. """
  1232. def __init__(self, parent):
  1233. AbstractToolbar.__init__(self, parent)
  1234. self.InitToolbar(self.ToolbarData())
  1235. # realize the toolbar
  1236. self.Realize()
  1237. def ToolbarData(self):
  1238. """!Toolbar data"""
  1239. self.histogram = wx.NewId()
  1240. self.rendermap = wx.NewId()
  1241. self.erase = wx.NewId()
  1242. self.font = wx.NewId()
  1243. self.save = wx.NewId()
  1244. self.hprint = wx.NewId()
  1245. self.quit = wx.NewId()
  1246. # tool, label, bitmap, kind, shortHelp, longHelp, handler
  1247. return (
  1248. (self.histogram, 'histogram', Icons["histogram"].GetBitmap(),
  1249. wx.ITEM_NORMAL, Icons["histogram"].GetLabel(), Icons["histogram"].GetDesc(),
  1250. self.parent.OnOptions),
  1251. (self.rendermap, 'rendermap', Icons["displaymap"].GetBitmap(),
  1252. wx.ITEM_NORMAL, Icons["displaymap"].GetLabel(), Icons["displaymap"].GetDesc(),
  1253. self.parent.OnRender),
  1254. (self.erase, 'erase', Icons["erase"].GetBitmap(),
  1255. wx.ITEM_NORMAL, Icons["erase"].GetLabel(), Icons["erase"].GetDesc(),
  1256. self.parent.OnErase),
  1257. (self.font, 'font', Icons["font"].GetBitmap(),
  1258. wx.ITEM_NORMAL, Icons["font"].GetLabel(), Icons["font"].GetDesc(),
  1259. self.parent.SetHistFont),
  1260. ('', '', '', '', '', '', ''),
  1261. (self.save, 'save', Icons["savefile"].GetBitmap(),
  1262. wx.ITEM_NORMAL, Icons["savefile"].GetLabel(), Icons["savefile"].GetDesc(),
  1263. self.parent.SaveToFile),
  1264. (self.hprint, 'print', Icons["printmap"].GetBitmap(),
  1265. wx.ITEM_NORMAL, Icons["printmap"].GetLabel(), Icons["printmap"].GetDesc(),
  1266. self.parent.PrintMenu),
  1267. ('', '', '', '', '', '', ''),
  1268. (self.quit, 'quit', Icons["quit"].GetBitmap(),
  1269. wx.ITEM_NORMAL, Icons["quit"].GetLabel(), Icons["quit"].GetDesc(),
  1270. self.parent.OnQuit)
  1271. )
  1272. class LayerManagerToolbar(AbstractToolbar):
  1273. """!Layer Manager toolbar (see wxgui.py)
  1274. """
  1275. def __init__(self, parent):
  1276. AbstractToolbar.__init__(self, parent)
  1277. self.InitToolbar(self.ToolbarData())
  1278. # realize the toolbar
  1279. self.Realize()
  1280. def ToolbarData(self):
  1281. """!Toolbar data"""
  1282. self.newdisplay = wx.NewId()
  1283. self.workspaceLoad = wx.NewId()
  1284. self.workspaceOpen = wx.NewId()
  1285. self.workspaceSave = wx.NewId()
  1286. self.addrast = wx.NewId()
  1287. self.addshaded = wx.NewId()
  1288. self.addvect = wx.NewId()
  1289. self.addthematic = wx.NewId()
  1290. self.addcmd = wx.NewId()
  1291. self.addgrp = wx.NewId()
  1292. self.addovl = wx.NewId()
  1293. self.delcmd = wx.NewId()
  1294. self.attribute = wx.NewId()
  1295. self.preferences = wx.NewId()
  1296. # tool, label, bitmap, kind, shortHelp, longHelp, handler
  1297. return (
  1298. (self.newdisplay, 'newdisplay', Icons["newdisplay"].GetBitmap(),
  1299. wx.ITEM_NORMAL, Icons["newdisplay"].GetLabel(), Icons["newdisplay"].GetDesc(),
  1300. self.parent.OnNewDisplay),
  1301. ('', '', '', '', '', '', ''),
  1302. (self.workspaceLoad, 'workspaceLoad', Icons["workspaceLoad"].GetBitmap(),
  1303. wx.ITEM_NORMAL, Icons["workspaceLoad"].GetLabel(), Icons["workspaceLoad"].GetDesc(),
  1304. self.parent.OnWorkspace),
  1305. (self.workspaceOpen, 'workspaceOpen', Icons["workspaceOpen"].GetBitmap(),
  1306. wx.ITEM_NORMAL, Icons["workspaceOpen"].GetLabel(), Icons["workspaceOpen"].GetDesc(),
  1307. self.parent.OnWorkspaceOpen),
  1308. (self.workspaceSave, 'workspaceSave', Icons["workspaceSave"].GetBitmap(),
  1309. wx.ITEM_NORMAL, Icons["workspaceSave"].GetLabel(), Icons["workspaceSave"].GetDesc(),
  1310. self.parent.OnWorkspaceSave),
  1311. ('', '', '', '', '', '', ''),
  1312. (self.addrast, 'addrast', Icons["addrast"].GetBitmap(),
  1313. wx.ITEM_NORMAL, Icons["addrast"].GetLabel(), Icons["addrast"].GetDesc(),
  1314. self.parent.OnAddRaster),
  1315. (self.addshaded, 'addshaded', Icons["addshaded"].GetBitmap(),
  1316. wx.ITEM_NORMAL, _("Add various raster-based map layers"), "",
  1317. self.parent.OnAddRasterMisc),
  1318. (self.addvect, 'addvect', Icons["addvect"].GetBitmap(),
  1319. wx.ITEM_NORMAL, Icons["addvect"].GetLabel(), Icons["addvect"].GetDesc(),
  1320. self.parent.OnAddVector),
  1321. (self.addthematic, 'addthematic', Icons["addthematic"].GetBitmap(),
  1322. wx.ITEM_NORMAL, _("Add various vector-based map layers"), "",
  1323. self.parent.OnAddVectorMisc),
  1324. (self.addcmd, 'addcmd', Icons["addcmd"].GetBitmap(),
  1325. wx.ITEM_NORMAL, Icons["addcmd"].GetLabel(), Icons["addcmd"].GetDesc(),
  1326. self.parent.OnAddCommand),
  1327. (self.addgrp, 'addgrp', Icons["addgrp"].GetBitmap(),
  1328. wx.ITEM_NORMAL, Icons["addgrp"].GetLabel(), Icons["addgrp"].GetDesc(),
  1329. self.parent.OnAddGroup),
  1330. (self.addovl, 'addovl', Icons["addovl"].GetBitmap(),
  1331. wx.ITEM_NORMAL, Icons["addovl"].GetLabel(), Icons["addovl"].GetDesc(),
  1332. self.parent.OnAddOverlay),
  1333. (self.delcmd, 'delcmd', Icons["delcmd"].GetBitmap(),
  1334. wx.ITEM_NORMAL, Icons["delcmd"].GetLabel(), Icons["delcmd"].GetDesc(),
  1335. self.parent.OnDeleteLayer),
  1336. ('', '', '', '', '', '', ''),
  1337. (self.attribute, 'attrtable', Icons["attrtable"].GetBitmap(),
  1338. wx.ITEM_NORMAL, Icons["attrtable"].GetLabel(), Icons["attrtable"].GetDesc(),
  1339. self.parent.OnShowAttributeTable),
  1340. ('', '', '', '', '', '', ''),
  1341. (self.preferences, 'preferences', Icons["settings"].GetBitmap(),
  1342. wx.ITEM_NORMAL, Icons["settings"].GetLabel(), Icons["settings"].GetDesc(),
  1343. self.parent.OnPreferences)
  1344. )