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

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Apr 13 13:33:25 EDT 2008


Author: martinl
Date: 2008-04-13 13:33:23 -0400 (Sun, 13 Apr 2008)
New Revision: 30975

Modified:
   grass/trunk/gui/wxpython/gui_modules/workspace.py
   grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
   grass/trunk/gui/wxpython/wxgui.py
   grass/trunk/gui/wxpython/xml/grass-gxw.dtd
Log:
wxGUI: mark in workspace file (gxw) selected map layers

Modified: grass/trunk/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/workspace.py	2008-04-13 16:23:45 UTC (rev 30974)
+++ grass/trunk/gui/wxpython/gui_modules/workspace.py	2008-04-13 17:33:23 UTC (rev 30975)
@@ -74,10 +74,11 @@
 
         elif name == 'layer':
             self.inLayer = True
-            self.layerType    = attrs.get('type', None)
-            self.layerName    = attrs.get('name', None)
-            self.layerChecked = attrs.get('checked', None)
-            self.layerOpacity = attrs.get('opacity', None)
+            self.layerType     = attrs.get('type', None)
+            self.layerName     = attrs.get('name', None)
+            self.layerChecked  = attrs.get('checked', None)
+            self.layerOpacity  = attrs.get('opacity', None)
+            self.layerSelected = False;
             self.cmd = []
 
         elif name == 'task':
@@ -98,6 +99,10 @@
             name = attrs.get('name', None)
             self.cmd.append('-' + name)
 
+        elif name == 'selected':
+            if self.inLayer:
+                self.layerSelected = True;
+            
     def endElement(self, name):
         if name == 'gxw':
             self.inGxw = False
@@ -112,13 +117,14 @@
         elif name == 'layer':
             self.inLayer = False
             self.layers.append({
-                    "type"    : self.layerType,
-                    "name"    : self.layerName,
-                    "checked" : int(self.layerChecked),
-                    "opacity" : None,
-                    "cmd"     : None,
-                    "group"   : self.inGroup,
-                    "display" : self.displayIndex})
+                    "type"     : self.layerType,
+                    "name"     : self.layerName,
+                    "checked"  : int(self.layerChecked),
+                    "opacity"  : None,
+                    "cmd"      : None,
+                    "group"    : self.inGroup,
+                    "display"  : self.displayIndex,
+                    "selected" : self.layerSelected})
 
             if self.layerOpacity:
                 self.layers[-1]["opacity"] = float(self.layerOpacity)

Modified: grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py	2008-04-13 16:23:45 UTC (rev 30974)
+++ grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py	2008-04-13 17:33:23 UTC (rev 30975)
@@ -96,7 +96,7 @@
 
         # title
         self.mapdisplay.SetTitle(_("GRASS GIS Map Display: " +
-                                   str(self.disp_idx) + 
+                                   str(self.disp_idx + 1) + 
                                    " - Location: " + grassenv.GetGRASSVariable("LOCATION_NAME")))
 
         # show new display
@@ -407,7 +407,8 @@
         """Rename layer"""
         self.EditLabel(self.layer_selected)
 
