[GRASS-SVN] r30168 - in grass/trunk/gui/wxpython: . docs gui_modules icons icons/silk

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Feb 15 14:29:15 EST 2008


Author: martinl
Date: 2008-02-15 14:29:15 -0500 (Fri, 15 Feb 2008)
New Revision: 30168

Modified:
   grass/trunk/gui/wxpython/docs/wxGUI.html
   grass/trunk/gui/wxpython/gis_set.py
   grass/trunk/gui/wxpython/gui_modules/globalvar.py
   grass/trunk/gui/wxpython/gui_modules/menudata.py
   grass/trunk/gui/wxpython/gui_modules/menuform.py
   grass/trunk/gui/wxpython/gui_modules/utils.py
   grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
   grass/trunk/gui/wxpython/icons/icon.py
   grass/trunk/gui/wxpython/icons/silk/__init__.py
   grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: Bulk loading of selected map layers (raster, vector) into layer tree. Fn ImportWx() renamed to CheckForWx().

Modified: grass/trunk/gui/wxpython/docs/wxGUI.html
===================================================================
--- grass/trunk/gui/wxpython/docs/wxGUI.html	2008-02-15 18:46:09 UTC (rev 30167)
+++ grass/trunk/gui/wxpython/docs/wxGUI.html	2008-02-15 19:29:15 UTC (rev 30168)
@@ -1,16 +1,16 @@
 <h2>DESCRIPTION</h2>
 
 To start the wxPython-based GUI automatically with each session run
-GRASS with 'wx' switch
+GRASS with 'wxpython' switch
 
 <div class="code"><pre>
-    grass -wx
+    grass -wxpython
 </pre></div>
 
-or define in your <tt>.grassrc</tt> file 'GRASS_GUI' variable
+or define in your <tt>.grassrc6</tt> file 'GRASS_GUI' variable
 
 <div class="code"><pre>
-    GRASS_GUI: wx
+    GRASS_GUI: wxpython
 </pre></div>
 
 The GUI can be quit by selecting the 'File->Exit' menu item. The GUI
@@ -18,9 +18,18 @@
 typing
 
 <div class="code"><pre>
-    wxgui
+    g.gui wxpython
 </pre></div>
 
+or 
+
+<div class="code"><pre>
+    g.gui wxpython workspace=file.grc
+</pre></div>
+
+to launch wxGUI and load workspace file on start-up.
+
+<p>
 The GUI is composed by <em>two</em> main components:
 
 <ul>
@@ -74,58 +83,62 @@
 
 <dl>
 
-<dt><img src="../../etc/wx/icons/silk/application_add.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/application_add.png">&nbsp;
   <img src="icons/gui-startmon.gif"> Open new Map Display Window</dt>
 <dd>Opens a new map display and creates empty layer tree tab in Layer Manager.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/page_white.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/page_white.png">&nbsp;
   <img src="icons/file-new.gif">Creates new workspace file</dt>
 <dd>Removes all layers in the layer tree and creates a new, empty tree
 where new layers can be added.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/folder.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/page_white_get.png">&nbsp;
