"""! @package toolbar @brief wxGUI toolbar widgets Classes: - AbstractToolbar - MapToolbar - GCPMapToolbar - GCPDisplayToolbar - VDigitToolbar - ProfileToolbar - LMNvizToolbar - ModelToolbar - HistogramToolbar - Histogram2Toolbar - ScatterplotToolbar - LMWorkspaceToolbar - LMDataToolbar - LMToolsToolbar - LMMiscToolbar - LMVectorToolbar - PsMapToolbar (C) 2007-2011 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details. @author Michael Barton @author Jachym Cepicky @author Martin Landa @author Anna Kratochvilova """ import os import sys import platform from grass.script import core as grass import wx import globalvar from gdialogs import CreateNewVector from vdigit import VDigitSettingsDialog, haveVDigit, VDigit from debug import Debug from preferences import globalSettings as UserSettings from gcmd import RunCommand, GError from nviz import haveNviz from nviz_preferences import NvizPreferencesDialog sys.path.append(os.path.join(globalvar.ETCWXDIR, "icons")) from icon import Icons class AbstractToolbar(wx.ToolBar): """!Abstract toolbar class""" def __init__(self, parent): self.parent = parent wx.ToolBar.__init__(self, parent = self.parent, id = wx.ID_ANY) self.action = dict() self.Bind(wx.EVT_TOOL, self.OnTool) self.SetToolBitmapSize(globalvar.toolbarSize) def InitToolbar(self, toolData): """!Initialize toolbar, add tools to the toolbar """ for tool in toolData: self.CreateTool(*tool) self._data = toolData def _toolbarData(self): """!Toolbar data (virtual)""" return None def CreateTool(self, label, bitmap, kind, shortHelp, longHelp, handler, pos = -1): """!Add tool to the toolbar @param pos if -1 add tool, if > 0 insert at given pos @return id of tool """ bmpDisabled = wx.NullBitmap tool = -1 if label: tool = vars(self)[label] = wx.NewId() Debug.msg(3, "CreateTool(): tool=%d, label=%s bitmap=%s" % \ (tool, label, bitmap)) if pos < 0: toolWin = self.AddLabelTool(tool, label, bitmap, bmpDisabled, kind, shortHelp, longHelp) else: toolWin = self.InsertLabelTool(pos, tool, label, bitmap, bmpDisabled, kind, shortHelp, longHelp) self.Bind(wx.EVT_TOOL, handler, toolWin) else: # separator self.AddSeparator() return tool def EnableLongHelp(self, enable = True): """!Enable/disable long help @param enable True for enable otherwise disable """ for tool in self._data: if tool[0] == '': # separator continue if enable: self.SetToolLongHelp(vars(self)[tool[0]], tool[4]) else: self.SetToolLongHelp(vars(self)[tool[0]], "") def OnTool(self, event): """!Tool selected """ if self.parent.GetName() == "GCPFrame": return if hasattr(self.parent, 'toolbars'): if self.parent.GetToolbar('vdigit'): # update vdigit toolbar (unselect currently selected tool) id = self.parent.toolbars['vdigit'].GetAction(type = 'id') self.parent.toolbars['vdigit'].ToggleTool(id, False) if event: # deselect previously selected tool id = self.action.get('id', -1) if id != event.GetId(): self.ToggleTool(self.action['id'], False) else: self.ToggleTool(self.action['id'], True) self.action['id'] = event.GetId() event.Skip() else: # initialize toolbar self.ToggleTool(self.action['id'], True) def GetAction(self, type = 'desc'): """!Get current action info""" return self.action.get(type, '') def SelectDefault(self, event): """!Select default tool""" self.ToggleTool(self.defaultAction['id'], True) self.defaultAction['bind'](event) self.action = { 'id' : self.defaultAction['id'], 'desc' : self.defaultAction.get('desc', '') } def FixSize(self, width): """!Fix toolbar width on Windows @todo Determine why combobox causes problems here """ if platform.system() == 'Windows': size = self.GetBestSize() self.SetSize((size[0] + width, size[1])) def Enable(self, tool, enable = True): """!Enable/Disable defined tool @param tool name @param enable True to enable otherwise disable tool """ try: id = getattr(self, tool) except AttributeError: return self.EnableTool(id, enable) def EnableAll(self, enable = True): """!Enable/Disable all tools @param enable True to enable otherwise disable tool """ for item in self._toolbarData(): if not item[0]: continue self.Enable(item[0], enable) def _getToolbarData(self, data): """!Define tool """ retData = list() for args in data: retData.append(self._defineTool(*args)) return retData def _defineTool(self, name = None, icon = None, handler = None, item = wx.ITEM_NORMAL, pos = -1): """!Define tool """ if name: return (name, icon.GetBitmap(), item, icon.GetLabel(), icon.GetDesc(), handler, pos) return ("", "", "", "", "", "") # separator class MapToolbar(AbstractToolbar): """!Map Display toolbar """ def __init__(self, parent, mapcontent): """!Map Display constructor @param parent reference to MapFrame @param mapcontent reference to render.Map (registred by MapFrame) """ self.mapcontent = mapcontent # render.Map AbstractToolbar.__init__(self, parent = parent) # MapFrame self.InitToolbar(self._toolbarData()) # optional tools choices = [ _('2D view'), ] self.toolId = { '2d' : 0 } if self.parent.GetLayerManager(): log = self.parent.GetLayerManager().GetLogWindow() if haveNviz: choices.append(_('3D view')) self.toolId['3d'] = 1 else: from nviz import errorMsg log.WriteCmdLog(_('3D view mode not available')) log.WriteWarning(_('Reason: %s') % str(errorMsg)) log.WriteLog(_('Note that the wxGUI\'s 3D view mode is currently disabled ' 'on MS Windows (hopefully this will be fixed soon). ' 'Please keep an eye out for updated versions of GRASS. ' 'In the meantime you can use "NVIZ" from the File menu.'), wrap = 60) self.toolId['3d'] = -1 if haveVDigit: choices.append(_('Digitize')) if self.toolId['3d'] > -1: self.toolId['vdigit'] = 2 else: self.toolId['vdigit'] = 1 else: from vdigit import errorMsg log.WriteCmdLog(_('Vector digitizer not available')) log.WriteWarning(_('Reason: %s') % errorMsg) log.WriteLog(_('Note that the wxGUI\'s vector digitizer is currently disabled ' '(hopefully this will be fixed soon). ' 'Please keep an eye out for updated versions of GRASS. ' 'In the meantime you can use "v.digit" from the Develop Vector menu.'), wrap = 60) self.toolId['vdigit'] = -1 self.combo = wx.ComboBox(parent = self, id = wx.ID_ANY, choices = choices, style = wx.CB_READONLY, size = (110, -1)) self.combo.SetSelection(0) self.comboid = self.AddControl(self.combo) self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectTool, self.comboid) # realize the toolbar self.Realize() # workaround for Mac bug. May be fixed by 2.8.8, but not before then. self.combo.Hide() self.combo.Show() self.action = { 'id' : self.pointer } self.defaultAction = { 'id' : self.pointer, 'bind' : self.parent.OnPointer } self.OnTool(None) self.EnableTool(self.zoomback, False) self.FixSize(width = 90) def _toolbarData(self): """!Toolbar data""" icons = Icons['displayWindow'] return self._getToolbarData((('displaymap', icons['display'], self.parent.OnDraw), ('rendermap', icons['render'], self.parent.OnRender), ('erase', icons['erase'], self.parent.OnErase), (None, ), ('pointer', icons['pointer'], self.parent.OnPointer, wx.ITEM_CHECK), ('query', icons['query'], self.parent.OnQuery, wx.ITEM_CHECK), ('pan', icons['pan'], self.parent.OnPan, wx.ITEM_CHECK), ('zoomin', icons['zoomIn'], self.parent.OnZoomIn, wx.ITEM_CHECK), ('zoomout', icons['zoomOut'], self.parent.OnZoomOut, wx.ITEM_CHECK), ('zoomextent', icons['zoomExtent'], self.parent.OnZoomToMap), ('zoomback', icons['zoomBack'], self.parent.OnZoomBack), ('zoommenu', icons['zoomMenu'], self.parent.OnZoomMenu), (None, ), ('analyze', icons['analyze'], self.parent.OnAnalyze), (None, ), ('dec', icons['overlay'], self.parent.OnDecoration), (None, ), ('savefile', icons['saveFile'], self.parent.SaveToFile), ('printmap', icons['print'], self.parent.PrintMenu), (None, )) ) def InsertTool(self, data): """!Insert tool to toolbar @param data toolbar data""" data = self._getToolbarData(data) for tool in data: self.CreateTool(*tool) self.Realize() self.parent._mgr.GetPane('mapToolbar').BestSize(self.GetBestSize()) self.parent._mgr.Update() def RemoveTool(self, tool): """!Remove tool from toolbar @param tool tool id""" self.DeleteTool(tool) self.parent._mgr.GetPane('mapToolbar').BestSize(self.GetBestSize()) self.parent._mgr.Update() def ChangeToolsDesc(self, mode2d): """!Change description of zoom tools for 2D/3D view""" if mode2d: set = 'displayWindow' else: set = 'nviz' for i, data in enumerate(self._data): for tool, toolname in (('zoomin', 'zoomIn'),('zoomout', 'zoomOut')): if data[0] == tool: tmp = list(data) tmp[4] = Icons[set][toolname].GetDesc() self._data[i] = tuple(tmp) def OnSelectTool(self, event): """!Select / enable tool available in tools list """ tool = event.GetSelection() if tool == self.toolId['2d']: self.ExitToolbars() self.Enable2D(True) self.ChangeToolsDesc(mode2d = True) elif tool == self.toolId['3d'] and \ not (self.parent.MapWindow3D and self.parent.IsPaneShown('3d')): self.ExitToolbars() self.parent.AddNviz() elif tool == self.toolId['vdigit'] and \ not self.parent.GetToolbar('vdigit'): self.ExitToolbars() self.parent.AddToolbar("vdigit") self.parent.MapWindow.SetFocus() def ExitToolbars(self): if self.parent.GetToolbar('vdigit'): self.parent.toolbars['vdigit'].OnExit() if self.parent.GetLayerManager().IsPaneShown('toolbarNviz'): self.parent.RemoveNviz() def Enable2D(self, enabled): """!Enable/Disable 2D display mode specific tools""" for tool in (self.zoommenu, self.analyze, self.printmap): self.EnableTool(tool, enabled) class GCPManToolbar(AbstractToolbar): """!Toolbar for managing ground control points @param parent reference to GCP widget """ def __init__(self, parent): AbstractToolbar.__init__(self, parent) self.InitToolbar(self._toolbarData()) # realize the toolbar self.Realize() def _toolbarData(self): icons = Icons['georectify'] return self._getToolbarData((('gcpSave', icons["gcpSave"], self.parent.SaveGCPs), ('gcpReload', icons["gcpReload"], self.parent.ReloadGCPs), (None, ), ('gcpAdd', icons["gcpAdd"], self.parent.AddGCP), ('gcpDelete', icons["gcpDelete"], self.parent.DeleteGCP), ('gcpClear', icons["gcpClear"], self.parent.ClearGCP), (None, ), ('rms', icons["gcpRms"], self.parent.OnRMS), ('georect', icons["georectify"], self.parent.OnGeorect)) ) class GCPDisplayToolbar(AbstractToolbar): """!GCP Display toolbar """ def __init__(self, parent): """!GCP Display toolbar constructor """ AbstractToolbar.__init__(self, parent) self.InitToolbar(self._toolbarData()) # add tool to toggle active map window self.togglemapid = wx.NewId() self.togglemap = wx.Choice(parent = self, id = self.togglemapid, choices = [_('source'), _('target')], style = wx.CB_READONLY) self.InsertControl(10, self.togglemap) self.SetToolShortHelp(self.togglemapid, '%s %s %s' % (_('Set map canvas for '), Icons['displayWindow']["zoomBack"].GetLabel(), _(' / Zoom to map'))) # realize the toolbar self.Realize() self.action = { 'id' : self.gcpset } self.defaultAction = { 'id' : self.gcpset, 'bind' : self.parent.OnPointer } self.OnTool(None) self.EnableTool(self.zoomback, False) def _toolbarData(self): """!Toolbar data""" icons = Icons['displayWindow'] return self._getToolbarData((("displaymap", icons["display"], self.parent.OnDraw), ("rendermap", icons["render"], self.parent.OnRender), ("erase", icons["erase"], self.parent.OnErase), (None, ), ("gcpset", Icons["georectify"]["gcpSet"], self.parent.OnPointer), ("pan", icons["pan"], self.parent.OnPan), ("zoomin", icons["zoomIn"], self.parent.OnZoomIn), ("zoomout", icons["zoomOut"], self.parent.OnZoomOut), ("zoommenu", icons["zoomMenu"], self.parent.OnZoomMenuGCP), (None, ), ("zoomback", icons["zoomBack"], self.parent.OnZoomBack), ("zoomtomap", icons["zoomExtent"], self.parent.OnZoomToMap), (None, ), ('settings', Icons["georectify"]["settings"], self.parent.OnSettings), ('help', Icons["misc"]["help"], self.parent.OnHelp), (None, ), ('quit', Icons["georectify"]["quit"], self.parent.OnQuit)) ) class VDigitToolbar(AbstractToolbar): """!Toolbar for digitization """ def __init__(self, parent, MapWindow, tools = [], layerTree = None, log = None): self.MapWindow = MapWindow self.Map = MapWindow.GetMap() # Map class instance self.layerTree = layerTree # reference to layer tree associated to map display self.log = log # log area self.tools = tools AbstractToolbar.__init__(self, parent) self.digit = None # currently selected map layer for editing (reference to MapLayer instance) self.mapLayer = None # list of vector layers from Layer Manager (only in the current mapset) self.layers = [] self.comboid = self.combo = None self.undo = -1 # only one dialog can be open self.settingsDialog = None # create toolbars (two rows optionally) self.InitToolbar(self._toolbarData()) self.Bind(wx.EVT_TOOL, self.OnTool) # default action (digitize new point, line, etc.) self.action = { 'desc' : '', 'type' : '', 'id' : -1 } # list of available vector maps self.UpdateListOfLayers(updateTool = True) # realize toolbar self.Realize() # workaround for Mac bug. May be fixed by 2.8.8, but not before then. if self.combo: self.combo.Hide() self.combo.Show() # disable undo/redo if self.undo: self.EnableTool(self.undo, False) # toogle to pointer by default self.OnTool(None) self.FixSize(width = 105) def _toolbarData(self): """!Toolbar data """ data = [] icons = Icons['vdigit'] if not self.tools or 'selector' in self.tools: data.append((None, )) if not self.tools or 'addPoint' in self.tools: data.append(("addPoint", icons["addPoint"], self.OnAddPoint, wx.ITEM_CHECK)) if not self.tools or 'addLine' in self.tools: data.append(("addLine", icons["addLine"], self.OnAddLine, wx.ITEM_CHECK)) if not self.tools or 'addBoundary' in self.tools: data.append(("addBoundary", icons["addBoundary"], self.OnAddBoundary, wx.ITEM_CHECK)) if not self.tools or 'addCentroid' in self.tools: data.append(("addCentroid", icons["addCentroid"], self.OnAddCentroid, wx.ITEM_CHECK)) if not self.tools or 'addArea' in self.tools: data.append(("addArea", icons["addArea"], self.OnAddArea, wx.ITEM_CHECK)) if not self.tools or 'moveVertex' in self.tools: data.append(("moveVertex", icons["moveVertex"], self.OnMoveVertex, wx.ITEM_CHECK)) if not self.tools or 'addVertex' in self.tools: data.append(("addVertex", icons["addVertex"], self.OnAddVertex, wx.ITEM_CHECK)) if not self.tools or 'removeVertex' in self.tools: data.append(("removeVertex", icons["removeVertex"], self.OnRemoveVertex, wx.ITEM_CHECK)) if not self.tools or 'editLine' in self.tools: data.append(("editLine", icons["editLine"], self.OnEditLine, wx.ITEM_CHECK)) if not self.tools or 'moveLine' in self.tools: data.append(("moveLine", icons["moveLine"], self.OnMoveLine, wx.ITEM_CHECK)) if not self.tools or 'deleteLine' in self.tools: data.append(("deleteLine", icons["deleteLine"], self.OnDeleteLine, wx.ITEM_CHECK)) if not self.tools or 'displayCats' in self.tools: data.append(("displayCats", icons["displayCats"], self.OnDisplayCats, wx.ITEM_CHECK)) if not self.tools or 'displayAttr' in self.tools: data.append(("displayAttr", icons["displayAttr"], self.OnDisplayAttr, wx.ITEM_CHECK)) if not self.tools or 'additionalSelf.Tools' in self.tools: data.append(("additionalTools", icons["additionalTools"], self.OnAdditionalToolMenu, wx.ITEM_CHECK)) if not self.tools or 'undo' in self.tools or \ 'settings' in self.tools or \ 'quit' in self.tools: data.append((None, )) if not self.tools or 'undo' in self.tools: data.append(("undo", icons["undo"], self.OnUndo)) if not self.tools or 'settings' in self.tools: data.append(("settings", icons["settings"], self.OnSettings)) if not self.tools or 'quit' in self.tools: data.append(("quit", icons["quit"], self.OnExit)) return self._getToolbarData(data) def OnTool(self, event): """!Tool selected -> disable selected tool in map toolbar""" if self.parent.GetName() == 'IClassWindow': toolbarName = 'iClassMap' else: toolbarName = 'map' aId = self.parent.toolbars[toolbarName].GetAction(type = 'id') self.parent.toolbars[toolbarName].ToggleTool(aId, False) # set cursor cursor = self.parent.cursors["cross"] self.MapWindow.SetCursor(cursor) # pointer self.parent.OnPointer(None) if event: # deselect previously selected tool aId = self.action.get('id', -1) if aId != event.GetId() and \ self.action['id'] != -1: self.ToggleTool(self.action['id'], False) else: self.ToggleTool(self.action['id'], True) self.action['id'] = event.GetId() event.Skip() if self.action['id'] != -1: self.ToggleTool(self.action['id'], True) # clear tmp canvas if self.action['id'] != aId: self.MapWindow.ClearLines(pdc = self.MapWindow.pdcTmp) if self.digit and \ len(self.MapWindow.digit.GetDisplay().GetSelected()) > 0: # cancel action self.MapWindow.OnMiddleDown(None) # set focus self.MapWindow.SetFocus() def OnAddPoint(self, event): """!Add point to the vector map Laier""" Debug.msg (2, "VDigitToolbar.OnAddPoint()") self.action = { 'desc' : "addLine", 'type' : "point", 'id' : self.addPoint } self.MapWindow.mouse['box'] = 'point' def OnAddLine(self, event): """!Add line to the vector map layer""" Debug.msg (2, "VDigitToolbar.OnAddLine()") self.action = { 'desc' : "addLine", 'type' : "line", 'id' : self.addLine } self.MapWindow.mouse['box'] = 'line' ### self.MapWindow.polycoords = [] # reset temp line def OnAddBoundary(self, event): """!Add boundary to the vector map layer""" Debug.msg (2, "VDigitToolbar.OnAddBoundary()") if self.action['desc'] != 'addLine' or \ self.action['type'] != 'boundary': self.MapWindow.polycoords = [] # reset temp line self.action = { 'desc' : "addLine", 'type' : "boundary", 'id' : self.addBoundary } self.MapWindow.mouse['box'] = 'line' def OnAddCentroid(self, event): """!Add centroid to the vector map layer""" Debug.msg (2, "VDigitToolbar.OnAddCentroid()") self.action = { 'desc' : "addLine", 'type' : "centroid", 'id' : self.addCentroid } self.MapWindow.mouse['box'] = 'point' def OnAddArea(self, event): """!Add area to the vector map layer""" Debug.msg (2, "VDigitToolbar.OnAddCentroid()") self.action = { 'desc' : "addLine", 'type' : "area", 'id' : self.addArea } self.MapWindow.mouse['box'] = 'line' def OnExit (self, event=None): """!Quit digitization tool""" # stop editing of the currently selected map layer if self.mapLayer: self.StopEditing() # close dialogs if still open if self.settingsDialog: self.settingsDialog.OnCancel(None) # set default mouse settings self.MapWindow.mouse['use'] = "pointer" self.MapWindow.mouse['box'] = "point" self.MapWindow.polycoords = [] # disable the toolbar self.parent.RemoveToolbar("vdigit") def OnMoveVertex(self, event): """!Move line vertex""" Debug.msg(2, "Digittoolbar.OnMoveVertex():") self.action = { 'desc' : "moveVertex", 'id' : self.moveVertex } self.MapWindow.mouse['box'] = 'point' def OnAddVertex(self, event): """!Add line vertex""" Debug.msg(2, "Digittoolbar.OnAddVertex():") self.action = { 'desc' : "addVertex", 'id' : self.addVertex } self.MapWindow.mouse['box'] = 'point' def OnRemoveVertex(self, event): """!Remove line vertex""" Debug.msg(2, "Digittoolbar.OnRemoveVertex():") self.action = { 'desc' : "removeVertex", 'id' : self.removeVertex } self.MapWindow.mouse['box'] = 'point' def OnEditLine(self, event): """!Edit line""" Debug.msg(2, "Digittoolbar.OnEditLine():") self.action = { 'desc' : "editLine", 'id' : self.editLine } self.MapWindow.mouse['box'] = 'line' def OnMoveLine(self, event): """!Move line""" Debug.msg(2, "Digittoolbar.OnMoveLine():") self.action = { 'desc' : "moveLine", 'id' : self.moveLine } self.MapWindow.mouse['box'] = 'box' def OnDeleteLine(self, event): """!Delete line""" Debug.msg(2, "Digittoolbar.OnDeleteLine():") self.action = { 'desc' : "deleteLine", 'id' : self.deleteLine } self.MapWindow.mouse['box'] = 'box' def OnDisplayCats(self, event): """!Display/update categories""" Debug.msg(2, "Digittoolbar.OnDisplayCats():") self.action = { 'desc' : "displayCats", 'id' : self.displayCats } self.MapWindow.mouse['box'] = 'point' def OnDisplayAttr(self, event): """!Display/update attributes""" Debug.msg(2, "Digittoolbar.OnDisplayAttr():") self.action = { 'desc' : "displayAttrs", 'id' : self.displayAttr } self.MapWindow.mouse['box'] = 'point' def OnUndo(self, event): """!Undo previous changes""" self.digit.Undo() event.Skip() def EnableUndo(self, enable = True): """!Enable 'Undo' in toolbar @param enable False for disable """ if enable: if self.GetToolEnabled(self.undo) is False: self.EnableTool(self.undo, True) else: if self.GetToolEnabled(self.undo) is True: self.EnableTool(self.undo, False) def OnSettings(self, event): """!Show settings dialog""" if self.digit is None: try: self.digit = self.MapWindow.digit = VDigit(mapwindow = self.MapWindow) except SystemExit: self.digit = self.MapWindow.digit = None if not self.settingsDialog: self.settingsDialog = VDigitSettingsDialog(parent = self.parent, title = _("Digitization settings"), style = wx.DEFAULT_DIALOG_STYLE) self.settingsDialog.Show() def OnAdditionalToolMenu(self, event): """!Menu for additional tools""" point = wx.GetMousePosition() toolMenu = wx.Menu() for label, itype, handler, desc in ( (_('Break selected lines/boundaries at intersection'), wx.ITEM_CHECK, self.OnBreak, "breakLine"), (_('Connect selected lines/boundaries'), wx.ITEM_CHECK, self.OnConnect, "connectLine"), (_('Copy categories'), wx.ITEM_CHECK, self.OnCopyCats, "copyCats"), (_('Copy features from (background) vector map'), wx.ITEM_CHECK, self.OnCopy, "copyLine"), (_('Copy attributes'), wx.ITEM_CHECK, self.OnCopyAttrb, "copyAttrs"), (_('Feature type conversion'), wx.ITEM_CHECK, self.OnTypeConversion, "typeConv"), (_('Flip selected lines/boundaries'), wx.ITEM_CHECK, self.OnFlip, "flipLine"), (_('Merge selected lines/boundaries'), wx.ITEM_CHECK, self.OnMerge, "mergeLine"), (_('Snap selected lines/boundaries (only to nodes)'), wx.ITEM_CHECK, self.OnSnap, "snapLine"), (_('Split line/boundary'), wx.ITEM_CHECK, self.OnSplitLine, "splitLine"), (_('Query features'), wx.ITEM_CHECK, self.OnQuery, "queryLine"), (_('Z bulk-labeling of 3D lines'), wx.ITEM_CHECK, self.OnZBulk, "zbulkLine")): # Add items to the menu item = wx.MenuItem(parentMenu = toolMenu, id = wx.ID_ANY, text = label, kind = itype) toolMenu.AppendItem(item) self.MapWindow.Bind(wx.EVT_MENU, handler, item) if self.action['desc'] == desc: item.Check(True) # Popup the menu. If an item is selected then its handler # will be called before PopupMenu returns. self.MapWindow.PopupMenu(toolMenu) toolMenu.Destroy() if self.action['desc'] == 'addPoint': self.ToggleTool(self.additionalTools, False) def OnCopy(self, event): """!Copy selected features from (background) vector map""" if self.action['desc'] == 'copyLine': # select previous action self.ToggleTool(self.addPoint, True) self.ToggleTool(self.additionalTools, False) self.OnAddPoint(event) return Debug.msg(2, "Digittoolbar.OnCopy():") self.action = { 'desc' : "copyLine", 'id' : self.additionalTools } self.MapWindow.mouse['box'] = 'box' def OnSplitLine(self, event): """!Split line""" if self.action['desc'] == 'splitLine': # select previous action self.ToggleTool(self.addPoint, True) self.ToggleTool(self.additionalTools, False) self.OnAddPoint(event) return Debug.msg(2, "Digittoolbar.OnSplitLine():") self.action = { 'desc' : "splitLine", 'id' : self.additionalTools } self.MapWindow.mouse['box'] = 'point' def OnCopyCats(self, event): """!Copy categories""" if self.action['desc'] == 'copyCats': # select previous action self.ToggleTool(self.addPoint, True) self.ToggleTool(self.copyCats, False) self.OnAddPoint(event) return Debug.msg(2, "Digittoolbar.OnCopyCats():") self.action = { 'desc' : "copyCats", 'id' : self.additionalTools } self.MapWindow.mouse['box'] = 'point' def OnCopyAttrb(self, event): """!Copy attributes""" if self.action['desc'] == 'copyAttrs': # select previous action self.ToggleTool(self.addPoint, True) self.ToggleTool(self.copyCats, False) self.OnAddPoint(event) return Debug.msg(2, "Digittoolbar.OnCopyAttrb():") self.action = { 'desc' : "copyAttrs", 'id' : self.additionalTools } self.MapWindow.mouse['box'] = 'point' def OnFlip(self, event): """!Flip selected lines/boundaries""" if self.action['desc'] == 'flipLine': # select previous action self.ToggleTool(self.addPoint, True) self.ToggleTool(self.additionalTools, False) self.OnAddPoint(event) return Debug.msg(2, "Digittoolbar.OnFlip():") self.action = { 'desc' : "flipLine", 'id' : self.additionalTools } self.MapWindow.mouse['box'] = 'box' def OnMerge(self, event): """!Merge selected lines/boundaries""" if self.action['desc'] == 'mergeLine': # select previous action self.ToggleTool(self.addPoint, True) self.ToggleTool(self.additionalTools, False) self.OnAddPoint(event) return Debug.msg(2, "Digittoolbar.OnMerge():") self.action = { 'desc' : "mergeLine", 'id' : self.additionalTools } self.MapWindow.mouse['box'] = 'box' def OnBreak(self, event): """!Break selected lines/boundaries""" if self.action['desc'] == 'breakLine': # select previous action self.ToggleTool(self.addPoint, True) self.ToggleTool(self.additionalTools, False) self.OnAddPoint(event) return Debug.msg(2, "Digittoolbar.OnBreak():") self.action = { 'desc' : "breakLine", 'id' : self.additionalTools } self.MapWindow.mouse['box'] = 'box' def OnSnap(self, event): """!Snap selected features""" if self.action['desc'] == 'snapLine': # select previous action self.ToggleTool(self.addPoint, True) self.ToggleTool(self.additionalTools, False) self.OnAddPoint(event) return Debug.msg(2, "Digittoolbar.OnSnap():") self.action = { 'desc' : "snapLine", 'id' : self.additionalTools } self.MapWindow.mouse['box'] = 'box' def OnConnect(self, event): """!Connect selected lines/boundaries""" if self.action['desc'] == 'connectLine': # select previous action self.ToggleTool(self.addPoint, True) self.ToggleTool(self.additionalTools, False) self.OnAddPoint(event) return Debug.msg(2, "Digittoolbar.OnConnect():") self.action = { 'desc' : "connectLine", 'id' : self.additionalTools } self.MapWindow.mouse['box'] = 'box' def OnQuery(self, event): """!Query selected lines/boundaries""" if self.action['desc'] == 'queryLine': # select previous action self.ToggleTool(self.addPoint, True) self.ToggleTool(self.additionalTools, False) self.OnAddPoint(event) return Debug.msg(2, "Digittoolbar.OnQuery(): %s" % \ UserSettings.Get(group = 'vdigit', key = 'query', subkey = 'selection')) self.action = { 'desc' : "queryLine", 'id' : self.additionalTools } self.MapWindow.mouse['box'] = 'box' def OnZBulk(self, event): """!Z bulk-labeling selected lines/boundaries""" if not self.digit.IsVector3D(): GError(parent = self.parent, message = _("Vector map is not 3D. Operation canceled.")) return if self.action['desc'] == 'zbulkLine': # select previous action self.ToggleTool(self.addPoint, True) self.ToggleTool(self.additionalTools, False) self.OnAddPoint(event) return Debug.msg(2, "Digittoolbar.OnZBulk():") self.action = { 'desc' : "zbulkLine", 'id' : self.additionalTools } self.MapWindow.mouse['box'] = 'line' def OnTypeConversion(self, event): """!Feature type conversion Supported conversions: - point <-> centroid - line <-> boundary """ if self.action['desc'] == 'typeConv': # select previous action self.ToggleTool(self.addPoint, True) self.ToggleTool(self.additionalTools, False) self.OnAddPoint(event) return Debug.msg(2, "Digittoolbar.OnTypeConversion():") self.action = { 'desc' : "typeConv", 'id' : self.additionalTools } self.MapWindow.mouse['box'] = 'box' def OnSelectMap (self, event): """!Select vector map layer for editing If there is a vector map layer already edited, this action is firstly terminated. The map layer is closed. After this the selected map layer activated for editing. """ if event.GetSelection() == 0: # create new vector map layer if self.mapLayer: openVectorMap = self.mapLayer.GetName(fullyQualified = False)['name'] else: openVectorMap = None dlg = CreateNewVector(self.parent, exceptMap = openVectorMap, log = self.log, cmd = (('v.edit', { 'flags' : 'b', 'tool' : 'create' }, 'map')), disableAdd = True) if dlg and dlg.GetName(): # add layer to map layer tree if self.layerTree: mapName = dlg.GetName() + '@' + grass.gisenv()['MAPSET'] self.layerTree.AddLayer(ltype = 'vector', lname = mapName, lcmd = ['d.vect', 'map=%s' % mapName]) vectLayers = self.UpdateListOfLayers(updateTool = True) selection = vectLayers.index(mapName) # create table ? if dlg.IsChecked('table'): lmgr = self.parent.GetLayerManager() if lmgr: lmgr.OnShowAttributeTable(None, selection = 'table') dlg.Destroy() else: self.combo.SetValue(_('Select vector map')) if dlg: dlg.Destroy() return else: selection = event.GetSelection() - 1 # first option is 'New vector map' # skip currently selected map if self.layers[selection] == self.mapLayer: return if self.mapLayer: # deactive map layer for editing self.StopEditing() # select the given map layer for editing self.StartEditing(self.layers[selection]) event.Skip() def StartEditing (self, mapLayer): """!Start editing selected vector map layer. @param mapLayer MapLayer to be edited """ # deactive layer self.Map.ChangeLayerActive(mapLayer, False) # clean map canvas self.MapWindow.EraseMap() # unset background map if needed if mapLayer: if UserSettings.Get(group = 'vdigit', key = 'bgmap', subkey = 'value', internal = True) == mapLayer.GetName(): UserSettings.Set(group = 'vdigit', key = 'bgmap', subkey = 'value', value = '', internal = True) self.parent.SetStatusText(_("Please wait, " "opening vector map <%s> for editing...") % mapLayer.GetName(), 0) self.MapWindow.pdcVector = wx.PseudoDC() self.digit = self.MapWindow.digit = VDigit(mapwindow = self.MapWindow) self.mapLayer = mapLayer # open vector map if self.digit.OpenMap(mapLayer.GetName()) is None: self.mapLayer = None self.StopEditing() return False # check feature type (only for OGR layers) fType = self.digit.GetFeatureType() self.EnableAll() self.EnableUndo(False) if fType == 'Point': for tool in (self.addLine, self.addBoundary, self.addCentroid, self.addArea, self.moveVertex, self.addVertex, self.removeVertex, self.editLine): self.EnableTool(tool, False) elif fType == 'Line String': for tool in (self.addPoint, self.addBoundary, self.addCentroid, self.addArea): self.EnableTool(tool, False) elif fType == 'Polygon': for tool in (self.addPoint, self.addLine, self.addBoundary, self.addCentroid): self.EnableTool(tool, False) elif fType: GError(parent = self, message = _("Unsupported feature type '%s'. Unable to edit " "OGR layer <%s>.") % (fType, mapLayer.GetName())) self.digit.CloseMap() self.mapLayer = None self.StopEditing() return False # update toolbar if self.combo: self.combo.SetValue(mapLayer.GetName()) if 'map' in self.parent.toolbars: self.parent.toolbars['map'].combo.SetValue (_('Digitize')) if self.parent.GetName() != "IClassWindow": lmgr = self.parent.GetLayerManager() if lmgr: lmgr.toolbars['tools'].Enable('vdigit', enable = False) Debug.msg (4, "VDigitToolbar.StartEditing(): layer=%s" % mapLayer.GetName()) # change cursor if self.MapWindow.mouse['use'] == 'pointer': self.MapWindow.SetCursor(self.parent.cursors["cross"]) if not self.MapWindow.resize: self.MapWindow.UpdateMap(render = True) # respect opacity opacity = mapLayer.GetOpacity(float = True) if opacity < 1.0: alpha = int(opacity * 255) self.digit.GetDisplay().UpdateSettings(alpha = alpha) return True def StopEditing(self): """!Stop editing of selected vector map layer. @return True on success @return False on failure """ if self.combo: self.combo.SetValue (_('Select vector map')) # save changes if self.mapLayer: Debug.msg (4, "VDigitToolbar.StopEditing(): layer=%s" % self.mapLayer.GetName()) if UserSettings.Get(group = 'vdigit', key = 'saveOnExit', subkey = 'enabled') is False: if self.digit.GetUndoLevel() > -1: dlg = wx.MessageDialog(parent = self.parent, message = _("Do you want to save changes " "in vector map <%s>?") % self.mapLayer.GetName(), caption = _("Save changes?"), style = wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_NO: # revert changes self.digit.Undo(0) dlg.Destroy() self.parent.SetStatusText(_("Please wait, " "closing and rebuilding topology of " "vector map <%s>...") % self.mapLayer.GetName(), 0) self.digit.CloseMap() lmgr = self.parent.GetLayerManager() if lmgr: lmgr.toolbars['tools'].Enable('vdigit', enable = True) lmgr.GetLogWindow().GetProgressBar().SetValue(0) lmgr.GetLogWindow().WriteCmdLog(_("Editing of vector map <%s> successfully finished") % \ self.mapLayer.GetName(), switchPage = False) # re-active layer item = self.parent.tree.FindItemByData('maplayer', self.mapLayer) if item and self.parent.tree.IsItemChecked(item): self.Map.ChangeLayerActive(self.mapLayer, True) # change cursor self.MapWindow.SetCursor(self.parent.cursors["default"]) self.MapWindow.pdcVector = None # close dialogs for dialog in ('attributes', 'category'): if self.parent.dialogs[dialog]: self.parent.dialogs[dialog].Close() self.parent.dialogs[dialog] = None del self.digit del self.MapWindow.digit self.mapLayer = None self.MapWindow.redrawAll = True return True def UpdateListOfLayers (self, updateTool = False): """!Update list of available vector map layers. This list consists only editable layers (in the current mapset) @param updateTool True to update also toolbar """ Debug.msg (4, "VDigitToolbar.UpdateListOfLayers(): updateTool=%d" % \ updateTool) layerNameSelected = None # name of currently selected layer if self.mapLayer: layerNameSelected = self.mapLayer.GetName() # select vector map layer in the current mapset layerNameList = [] self.layers = self.Map.GetListOfLayers(l_type = "vector", l_mapset = grass.gisenv()['MAPSET']) for layer in self.layers: if not layer.name in layerNameList: # do not duplicate layer layerNameList.append (layer.GetName()) if updateTool: # update toolbar if not self.mapLayer: value = _('Select vector map') else: value = layerNameSelected if not self.comboid: if not self.tools or 'selector' in self.tools: self.combo = wx.ComboBox(self, id = wx.ID_ANY, value = value, choices = [_('New vector map'), ] + layerNameList, size = (80, -1), style = wx.CB_READONLY) self.comboid = self.InsertControl(0, self.combo) self.parent.Bind(wx.EVT_COMBOBOX, self.OnSelectMap, self.comboid) else: self.combo.SetItems([_('New vector map'), ] + layerNameList) self.Realize() return layerNameList def GetLayer(self): """!Get selected layer for editing -- MapLayer instance""" return self.mapLayer class ProfileToolbar(AbstractToolbar): """!Toolbar for profiling raster map """ def __init__(self, parent): AbstractToolbar.__init__(self, parent) self.InitToolbar(self._toolbarData()) # realize the toolbar self.Realize() def _toolbarData(self): """!Toolbar data""" icons = Icons['plot'] return self._getToolbarData((('addraster', Icons['layerManager']["addRast"], self.parent.OnSelectRaster), ('transect', icons["transect"], self.parent.OnDrawTransect), (None, ), ('draw', icons["draw"], self.parent.OnCreateProfile), ('erase', Icons['displayWindow']["erase"], self.parent.OnErase), ('drag', Icons['displayWindow']['pan'], self.parent.OnDrag), ('zoom', Icons['displayWindow']['zoomIn'], self.parent.OnZoom), ('unzoom', Icons['displayWindow']['zoomBack'], self.parent.OnRedraw), (None, ), ('statistics', icons['statistics'], self.parent.OnStats), ('datasave', icons["save"], self.parent.SaveProfileToFile), ('image', Icons['displayWindow']["saveFile"], self.parent.SaveToFile), ('print', Icons['displayWindow']["print"], self.parent.PrintMenu), (None, ), ('settings', icons["options"], self.parent.PlotOptionsMenu), ('quit', icons["quit"], self.parent.OnQuit), )) class LMNvizToolbar(AbstractToolbar): """!Nviz toolbar """ def __init__(self, parent): self.lmgr = parent AbstractToolbar.__init__(self, parent) # only one dialog can be open self.settingsDialog = None self.InitToolbar(self._toolbarData()) # realize the toolbar self.Realize() def _toolbarData(self): """!Toolbar data""" icons = Icons['nviz'] return self._getToolbarData((("nvizCmd", icons['nvizCmd'], self.OnNvizCmd), (None, ), ("settings", icons["settings"], self.OnSettings), ("help", icons["help"], self.OnHelp)) ) def OnNvizCmd(self, event): """!Show m.nviz.image command""" self.lmgr.GetLayerTree().GetMapDisplay().GetWindow().OnNvizCmd() def OnHelp(self, event): """!Show 3D view mode help""" if not self.lmgr: RunCommand('g.manual', entry = 'wxGUI.Nviz') else: log = self.lmgr.GetLogWindow() log.RunCmd(['g.manual', 'entry=wxGUI.Nviz']) def OnSettings(self, event): """!Show nviz notebook page""" if not self.settingsDialog: self.settingsDialog = NvizPreferencesDialog(parent = self.parent) self.settingsDialog.Show() class ModelToolbar(AbstractToolbar): """!Graphical modeler toolbar (see gmodeler.py) """ def __init__(self, parent): AbstractToolbar.__init__(self, parent) self.InitToolbar(self._toolbarData()) # realize the toolbar self.Realize() def _toolbarData(self): """!Toolbar data""" icons = Icons['modeler'] return self._getToolbarData((('new', icons['new'], self.parent.OnModelNew), ('open', icons['open'], self.parent.OnModelOpen), ('save', icons['save'], self.parent.OnModelSave), ('image', icons['toImage'], self.parent.OnExportImage), ('python', icons['toPython'], self.parent.OnExportPython), (None, ), ('action', icons['actionAdd'], self.parent.OnAddAction), ('data', icons['dataAdd'], self.parent.OnAddData), ('relation', icons['relation'], self.parent.OnDefineRelation), ('loop', icons['loop'], self.parent.OnDefineLoop), (None, ), ('redraw', icons['redraw'], self.parent.OnCanvasRefresh), ('validate', icons['validate'], self.parent.OnValidateModel), ('run', icons['run'], self.parent.OnRunModel), (None, ), ("variables", icons['variables'], self.parent.OnVariables), ("settings", icons['settings'], self.parent.OnPreferences), ("help", Icons['misc']['help'], self.parent.OnHelp), (None, ), ('quit', icons['quit'], self.parent.OnCloseWindow)) ) class HistogramToolbar(AbstractToolbar): """!Histogram toolbar (see histogram.py) """ def __init__(self, parent): AbstractToolbar.__init__(self, parent) self.InitToolbar(self._toolbarData()) # realize the toolbar self.Realize() def _toolbarData(self): """!Toolbar data""" icons = Icons['displayWindow'] return self._getToolbarData((('histogram', icons["histogram"], self.parent.OnOptions), ('rendermao', icons["display"], self.parent.OnRender), ('erase', icons["erase"], self.parent.OnErase), ('font', Icons['misc']["font"], self.parent.SetHistFont), (None, ), ('save', icons["saveFile"], self.parent.SaveToFile), ('hprint', icons["print"], self.parent.PrintMenu), (None, ), ('quit', Icons['misc']["quit"], self.parent.OnQuit)) ) class Histogram2Toolbar(AbstractToolbar): """!Toolbar for histogramming raster map """ def __init__(self, parent): AbstractToolbar.__init__(self, parent) self.InitToolbar(self._toolbarData()) # realize the toolbar self.Realize() def _toolbarData(self): """!Toolbar data""" icons = Icons['plot'] return self._getToolbarData((('addraster', Icons['layerManager']["addRast"], self.parent.OnSelectRaster), (None, ), ('draw', icons["draw"], self.parent.OnCreateHist), ('erase', Icons['displayWindow']["erase"], self.parent.OnErase), ('drag', Icons['displayWindow']['pan'], self.parent.OnDrag), ('zoom', Icons['displayWindow']['zoomIn'], self.parent.OnZoom), ('unzoom', Icons['displayWindow']['zoomBack'], self.parent.OnRedraw), (None, ), ('statistics', icons['statistics'], self.parent.OnStats), ('image', Icons['displayWindow']["saveFile"], self.parent.SaveToFile), ('print', Icons['displayWindow']["print"], self.parent.PrintMenu), (None, ), ('settings', icons["options"], self.parent.PlotOptionsMenu), ('quit', icons["quit"], self.parent.OnQuit), )) class ScatterplotToolbar(AbstractToolbar): """!Toolbar for bivariate scatterplots of raster map pairs """ def __init__(self, parent): AbstractToolbar.__init__(self, parent) self.InitToolbar(self._toolbarData()) # realize the toolbar self.Realize() def _toolbarData(self): """!Toolbar data""" icons = Icons['plot'] # icons2 = Icons['modeler'] return self._getToolbarData((('addraster', Icons['layerManager']["addRast"], self.parent.OnSelectRaster), (None, ), ('draw', icons["draw"], self.parent.OnCreateScatter), ('erase', Icons['displayWindow']["erase"], self.parent.OnErase), ('drag', Icons['displayWindow']['pan'], self.parent.OnDrag), ('zoom', Icons['displayWindow']['zoomIn'], self.parent.OnZoom), ('unzoom', Icons['displayWindow']['zoomBack'], self.parent.OnRedraw), (None, ), ('statistics', icons['statistics'], self.parent.OnRegression), ('image', Icons['displayWindow']["saveFile"], self.parent.SaveToFile), ('print', Icons['displayWindow']["print"], self.parent.PrintMenu), (None, ), ('settings', icons["options"], self.parent.PlotOptionsMenu), ('quit', icons["quit"], self.parent.OnQuit), )) class LMWorkspaceToolbar(AbstractToolbar): """!Layer Manager `workspace` toolbar """ def __init__(self, parent): AbstractToolbar.__init__(self, parent) self.InitToolbar(self._toolbarData()) # realize the toolbar self.Realize() def _toolbarData(self): """!Toolbar data """ icons = Icons['layerManager'] return self._getToolbarData((('newdisplay', icons["newdisplay"], self.parent.OnNewDisplay), (None, ), ('workspaceNew', icons["workspaceNew"], self.parent.OnWorkspaceNew), ('workspaceOpen', icons["workspaceOpen"], self.parent.OnWorkspaceOpen), ('workspaceSave', icons["workspaceSave"], self.parent.OnWorkspaceSave), )) class LMDataToolbar(AbstractToolbar): """!Layer Manager `data` toolbar """ def __init__(self, parent): AbstractToolbar.__init__(self, parent) self.InitToolbar(self._toolbarData()) # realize the toolbar self.Realize() def _toolbarData(self): """!Toolbar data """ icons = Icons['layerManager'] return self._getToolbarData((('addMulti', icons["addMulti"], self.parent.OnAddMaps), ('addrast', icons["addRast"], self.parent.OnAddRaster), ('rastmisc', icons["rastMisc"], self.parent.OnAddRasterMisc), ('addvect', icons["addVect"], self.parent.OnAddVector), ('vectmisc', icons["vectMisc"], self.parent.OnAddVectorMisc), ('addgrp', icons["addGroup"], self.parent.OnAddGroup), ('addovl', icons["addOverlay"], self.parent.OnAddOverlay), ('delcmd', icons["delCmd"], self.parent.OnDeleteLayer), )) class LMToolsToolbar(AbstractToolbar): """!Layer Manager `tools` toolbar """ def __init__(self, parent): AbstractToolbar.__init__(self, parent) self.InitToolbar(self._toolbarData()) # realize the toolbar self.Realize() def _toolbarData(self): """!Toolbar data """ icons = Icons['layerManager'] return self._getToolbarData((('importMap', icons["import"], self.parent.OnImportMenu), (None, ), ('mapCalc', icons["mapcalc"], self.parent.OnMapCalculator), ('georect', Icons["georectify"]["georectify"], self.parent.OnGCPManager), ('modeler', icons["modeler"], self.parent.OnGModeler), ('mapOutput', icons['mapOutput'], self.parent.OnPsMap) )) class LMMiscToolbar(AbstractToolbar): """!Layer Manager `misc` toolbar """ def __init__(self, parent): AbstractToolbar.__init__(self, parent) self.InitToolbar(self._toolbarData()) # realize the toolbar self.Realize() def _toolbarData(self): """!Toolbar data """ icons = Icons['layerManager'] return self._getToolbarData((('settings', icons["settings"], self.parent.OnPreferences), ('help', Icons["misc"]["help"], self.parent.OnHelp), )) class LMVectorToolbar(AbstractToolbar): """!Layer Manager `vector` toolbar """ def __init__(self, parent): AbstractToolbar.__init__(self, parent) self.InitToolbar(self._toolbarData()) # realize the toolbar self.Realize() def _toolbarData(self): """!Toolbar data """ icons = Icons['layerManager'] return self._getToolbarData((('vdigit', icons["vdigit"], self.parent.OnVDigit), ('attribute', icons["attrTable"], self.parent.OnShowAttributeTable), )) class PsMapToolbar(AbstractToolbar): def __init__(self, parent): """!Toolbar Cartographic Composer (psmap.py) @param parent parent window """ AbstractToolbar.__init__(self, parent) self.InitToolbar(self._toolbarData()) self.Realize() self.action = { 'id' : self.pointer } self.defaultAction = { 'id' : self.pointer, 'bind' : self.parent.OnPointer } self.OnTool(None) from psmap import havePILImage if not havePILImage: self.EnableTool(self.preview, False) def _toolbarData(self): """!Toolbar data """ icons = Icons['psMap'] return self._getToolbarData((('loadFile', icons['scriptLoad'], self.parent.OnLoadFile), ('instructionFile', icons['scriptSave'], self.parent.OnInstructionFile), (None, ), ('pagesetup', icons['pageSetup'], self.parent.OnPageSetup), (None, ), ("pointer", Icons["displayWindow"]["pointer"], self.parent.OnPointer, wx.ITEM_CHECK), ('pan', Icons["displayWindow"]['pan'], self.parent.OnPan, wx.ITEM_CHECK), ("zoomin", Icons["displayWindow"]["zoomIn"], self.parent.OnZoomIn, wx.ITEM_CHECK), ("zoomout", Icons["displayWindow"]["zoomOut"], self.parent.OnZoomOut, wx.ITEM_CHECK), ('zoomAll', icons['fullExtent'], self.parent.OnZoomAll), (None, ), ('addMap', icons['addMap'], self.parent.OnAddMap, wx.ITEM_CHECK), ('addRaster', icons['addRast'], self.parent.OnAddRaster), ('addVector', icons['addVect'], self.parent.OnAddVect), ("dec", Icons["displayWindow"]["overlay"], self.parent.OnDecoration), ("delete", icons["deleteObj"], self.parent.OnDelete), (None, ), ("preview", icons["preview"], self.parent.OnPreview), ('generatePS', icons['psExport'], self.parent.OnPSFile), ('generatePDF', icons['pdfExport'], self.parent.OnPDFFile), (None, ), ("help", Icons['misc']['help'], self.parent.OnHelp), ('quit', icons['quit'], self.parent.OnCloseWindow)) )