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