+  <img src="icons/file-new.gif">Load map layers (raster, vector) into workspace</dt>
+<dd>Loads selected raster or vector maps into current layer tree.</dd>
+
+<dt><img src="../../etc/wxpython/icons/silk/folder.png">&nbsp;
   <img src="icons/file-open.gif">Open an existing workspace file</dt>
 <dd>Opens an previously saved workspace file, containing a set of display
 layers and their option settings.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/page_save.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/page_save.png">&nbsp;
   <img src="icons/file-save.gif"> Save layers composition to workspace
   file</dt>
 <dd>Saves current set of layers and their options to a workspace
   file.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/image_add.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/image_add.png">&nbsp;
   <img src="icons/element-cell.gif"> Add raster-based map layer</dt>
 <dd>Adds raster map to layer tree, see <em><a href="d.rast.html">d.rast</a></em>. Includes also shaded relief map, RGB or HIS map or raster flow arrows map.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/picture_empty.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/picture_empty.png">&nbsp;
   <img src="icons/module-d.shadedmap.gif"> Add shaded relief map layer</dt>
 <dd>Adds shaded relief raster map layer,
 see <em><a href="d.shadedmap.html">d.shadedmap</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/rgb.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/rgb.png">&nbsp;
   <img src="icons/channel-rgb.gif"> Add RGB raster layer</dt>
 <dd>Combines and displays three raster maps defined as red, green, and blue
 channels, see <em><a href="d.rgb.html">d.rgb</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/his.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/his.png">&nbsp;
   <img src="icons/channel-his.gif"> Add HIS raster layer</dt>
 <dd>Combines and displays two or three raster maps defined as hue,
 intensity, and (optionally) saturation channels,
 see <em><a href="d.his.html">d.his</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/arrow_out.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/arrow_out.png">&nbsp;
   <img src="icons/module-d.rast.arrow.gif"> Add raster arrows layer</dt>
 <dd>Adds map of raster cells with directional arrows drawn.  Arrow
 direction and length are determined by separate aspect/directional map
 and (optional) slope/intensity map,
 see <em><a href="d.rast.arrow.html">d.rast.arrow</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/map_add.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/map_add.png">&nbsp;
   <img src="icons/element-vector.gif"> Add vector-based map layer</dt>
 <dd>Adds a vector map layer, see <em><a href="d.vect.html">d.vect</a></em>. Includes also thematic vector map or thematic charts layer.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/thematic.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/thematic.png">&nbsp;
   <img src="icons/module-d.vect.thematic.gif"> Add thematic map layer
   (for all vector types)</dt>
 <dd>Adds layer for thematic display values from a numeric attribute
@@ -138,7 +151,7 @@
 printing,
 see <em><a href="d.vect.thematic.html">d.vect.thematic</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/chart_bar.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/chart_bar.png">&nbsp;
   <img src="icons/module-d.vect.chart.gif"> Add thematic charts layer
 (for vector points)</dt>
 <dd>Adds layer in which pie or bar charts can be automatically created
@@ -148,7 +161,7 @@
 on attribute column),
 see <em><a href="d.vect.chart.html">d.vect.chart</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/cog_add.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/cog_add.png">&nbsp;
   <img src="icons/gui-cmd.gif"> Add command layer</dt>
 <dd>Adds a layer in which a GRASS GIS command or command list can be entered.
 For a command list use the pipe symbol as ";" as separator.
@@ -165,16 +178,16 @@
 </pre></div>
 </dd>
 
-<dt><img src="../../etc/wx/icons/silk/folder_add.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/folder_add.png">&nbsp;
   <img src="icons/gui-group.gif"> Add layer group</dt>
 <dd>Adds an empty layer group. Layers can then be added to the group.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/images.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/images.png">&nbsp;
   <img src="icons/module-d.grid.gif"> Add overlay grids and lines</dt>
 <dd>Adds layer to display regular grid (for all locations), or geodesic and
 rhumblines (for latitude/longitude locations only), see <em><a href="d.grid.html">d.grid</a>, <a href="d.geodesic.html">d.geodesic</a>, <a href="d.rhumbline.html">d.rhumbline</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/tag_blue_add.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/tag_blue_add.png">&nbsp;
   <img src="icons/module-d.labels.gif"> Add labels layer for vector
 objects (from existing labels file)</dt>
 <dd>Add raster text layer from a labels file for vector objects
@@ -183,11 +196,11 @@
 created with a text editor,
 see <em><a href="d.labels.html">d.labels</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/bin_closed.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/bin_closed.png">&nbsp;
   <img src="icons/edit-cut.gif"> Remove layer for layer tree</dt>
 <dd>Removes selected layer or layer group from layer tree.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/application_view_columns.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/application_view_columns.png">&nbsp;
   <img src="icons/db-values.gif"> Open <a href="wxGUI.Attribute_Table_Manager.html">Attribute Table Manager</a> for selected vector map</dt>
 <dd>Displays attribute data of selected vector map.</dd>
 
@@ -225,29 +238,29 @@
 
 <dl>
 
