GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
lmgr/toolbars.py
Go to the documentation of this file.
1 """!
2 @package lmgr.toolbars
3 
4 @brief wxGUI Layer Manager - toolbars
5 
6 Classes:
7  - toolbars::LMWorkspaceToolbar
8  - toolbars::LMDataToolbar
9  - toolbars::LMToolsToolbar
10  - toolbars::LMMiscToolbar
11  - toolbars::LMVectorToolbar
12  - toolbars::LMNvizToolbar
13 
14 (C) 2007-2011 by the GRASS Development Team
15 
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 
19 @author Michael Barton
20 @author Jachym Cepicky
21 @author Martin Landa <landa.martin gmail.com>
22 @author Anna Kratochvilova <kratochanna gmail.com>
23 """
24 
25 import os
26 import sys
27 
28 from core import globalvar
29 from core.gcmd import RunCommand
30 from nviz.preferences import NvizPreferencesDialog
31 from gui_core.toolbars import BaseToolbar, BaseIcons
32 from icons.icon import MetaIcon
33 
35  """!Layer Manager `workspace` toolbar
36  """
37  def __init__(self, parent):
38  BaseToolbar.__init__(self, parent)
39 
40  self.InitToolbar(self._toolbarData())
41 
42  # realize the toolbar
43  self.Realize()
44 
45  def _toolbarData(self):
46  """!Toolbar data
47  """
48  icons = {
49  'newdisplay' : MetaIcon(img = 'monitor-create',
50  label = _('Start new map display')),
51  'workspaceNew' : MetaIcon(img = 'create',
52  label = _('Create new workspace (Ctrl+N)')),
53  'workspaceOpen' : MetaIcon(img = 'open',
54  label = _('Open existing workspace file (Ctrl+O)')),
55  'workspaceSave' : MetaIcon(img = 'save',
56  label = _('Save current workspace to file (Ctrl+S)')),
57  }
58  return self._getToolbarData((('newdisplay', icons["newdisplay"],
59  self.parent.OnNewDisplay),
60  (None, ),
61  ('workspaceNew', icons["workspaceNew"],
62  self.parent.OnWorkspaceNew),
63  ('workspaceOpen', icons["workspaceOpen"],
64  self.parent.OnWorkspaceOpen),
65  ('workspaceSave', icons["workspaceSave"],
66  self.parent.OnWorkspaceSave),
67  ))
68 
70  """!Layer Manager `data` toolbar
71  """
72  def __init__(self, parent):
73  BaseToolbar.__init__(self, parent)
74 
75  self.InitToolbar(self._toolbarData())
76 
77  # realize the toolbar
78  self.Realize()
79 
80  def _toolbarData(self):
81  """!Toolbar data
82  """
83  icons = {
84  'addMulti' : MetaIcon(img = 'layer-open',
85  label = _('Add multiple raster or vector map layers (Ctrl+Shift+L)')),
86  'addRast' : BaseIcons['addRast'].SetLabel(_("Add raster map layer (Ctrl+Shift+R)")),
87  'rastMisc' : MetaIcon(img = 'layer-raster-more',
88  label = _('Add various raster map layers (RGB, HIS, shaded relief...)')),
89  'addVect' : BaseIcons['addVect'].SetLabel(_("Add vector map layer (Ctrl+Shift+V)")),
90  'vectMisc' : MetaIcon(img = 'layer-vector-more',
91  label = _('Add various vector map layers (thematic, chart...)')),
92  'addGroup' : MetaIcon(img = 'layer-group-add',
93  label = _('Add group')),
94  'addOverlay' : MetaIcon(img = 'layer-more',
95  label = _('Add grid or vector labels overlay')),
96  'delCmd' : MetaIcon(img = 'layer-remove',
97  label = _('Remove selected map layer(s) from layer tree')),
98  }
99 
100  return self._getToolbarData((('addMulti', icons["addMulti"],
101  self.parent.OnAddMaps),
102  ('addrast', icons["addRast"],
103  self.parent.OnAddRaster),
104  ('rastmisc', icons["rastMisc"],
105  self.parent.OnAddRasterMisc),
106  ('addvect', icons["addVect"],
107  self.parent.OnAddVector),
108  ('vectmisc', icons["vectMisc"],
109  self.parent.OnAddVectorMisc),
110  ('addgrp', icons["addGroup"],
111  self.parent.OnAddGroup),
112  ('addovl', icons["addOverlay"],
113  self.parent.OnAddOverlay),
114  ('delcmd', icons["delCmd"],
115  self.parent.OnDeleteLayer),
116  ))
117 
119  """!Layer Manager `tools` toolbar
120  """
121  def __init__(self, parent):
122  BaseToolbar.__init__(self, parent)
123 
124  self.InitToolbar(self._toolbarData())
125 
126  # realize the toolbar
127  self.Realize()
128 
129  def _toolbarData(self):
130  """!Toolbar data
131  """
132  icons = {
133  'import' : MetaIcon(img = 'layer-import',
134  label = _('Import/link raster or vector data')),
135  'mapcalc' : MetaIcon(img = 'calculator',
136  label = _('Raster Map Calculator')),
137  'modeler' : MetaIcon(img = 'modeler-main',
138  label = _('Graphical Modeler')),
139  'georectify' : MetaIcon(img = 'georectify',
140  label = _('Georectifier')),
141  'composer': MetaIcon(img = 'print-compose',
142  label = _('Cartographic Composer')),
143  }
144 
145  return self._getToolbarData((('importMap', icons["import"],
146  self.parent.OnImportMenu),
147  (None, ),
148  ('mapCalc', icons["mapcalc"],
149  self.parent.OnMapCalculator),
150  ('georect', icons["georectify"],
151  self.parent.OnGCPManager),
152  ('modeler', icons["modeler"],
153  self.parent.OnGModeler),
154  ('mapOutput', icons['composer'],
155  self.parent.OnPsMap)
156  ))
157 
159  """!Layer Manager `misc` toolbar
160  """
161  def __init__(self, parent):
162  BaseToolbar.__init__(self, parent)
163 
164  self.InitToolbar(self._toolbarData())
165 
166  # realize the toolbar
167  self.Realize()
168 
169  def _toolbarData(self):
170  """!Toolbar data
171  """
172  icons = {
173  'settings' : BaseIcons['settings'].SetLabel(_('GUI settings')),
174  'help' : BaseIcons['help'].SetLabel(_('GRASS manual')),
175  }
176 
177  return self._getToolbarData((('settings', icons["settings"],
178  self.parent.OnPreferences),
179  ('help', icons["help"],
180  self.parent.OnHelp),
181  ))
182 
184  """!Layer Manager `vector` toolbar
185  """
186  def __init__(self, parent):
187  BaseToolbar.__init__(self, parent)
188 
189  self.InitToolbar(self._toolbarData())
190 
191  # realize the toolbar
192  self.Realize()
193 
194  def _toolbarData(self):
195  """!Toolbar data
196  """
197  icons = {
198  'vdigit' : MetaIcon(img = 'edit',
199  label = _('Edit vector maps')),
200  'attrTable' : MetaIcon(img = 'table',
201  label = _('Show attribute table')),
202  }
203 
204  return self._getToolbarData((('vdigit', icons["vdigit"],
205  self.parent.OnVDigit),
206  ('attribute', icons["attrTable"],
207  self.parent.OnShowAttributeTable),
208  ))
209 
211  """!Nviz toolbar
212  """
213  def __init__(self, parent):
214  self.lmgr = parent
215 
216  BaseToolbar.__init__(self, parent)
217 
218  # only one dialog can be open
219  self.settingsDialog = None
220 
221  self.InitToolbar(self._toolbarData())
222 
223  # realize the toolbar
224  self.Realize()
225 
226  def _toolbarData(self):
227  """!Toolbar data"""
228  icons = {
229  'cmd' : MetaIcon(img = 'script-save',
230  label = _('Generate command for m.nviz.image'),
231  desc = _('Generate command for m.nviz.image based on current state')),
232  'settings' : MetaIcon(img = '3d-settings',
233  label = _('3D view mode settings'),
234  desc = _('Show 3D view mode settings dialog')),
235  'help' : MetaIcon(img = '3d-help',
236  label = _('Show 3D view mode manual')),
237  }
238 
239  return self._getToolbarData((("nvizCmd", icons['cmd'],
240  self.OnNvizCmd),
241  (None, ),
242  ("settings", icons["settings"],
243  self.OnSettings),
244  ("help", icons["help"],
245  self.OnHelp))
246  )
247 
248  def OnNvizCmd(self, event):
249  """!Show m.nviz.image command"""
250  self.lmgr.GetLayerTree().GetMapDisplay().GetWindow().OnNvizCmd()
251 
252  def OnHelp(self, event):
253  """!Show 3D view mode help"""
254  if not self.lmgr:
255  RunCommand('g.manual',
256  entry = 'wxGUI.Nviz')
257  else:
258  log = self.lmgr.GetLogWindow()
259  log.RunCmd(['g.manual',
260  'entry=wxGUI.Nviz'])
261 
262  def OnSettings(self, event):
263  """!Show nviz notebook page"""
264  if not self.settingsDialog:
265  self.settingsDialog = NvizPreferencesDialog(parent = self.parent)
266  self.settingsDialog.Show()
wxGUI command interface
def OnHelp
Show 3D view mode help.
def _toolbarData
Toolbar data (virtual)
Layer Manager vector toolbar.
Layer Manager tools toolbar.
Layer Manager data toolbar.
def _getToolbarData
Define tool.
Layer Manager workspace toolbar.
def InitToolbar
Initialize toolbar, add tools to the toolbar.
def OnNvizCmd
Show m.nviz.image command.
Abstract toolbar class.
Layer Manager misc toolbar.
Base classes toolbar widgets.
def OnSettings
Show nviz notebook page.
def RunCommand
Run GRASS command.
Definition: gcmd.py:625