2 @package mapdisp.toolbars
4 @brief Map display frame - toolbars
9 (C) 2007-2011 by the GRASS Development Team
11 This program is free software under the GNU General Public License
12 (>=v2). Read the file COPYING that comes with GRASS for details.
14 @author Michael Barton
15 @author Jachym Cepicky
16 @author Martin Landa <landa.martin gmail.com>
24 from icons.icon
import MetaIcon
27 'query' : MetaIcon(img =
'info',
28 label = _(
'Query raster/vector map(s)'),
29 desc = _(
'Query selected raster/vector map(s)')),
30 'addBarscale': MetaIcon(img =
'scalebar-add',
31 label = _(
'Add scalebar and north arrow')),
32 'addLegend' : MetaIcon(img =
'legend-add',
33 label = _(
'Add legend')),
34 'addNorthArrow': MetaIcon(img =
'north-arrow-add',
35 label = _(
'North Arrow')),
36 'analyze' : MetaIcon(img =
'layer-raster-analyze',
37 label = _(
'Analyze map'),
38 desc = _(
'Measuring, profiling, histogramming, ...')),
39 'measure' : MetaIcon(img =
'measure-length',
40 label = _(
'Measure distance')),
41 'profile' : MetaIcon(img =
'layer-raster-profile',
42 label = _(
'Profile surface map')),
43 'scatter' : MetaIcon(img =
'layer-raster-profile',
44 label = _(
"Create bivariate scatterplot of raster maps")),
45 'addText' : MetaIcon(img =
'text-add',
46 label = _(
'Add text layer')),
47 'histogram' : MetaIcon(img =
'layer-raster-histogram',
48 label = _(
'Create histogram of raster map')),
52 'rotate' : MetaIcon(img =
'3d-rotate',
53 label = _(
'Rotate 3D scene'),
54 desc = _(
'Drag with mouse to rotate 3D scene')),
55 'flyThrough': MetaIcon(img =
'flythrough',
56 label = _(
'Fly-through mode'),
57 desc = _(
'Drag with mouse, hold Ctrl down for different mode'
58 ' or Shift to accelerate')),
59 'zoomIn' : BaseIcons[
'zoomIn'].SetLabel(desc = _(
'Click mouse to zoom')),
60 'zoomOut' : BaseIcons[
'zoomOut'].SetLabel(desc = _(
'Click mouse to unzoom'))
64 """!Map Display toolbar
67 """!Map Display constructor
69 @param parent reference to MapFrame
70 @param mapcontent reference to render.Map (registred by MapFrame)
73 BaseToolbar.__init__(self, parent = parent)
78 choices = [ _(
'2D view'), ]
80 if self.parent.GetLayerManager():
81 log = self.parent.GetLayerManager().GetLogWindow()
84 choices.append(_(
'3D view'))
88 log.WriteCmdLog(_(
'3D view mode not available'))
89 log.WriteWarning(_(
'Reason: %s') % str(errorMsg))
90 log.WriteLog(_(
'Note that the wxGUI\'s 3D view mode is currently disabled '
91 'on MS Windows (hopefully this will be fixed soon). '
92 'Please keep an eye out for updated versions of GRASS. '
93 'In the meantime you can use "NVIZ" from the File menu.'), wrap = 60)
98 choices.append(_(
'Digitize'))
105 log.WriteCmdLog(_(
'Vector digitizer not available'))
106 log.WriteWarning(_(
'Reason: %s') % errorMsg)
107 log.WriteLog(_(
'Note that the wxGUI\'s vector digitizer is currently disabled '
108 '(hopefully this will be fixed soon). '
109 'Please keep an eye out for updated versions of GRASS. '
110 'In the meantime you can use "v.digit" from the Develop Vector menu.'), wrap = 60)
112 self.
toolId[
'vdigit'] = -1
114 self.
combo = wx.ComboBox(parent = self, id = wx.ID_ANY,
116 style = wx.CB_READONLY, size = (110, -1))
117 self.combo.SetSelection(0)
131 'bind' : self.parent.OnPointer }
135 self.EnableTool(self.zoomBack,
False)
139 def _toolbarData(self):
143 (
'renderMap', BaseIcons[
'render'],
144 self.parent.OnRender),
145 (
'erase', BaseIcons[
'erase'],
146 self.parent.OnErase),
148 (
'pointer', BaseIcons[
'pointer'],
149 self.parent.OnPointer,
151 (
'query', MapIcons[
'query'],
154 (
'pan', BaseIcons[
'pan'],
157 (
'zoomIn', BaseIcons[
'zoomIn'],
158 self.parent.OnZoomIn,
160 (
'zoomOut', BaseIcons[
'zoomOut'],
161 self.parent.OnZoomOut,
163 (
'zoomExtent', BaseIcons[
'zoomExtent'],
164 self.parent.OnZoomToMap),
165 (
'zoomBack', BaseIcons[
'zoomBack'],
166 self.parent.OnZoomBack),
167 (
'zoomMenu', BaseIcons[
'zoomMenu'],
168 self.parent.OnZoomMenu),
170 (
'analyze', MapIcons[
'analyze'],
173 (
'overlay', BaseIcons[
'overlay'],
176 (
'saveFile', BaseIcons[
'saveFile'],
177 self.parent.SaveToFile),
178 (
'printMap', BaseIcons[
'print'],
179 self.parent.PrintMenu),
183 """!Insert tool to toolbar
185 @param data toolbar data"""
191 self.parent._mgr.GetPane(
'mapToolbar').BestSize(self.GetBestSize())
192 self.parent._mgr.Update()
195 """!Remove tool from toolbar
197 @param tool tool id"""
198 self.DeleteTool(tool)
200 self.parent._mgr.GetPane(
'mapToolbar').BestSize(self.GetBestSize())
201 self.parent._mgr.Update()
204 """!Change description of zoom tools for 2D/3D view"""
209 for i, data
in enumerate(self.
_data):
210 for tool
in ((
'zoomIn',
'zoomOut')):
213 tmp[4] = icons[tool].GetDesc()
214 self.
_data[i] = tuple(tmp)
217 """!Select / enable tool available in tools list
219 tool = event.GetSelection()
221 if tool == self.
toolId[
'2d']:
226 elif tool == self.
toolId[
'3d']
and \
227 not (self.parent.MapWindow3D
and self.parent.IsPaneShown(
'3d')):
229 self.parent.AddNviz()
231 elif tool == self.
toolId[
'vdigit']
and \
232 not self.parent.GetToolbar(
'vdigit'):
234 self.parent.AddToolbar(
"vdigit")
235 self.parent.MapWindow.SetFocus()
238 """!Analysis tools menu
240 self.
_onMenu(((MapIcons[
"measure"], self.parent.OnMeasure),
241 (MapIcons[
"profile"], self.parent.OnProfile),
242 (MapIcons[
"histogram"], self.parent.OnHistogram)))
245 """!Decorations overlay menu
247 if self.parent.IsPaneShown(
'3d'):
248 self.
_onMenu(((MapIcons[
"addNorthArrow"], self.parent.OnAddArrow),
249 (MapIcons[
"addLegend"], self.parent.OnAddLegend),
250 (MapIcons[
"addText"], self.parent.OnAddText)))
252 self.
_onMenu(((MapIcons[
"addBarscale"], self.parent.OnAddBarscale),
253 (MapIcons[
"addLegend"], self.parent.OnAddLegend),
254 (MapIcons[
"addText"], self.parent.OnAddText)))
257 if self.parent.GetToolbar(
'vdigit'):
258 self.parent.toolbars[
'vdigit'].OnExit()
259 if self.parent.GetLayerManager().IsPaneShown(
'toolbarNviz'):
260 self.parent.RemoveNviz()
263 """!Enable/Disable 2D display mode specific tools"""
264 for tool
in (self.zoomMenu,
267 self.EnableTool(tool, enabled)