-<dt><img src="../../etc/wx/icons/silk/map_go.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/map_go.png">&nbsp;
   <img src="icons/gui-display.gif"> Display active layers (current region)</dt>
 <dd>Displays all active layers from layer tree at current resolution
 and region extents for that map display window.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/arrow_refresh.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/arrow_refresh.png">&nbsp;
   <img src="icons/gui-redraw.gif"> Re-render and display all active
 layers and zoom to current region</dt>
 <dd>Resets the region to the display resolution and extents and forces
 re-display and re-rendering all active layers.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/cross.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/cross.png">&nbsp;
   <img src="icons/gui-erase.gif"> Erase display content</dt>
 <dd>Erases the currently selected map display to a white background;
 also removes all frames,
 see <em><a href="d.erase.html">d.erase</a>, <a href="d.frame.html">d.frame
 -e</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/cursor.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/cursor.png">&nbsp;
   <img src="icons/gui-pointer.gif"> Arrow cursor</dt>
 <dd>Select arrow cursor for map display.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/information.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/information.png">&nbsp;
   <img src="icons/gui-query.gif"> Query tool (select a map first)</dt>
 <dd>Query selected raster, RGB raster (all three map channels will be
 queried), or vector map(s) using the mouse. Map(s) must be selected
@@ -256,7 +269,7 @@
 window,
 see <em><a href="r.what.html">r.what</a>, <a href="v.what.html">v.what</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/arrow_out.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/arrow_out.png">&nbsp;
   <img src="icons/gui-pan.gif"> Pan</dt>
 <dd>Interactive selection of a new center of view in the active
 display monitor. Drag the pan cursor while pressing the left mouse
@@ -265,7 +278,7 @@
 does <em>not</em> affect the computational region for other GIS
 processes, see <em><a href="g.region.html">g.region</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/zoom_in.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/zoom_in.png">&nbsp;
   <img src="icons/gui-zoom_in.gif"> Zoom in</dt>
 <dd>Interactive zooming with the mouse in the active display monitor.
 Drawing a box or just click with the mouse (left button) and zoom-in
@@ -277,7 +290,7 @@
 does <em>not</em> affect the computational region for other GIS
 processes, see <em><a href="g.region.html">g.region</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/zoom_out.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/zoom_out.png">&nbsp;
   <img src="icons/gui-zoom_out.gif"> Zoom out</dt>
 <dd>Interactive zooming with the mouse in the active display monitor.
 Drawing a box or just click with the mouse (left button) and zoom-out
