toolbars.py 64 KB

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