toolbars.py 65 KB

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