@@ -290,12 +303,12 @@
 other GIS processes,
 see <em><a href="g.region.html">g.region</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/zoom_back.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/zoom_back.png">&nbsp;
   <img src="icons/gui-zoom_back.gif"> Revert zoom</dt>
 <dd>Returns to the previous zoom. Up to 10 levels of zoom back are
 maintained, see <em><a href="g.region.html">g.region</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/zoom.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/zoom.png">&nbsp;
   <img src="icons/gui-mapzoom.gif"> Zoom menu</dt>
 <dd>Automatic zoom settings menu. Zoom to match the extents of a selected
 map, zoom to match the computational region (set with
@@ -305,12 +318,12 @@
 current display extents (does not change the resolution).
 See <em><a href="g.region.html">g.region</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/application_lightning.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/application_lightning.png">&nbsp;
   <img src="icons/gui-rastanalyze.gif"> Analyze menu</dt>
 <dd>Contains functions for distance measurement, creating histogram or
 profile tool.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/sum.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/sum.png">&nbsp;
   <img src="icons/gui-measure.gif"> Distance measurement tool</dt>
 <dd>Interactive measurement of lengths defined with the mouse. The
 length of each segment and the cumulative length of all segments
@@ -318,7 +331,7 @@
 measured in the current measurement unit,
 see <em><a href="d.measure.html">d.measure</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/wand.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/wand.png">&nbsp;
   <img src="icons/gui-profile.gif"> Profile tool</dt>
 <dd>Interactively create profile of a raster map. Profile transect is
 drawn with the mouse in map display. The profile may be of the
@@ -326,39 +339,39 @@
 see <em><a href="gm_profile.html">Profile Tool help
 page</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/chart_bar.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/chart_bar.png">&nbsp;
   <img src="icons/module-d.histogram.gif"> Display histogram of selected raster map</td>
 <dd>Displays histogram of selected raster map or image in new window,
 see <em><a href="d.histogram.html">d.histogram</a</em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/overlays.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/overlays.png">&nbsp;
   <img src="icons/gui-rastanalyze.gif"> Add overlay</dt>
 <dd>Adds overlay to map display like barscale, north arrow, text.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/page_white_picture.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/page_white_picture.png">&nbsp;
   <img src="icons/module-d.barscale.gif"> Add scalebar and north arrow</dt>
 <dd>Adds layer to display a combined scalebar and north arrow. Options
 include scalebar placement (using screen coordinates or a mouse),
 scalebar format, and scalebar colors,
 see <em><a href="d.barscale.html">d.barscale</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/page_green.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/page_green.png">&nbsp;
   <img src="icons/module-d.legend.gif"> Add legend of raster map</dt>
 <dd>Adds layer to display with legend of selected raster map,
 see <a href="d.legend.html">d.legend</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/textfield_add.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/textfield_add.png">&nbsp;
   <img src="icons/module-d.text.gif"> Add text layer</dt>
 <dd>Adds layer to display a line of text using default GRASS font
 (selected with <em><a href="d.font.html">d.font</a></em>).  Options
 include: text placement (screen coordinates); and text size, bolding,
 and color, see <em><a href="d.text.html">d.text</a></em>.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/picture_save.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/picture_save.png">&nbsp;
   <img src="icons/file-save.gif"> Export map display</dt>
 <dd>Exports visible map display to different raster graphic formats.</dd>
 
-<dt><img src="../../etc/wx/icons/silk/printer.png">&nbsp;
+<dt><img src="../../etc/wxpython/icons/silk/printer.png">&nbsp;
   <img src="icons/file-print.gif"> Print map</dt>
 <dd>Prints map on the UNIX <i>lpr</i> printer or PostScript device;
 saves visible map display (including PostScript text and labels) to PDF

Modified: grass/trunk/gui/wxpython/gis_set.py
===================================================================
--- grass/trunk/gui/wxpython/gis_set.py	2008-02-15 18:46:09 UTC (rev 30167)
+++ grass/trunk/gui/wxpython/gis_set.py	2008-02-15 19:29:15 UTC (rev 30168)
@@ -28,7 +28,8 @@
 from gui_modules import utils
 from gui_modules import globalvar
 
-utils.ImportWx()
+utils.CheckForWx()
+import wx
 import wx.html
 import wx.lib.rcsizer as rcs
 import wx.lib.filebrowsebutton as filebrowse

Modified: grass/trunk/gui/wxpython/gui_modules/globalvar.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/globalvar.py	2008-02-15 18:46:09 UTC (rev 30167)
+++ grass/trunk/gui/wxpython/gui_modules/globalvar.py	2008-02-15 19:29:15 UTC (rev 30168)
@@ -19,7 +19,8 @@
 import os
 
 import utils
-utils.ImportWx()
+utils.CheckForWx()
+import wx
 import wx.lib.flatnotebook as FN
 
 """

Modified: grass/trunk/gui/wxpython/gui_modules/menudata.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menudata.py	2008-02-15 18:46:09 UTC (rev 30167)
+++ grass/trunk/gui/wxpython/gui_modules/menudata.py	2008-02-15 19:29:15 UTC (rev 30168)
@@ -29,6 +29,7 @@
               ("Workspace", (
                  ("New", "Create new workspace file (erase current workspace settings first)", "self.OnWorkspaceNew", ""),
                  ("Open", "Open existing workspace file", "self.OnWorkspaceOpen", ""),
+                 ("Load", "Load map layers into layer tree", "self.OnWorkspaceLoad", ""),
                  ("Save", "Save current workspace to file", "self.OnWorkspaceSave", ""),
                  ("Save as", "Save current workspace as", "self.OnWorkspaceSaveAs", ""),
                  ("Close", "Close selected workspace file", "self.OnWorkspaceClose", ""),

Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2008-02-15 18:46:09 UTC (rev 30167)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2008-02-15 19:29:15 UTC (rev 30168)
@@ -52,7 +52,8 @@
 import textwrap
 
 import utils
-utils.ImportWx()
+utils.CheckForWx()
+import wx
 import wx.lib.flatnotebook as FN
 import wx.lib.colourselect as csel
 import wx.lib.filebrowsebutton as filebrowse

Modified: grass/trunk/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/utils.py	2008-02-15 18:46:09 UTC (rev 30167)
+++ grass/trunk/gui/wxpython/gui_modules/utils.py	2008-02-15 19:29:15 UTC (rev 30168)
@@ -112,7 +112,7 @@
         
     return catstr.strip(',')
 
-def ImportWx():
+def CheckForWx():
     """Try to import wx module and check its version"""
     majorVersion = 2.8
     minorVersion = 1.1
@@ -130,3 +130,29 @@
             '. wxPython >= %s.%s is required. Detailed information in README file.' % \
             (str(majorVersion), str(minorVersion))
         sys.exit(1)
+
+def ListOfMapsets():
+    """Get list of available/accessible mapsets
+
+    @return ([available mapsets], [accessible mapsets]) 
+    """
+    import gcmd
+    all_mapsets = []
+    accessible_mapsets = []
+    
+    cmd = gcmd.Command(['g.mapsets', '-l'])
+    
+    try:
+        for mset in cmd.ReadStdOutput()[0].split(' '):
+            all_mapsets.append(mset.strip('%s' % os.linesep))
+    except:
+        raise gcmd.CmdError('Unable to get list of available mapsets.')
+            
+    cmd = gcmd.Command(['g.mapsets', '-p'])
+    try:
+        for mset in cmd.ReadStdOutput()[0].split(' '):
+            accessible_mapsets.append(mset.strip('\n'))
+    except:
+        raise gcmd.CmdError('Unable to get list of accessible mapsets.')
+
+    return (all_mapsets, accessible_mapsets)

Modified: grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py	2008-02-15 18:46:09 UTC (rev 30167)
+++ grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py	2008-02-15 19:29:15 UTC (rev 30168)
@@ -9,6 +9,7 @@
     * GMStdout
     * GMStrerr
     * GMStc
+    * LoadMapLayersDialog
 
 PURPOSE:    Utility classes for GRASS wxPython GUI. Main functions include tree control
             for GIS map layer management, command console, and command parsing.
@@ -1416,3 +1417,172 @@
         of the string"""
         str = textwrap.fill(str, wrap) + os.linesep
         self.AddText(str)
+
+class LoadMapLayersDialog(wx.Dialog):
+    """Load 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)
+
+        self.parent = parent # GMFrame
+
+        #
+        # dialog body
+        #
+        self.bodySizer = self.__createDialogBody()
+        # update list of layer to be loaded
+        self.LoadMapLayers(self.layerType.GetStringSelection()[:4],
+                           self.mapset.GetStringSelection())
+        #
+        # buttons
+        #
+        btnCancel = wx.Button(self, wx.ID_CANCEL)
+        btnOk = wx.Button(self, wx.ID_OK, _("Load") )
+        btnOk.SetDefault()
+
+        #
+        # bindigs
+        #
+        #btnOk.Bind(wx.EVT_BUTTON, self.OnOK)
+        #btnCancel.Bind(wx.EVT_BUTTON, self.OnCancel)
+
+        #
+        # sizers & do layout
+        #
+        btnSizer = wx.StdDialogButtonSizer()
+        btnSizer.AddButton(btnCancel)
+        btnSizer.AddButton(btnOk)
+        btnSizer.Realize()
+        
+        mainSizer = wx.BoxSizer(wx.VERTICAL)
+        mainSizer.Add(item=self.bodySizer, proportion=1,
+                      flag=wx.EXPAND | wx.ALL, border=5)
+        mainSizer.Add(item=btnSizer, proportion=0,
+                      flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5)
+
+        self.SetSizer(mainSizer)
+        mainSizer.Fit(self)
+
+        # set dialog min size
+        self.SetMinSize(self.GetSize())
+        
+    def __createDialogBody(self):
+        bodySizer = wx.GridBagSizer(vgap=3, hgap=3)
+        bodySizer.AddGrowableCol(1)
+        bodySizer.AddGrowableRow(2)
+        
+        # layer type
+        bodySizer.Add(item=wx.StaticText(parent=self, label=_("Layer type:")),
+                      flag=wx.ALIGN_CENTER_VERTICAL,
+                      pos=(0,0))
+
+        self.layerType = wx.Choice(parent=self, id=wx.ID_ANY,
+                                   choices=['raster', 'vector'], size=(200,-1))
+        self.layerType.SetSelection(0)
+        bodySizer.Add(item=self.layerType,
+                      pos=(0,1))
+        
+        # mapset filter
+        bodySizer.Add(item=wx.StaticText(parent=self, label=_("Mapset:")),
+                      flag=wx.ALIGN_CENTER_VERTICAL,
+                      pos=(1,0))
+        self.mapset = wx.ComboBox(parent=self, id=wx.ID_ANY,
+                                  style=wx.CB_SIMPLE | wx.CB_READONLY,
+                                  choices=utils.ListOfMapsets()[0],
+                                  size=(200,-1))
+        self.mapset.SetStringSelection(grassenv.GetGRASSVariable("MAPSET"))
+        bodySizer.Add(item=self.mapset,
+                      pos=(1,1))
+
+        # layer list 
+        bodySizer.Add(item=wx.StaticText(parent=self, label=_("List of maps:")),
+                      flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_TOP,
+                      pos=(2,0))
+        self.layers = wx.CheckListBox(parent=self, id=wx.ID_ANY,
+                                      size=(250, 100),
+                                      choices=[])
+        bodySizer.Add(item=self.layers,
+                      flag=wx.EXPAND,
+                      pos=(2,1))
+
+        # bindings
+        self.layerType.Bind(wx.EVT_CHOICE, self.OnChangeParams)
+        self.mapset.Bind(wx.EVT_COMBOBOX, self.OnChangeParams)
+        self.layers.Bind(wx.EVT_RIGHT_DOWN, self.OnMenu)
+        
+        return bodySizer
+
+    def LoadMapLayers(self, type, mapset):
+        """Load list of map layers
+
+        @param type layer type ('raster' or 'vector')
+        @param mapset mapset name
+        """
+        list = gcmd.Command(['g.mlist',
+                             'type=%s' % type,
+                             'mapset=%s' % mapset])
+
+        maps = []
+        for map in list.ReadStdOutput():
+            maps.append(map)
+            
+        self.layers.Set(maps)
+        
+        # check all items by default
+        for item in range(self.layers.GetCount()):
+            self.layers.Check(item)
+
+    def OnChangeParams(self, event):
+        """Filter parameters changed by user"""
+        # update list of layer to be loaded
+        self.LoadMapLayers(self.layerType.GetStringSelection()[:4],
+                           self.mapset.GetStringSelection())
+    
+        event.Skip()
+
+    def OnMenu(self, event):
+        """Table description area, context menu"""
+        if not hasattr(self, "popupID1"):
+            self.popupDataID1 = wx.NewId()
+            self.popupDataID2 = wx.NewId()
+
+            self.Bind(wx.EVT_MENU, self.OnSelectAll,   id=self.popupDataID1)
+            self.Bind(wx.EVT_MENU, self.OnDeselectAll, id=self.popupDataID2)
+
+        # generate popup-menu
+        menu = wx.Menu()
+        menu.Append(self.popupDataID1, _("Select all"))
+        menu.Append(self.popupDataID2, _("Deselect all"))
+
+        self.PopupMenu(menu)
+        menu.Destroy()
+
+    def OnSelectAll(self, event):
+        """Select all map layer from list"""
+        for item in range(self.layers.GetCount()):
+            self.layers.Check(item, True)
+
+    def OnDeselectAll(self, event):
+        """Select all map layer from list"""
+        for item in range(self.layers.GetCount()):
+            self.layers.Check(item, False)
+
+    def GetMapLayers(self):
+        """Return list of checked map layers"""
+        layerNames = []
+        for indx in self.layers.GetSelections():
+            # layers.append(self.layers.GetStringSelec(indx))
+            pass
+
+        # return fully qualified map names
+        mapset = self.mapset.GetStringSelection()
+        for item in range(self.layers.GetCount()):
+            if not self.layers.IsChecked(item):
+                continue
+            layerNames.append(self.layers.GetString(item) + '@' + mapset)
+
+        return layerNames
+    
+    def GetLayerType(self):
+        """Get selected layer type"""
+        return self.layerType.GetStringSelection()
+    

Modified: grass/trunk/gui/wxpython/icons/icon.py
===================================================================
--- grass/trunk/gui/wxpython/icons/icon.py	2008-02-15 18:46:09 UTC (rev 30167)
+++ grass/trunk/gui/wxpython/icons/icon.py	2008-02-15 19:29:15 UTC (rev 30168)
@@ -84,6 +84,7 @@
     # gis manager
     "newdisplay" : 'gui-startmon.gif',
     "workspaceNew" : 'file-new.gif',
+    "workspaceLoad" : 'file-new.gif', # change the icon if possible
     "workspaceOpen" : 'file-open.gif',
     "workspaceSave" : 'file-save.gif',
     "addrast"    : 'element-cell.gif',
@@ -239,6 +240,7 @@
     # gis manager
     "newdisplay" : MetaIcon (img=icons_img["newdisplay"], label="Start new display"),
     "workspaceNew" : MetaIcon (img=icons_img["workspaceNew"], label="Create new workspace file"),
+    "workspaceLoad" : MetaIcon (img=icons_img["workspaceLoad"], label="Load map layers into workspace"),
     "workspaceOpen" : MetaIcon (img=icons_img["workspaceOpen"], label="Open existing workspace file"),
     "workspaceSave" : MetaIcon (img=icons_img["workspaceSave"], label="Save current workspace to file"),
     # TODO: "layer" is not conformant with GRASS vocabulary (vector layer: 1..x) ! 

Modified: grass/trunk/gui/wxpython/icons/silk/__init__.py
===================================================================
--- grass/trunk/gui/wxpython/icons/silk/__init__.py	2008-02-15 18:46:09 UTC (rev 30167)
+++ grass/trunk/gui/wxpython/icons/silk/__init__.py	2008-02-15 19:29:15 UTC (rev 30168)
@@ -60,6 +60,7 @@
     # gis manager
     "newdisplay" : 'application_add.png',
     "workspaceNew" : 'page_white.png',
+    "workspaceLoad" : 'page_white_get.png',
     "workspaceOpen" : 'folder.png',
     "workspaceSave" : 'page_save.png',
     "addrast"    : 'image_add.png',

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2008-02-15 18:46:09 UTC (rev 30167)
+++ grass/trunk/gui/wxpython/wxgui.py	2008-02-15 19:29:15 UTC (rev 30168)
@@ -51,7 +51,8 @@
 sys.path.append(gmpath)
 
 import gui_modules.utils as utils
-utils.ImportWx()
+utils.CheckForWx()
+import wx
 import wx.aui
 import wx.combo
 import wx.html
@@ -459,6 +460,26 @@
 
         wx.AboutBox(info)
 
+    def OnWorkspace(self, event):
+        """Workspace menu (new, load)"""
+        point = wx.GetMousePosition()
+        menu = wx.Menu()
+
+        # Add items to the menu
+        new = wx.MenuItem(menu, wx.ID_ANY, Icons["workspaceNew"].GetLabel())
+        new.SetBitmap(Icons["workspaceNew"].GetBitmap(self.iconsize))
+        menu.AppendItem(new)
+        self.Bind(wx.EVT_MENU, self.OnWorkspaceNew, new)
+
+        load = wx.MenuItem(menu, wx.ID_ANY, Icons["workspaceLoad"].GetLabel())
+        load.SetBitmap(Icons["workspaceLoad"].GetBitmap(self.iconsize))
+        menu.AppendItem(load)
+        self.Bind(wx.EVT_MENU, self.OnWorkspaceLoad, load)
+
+        # create menu
+        self.PopupMenu(menu)
+        menu.Destroy()
+
     def OnWorkspaceNew(self, event=None):
         """Create new workspace file
 
@@ -572,6 +593,28 @@
 
         return True
 
+    def OnWorkspaceLoad(self, event=None):
+        """Load given map layers into layer tree"""
+        dialog = wxgui_utils.LoadMapLayersDialog(parent=self, title=_("Load map layers into layer tree"))
+
+        if dialog.ShowModal() == wx.ID_OK:
+            maptree = self.curr_page.maptree
+            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=True,
+                                           lopacity=1.0,
+                                           lcmd=cmd,
+                                           lgroup=None)
+                maptree.PropertiesDialog(newItem, show=False)
+
+            # reverse list of map layers
+            maptree.Map.ReverseListOfLayers()
+
     def OnWorkspaceSaveAs(self, event=None):
         """Save workspace definition to selected file"""
 