-    def AddLayer(self, ltype, lname=None, lchecked=None, lopacity=None, lcmd=None, lgroup=None):
+    def AddLayer(self, ltype, lname=None, lchecked=None,
+                 lopacity=None, lcmd=None, lgroup=None):
         """Add new item to the layer tree, create corresponding MapLayer instance.
         Launch property dialog if needed (raster, vector, etc.)
 

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2008-04-13 16:23:45 UTC (rev 30974)
+++ grass/trunk/gui/wxpython/wxgui.py	2008-04-13 17:33:23 UTC (rev 30975)
@@ -111,7 +111,7 @@
         self._auimgr = wx.aui.AuiManager(self)
 
         # initialize variables
-        self.disp_idx      = 1            # index value for map displays and layer trees
+        self.disp_idx      = 0            # index value for map displays and layer trees
         self.curr_page     = ''           # currently selected page for layer tree notebook
         self.curr_pagenum  = ''           # currently selected page number for layer tree notebook
         self.encoding      = 'ISO-8859-1' # default encoding for display fonts
@@ -166,7 +166,8 @@
 
         # show map display widnow
         # -> OnSize() -> UpdateMap()
-        self.curr_page.maptree.mapdisplay.Show()
+        if not self.curr_page.maptree.mapdisplay.IsShown():
+            self.curr_page.maptree.mapdisplay.Show()
 
     def __doLayout(self):
         """Do Layout (unused bacause of aui manager...)"""
@@ -600,18 +601,33 @@
             wx.Yield()
 
             maptree = None
+            selected = [] # list of selected layers
             for layer in gxwXml.layers:
                 if layer['display'] >= self.disp_idx:
                     # start new map display if no display is available
                     self.NewDisplay()
+
                 maptree = self.gm_cb.GetPage(layer['display']).maptree
+
+                if not maptree.mapdisplay.IsShown():
+                    # show map display
+                    maptree.mapdisplay.Show()
+
                 newItem = maptree.AddLayer(ltype=layer['type'],
                                            lname=layer['name'],
                                            lchecked=layer['checked'],
                                            lopacity=layer['opacity'],
                                            lcmd=layer['cmd'],
                                            lgroup=layer['group'])
-            #   maptree.PropertiesDialog(newItem, show=False)
+                if layer['selected']:
+                    selected.append((maptree, newItem))
+                else:
+                    maptree.SelectItem(newItem, select=False)
+                    
+            for maptree, layer in selected:
+                if not maptree.IsSelected(layer):
+                    maptree.SelectItem(layer, select=True)
+                    maptree.layer_selected = layer
 
             busy.Destroy()
             
@@ -775,8 +791,12 @@
                 opacity = maplayer.GetOpacity(float=True)
                 file.write('%s<layer type="%s" name="%s" checked="%d" opacity="%f">\n' % \
                                (' ' * self.indent, type, name, checked, opacity));
+
+                self.indent += 4
+                # selected ?
+                if item == mapTree.layer_selected:
+                    file.write('%s<selected />\n' % (' ' * self.indent))
                 # layer properties
-                self.indent += 4
                 file.write('%s<task name="%s">\n' % (' ' * self.indent, cmd[0]))
                 self.indent += 4
                 for option in cmd[1:]:
@@ -1075,7 +1095,7 @@
 
         # make a new page in the bookcontrol for the layer tree (on page 0 of the notebook)
         self.pg_panel = wx.Panel(self.gm_cb, id=wx.ID_ANY, style= wx.EXPAND)
-        self.gm_cb.AddPage(self.pg_panel, text="Display "+ str(self.disp_idx), select = True)
+        self.gm_cb.AddPage(self.pg_panel, text="Display "+ str(self.disp_idx + 1), select = True)
         self.curr_page = self.gm_cb.GetCurrentPage()
 
         # create layer tree (tree control for managing GIS layers)  and put on new notebook page

Modified: grass/trunk/gui/wxpython/xml/grass-gxw.dtd
===================================================================
--- grass/trunk/gui/wxpython/xml/grass-gxw.dtd	2008-04-13 16:23:45 UTC (rev 30974)
+++ grass/trunk/gui/wxpython/xml/grass-gxw.dtd	2008-04-13 17:33:23 UTC (rev 30975)
@@ -29,7 +29,7 @@
 
 <!--    map layer
 -->
-<!ELEMENT layer (task?)>
+<!ELEMENT layer (selected?, task?)>
 <!ATTLIST layer	type	CDATA #REQUIRED>
 <!ATTLIST layer	name	CDATA #REQUIRED>
 <!ATTLIST layer	checked CDATA #REQUIRED>
@@ -38,9 +38,13 @@
 <!--	task describes the interface of a single
 	GRASS command. 
 -->
-<!ELEMENT task	        (parameter*, flag*)>
+<!ELEMENT task	        (flag*, parameter*)>
 <!ATTLIST task	name	CDATA #REQUIRED>
 
+<!--	layer selected
+-->
+<!ELEMENT selected      EMPTY>
+
 <!--	a parameter must have a name and a value
 -->
 <!ELEMENT parameter     (value)>
@@ -53,5 +57,5 @@
 
 <!--    enabled flag
 -->
-<!ELEMENT flag         EMPTY>
-<!ATTLIST flag         name            CDATA #REQUIRED>
+<!ELEMENT flag          EMPTY>
+<!ATTLIST flag          name            CDATA #REQUIRED>



More information about the grass-commit mailing list