[GRASS-SVN] r46590 - in grass/trunk/gui/wxpython: . gui_modules icons xml

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jun 7 13:49:18 EDT 2011


Author: martinl
Date: 2011-06-07 10:49:18 -0700 (Tue, 07 Jun 2011)
New Revision: 46590

Modified:
   grass/trunk/gui/wxpython/gui_modules/gdialogs.py
   grass/trunk/gui/wxpython/gui_modules/toolbars.py
   grass/trunk/gui/wxpython/icons/icon.py
   grass/trunk/gui/wxpython/wxgui.py
   grass/trunk/gui/wxpython/xml/menudata.xml
Log:
wxGUI: seperate 'main' toolbar into 'workspace', 'data' and 'misc' toolbar


Modified: grass/trunk/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gdialogs.py	2011-06-07 16:32:57 UTC (rev 46589)
+++ grass/trunk/gui/wxpython/gui_modules/gdialogs.py	2011-06-07 17:49:18 UTC (rev 46590)
@@ -11,7 +11,7 @@
  - SavedRegion
  - DecorationDialog
  - TextLayerDialog 
- - LoadMapLayersDialog
+ - AddMapLayersDialog
  - ImportDialog
  - GdalImportDialog
  - DxfImportDialog
@@ -717,8 +717,8 @@
                  'coords' : self.currCoords,
                  'active' : self.chkbox.IsChecked() }
 
-class LoadMapLayersDialog(wx.Dialog):
-    """!Load selected map layers (raster, vector) into layer tree"""
+class AddMapLayersDialog(wx.Dialog):
+    """!Add selected map layers (raster, vector) into layer tree"""
     def __init__(self, parent, title, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
         wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title, style=style)
 
@@ -735,10 +735,11 @@
         #
         # buttons
         #
-        btnCancel = wx.Button(self, wx.ID_CANCEL)
-        btnOk = wx.Button(self, wx.ID_OK, _("&Load") )
+        btnCancel = wx.Button(parent = self, id = wx.ID_CANCEL)
+        btnOk = wx.Button(parent = self, id = wx.ID_OK, label = _("&Add"))
         btnOk.SetDefault()
-        
+        btnOk.SetToolTipString(_("Add selected map layers to current display"))
+
         #
         # sizers & do layout
         #

Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py	2011-06-07 16:32:57 UTC (rev 46589)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py	2011-06-07 17:49:18 UTC (rev 46590)
@@ -13,8 +13,10 @@
  - NvizToolbar
  - ModelToolbar
  - HistogramToolbar
- - LayerManagerToolbar
- - ToolsToolbar
+ - LMWorkspaceToolbar
+ - LMDataToolbar
+ - LMToolsToolbar
+ - LMMiscToolbar
  - PsMapToolbar
 
 (C) 2007-2011 by the GRASS Development Team
@@ -1558,8 +1560,8 @@
                                       self.parent.OnQuit))
                                     )
 
-class LayerManagerToolbar(AbstractToolbar):
-    """!Layer Manager toolbar (see wxgui.py)
+class LMWorkspaceToolbar(AbstractToolbar):
+    """!Layer Manager `workspace` toolbar
     """
     def __init__(self, parent):
         AbstractToolbar.__init__(self, parent)
@@ -1573,9 +1575,35 @@
         """!Toolbar data
         """
         self.newdisplay = wx.NewId()
-        self.workspaceLoad = wx.NewId()
         self.workspaceOpen = wx.NewId()
         self.workspaceSave = wx.NewId()
+        
+        icons = Icons['layerManager']
+        return self._getToolbarData(((self.newdisplay, 'newdisplay', icons["newdisplay"],
+                                      self.parent.OnNewMenu),
+                                     (None, ),
+                                     (self.workspaceOpen, 'workspaceOpen', icons["workspaceOpen"],
+                                      self.parent.OnWorkspaceOpen),
+                                     (self.workspaceSave, '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
+        """
+        self.importMap = wx.NewId()
+        self.addMulti = wx.NewId()
         self.addrast = wx.NewId()
         self.rastmisc = wx.NewId()
         self.addvect = wx.NewId()
@@ -1583,21 +1611,12 @@
         self.addgrp = wx.NewId()
         self.addovl = wx.NewId()
         self.delcmd = wx.NewId()
+        self.vdigit = wx.NewId()
         self.attribute = wx.NewId()
-        self.preferences = wx.NewId()
-        self.help = wx.NewId()
         
         icons = Icons['layerManager']
