GRASS Programmer's Manual  6.4.2(2012)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
toolbars.py
Go to the documentation of this file.
1 """!
2 @package toolbar
3 
4 @brief wxGUI toolbar widgets
5 
6 Classes:
7  - AbstractToolbar
8  - MapToolbar
9  - GCPMapToolbar
10  - GCPDisplayToolbar
11  - VDigitToolbar
12  - ProfileToolbar
13  - NvizToolbar
14  - ModelToolbar
15  - HistogramToolbar
16  - LMWorkspaceToolbar
17  - LMDataToolbar
18  - LMToolsToolbar
19  - LMMiscToolbar
20  - LMVectorToolbar
21  - PsMapToolbar
22 
23 (C) 2007-2011 by the GRASS Development Team
24 This program is free software under the GNU General Public License
25 (>=v2). Read the file COPYING that comes with GRASS for details.
26 
27 @author Michael Barton
28 @author Jachym Cepicky
29 @author Martin Landa <landa.martin gmail.com>
30 @author Anna Kratochvilova <anna.kratochvilova fsv.cvut.cz>
31 """
32 
33 import os
34 import sys
35 import platform
36 
37 from grass.script import core as grass
38 
39 import wx
40 
41 import globalvar
42 import gcmd
43 import gdialogs
44 from vdigit import VDigitSettingsDialog, haveVDigit, VDigit
45 from debug import Debug
46 from preferences import globalSettings as UserSettings
47 from nviz import haveNviz
48 from nviz_preferences import NvizPreferencesDialog
49 
50 sys.path.append(os.path.join(globalvar.ETCWXDIR, "icons"))
51 from icon import Icons
52 
53 class AbstractToolbar(wx.ToolBar):
54  """!Abstract toolbar class"""
55  def __init__(self, parent):
56  self.parent = parent
57  wx.ToolBar.__init__(self, parent = self.parent, id = wx.ID_ANY)
58 
59  self.action = dict()
60 
61  self.Bind(wx.EVT_TOOL, self.OnTool)
62 
63  self.SetToolBitmapSize(globalvar.toolbarSize)
64 
65  def InitToolbar(self, toolData):
66  """!Initialize toolbar, add tools to the toolbar
67  """
68  for tool in toolData:
69  self.CreateTool(*tool)
70 
71  self._data = toolData
72 
73  def _toolbarData(self):
74  """!Toolbar data (virtual)"""
75  return None
76 
77  def CreateTool(self, label, bitmap, kind,
78  shortHelp, longHelp, handler):
79  """!Add tool to the toolbar
80 
81  @return id of tool
82  """
83  bmpDisabled = wx.NullBitmap
84  tool = -1
85  if label:
86  tool = vars(self)[label] = wx.NewId()
87  Debug.msg(3, "CreateTool(): tool=%d, label=%s bitmap=%s" % \
88  (tool, label, bitmap))
89 
90  toolWin = self.AddLabelTool(tool, label, bitmap,
91  bmpDisabled, kind,
92  shortHelp, longHelp)
93  self.Bind(wx.EVT_TOOL, handler, toolWin)
94  else: # separator
95  self.AddSeparator()
96 
97  return tool
98 
99  def EnableLongHelp(self, enable = True):
100  """!Enable/disable long help
101 
102  @param enable True for enable otherwise disable
103  """
104  for tool in self._data:
105  if tool[0] == '': # separator
106  continue
107 
108  if enable:
109  self.SetToolLongHelp(vars(self)[tool[0]], tool[4])
110  else:
111  self.SetToolLongHelp(vars(self)[tool[0]], "")
112 
113  def OnTool(self, event):
114  """!Tool selected
115  """
116  if self.parent.GetName() == "GCPFrame":
117  return
118 
119  if hasattr(self.parent, 'toolbars'):
120  if self.parent.toolbars['vdigit']:
121  # update vdigit toolbar (unselect currently selected tool)
122  id = self.parent.toolbars['vdigit'].GetAction(type = 'id')
123  self.parent.toolbars['vdigit'].ToggleTool(id, False)
124 
125  if event:
126  # deselect previously selected tool
127  id = self.action.get('id', -1)
128  if id != event.GetId():
129  self.ToggleTool(self.action['id'], False)
130  else:
131  self.ToggleTool(self.action['id'], True)
132 
133  self.action['id'] = event.GetId()
134 
135  event.Skip()
136  else:
137  # initialize toolbar
138  self.ToggleTool(self.action['id'], True)
139 
140  def GetAction(self, type = 'desc'):
141  """!Get current action info"""
142  return self.action.get(type, '')
143 
144  def SelectDefault(self, event):
145  """!Select default tool"""
146  self.ToggleTool(self.defaultAction['id'], True)
147  self.defaultAction['bind'](event)
148  self.action = { 'id' : self.defaultAction['id'],
149  'desc' : self.defaultAction.get('desc', '') }
150 
151  def FixSize(self, width):
152  """!Fix toolbar width on Windows
153 
154  @todo Determine why combobox causes problems here
155  """
156  if platform.system() == 'Windows':
157  size = self.GetBestSize()
158  self.SetSize((size[0] + width, size[1]))
159 
160  def Enable(self, tool, enable = True):
161  """!Enable defined tool
162 
163  @param tool name
164  @param enable True to enable otherwise disable tool
165  """
166  try:
167  id = getattr(self, tool)
168  except AttributeError:
169  return
170 
171  self.EnableTool(id, enable)
172 
173  def _getToolbarData(self, data):
174  """!Define tool
175  """
176  retData = list()
177  for args in data:
178  retData.append(self._defineTool(*args))
179 
180  return retData
181 
182  def _defineTool(self, name = None, icon = None, handler = None, item = wx.ITEM_NORMAL):
183  """!Define tool
184  """
185  if name:
186  return (name, icon.GetBitmap(),
187  item, icon.GetLabel(), icon.GetDesc(),
188  handler)
189  return ("", "", "", "", "", "") # separator
190 
192  """!Map Display toolbar
193  """
194  def __init__(self, parent, mapcontent):
195  """!Map Display constructor
196 
197  @param parent reference to MapFrame
198  @param mapcontent reference to render.Map (registred by MapFrame)
199  """
200  self.mapcontent = mapcontent # render.Map
201  AbstractToolbar.__init__(self, parent = parent) # MapFrame
202 
203  self.InitToolbar(self._toolbarData())
204 
205  # optional tools
206  choices = [ _('2D view'), ]
207  self.toolId = { '2d' : 0 }
208  if self.parent.GetLayerManager():
209  log = self.parent.GetLayerManager().GetLogWindow()
210 
211  if haveNviz:
212  choices.append(_('3D view'))
213  self.toolId['3d'] = 1
214  else:
215  from nviz import errorMsg
216  ### log.WriteCmdLog(_('3D view mode not available'))
217  ### log.WriteWarning(_('Reason: %s') % str(errorMsg))
218  ### log.WriteLog(_('Note that the wxGUI\'s 3D view mode is currently disabled '
219  ### 'on MS Windows (hopefully this will be fixed soon). '
220  ### 'Please keep an eye out for updated versions of GRASS. '
221  ### 'In the meantime you can use "NVIZ" from the File menu.'), wrap = 60)
222 
223  self.toolId['3d'] = -1
224 
225  if haveVDigit:
226  choices.append(_('Digitize'))
227  if self.toolId['3d'] > -1:
228  self.toolId['vdigit'] = 2
229  else:
230  self.toolId['vdigit'] = 1
231  else:
232  from vdigit import errorMsg
233  log.WriteCmdLog(_('Vector digitizer not available'))
234  log.WriteWarning(_('Reason: %s') % errorMsg)
235  log.WriteLog(_('Note that the wxGUI\'s vector digitizer is currently disabled '
236  '(hopefully this will be fixed soon). '
237  'Please keep an eye out for updated versions of GRASS. '
238  'In the meantime you can use "v.digit" from the Develop Vector menu.'), wrap = 60)
239 
240  self.toolId['vdigit'] = -1
241 
242  self.combo = wx.ComboBox(parent = self, id = wx.ID_ANY,
243  choices = choices,
244  style = wx.CB_READONLY, size = (110, -1))
245  self.combo.SetSelection(0)
246 
247  self.comboid = self.AddControl(self.combo)
248  self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectTool, self.comboid)
249 
250  # realize the toolbar
251  self.Realize()
252 
253  # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
254  self.combo.Hide()
255  self.combo.Show()
256 
257  self.action = { 'id' : self.pointer }
258  self.defaultAction = { 'id' : self.pointer,
259  'bind' : self.parent.OnPointer }
260 
261  self.OnTool(None)
262 
263  self.EnableTool(self.zoomback, False)
264 
265  self.FixSize(width = 90)
266 
267  def _toolbarData(self):
268  """!Toolbar data"""
269  icons = Icons['displayWindow']
270  return self._getToolbarData((('displaymap', icons['display'],
271  self.parent.OnDraw),
272  ('rendermap', icons['render'],
273  self.parent.OnRender),
274  ('erase', icons['erase'],
275  self.parent.OnErase),
276  (None, ),
277  ('pointer', icons['pointer'],
278  self.parent.OnPointer,
279  wx.ITEM_CHECK),
280  ('query', icons['query'],
281  self.parent.OnQuery,
282  wx.ITEM_CHECK),
283  ('pan', icons['pan'],
284  self.parent.OnPan,
285  wx.ITEM_CHECK),
286  ('zoomin', icons['zoomIn'],
287  self.parent.OnZoomIn,
288  wx.ITEM_CHECK),
289  ('zoomout', icons['zoomOut'],
290  self.parent.OnZoomOut,
291  wx.ITEM_CHECK),
292  ('zoomextent', icons['zoomExtent'],
293  self.parent.OnZoomToMap),
294  ('zoomback', icons['zoomBack'],
295  self.parent.OnZoomBack),
296  ('zoommenu', icons['zoomMenu'],
297  self.parent.OnZoomMenu),
298  (None, ),
299  ('analyze', icons['analyze'],
300  self.parent.OnAnalyze),
301  (None, ),
302  ('dec', icons['overlay'],
303  self.parent.OnDecoration),
304  (None, ),
305  ('savefile', icons['saveFile'],
306  self.parent.SaveToFile),
307  ('printmap', icons['print'],
308  self.parent.PrintMenu),
309  (None, ))
310  )
311 
312  def OnSelectTool(self, event):
313  """!Select / enable tool available in tools list
314  """
315  tool = event.GetSelection()
316 
317  if tool == self.toolId['2d']:
318  self.ExitToolbars()
319  self.Enable2D(True)
320 
321  elif tool == self.toolId['3d'] and \
322  not self.parent.toolbars['nviz']:
323  self.ExitToolbars()
324  self.parent.AddToolbar("nviz")
325 
326  elif tool == self.toolId['vdigit'] and \
327  not self.parent.toolbars['vdigit']:
328  self.ExitToolbars()
329  self.parent.AddToolbar("vdigit")
330  self.parent.MapWindow.SetFocus()
331 
332  def ExitToolbars(self):
333  if self.parent.toolbars['vdigit']:
334  self.parent.toolbars['vdigit'].OnExit()
335  if self.parent.toolbars['nviz']:
336  self.parent.toolbars['nviz'].OnExit()
337 
338  def Enable2D(self, enabled):
339  """!Enable/Disable 2D display mode specific tools"""
340  for tool in (self.pointer,
341  self.pan,
342  self.zoomin,
343  self.zoomout,
344  self.zoomback,
345  self.zoommenu,
346  self.analyze,
347  self.dec,
348  self.printmap):
349  self.EnableTool(tool, enabled)
350 
352  """!Toolbar for managing ground control points
353 
354  @param parent reference to GCP widget
355  """
356  def __init__(self, parent):
357  AbstractToolbar.__init__(self, parent)
358 
359  self.InitToolbar(self._toolbarData())
360 
361  # realize the toolbar
362  self.Realize()
363 
364  def _toolbarData(self):
365  icons = Icons['georectify']
366  return self._getToolbarData((('gcpSave', icons["gcpSave"],
367  self.parent.SaveGCPs),
368  ('gcpReload', icons["gcpReload"],
369  self.parent.ReloadGCPs),
370  (None, ),
371  ('gcpAdd', icons["gcpAdd"],
372  self.parent.AddGCP),
373  ('gcpDelete', icons["gcpDelete"],
374  self.parent.DeleteGCP),
375  ('gcpClear', icons["gcpClear"],
376  self.parent.ClearGCP),
377  (None, ),
378  ('rms', icons["gcpRms"],
379  self.parent.OnRMS),
380  ('georect', icons["georectify"],
381  self.parent.OnGeorect))
382  )
383 
385  """
386  GCP Display toolbar
387  """
388  def __init__(self, parent):
389  """!
390  GCP Display toolbar constructor
391  """
392  AbstractToolbar.__init__(self, parent)
393 
394  self.InitToolbar(self._toolbarData())
395 
396  # add tool to toggle active map window
397  self.togglemapid = wx.NewId()
398  self.togglemap = wx.Choice(parent = self, id = self.togglemapid,
399  choices = [_('source'), _('target')],
400  style = wx.CB_READONLY)
401 
402  self.InsertControl(10, self.togglemap)
403 
404  self.SetToolShortHelp(self.togglemapid, '%s %s %s' % (_('Set map canvas for '),
405  Icons['displayWindow']["zoomBack"].GetLabel(),
406  _(' / Zoom to map')))
407 
408  # realize the toolbar
409  self.Realize()
410 
411  self.action = { 'id' : self.gcpset }
412  self.defaultAction = { 'id' : self.gcpset,
413  'bind' : self.parent.OnPointer }
414 
415  self.OnTool(None)
416 
417  self.EnableTool(self.zoomback, False)
418 
419  def _toolbarData(self):
420  """!Toolbar data"""
421  icons = Icons['displayWindow']
422  return self._getToolbarData((("displaymap", icons["display"],
423  self.parent.OnDraw),
424  ("rendermap", icons["render"],
425  self.parent.OnRender),
426  ("erase", icons["erase"],
427  self.parent.OnErase),
428  (None, ),
429  ("gcpset", Icons["georectify"]["gcpSet"],
430  self.parent.OnPointer),
431  ("pan", icons["pan"],
432  self.parent.OnPan),
433  ("zoomin", icons["zoomIn"],
434  self.parent.OnZoomIn),
435  ("zoomout", icons["zoomOut"],
436  self.parent.OnZoomOut),
437  ("zoommenu", icons["zoomMenu"],
438  self.parent.OnZoomMenuGCP),
439  (None, ),
440  ("zoomback", icons["zoomBack"],
441  self.parent.OnZoomBack),
442  ("zoomtomap", icons["zoomExtent"],
443  self.parent.OnZoomToMap),
444  (None, ),
445  ('settings', Icons["georectify"]["settings"],
446  self.parent.OnSettings),
447  ('help', Icons["misc"]["help"],
448  self.parent.OnHelp),
449  (None, ),
450  ('quit', Icons["georectify"]["quit"],
451  self.parent.OnQuit))
452  )
453 
454  def OnZoomMap(self, event):
455  """!Zoom to selected map"""
456  self.parent.MapWindow.ZoomToMap(layers = self.mapcontent.GetListOfLayers())
457  if event:
458  event.Skip()
459 
461  """!Toolbar for digitization
462  """
463  def __init__(self, parent, mapcontent, layerTree = None, log = None):
464  self.mapcontent = mapcontent # Map class instance
465  self.layerTree = layerTree # reference to layer tree associated to map display
466  self.log = log # log area
467  AbstractToolbar.__init__(self, parent)
468  self.digit = None
469 
470  # currently selected map layer for editing (reference to MapLayer instance)
471  self.mapLayer = None
472  # list of vector layers from Layer Manager (only in the current mapset)
473  self.layers = []
474 
475  self.comboid = None
476 
477  # only one dialog can be open
478  self.settingsDialog = None
479 
480  # create toolbars (two rows optionally)
481  self.InitToolbar(self._toolbarData())
482  self.Bind(wx.EVT_TOOL, self.OnTool)
483 
484  # default action (digitize new point, line, etc.)
485  self.action = { 'desc' : '',
486  'type' : '',
487  'id' : -1 }
488 
489  # list of available vector maps
490  self.UpdateListOfLayers(updateTool = True)
491 
492  # realize toolbar
493  self.Realize()
494  # workaround for Mac bug. May be fixed by 2.8.8, but not before then.
495  self.combo.Hide()
496  self.combo.Show()
497 
498  # disable undo/redo
499  self.EnableTool(self.undo, False)
500 
501  ### hide undo before releasing 6.4.2 - this tool is quite buggy in GRASS 6
502  self.RemoveTool(self.undo)
503 
504  # toogle to pointer by default
505  self.OnTool(None)
506 
507  self.FixSize(width = 105)
508 
509  def _toolbarData(self):
510  """!Toolbar data
511  """
512  data = []
513  icons = Icons['vdigit']
514  return self._getToolbarData(((None, ),
515  ("addPoint", icons["addPoint"],
516  self.OnAddPoint,
517  wx.ITEM_CHECK),
518  ("addLine", icons["addLine"],
519  self.OnAddLine,
520  wx.ITEM_CHECK),
521  ("addBoundary", icons["addBoundary"],
522  self.OnAddBoundary,
523  wx.ITEM_CHECK),
524  ("addCentroid", icons["addCentroid"],
525  self.OnAddCentroid,
526  wx.ITEM_CHECK),
527  ("addArea", icons["addArea"],
528  self.OnAddArea,
529  wx.ITEM_CHECK),
530  ("moveVertex", icons["moveVertex"],
531  self.OnMoveVertex,
532  wx.ITEM_CHECK),
533  ("addVertex", icons["addVertex"],
534  self.OnAddVertex,
535  wx.ITEM_CHECK),
536  ("removeVertex", icons["removeVertex"],
537  self.OnRemoveVertex,
538  wx.ITEM_CHECK),
539  ("editLine", icons["editLine"],
540  self.OnEditLine,
541  wx.ITEM_CHECK),
542  ("moveLine", icons["moveLine"],
543  self.OnMoveLine,
544  wx.ITEM_CHECK),
545  ("deleteLine", icons["deleteLine"],
546  self.OnDeleteLine,
547  wx.ITEM_CHECK),
548  ("displayCats", icons["displayCats"],
549  self.OnDisplayCats,
550  wx.ITEM_CHECK),
551  ("displayAttr", icons["displayAttr"],
552  self.OnDisplayAttr,
553  wx.ITEM_CHECK),
554  ("additionalTools", icons["additionalTools"],
556  wx.ITEM_CHECK),
557  (None, ),
558  ("undo", icons["undo"],
559  self.OnUndo),
560  ("settings", icons["settings"],
561  self.OnSettings),
562  ("quit", icons["quit"],
563  self.OnExit))
564  )
565 
566  def OnTool(self, event):
567  """!Tool selected -> disable selected tool in map toolbar"""
568  aId = self.parent.toolbars['map'].GetAction(type = 'id')
569  self.parent.toolbars['map'].ToggleTool(aId, False)
570 
571  # set cursor
572  cursor = self.parent.cursors["cross"]
573  self.parent.MapWindow.SetCursor(cursor)
574 
575  # pointer
576  self.parent.OnPointer(None)
577 
578  if event:
579  # deselect previously selected tool
580  aId = self.action.get('id', -1)
581  if aId != event.GetId() and \
582  self.action['id'] != -1:
583  self.ToggleTool(self.action['id'], False)
584  else:
585  self.ToggleTool(self.action['id'], True)
586 
587  self.action['id'] = event.GetId()
588 
589  event.Skip()
590 
591  if self.action['id'] != -1:
592  self.ToggleTool(self.action['id'], True)
593 
594  # clear tmp canvas
595  if self.action['id'] != aId:
596  self.parent.MapWindow.ClearLines(pdc = self.parent.MapWindow.pdcTmp)
597  if self.digit and \
598  len(self.parent.MapWindow.digit.GetDisplay().GetSelected()) > 0:
599  # cancel action
600  self.parent.MapWindow.OnMiddleDown(None)
601 
602  # set focus
603  self.parent.MapWindow.SetFocus()
604 
605  def OnAddPoint(self, event):
606  """!Add point to the vector map Laier"""
607  Debug.msg (2, "VDigitToolbar.OnAddPoint()")
608  self.action = { 'desc' : "addLine",
609  'type' : "point",
610  'id' : self.addPoint }
611  self.parent.MapWindow.mouse['box'] = 'point'
612 
613  def OnAddLine(self, event):
614  """!Add line to the vector map layer"""
615  Debug.msg (2, "VDigitToolbar.OnAddLine()")
616  self.action = { 'desc' : "addLine",
617  'type' : "line",
618  'id' : self.addLine }
619  self.parent.MapWindow.mouse['box'] = 'line'
620  ### self.parent.MapWindow.polycoords = [] # reset temp line
621 
622  def OnAddBoundary(self, event):
623  """!Add boundary to the vector map layer"""
624  Debug.msg (2, "VDigitToolbar.OnAddBoundary()")
625  if self.action['desc'] != 'addLine' or \
626  self.action['type'] != 'boundary':
627  self.parent.MapWindow.polycoords = [] # reset temp line
628  self.action = { 'desc' : "addLine",
629  'type' : "boundary",
630  'id' : self.addBoundary }
631  self.parent.MapWindow.mouse['box'] = 'line'
632 
633  def OnAddCentroid(self, event):
634  """!Add centroid to the vector map layer"""
635  Debug.msg (2, "VDigitToolbar.OnAddCentroid()")
636  self.action = { 'desc' : "addLine",
637  'type' : "centroid",
638  'id' : self.addCentroid }
639  self.parent.MapWindow.mouse['box'] = 'point'
640 
641  def OnAddArea(self, event):
642  """!Add area to the vector map layer"""
643  Debug.msg (2, "VDigitToolbar.OnAddCentroid()")
644  self.action = { 'desc' : "addLine",
645  'type' : "area",
646  'id' : self.addArea }
647  self.parent.MapWindow.mouse['box'] = 'line'
648 
649  def OnExit (self, event=None):
650  """!Quit digitization tool"""
651  # stop editing of the currently selected map layer
652  if self.mapLayer:
653  self.StopEditing()
654 
655  # close dialogs if still open
656  if self.settingsDialog:
657  self.settingsDialog.OnCancel(None)
658 
659  # set default mouse settings
660  self.parent.MapWindow.mouse['use'] = "pointer"
661  self.parent.MapWindow.mouse['box'] = "point"
662  self.parent.MapWindow.polycoords = []
663 
664  # disable the toolbar
665  self.parent.RemoveToolbar("vdigit")
666 
667  def OnMoveVertex(self, event):
668  """!Move line vertex"""
669  Debug.msg(2, "Digittoolbar.OnMoveVertex():")
670  self.action = { 'desc' : "moveVertex",
671  'id' : self.moveVertex }
672  self.parent.MapWindow.mouse['box'] = 'point'
673 
674  def OnAddVertex(self, event):
675  """!Add line vertex"""
676  Debug.msg(2, "Digittoolbar.OnAddVertex():")
677  self.action = { 'desc' : "addVertex",
678  'id' : self.addVertex }
679  self.parent.MapWindow.mouse['box'] = 'point'
680 
681  def OnRemoveVertex(self, event):
682  """!Remove line vertex"""
683  Debug.msg(2, "Digittoolbar.OnRemoveVertex():")
684  self.action = { 'desc' : "removeVertex",
685  'id' : self.removeVertex }
686  self.parent.MapWindow.mouse['box'] = 'point'
687 
688  def OnEditLine(self, event):
689  """!Edit line"""
690  Debug.msg(2, "Digittoolbar.OnEditLine():")
691  self.action = { 'desc' : "editLine",
692  'id' : self.editLine }
693  self.parent.MapWindow.mouse['box'] = 'line'
694 
695  def OnMoveLine(self, event):
696  """!Move line"""
697  Debug.msg(2, "Digittoolbar.OnMoveLine():")
698  self.action = { 'desc' : "moveLine",
699  'id' : self.moveLine }
700  self.parent.MapWindow.mouse['box'] = 'box'
701 
702  def OnDeleteLine(self, event):
703  """!Delete line"""
704  Debug.msg(2, "Digittoolbar.OnDeleteLine():")
705  self.action = { 'desc' : "deleteLine",
706  'id' : self.deleteLine }
707  self.parent.MapWindow.mouse['box'] = 'box'
708 
709  def OnDisplayCats(self, event):
710  """!Display/update categories"""
711  Debug.msg(2, "Digittoolbar.OnDisplayCats():")
712  self.action = { 'desc' : "displayCats",
713  'id' : self.displayCats }
714  self.parent.MapWindow.mouse['box'] = 'point'
715 
716  def OnDisplayAttr(self, event):
717  """!Display/update attributes"""
718  Debug.msg(2, "Digittoolbar.OnDisplayAttr():")
719  self.action = { 'desc' : "displayAttrs",
720  'id' : self.displayAttr }
721  self.parent.MapWindow.mouse['box'] = 'point'
722 
723  def OnUndo(self, event):
724  """!Undo previous changes"""
725  self.digit.Undo()
726 
727  event.Skip()
728 
729  def EnableUndo(self, enable=True):
730  """!Enable 'Undo' in toolbar
731 
732  @param enable False for disable
733  """
734  if enable:
735  if self.GetToolEnabled(self.undo) is False:
736  self.EnableTool(self.undo, True)
737  else:
738  if self.GetToolEnabled(self.undo) is True:
739  self.EnableTool(self.undo, False)
740 
741  def OnSettings(self, event):
742  """!Show settings dialog"""
743  if self.digit is None:
744  try:
745  self.digit = self.parent.MapWindow.digit = VDigit(mapwindow = self.parent.MapWindow)
746  except SystemExit:
747  self.digit = self.parent.MapWindow.digit = None
748 
749  if not self.settingsDialog:
750  self.settingsDialog = VDigitSettingsDialog(parent = self.parent, title = _("Digitization settings"),
751  style = wx.DEFAULT_DIALOG_STYLE)
752  self.settingsDialog.Show()
753 
754  def OnAdditionalToolMenu(self, event):
755  """!Menu for additional tools"""
756  point = wx.GetMousePosition()
757  toolMenu = wx.Menu()
758 
759  for label, itype, handler, desc in (
760  (_('Break selected lines/boundaries at intersection'),
761  wx.ITEM_CHECK, self.OnBreak, "breakLine"),
762  (_('Connect selected lines/boundaries'),
763  wx.ITEM_CHECK, self.OnConnect, "connectLine"),
764  (_('Copy categories'),
765  wx.ITEM_CHECK, self.OnCopyCats, "copyCats"),
766  (_('Copy features from (background) vector map'),
767  wx.ITEM_CHECK, self.OnCopy, "copyLine"),
768  (_('Copy attributes'),
769  wx.ITEM_CHECK, self.OnCopyAttrb, "copyAttrs"),
770  (_('Feature type conversion'),
771  wx.ITEM_CHECK, self.OnTypeConversion, "typeConv"),
772  (_('Flip selected lines/boundaries'),
773  wx.ITEM_CHECK, self.OnFlip, "flipLine"),
774  (_('Merge selected lines/boundaries'),
775  wx.ITEM_CHECK, self.OnMerge, "mergeLine"),
776  (_('Snap selected lines/boundaries (only to nodes)'),
777  wx.ITEM_CHECK, self.OnSnap, "snapLine"),
778  (_('Split line/boundary'),
779  wx.ITEM_CHECK, self.OnSplitLine, "splitLine"),
780  (_('Query features'),
781  wx.ITEM_CHECK, self.OnQuery, "queryLine"),
782  (_('Z bulk-labeling of 3D lines'),
783  wx.ITEM_CHECK, self.OnZBulk, "zbulkLine")):
784  # Add items to the menu
785  item = wx.MenuItem(parentMenu = toolMenu, id = wx.ID_ANY,
786  text = label,
787  kind = itype)
788  toolMenu.AppendItem(item)
789  self.parent.MapWindow.Bind(wx.EVT_MENU, handler, item)
790  if self.action['desc'] == desc:
791  item.Check(True)
792 
793  # Popup the menu. If an item is selected then its handler
794  # will be called before PopupMenu returns.
795  self.parent.MapWindow.PopupMenu(toolMenu)
796  toolMenu.Destroy()
797 
798  if self.action['desc'] == 'addPoint':
799  self.ToggleTool(self.additionalTools, False)
800 
801  def OnCopy(self, event):
802  """!Copy selected features from (background) vector map"""
803  if self.action['desc'] == 'copyLine': # select previous action
804  self.ToggleTool(self.addPoint, True)
805  self.ToggleTool(self.additionalTools, False)
806  self.OnAddPoint(event)
807  return
808 
809  Debug.msg(2, "Digittoolbar.OnCopy():")
810  self.action = { 'desc' : "copyLine",
811  'id' : self.additionalTools }
812  self.parent.MapWindow.mouse['box'] = 'box'
813 
814  def OnSplitLine(self, event):
815  """!Split line"""
816  if self.action['desc'] == 'splitLine': # select previous action
817  self.ToggleTool(self.addPoint, True)
818  self.ToggleTool(self.additionalTools, False)
819  self.OnAddPoint(event)
820  return
821 
822  Debug.msg(2, "Digittoolbar.OnSplitLine():")
823  self.action = { 'desc' : "splitLine",
824  'id' : self.additionalTools }
825  self.parent.MapWindow.mouse['box'] = 'point'
826 
827 
828  def OnCopyCats(self, event):
829  """!Copy categories"""
830  if self.action['desc'] == 'copyCats': # select previous action
831  self.ToggleTool(self.addPoint, True)
832  self.ToggleTool(self.copyCats, False)
833  self.OnAddPoint(event)
834  return
835 
836  Debug.msg(2, "Digittoolbar.OnCopyCats():")
837  self.action = { 'desc' : "copyCats",
838  'id' : self.additionalTools }
839  self.parent.MapWindow.mouse['box'] = 'point'
840 
841  def OnCopyAttrb(self, event):
842  """!Copy attributes"""
843  if self.action['desc'] == 'copyAttrs': # select previous action
844  self.ToggleTool(self.addPoint, True)
845  self.ToggleTool(self.copyCats, False)
846  self.OnAddPoint(event)
847  return
848 
849  Debug.msg(2, "Digittoolbar.OnCopyAttrb():")
850  self.action = { 'desc' : "copyAttrs",
851  'id' : self.additionalTools }
852  self.parent.MapWindow.mouse['box'] = 'point'
853 
854 
855  def OnFlip(self, event):
856  """!Flip selected lines/boundaries"""
857  if self.action['desc'] == 'flipLine': # select previous action
858  self.ToggleTool(self.addPoint, True)
859  self.ToggleTool(self.additionalTools, False)
860  self.OnAddPoint(event)
861  return
862 
863  Debug.msg(2, "Digittoolbar.OnFlip():")
864  self.action = { 'desc' : "flipLine",
865  'id' : self.additionalTools }
866  self.parent.MapWindow.mouse['box'] = 'box'
867 
868  def OnMerge(self, event):
869  """!Merge selected lines/boundaries"""
870  if self.action['desc'] == 'mergeLine': # select previous action
871  self.ToggleTool(self.addPoint, True)
872  self.ToggleTool(self.additionalTools, False)
873  self.OnAddPoint(event)
874  return
875 
876  Debug.msg(2, "Digittoolbar.OnMerge():")
877  self.action = { 'desc' : "mergeLine",
878  'id' : self.additionalTools }
879  self.parent.MapWindow.mouse['box'] = 'box'
880 
881  def OnBreak(self, event):
882  """!Break selected lines/boundaries"""
883  if self.action['desc'] == 'breakLine': # select previous action
884  self.ToggleTool(self.addPoint, True)
885  self.ToggleTool(self.additionalTools, False)
886  self.OnAddPoint(event)
887  return
888 
889  Debug.msg(2, "Digittoolbar.OnBreak():")
890  self.action = { 'desc' : "breakLine",
891  'id' : self.additionalTools }
892  self.parent.MapWindow.mouse['box'] = 'box'
893 
894  def OnSnap(self, event):
895  """!Snap selected features"""
896  if self.action['desc'] == 'snapLine': # select previous action
897  self.ToggleTool(self.addPoint, True)
898  self.ToggleTool(self.additionalTools, False)
899  self.OnAddPoint(event)
900  return
901 
902  Debug.msg(2, "Digittoolbar.OnSnap():")
903  self.action = { 'desc' : "snapLine",
904  'id' : self.additionalTools }
905  self.parent.MapWindow.mouse['box'] = 'box'
906 
907  def OnConnect(self, event):
908  """!Connect selected lines/boundaries"""
909  if self.action['desc'] == 'connectLine': # select previous action
910  self.ToggleTool(self.addPoint, True)
911  self.ToggleTool(self.additionalTools, False)
912  self.OnAddPoint(event)
913  return
914 
915  Debug.msg(2, "Digittoolbar.OnConnect():")
916  self.action = { 'desc' : "connectLine",
917  'id' : self.additionalTools }
918  self.parent.MapWindow.mouse['box'] = 'box'
919 
920  def OnQuery(self, event):
921  """!Query selected lines/boundaries"""
922  if self.action['desc'] == 'queryLine': # select previous action
923  self.ToggleTool(self.addPoint, True)
924  self.ToggleTool(self.additionalTools, False)
925  self.OnAddPoint(event)
926  return
927 
928  Debug.msg(2, "Digittoolbar.OnQuery(): %s" % \
929  UserSettings.Get(group = 'vdigit', key = 'query', subkey = 'selection'))
930  self.action = { 'desc' : "queryLine",
931  'id' : self.additionalTools }
932  self.parent.MapWindow.mouse['box'] = 'box'
933 
934  def OnZBulk(self, event):
935  """!Z bulk-labeling selected lines/boundaries"""
936  if not self.digit.IsVector3D():
937  gcmd.GError(parent = self.parent,
938  message = _("Vector map is not 3D. Operation canceled."))
939  return
940 
941  if self.action['desc'] == 'zbulkLine': # select previous action
942  self.ToggleTool(self.addPoint, True)
943  self.ToggleTool(self.additionalTools, False)
944  self.OnAddPoint(event)
945  return
946 
947  Debug.msg(2, "Digittoolbar.OnZBulk():")
948  self.action = { 'desc' : "zbulkLine",
949  'id' : self.additionalTools }
950  self.parent.MapWindow.mouse['box'] = 'line'
951 
952  def OnTypeConversion(self, event):
953  """!Feature type conversion
954 
955  Supported conversions:
956  - point <-> centroid
957  - line <-> boundary
958  """
959  if self.action['desc'] == 'typeConv': # select previous action
960  self.ToggleTool(self.addPoint, True)
961  self.ToggleTool(self.additionalTools, False)
962  self.OnAddPoint(event)
963  return
964 
965  Debug.msg(2, "Digittoolbar.OnTypeConversion():")
966  self.action = { 'desc' : "typeConv",
967  'id' : self.additionalTools }
968  self.parent.MapWindow.mouse['box'] = 'box'
969 
970  def OnSelectMap (self, event):
971  """!Select vector map layer for editing
972 
973  If there is a vector map layer already edited, this action is
974  firstly terminated. The map layer is closed. After this the
975  selected map layer activated for editing.
976  """
977  if event.GetSelection() == 0: # create new vector map layer
978  if self.mapLayer:
979  openVectorMap = self.mapLayer.GetName(fullyQualified = False)['name']
980  else:
981  openVectorMap = None
982  dlg = gdialogs.CreateNewVector(self.parent,
983  exceptMap = openVectorMap, log = self.log,
984  cmd = (('v.edit',
985  { 'tool' : 'create' },
986  'map')),
987  disableAdd = True)
988 
989  if dlg and dlg.GetName():
990  # add layer to map layer tree
991  if self.layerTree:
992  mapName = dlg.GetName() + '@' + grass.gisenv()['MAPSET']
993  self.layerTree.AddLayer(ltype = 'vector',
994  lname = mapName,
995  lcmd = ['d.vect', 'map=%s' % mapName])
996 
997  vectLayers = self.UpdateListOfLayers(updateTool = True)
998  selection = vectLayers.index(mapName)
999 
1000  # create table ?
1001  if dlg.IsChecked('table'):
1002  lmgr = self.parent.GetLayerManager()
1003  if lmgr:
1004  lmgr.OnShowAttributeTable(None, selection = 1)
1005  dlg.Destroy()
1006  else:
1007  self.combo.SetValue(_('Select vector map'))
1008  if dlg:
1009  dlg.Destroy()
1010  return
1011  else:
1012  selection = event.GetSelection() - 1 # first option is 'New vector map'
1013 
1014  # skip currently selected map
1015  if self.layers[selection] == self.mapLayer:
1016  return
1017 
1018  if self.mapLayer:
1019  # deactive map layer for editing
1020  self.StopEditing()
1021 
1022  # select the given map layer for editing
1023  self.StartEditing(self.layers[selection])
1024 
1025  event.Skip()
1026 
1027  def StartEditing (self, mapLayer):
1028  """!Start editing selected vector map layer.
1029 
1030  @param mapLayer MapLayer to be edited
1031  """
1032  # deactive layer
1033  self.mapcontent.ChangeLayerActive(mapLayer, False)
1034 
1035  # clean map canvas
1036  self.parent.MapWindow.EraseMap()
1037 
1038  # unset background map if needed
1039  if mapLayer:
1040  if UserSettings.Get(group = 'vdigit', key = 'bgmap',
1041  subkey = 'value', internal = True) == mapLayer.GetName():
1042  UserSettings.Set(group = 'vdigit', key = 'bgmap',
1043  subkey = 'value', value = '', internal = True)
1044 
1045  self.parent.statusbar.SetStatusText(_("Please wait, "
1046  "opening vector map <%s> for editing...") % mapLayer.GetName(),
1047  0)
1048 
1049  self.parent.MapWindow.pdcVector = wx.PseudoDC()
1050  self.digit = self.parent.MapWindow.digit = VDigit(mapwindow = self.parent.MapWindow)
1051 
1052  self.mapLayer = mapLayer
1053 
1054  # open vector map
1055  if self.digit.OpenMap(mapLayer.GetName()) is None:
1056  self.mapLayer = None
1057  self.StopEditing()
1058  return False
1059 
1060  # update toolbar
1061  self.combo.SetValue(mapLayer.GetName())
1062  self.parent.toolbars['map'].combo.SetValue (_('Digitize'))
1063  lmgr = self.parent.GetLayerManager()
1064  if lmgr:
1065  lmgr.toolbars['tools'].Enable('vdigit', enable = False)
1066 
1067  Debug.msg (4, "VDigitToolbar.StartEditing(): layer=%s" % mapLayer.GetName())
1068 
1069  # change cursor
1070  if self.parent.MapWindow.mouse['use'] == 'pointer':
1071  self.parent.MapWindow.SetCursor(self.parent.cursors["cross"])
1072 
1073  if not self.parent.MapWindow.resize:
1074  self.parent.MapWindow.UpdateMap(render = True)
1075 
1076  # respect opacity
1077  opacity = mapLayer.GetOpacity(float = True)
1078  if opacity < 1.0:
1079  alpha = int(opacity * 255)
1080  self.digit.GetDisplay().UpdateSettings(alpha = alpha)
1081 
1082  return True
1083 
1084  def StopEditing(self):
1085  """!Stop editing of selected vector map layer.
1086 
1087  @return True on success
1088  @return False on failure
1089  """
1090  self.combo.SetValue (_('Select vector map'))
1091 
1092  # save changes
1093  if self.mapLayer:
1094  Debug.msg (4, "VDigitToolbar.StopEditing(): layer=%s" % self.mapLayer.GetName())
1095  if UserSettings.Get(group = 'vdigit', key = 'saveOnExit', subkey = 'enabled') is False:
1096  if self.digit.GetUndoLevel() > -1:
1097  dlg = wx.MessageDialog(parent = self.parent,
1098  message = _("Do you want to save changes "
1099  "in vector map <%s>?") % self.mapLayer.GetName(),
1100  caption = _("Save changes?"),
1101  style = wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
1102  if dlg.ShowModal() == wx.ID_NO:
1103  # revert changes
1104  self.digit.Undo(0)
1105  dlg.Destroy()
1106 
1107  self.parent.statusbar.SetStatusText(_("Please wait, "
1108  "closing and rebuilding topology of "
1109  "vector map <%s>...") % self.mapLayer.GetName(),
1110  0)
1111  lmgr = self.parent.GetLayerManager()
1112  if lmgr:
1113  lmgr.toolbars['tools'].Enable('vdigit', enable = True)
1114  lmgr.notebook.SetSelectionByName('output')
1115  self.digit.CloseMap()
1116  if lmgr:
1117  lmgr.GetLogWindow().GetProgressBar().SetValue(0)
1118  lmgr.GetLogWindow().WriteCmdLog(_("Editing of vector map <%s> successfully finished") % \
1119  self.mapLayer.GetName())
1120  # re-active layer
1121  item = self.parent.tree.FindItemByData('maplayer', self.mapLayer)
1122  if item and self.parent.tree.IsItemChecked(item):
1123  self.mapcontent.ChangeLayerActive(self.mapLayer, True)
1124 
1125  # change cursor
1126  self.parent.MapWindow.SetCursor(self.parent.cursors["default"])
1127  self.parent.MapWindow.pdcVector = None
1128 
1129  # close dialogs
1130  for dialog in ('attributes', 'category'):
1131  if self.parent.dialogs[dialog]:
1132  self.parent.dialogs[dialog].Close()
1133  self.parent.dialogs[dialog] = None
1134 
1135  del self.digit
1136  del self.parent.MapWindow.digit
1137 
1138  self.mapLayer = None
1139 
1140  self.parent.MapWindow.redrawAll = True
1141 
1142  return True
1143 
1144  def UpdateListOfLayers (self, updateTool = False):
1145  """!
1146  Update list of available vector map layers.
1147  This list consists only editable layers (in the current mapset)
1148 
1149  Optionally also update toolbar
1150  """
1151  Debug.msg (4, "VDigitToolbar.UpdateListOfLayers(): updateTool=%d" % \
1152  updateTool)
1153 
1154  layerNameSelected = None
1155  # name of currently selected layer
1156  if self.mapLayer:
1157  layerNameSelected = self.mapLayer.GetName()
1158 
1159  # select vector map layer in the current mapset
1160  layerNameList = []
1161  self.layers = self.mapcontent.GetListOfLayers(l_type = "vector",
1162  l_mapset = grass.gisenv()['MAPSET'])
1163  for layer in self.layers:
1164  if not layer.name in layerNameList: # do not duplicate layer
1165  layerNameList.append (layer.GetName())
1166 
1167  if updateTool: # update toolbar
1168  if not self.mapLayer:
1169  value = _('Select vector map')
1170  else:
1171  value = layerNameSelected
1172 
1173  if not self.comboid:
1174  self.combo = wx.ComboBox(self, id = wx.ID_ANY, value = value,
1175  choices = [_('New vector map'), ] + layerNameList, size = (80, -1),
1176  style = wx.CB_READONLY)
1177  self.comboid = self.InsertControl(0, self.combo)
1178  self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectMap, self.comboid)
1179  else:
1180  self.combo.SetItems([_('New vector map'), ] + layerNameList)
1181 
1182  self.Realize()
1183 
1184  return layerNameList
1185 
1186  def GetLayer(self):
1187  """!Get selected layer for editing -- MapLayer instance"""
1188  return self.mapLayer
1189 
1191  """!Toolbar for profiling raster map
1192  """
1193  def __init__(self, parent):
1194  AbstractToolbar.__init__(self, parent)
1195 
1196  self.InitToolbar(self._toolbarData())
1197 
1198  # realize the toolbar
1199  self.Realize()
1200 
1201  def _toolbarData(self):
1202  """!Toolbar data"""
1203  icons = Icons['profile']
1204  return self._getToolbarData((('addraster', Icons['layerManager']["addRast"],
1205  self.parent.OnSelectRaster),
1206  ('transect', icons["transect"],
1207  self.parent.OnDrawTransect),
1208  (None, ),
1209  ('draw', icons["draw"],
1210  self.parent.OnCreateProfile),
1211  ('erase', Icons['displayWindow']["erase"],
1212  self.parent.OnErase),
1213  ('drag', Icons['displayWindow']['pan'],
1214  self.parent.OnDrag),
1215  ('zoom', Icons['displayWindow']['zoomIn'],
1216  self.parent.OnZoom),
1217  ('unzoom', Icons['displayWindow']['zoomBack'],
1218  self.parent.OnRedraw),
1219  (None, ),
1220  ('datasave', icons["save"],
1221  self.parent.SaveProfileToFile),
1222  ('image', Icons['displayWindow']["saveFile"],
1223  self.parent.SaveToFile),
1224  ('print', Icons['displayWindow']["print"],
1225  self.parent.PrintMenu),
1226  (None, ),
1227  ('settings', icons["options"],
1228  self.parent.ProfileOptionsMenu),
1229  ('quit', icons["quit"],
1230  self.parent.OnQuit),
1231  ))
1232 
1234  """!Nviz toolbar
1235  """
1236  def __init__(self, parent, mapcontent):
1237  self.mapcontent = mapcontent
1238  self.lmgr = parent.GetLayerManager()
1239 
1240  AbstractToolbar.__init__(self, parent)
1241 
1242  # only one dialog can be open
1243  self.settingsDialog = None
1244 
1245  self.InitToolbar(self._toolbarData())
1246 
1247  # realize the toolbar
1248  self.Realize()
1249 
1250  def _toolbarData(self):
1251  """!Toolbar data"""
1252  icons = Icons['nviz']
1253  return self._getToolbarData((("view", icons["view"],
1254  self.OnShowPage),
1255  (None, ),
1256  ("surface", icons["surface"],
1257  self.OnShowPage),
1258  ("vector", icons["vector"],
1259  self.OnShowPage),
1260  ("volume", icons["volume"],
1261  self.OnShowPage),
1262  (None, ),
1263  ("light", icons["light"],
1264  self.OnShowPage),
1265  ("fringe", icons["fringe"],
1266  self.OnShowPage),
1267  (None, ),
1268  ("settings", icons["settings"],
1269  self.OnSettings),
1270  ("help", Icons['misc']["help"],
1271  self.OnHelp),
1272  (None, ),
1273  ('quit', icons["quit"],
1274  self.OnExit))
1275  )
1276 
1277  def OnShowPage(self, event):
1278  """!Go to the selected page"""
1279  if not self.lmgr or not hasattr(self.lmgr, "nviz"):
1280  event.Skip()
1281  return
1282 
1283  self.lmgr.notebook.SetSelectionByName('nviz')
1284  eId = event.GetId()
1285  if eId == self.view:
1286  self.lmgr.nviz.SetPage('view')
1287  elif eId == self.surface:
1288  self.lmgr.nviz.SetPage('surface')
1289  elif eId == self.surface:
1290  self.lmgr.nviz.SetPage('surface')
1291  elif eId == self.vector:
1292  self.lmgr.nviz.SetPage('vector')
1293  elif eId == self.volume:
1294  self.lmgr.nviz.SetPage('volume')
1295  elif eId == self.light:
1296  self.lmgr.nviz.SetPage('light')
1297  elif eId == self.fringe:
1298  self.lmgr.nviz.SetPage('fringe')
1299 
1300  self.lmgr.Raise()
1301 
1302  def OnHelp(self, event):
1303  """!Show 3D view mode help"""
1304  if not self.lmgr:
1305  gcmd.RunCommand('g.manual',
1306  entry = 'wxGUI.Nviz')
1307  else:
1308  log = self.lmgr.GetLogWindow()
1309  log.RunCmd(['g.manual',
1310  'entry=wxGUI.Nviz'])
1311 
1312  def OnSettings(self, event):
1313  """!Show nviz notebook page"""
1314  if not self.settingsDialog:
1315  self.settingsDialog = NvizPreferencesDialog(parent = self.parent)
1316  self.settingsDialog.Show()
1317 
1318  def OnExit (self, event = None):
1319  """!Quit nviz tool (swith to 2D mode)"""
1320  # set default mouse settings
1321  self.parent.MapWindow.mouse['use'] = "pointer"
1322  self.parent.MapWindow.mouse['box'] = "point"
1323  self.parent.MapWindow.polycoords = []
1324 
1325  # return to map layer page (gets rid of ugly exit bug)
1326  self.lmgr.notebook.SetSelectionByName('layers')
1327 
1328  # disable the toolbar
1329  self.parent.RemoveToolbar("nviz")
1330 
1332  """!Graphical modeler toolbar (see gmodeler.py)
1333  """
1334  def __init__(self, parent):
1335  AbstractToolbar.__init__(self, parent)
1336 
1337  self.InitToolbar(self._toolbarData())
1338 
1339  # realize the toolbar
1340  self.Realize()
1341 
1342  def _toolbarData(self):
1343  """!Toolbar data"""
1344  icons = Icons['modeler']
1345  return self._getToolbarData((('new', icons['new'],
1346  self.parent.OnModelNew),
1347  ('open', icons['open'],
1348  self.parent.OnModelOpen),
1349  ('save', icons['save'],
1350  self.parent.OnModelSave),
1351  ('image', icons['toImage'],
1352  self.parent.OnExportImage),
1353  ('python', icons['toPython'],
1354  self.parent.OnExportPython),
1355  (None, ),
1356  ('action', icons['actionAdd'],
1357  self.parent.OnAddAction),
1358  ('data', icons['dataAdd'],
1359  self.parent.OnAddData),
1360  ('relation', icons['relation'],
1361  self.parent.OnDefineRelation),
1362  (None, ),
1363  ('redraw', icons['redraw'],
1364  self.parent.OnCanvasRefresh),
1365  ('validate', icons['validate'],
1366  self.parent.OnValidateModel),
1367  ('run', icons['run'],
1368  self.parent.OnRunModel),
1369  (None, ),
1370  ("variables", icons['variables'],
1371  self.parent.OnVariables),
1372  ("settings", icons['settings'],
1373  self.parent.OnPreferences),
1374  ("help", Icons['misc']['help'],
1375  self.parent.OnHelp),
1376  (None, ),
1377  ('quit', icons['quit'],
1378  self.parent.OnCloseWindow))
1379  )
1380 
1382  """!Histogram toolbar (see histogram.py)
1383  """
1384  def __init__(self, parent):
1385  AbstractToolbar.__init__(self, parent)
1386 
1387  self.InitToolbar(self._toolbarData())
1388 
1389  # realize the toolbar
1390  self.Realize()
1391 
1392  def _toolbarData(self):
1393  """!Toolbar data"""
1394  icons = Icons['displayWindow']
1395  return self._getToolbarData((('histogram', icons["histogram"],
1396  self.parent.OnOptions),
1397  ('rendermao', icons["display"],
1398  self.parent.OnRender),
1399  ('erase', icons["erase"],
1400  self.parent.OnErase),
1401  ('font', Icons['misc']["font"],
1402  self.parent.SetHistFont),
1403  (None, ),
1404  ('save', icons["saveFile"],
1405  self.parent.SaveToFile),
1406  ('hprint', icons["print"],
1407  self.parent.PrintMenu),
1408  (None, ),
1409  ('quit', Icons['misc']["quit"],
1410  self.parent.OnQuit))
1411  )
1412 
1414  """!Layer Manager `workspace` toolbar
1415  """
1416  def __init__(self, parent):
1417  AbstractToolbar.__init__(self, parent)
1418 
1419  self.InitToolbar(self._toolbarData())
1420 
1421  # realize the toolbar
1422  self.Realize()
1423 
1424  def _toolbarData(self):
1425  """!Toolbar data
1426  """
1427  icons = Icons['layerManager']
1428  return self._getToolbarData((('newdisplay', icons["newdisplay"],
1429  self.parent.OnNewDisplay),
1430  (None, ),
1431  ('workspaceNew', icons["workspaceNew"],
1432  self.parent.OnWorkspaceNew),
1433  ('workspaceOpen', icons["workspaceOpen"],
1434  self.parent.OnWorkspaceOpen),
1435  ('workspaceSave', icons["workspaceSave"],
1436  self.parent.OnWorkspaceSave),
1437  ))
1438 
1440  """!Layer Manager `data` toolbar
1441  """
1442  def __init__(self, parent):
1443  AbstractToolbar.__init__(self, parent)
1444 
1445  self.InitToolbar(self._toolbarData())
1446 
1447  # realize the toolbar
1448  self.Realize()
1449 
1450  def _toolbarData(self):
1451  """!Toolbar data
1452  """
1453  icons = Icons['layerManager']
1454  return self._getToolbarData((('addMulti', icons["addMulti"],
1455  self.parent.OnAddMaps),
1456  ('addrast', icons["addRast"],
1457  self.parent.OnAddRaster),
1458  ('rastmisc', icons["rastMisc"],
1459  self.parent.OnAddRasterMisc),
1460  ('addvect', icons["addVect"],
1461  self.parent.OnAddVector),
1462  ('vectmisc', icons["vectMisc"],
1463  self.parent.OnAddVectorMisc),
1464  ('addgrp', icons["addGroup"],
1465  self.parent.OnAddGroup),
1466  ('addovl', icons["addOverlay"],
1467  self.parent.OnAddOverlay),
1468  ('delcmd', icons["delCmd"],
1469  self.parent.OnDeleteLayer),
1470  ))
1471 
1473  """!Layer Manager `tools` toolbar
1474  """
1475  def __init__(self, parent):
1476  AbstractToolbar.__init__(self, parent)
1477 
1478  self.InitToolbar(self._toolbarData())
1479 
1480  # realize the toolbar
1481  self.Realize()
1482 
1483  def _toolbarData(self):
1484  """!Toolbar data
1485  """
1486  icons = Icons['layerManager']
1487  return self._getToolbarData((('importMap', icons["import"],
1488  self.parent.OnImportMenu),
1489  (None, ),
1490  ('mapCalc', icons["mapcalc"],
1491  self.parent.OnMapCalculator),
1492  ('georect', Icons["georectify"]["georectify"],
1493  self.parent.OnGCPManager),
1494  ('modeler', icons["modeler"],
1495  self.parent.OnGModeler),
1496  ('mapOutput', icons['mapOutput'],
1497  self.parent.OnPsMap)
1498  ))
1499 
1501  """!Layer Manager `misc` toolbar
1502  """
1503  def __init__(self, parent):
1504  AbstractToolbar.__init__(self, parent)
1505 
1506  self.InitToolbar(self._toolbarData())
1507 
1508  # realize the toolbar
1509  self.Realize()
1510 
1511  def _toolbarData(self):
1512  """!Toolbar data
1513  """
1514  icons = Icons['layerManager']
1515  return self._getToolbarData((('settings', icons["settings"],
1516  self.parent.OnPreferences),
1517  ('help', Icons["misc"]["help"],
1518  self.parent.OnHelp),
1519  ))
1520 
1522  """!Layer Manager `vector` toolbar
1523  """
1524  def __init__(self, parent):
1525  AbstractToolbar.__init__(self, parent)
1526 
1527  self.InitToolbar(self._toolbarData())
1528 
1529  # realize the toolbar
1530  self.Realize()
1531 
1532  def _toolbarData(self):
1533  """!Toolbar data
1534  """
1535  icons = Icons['layerManager']
1536  return self._getToolbarData((('vdigit', icons["vdigit"],
1537  self.parent.OnVDigit),
1538  ('attribute', icons["attrTable"],
1539  self.parent.OnShowAttributeTable),
1540  ))
1541 
1543  def __init__(self, parent):
1544  """!Toolbar Cartographic Composer (psmap.py)
1545 
1546  @param parent parent window
1547  """
1548  AbstractToolbar.__init__(self, parent)
1549 
1550  self.InitToolbar(self._toolbarData())
1551 
1552  self.Realize()
1553 
1554  self.action = { 'id' : self.pointer }
1555  self.defaultAction = { 'id' : self.pointer,
1556  'bind' : self.parent.OnPointer }
1557  self.OnTool(None)
1558 
1559  from psmap import haveImage
1560  if not haveImage:
1561  self.EnableTool(self.preview, False)
1562 
1563  def _toolbarData(self):
1564  """!Toolbar data
1565  """
1566  icons = Icons['psMap']
1567  return self._getToolbarData((('loadFile', icons['scriptLoad'],
1568  self.parent.OnLoadFile),
1569  ('instructionFile', icons['scriptSave'],
1570  self.parent.OnInstructionFile),
1571  (None, ),
1572  ('pagesetup', icons['pageSetup'],
1573  self.parent.OnPageSetup),
1574  (None, ),
1575  ("pointer", Icons["displayWindow"]["pointer"],
1576  self.parent.OnPointer, wx.ITEM_CHECK),
1577  ('pan', Icons["displayWindow"]['pan'],
1578  self.parent.OnPan, wx.ITEM_CHECK),
1579  ("zoomin", Icons["displayWindow"]["zoomIn"],
1580  self.parent.OnZoomIn, wx.ITEM_CHECK),
1581  ("zoomout", Icons["displayWindow"]["zoomOut"],
1582  self.parent.OnZoomOut, wx.ITEM_CHECK),
1583  ('zoomAll', icons['fullExtent'],
1584  self.parent.OnZoomAll),
1585  (None, ),
1586  ('addMap', icons['addMap'],
1587  self.parent.OnAddMap, wx.ITEM_CHECK),
1588  ('addRaster', icons['addRast'],
1589  self.parent.OnAddRaster),
1590  ('addVector', icons['addVect'],
1591  self.parent.OnAddVect),
1592  ("dec", Icons["displayWindow"]["overlay"],
1593  self.parent.OnDecoration),
1594  ("delete", icons["deleteObj"],
1595  self.parent.OnDelete),
1596  (None, ),
1597  ("preview", icons["preview"],
1598  self.parent.OnPreview),
1599  ('generatePS', icons['psExport'],
1600  self.parent.OnPSFile),
1601  ('generatePDF', icons['pdfExport'],
1602  self.parent.OnPDFFile),
1603  (None, ),
1604  ("help", Icons['misc']['help'],
1605  self.parent.OnHelp),
1606  ('quit', icons['quit'],
1607  self.parent.OnCloseWindow))
1608  )