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