@@ -833,21 +876,33 @@
     def ToolbarData(self):
 
         return   (
-                 ('newdisplay', Icons["newdisplay"].GetBitmap(), Icons["newdisplay"].GetLabel(), self.NewDisplay),
+                 ('newdisplay', Icons["newdisplay"].GetBitmap(),
+                  Icons["newdisplay"].GetLabel(), self.NewDisplay),
                  ('', '', '', ''),
-                 ('workspaceNew', Icons["workspaceNew"].GetBitmap(), Icons["workspaceNew"].GetLabel(), self.OnWorkspaceNew),
-                 ('workspaceOpen', Icons["workspaceOpen"].GetBitmap(), Icons["workspaceOpen"].GetLabel(), self.OnWorkspaceOpen),
-                 ('workspaceSave', Icons["workspaceSave"].GetBitmap(), Icons["workspaceSave"].GetLabel(), self.OnWorkspaceSave),
+                 ('workspaceLoad', Icons["workspaceLoad"].GetBitmap(),
+                  Icons["workspaceLoad"].GetLabel(), self.OnWorkspace),
+                 ('workspaceOpen', Icons["workspaceOpen"].GetBitmap(),
+                  Icons["workspaceOpen"].GetLabel(), self.OnWorkspaceOpen),
+                 ('workspaceSave', Icons["workspaceSave"].GetBitmap(),
+                  Icons["workspaceSave"].GetLabel(), self.OnWorkspaceSave),
                  ('', '', '', ''),
-                 ('addrast', Icons["addrast"].GetBitmap(), Icons["addrast"].GetLabel(), self.OnRaster),
-                 ('addvect', Icons["addvect"].GetBitmap(), Icons["addvect"].GetLabel(), self.OnVector),
-                 ('addcmd',  Icons["addcmd"].GetBitmap(),  Icons["addcmd"].GetLabel(),  self.AddCommand),
-                 ('addgrp',  Icons["addgrp"].GetBitmap(),  Icons["addgrp"].GetLabel(), self.AddGroup),
-                 ('addovl',  Icons["addovl"].GetBitmap(),  Icons["addovl"].GetLabel(), self.OnOverlay),
-                 ('addlabels',  Icons["addlabels"].GetBitmap(),  Icons["addlabels"].GetLabel(), self.AddLabels),
-                 ('delcmd',  Icons["delcmd"].GetBitmap(),  Icons["delcmd"].GetLabel(), self.DeleteLayer),
+                 ('addrast', Icons["addrast"].GetBitmap(),
+                  Icons["addrast"].GetLabel(), self.OnRaster),
+                 ('addvect', Icons["addvect"].GetBitmap(),
+                  Icons["addvect"].GetLabel(), self.OnVector),
+                 ('addcmd',  Icons["addcmd"].GetBitmap(),
+                  Icons["addcmd"].GetLabel(),  self.AddCommand),
+                 ('addgrp',  Icons["addgrp"].GetBitmap(),
+                  Icons["addgrp"].GetLabel(), self.AddGroup),
+                 ('addovl',  Icons["addovl"].GetBitmap(),
+                  Icons["addovl"].GetLabel(), self.OnOverlay),
+                 ('addlabels',  Icons["addlabels"].GetBitmap(),
+                  Icons["addlabels"].GetLabel(), self.AddLabels),
+                 ('delcmd',  Icons["delcmd"].GetBitmap(),
+                  Icons["delcmd"].GetLabel(), self.DeleteLayer),
                  ('', '', '', ''),
-                 ('attrtable', Icons["attrtable"].GetBitmap(), Icons["attrtable"].GetLabel(), self.ShowAttributeTable)
+                 ('attrtable', Icons["attrtable"].GetBitmap(),
+                  Icons["attrtable"].GetLabel(), self.ShowAttributeTable)
                   )
 
     def ShowAttributeTable(self, event):