-        return self._getToolbarData(((self.newdisplay, 'newdisplay', icons["newdisplay"],
-                                      self.parent.OnNewMenu),
-                                     (None, ),
-                                     (self.workspaceLoad, 'workspaceLoad', icons["workspaceLoad"],
-                                      self.parent.OnLoadMenu),
-                                     (self.workspaceOpen, 'workspaceOpen', icons["workspaceOpen"],
-                                      self.parent.OnWorkspaceOpen),
-                                     (self.workspaceSave, 'workspaceSave', icons["workspaceSave"],
-                                      self.parent.OnWorkspaceSave),
-                                     (None, ),
+        return self._getToolbarData(((self.addMulti, 'addMulti', icons["addMulti"],
+                                      self.parent.OnAddMaps),
                                      (self.addrast, 'addRast', icons["addRast"],
                                       self.parent.OnAddRaster),
                                      (self.rastmisc, 'rastMisc', icons["rastMisc"],
@@ -1613,17 +1632,17 @@
                                      (self.delcmd, 'delCmd',  icons["delCmd"],
                                       self.parent.OnDeleteLayer),
                                      (None, ),
+                                     (self.importMap, 'import', icons["import"],
+                                      self.parent.OnImportMenu),
+                                     (None, ),
+                                     (self.vdigit, 'vdigit', icons["vdigit"],
+                                      self.parent.OnVDigit),
                                      (self.attribute, 'attrTable', icons["attrTable"],
                                       self.parent.OnShowAttributeTable),
-                                     (None, ),
-                                     (self.preferences, 'preferences', icons["settings"],
-                                      self.parent.OnPreferences),
-                                     (self.help, 'help', Icons["misc"]["help"],
-                                      self.parent.OnHelp),
                                      ))
 
-class ToolsToolbar(AbstractToolbar):
-    """!Layer Manager Tools toolbar (see wxgui.py)
+class LMToolsToolbar(AbstractToolbar):
+    """!Layer Manager `tools` toolbar
     """
     def __init__(self, parent):
         AbstractToolbar.__init__(self, parent)
@@ -1638,15 +1657,12 @@
         """
         self.georect = wx.NewId()
         self.modeler = wx.NewId() 
-        self.vdigit = wx.NewId()
         self.mapOutput = wx.NewId()
         self.mapCalc = wx.NewId()
         
         icons = Icons['layerManager']
         return self._getToolbarData(((self.mapCalc, 'mapCalc', icons["mapcalc"],
                                       self.parent.OnMapCalculator),
-                                     (self.vdigit, 'vdigit', icons["vdigit"],
-                                      self.parent.OnVDigit),
                                      (self.georect, 'georectify', Icons["georectify"]["georectify"],
                                       self.parent.OnGCPManager),
                                      (self.modeler, 'modeler', icons["modeler"],
@@ -1654,6 +1670,30 @@
                                      (self.mapOutput, '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
+        """
+        self.preferences = wx.NewId()
+        self.help = wx.NewId()
+        
+        icons = Icons['layerManager']
+        return self._getToolbarData(((self.preferences, 'preferences', icons["settings"],
+                                      self.parent.OnPreferences),
+                                     (self.help, 'help', Icons["misc"]["help"],
+                                      self.parent.OnHelp),
+                                     ))
     
 class PsMapToolbar(AbstractToolbar):
     def __init__(self, parent):

Modified: grass/trunk/gui/wxpython/icons/icon.py
===================================================================
--- grass/trunk/gui/wxpython/icons/icon.py	2011-06-07 16:32:57 UTC (rev 46589)
+++ grass/trunk/gui/wxpython/icons/icon.py	2011-06-07 17:49:18 UTC (rev 46590)
@@ -167,12 +167,14 @@
                                   label = _('Start new map display')),
         'workspaceNew'  : MetaIcon(img = iconSet.get('create', wx.ART_ERROR),
                                    label = _('Create new workspace (Ctrl+N)')),
-        'workspaceLoad' : MetaIcon(img = iconSet.get('layer-open', wx.ART_ERROR),
-                                   label = _('Load map layers into workspace (Ctrl+L)')),
         'workspaceOpen' : MetaIcon(img = iconSet.get('open', wx.ART_ERROR),
                                    label = _('Open existing workspace file (Ctrl+O)')),
         'workspaceSave' : MetaIcon(img = iconSet.get('save', wx.ART_ERROR),
                                    label = _('Save current workspace to file (Ctrl+S)')),
+        'addMulti'      : MetaIcon(img = iconSet.get('layer-open', wx.ART_ERROR),
+                                   label = _('Add multiple raster or vector map layers (Ctrl+L)')),
+        'import'        : MetaIcon(img = iconSet.get('layer-import', wx.ART_ERROR),
+                                   label = _('Import/link raster or vector data')),
         'rastImport' : MetaIcon(img = iconSet.get('layer-import', wx.ART_ERROR),
                                 label = _('Import raster data')),
         'rastLink'   : MetaIcon(img = iconSet.get('layer-import', wx.ART_ERROR),

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2011-06-07 16:32:57 UTC (rev 46589)
+++ grass/trunk/gui/wxpython/wxgui.py	2011-06-07 17:49:18 UTC (rev 46590)
@@ -83,7 +83,7 @@
 from gui_modules import nviz_tools
 from gui_modules.debug    import Debug
 from gui_modules.ghelp    import MenuTreeWindow, AboutWindow, InstallExtensionWindow
-from gui_modules.toolbars import LayerManagerToolbar, ToolsToolbar
+from gui_modules.toolbars import LMWorkspaceToolbar, LMDataToolbar, LMToolsToolbar, LMMiscToolbar
 from gui_modules.gpyshell import PyShellWindow
 from icons.icon           import Icons
 
@@ -129,18 +129,35 @@
         self._createMenuBar()
         self.statusbar = self.CreateStatusBar(number = 1)
         self.notebook  = self._createNoteBook()
-        self.toolbars  = { 'main'  : LayerManagerToolbar(parent = self),
-                           'tools' : ToolsToolbar(parent = self) }
+        self.toolbars  = { 'workspace' : LMWorkspaceToolbar(parent = self),
+                           'data'      : LMDataToolbar(parent = self),
+                           'tools'     : LMToolsToolbar(parent = self),
+                           'misc'      : LMMiscToolbar(parent = self) }
         
-        # self.SetToolBar(self.toolbar)
-        self._auimgr.AddPane(self.toolbars['main'],
+        self._auimgr.AddPane(self.toolbars['data'],
                              wx.aui.AuiPaneInfo().
-                             Name("toolbarMain").Caption(_("Main Toolbar")).
+                             Name("toolbarData").Caption(_("Data Toolbar")).
                              ToolbarPane().Top().
                              LeftDockable(False).RightDockable(False).
                              BottomDockable(False).TopDockable(True).
                              CloseButton(False).Layer(3).
-                             BestSize((self.toolbars['main'].GetSize())))
+                             BestSize((self.toolbars['data'].GetSize())))
+        self._auimgr.AddPane(self.toolbars['workspace'],
+                             wx.aui.AuiPaneInfo().
+                             Name("toolbarWorkspace").Caption(_("Workspace Toolbar")).
+                             ToolbarPane().Top().
+                             LeftDockable(False).RightDockable(False).
+                             BottomDockable(False).TopDockable(True).
+                             CloseButton(False).Layer(3).
+                             BestSize((self.toolbars['workspace'].GetSize())))
+        self._auimgr.AddPane(self.toolbars['misc'],
+                             wx.aui.AuiPaneInfo().
+                             Name("toolbarMisc").Caption(_("Misc Toolbar")).
+                             ToolbarPane().Top().
+                             LeftDockable(False).RightDockable(False).
+                             BottomDockable(False).TopDockable(True).
+                             CloseButton(False).Layer(2).
+                             BestSize((self.toolbars['misc'].GetSize())))
         self._auimgr.AddPane(self.toolbars['tools'],
                              wx.aui.AuiPaneInfo().
                              Name("toolbarTools").Caption(_("Tools Toolbar")).
@@ -630,12 +647,10 @@
         self._popupMenu((('newdisplay', self.OnNewDisplay),
                          ('workspaceNew',  self.OnWorkspaceNew)))
 
-    def OnLoadMenu(self, event):
-        """!Load maps menu (new, load, import, link)
+    def OnImportMenu(self, event):
+        """!Import maps menu (import, link)
         """
-        self._popupMenu((('workspaceLoad', self.OnWorkspaceLoad),
-                         (None, None),
-                         ('rastImport',    self.OnImportGdalLayers),
+        self._popupMenu((('rastImport',    self.OnImportGdalLayers),
                          ('rastLink',      self.OnLinkGdalLayers),
                          (None, None),
                          ('vectImport',    self.OnImportOgrLayers),
@@ -825,35 +840,7 @@
             mdisp.MapWindow2D.UpdateMap()
 
         return True
-
-    def OnWorkspaceLoad(self, event = None):
-        """!Load given map layers into layer tree"""
-        dialog = gdialogs.LoadMapLayersDialog(parent = self, title = _("Load map layers into layer tree"))
-
-        if dialog.ShowModal() == wx.ID_OK:
-            # start new map display if no display is available
-            if not self.curr_page:
-                self.NewDisplay()
-
-            maptree = self.curr_page.maptree
-            busy = wx.BusyInfo(message = _("Please wait, loading workspace..."),
-                               parent = self)
-            wx.Yield()
-            
-            for layerName in dialog.GetMapLayers():
-                if dialog.GetLayerType() == 'raster':
-                    cmd = ['d.rast', 'map=%s' % layerName]
-                elif dialog.GetLayerType() == 'vector':
-                    cmd = ['d.vect', 'map=%s' % layerName]
-                newItem = maptree.AddLayer(ltype = dialog.GetLayerType(),
-                                           lname = layerName,
-                                           lchecked = False,
-                                           lopacity = 1.0,
-                                           lcmd = cmd,
-                                           lgroup = None)
-
-            busy.Destroy()
-
+    
     def OnWorkspaceLoadGrcFile(self, event):
         """!Load map layers from GRC file (Tcl/Tk GUI) into map layer tree"""
         dlg = wx.FileDialog(parent = self, message = _("Choose GRC file to load"),
@@ -1240,7 +1227,35 @@
         self.disp_idx += 1
         
         return self.curr_page.maptree.mapdisplay
+    
+    def OnAddMaps(self, event = None):
+        """!Add selected map layers into layer tree"""
+        dialog = gdialogs.AddMapLayersDialog(parent = self, title = _("Add selected map layers into layer tree"))
 
+        if dialog.ShowModal() == wx.ID_OK:
+            # start new map display if no display is available
+            if not self.curr_page:
+                self.NewDisplay()
+
+            maptree = self.curr_page.maptree
+            busy = wx.BusyInfo(message = _("Please wait, loading workspace..."),
+                               parent = self)
+            wx.Yield()
+            
+            for layerName in dialog.GetMapLayers():
+                if dialog.GetLayerType() == 'raster':
+                    cmd = ['d.rast', 'map=%s' % layerName]
+                elif dialog.GetLayerType() == 'vector':
+                    cmd = ['d.vect', 'map=%s' % layerName]
+                newItem = maptree.AddLayer(ltype = dialog.GetLayerType(),
+                                           lname = layerName,
+                                           lchecked = False,
+                                           lopacity = 1.0,
+                                           lcmd = cmd,
+                                           lgroup = None)
+
+            busy.Destroy()
+    
     def OnAddRaster(self, event):
         """!Add raster map layer"""
         # start new map display if no display is available

Modified: grass/trunk/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/trunk/gui/wxpython/xml/menudata.xml	2011-06-07 16:32:57 UTC (rev 46589)
+++ grass/trunk/gui/wxpython/xml/menudata.xml	2011-06-07 17:49:18 UTC (rev 46590)
@@ -36,13 +36,6 @@
 	    </menuitem>
 	    <separator />
 	    <menuitem>
-	      <label>Load map layers</label>
-	      <help>Load map layers into layer tree</help>
-	      <handler>OnWorkspaceLoad</handler>
-	      <shortcut>Ctrl+L</shortcut>
-	    </menuitem>
-	    <separator />
-	    <menuitem>
 	      <label>Load GRC file (Tcl/Tk GUI)</label>
 	      <help>Load map layers from GRC file to layer tree</help>
 	      <handler>OnWorkspaceLoadGrcFile</handler>
@@ -70,6 +63,12 @@
 	    </menuitem>
 	    <separator />
 	    <menuitem>
+	      <label>Add multiple rasters or vectors</label>
+	      <help>Add multiple raster or vector map layers to current display</help>
+	      <handler>OnAddMaps</handler>
+	      <shortcut>Ctrl+L</shortcut>
+	    </menuitem>
+	    <menuitem>
 	      <label>Add raster</label>
 	      <help>Add raster map layer to current display</help>
 	      <handler>OnAddRaster</handler>



More information about the grass-commit mailing list