@@ -1166,22 +1221,9 @@
                            style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER):
         wx.Dialog.__init__(self, parent, id, title, pos, size, style)
 
-        cmdlist = ['g.mapsets', '-l']
-        self.all_mapsets = gcmd.Command(cmdlist).module_stdout.read().strip().split(' ')
-        for mset in self.all_mapsets:
-            indx = self.all_mapsets.index(mset)
-            self.all_mapsets[indx] = mset.strip('\n')
+        self.all_mapsets, self.accessible_mapsets = utils.ListOfMapsets()
+        self.curr_mapset = grassenv.GetGRASSVariable('MAPSET')
 
-        cmdlist = ['g.mapsets', '-p']
-        self.accessible_mapsets = gcmd.Command(cmdlist).module_stdout.read().strip().split(' ')
-        for mset in self.accessible_mapsets:
-            indx = self.accessible_mapsets.index(mset)
-            self.accessible_mapsets[indx] = mset.strip('\n')
-
-        cmdlist = ['g.gisenv', 'get=MAPSET']
-        self.curr_mapset = gcmd.Command(cmdlist).module_stdout.read().strip()
-
-
         # remove PERMANENT and current mapset from list because they are always accessible
         self.PERMANENT_ndx = self.all_mapsets.index("PERMANENT")
         self.all_mapsets.pop(self.PERMANENT_ndx)



More information about the grass-commit mailing list