[GRASS-SVN] r48775 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Oct 13 08:09:59 EDT 2011


Author: martinl
Date: 2011-10-13 05:09:59 -0700 (Thu, 13 Oct 2011)
New Revision: 48775

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
Log:
wxGUI/modeler: dynamic series more user friendly
	       (merge r48774 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py	2011-10-13 12:06:52 UTC (rev 48774)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py	2011-10-13 12:09:59 UTC (rev 48775)
@@ -849,7 +849,7 @@
                  'active' : self.chkbox.IsChecked() }
 
 class MapLayersDialog(wx.Dialog):
-    def __init__(self, parent, title,
+    def __init__(self, parent, title, modeler = False,
                  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
         """!Dialog for selecting map layers (raster, vector)"""
         wx.Dialog.__init__(self, parent = parent, id = wx.ID_ANY, title = title,
@@ -867,6 +867,12 @@
         self.fullyQualified = wx.CheckBox(parent = self, id = wx.ID_ANY,
                                           label = _("Use fully-qualified map names"))
         self.fullyQualified.SetValue(True)
+
+        self.dseries = None
+        if modeler:
+            self.dseries = wx.CheckBox(parent = self, id = wx.ID_ANY,
+                                       label = _("Dynamic series (%s)") % 'g.mlist')
+            self.dseries.SetValue(False)
         
         # buttons
         btnCancel = wx.Button(parent = self, id = wx.ID_CANCEL)
@@ -884,6 +890,10 @@
                       flag = wx.EXPAND | wx.ALL, border = 5)
         mainSizer.Add(item = self.fullyQualified, proportion = 0,
                       flag = wx.EXPAND | wx.LEFT | wx.RIGHT, border = 5)
+        if self.dseries:
+            mainSizer.Add(item = self.dseries, proportion = 0,
+                          flag = wx.EXPAND | wx.LEFT | wx.RIGHT, border = 5)
+        
         mainSizer.Add(item = btnSizer, proportion = 0,
                       flag = wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border = 5)
 
@@ -899,12 +909,12 @@
         bodySizer.AddGrowableRow(3)
         
         # layer type
-        bodySizer.Add(item = wx.StaticText(parent = self, label = _("Map layer type:")),
+        bodySizer.Add(item = wx.StaticText(parent = self, label = _("Map type:")),
                       flag = wx.ALIGN_CENTER_VERTICAL,
                       pos = (0,0))
         
         self.layerType = wx.Choice(parent = self, id = wx.ID_ANY,
-                                   choices = ['raster', 'vector'], size = (100,-1))
+                                   choices = [_('raster'), _('3D raster'), _('vector')], size = (100,-1))
         self.layerType.SetSelection(0)
         bodySizer.Add(item = self.layerType,
                       pos = (0,1))
@@ -928,7 +938,7 @@
                       pos = (1,1), span = (1, 2))
         
         # map name filter
-        bodySizer.Add(item = wx.StaticText(parent = self, label = _("Filter:")),
+        bodySizer.Add(item = wx.StaticText(parent = self, label = _("Pattern:")),
                       flag = wx.ALIGN_CENTER_VERTICAL,
                       pos = (2,0))
         
@@ -975,7 +985,7 @@
     def OnChangeParams(self, event):
         """!Filter parameters changed by user"""
         # update list of layer to be loaded
-        self.LoadMapLayers(self.layerType.GetStringSelection()[:4],
+        self.LoadMapLayers(self.GetLayerType(cmd = True),
                            self.mapset.GetStringSelection())
         
         event.Skip()
@@ -1064,9 +1074,39 @@
         
         return layerNames
     
-    def GetLayerType(self):
-        """!Get selected layer type"""
-        return self.layerType.GetStringSelection()
+    def GetLayerType(self, cmd = False):
+        """!Get selected layer type
+
+        @param cmd True for g.mlist
+        """
+        if not cmd:
+            return self.layerType.GetStringSelection()
+        
+        sel = self.layerType.GetSelection()
+        if sel == 0:
+            ltype = 'rast'
+        elif sel == 1:
+            ltype = 'rast3d'
+        else:
+            ltype = 'vect'
+        
+        return ltype
+
+    def GetDSeries(self):
+        """!Used by modeler only
+
+        @return g.mlist command
+        """
+        if not self.dseries or not self.dseries.IsChecked():
+            return ''
+        
+        cond = 'map in `g.mlist type=%s ' % self.GetLayerType(cmd = True)
+        patt = self.filter.GetValue()
+        if patt:
+            cond += 'pattern=%s ' % patt
+        cond += 'mapset=%s`' % self.mapset.GetStringSelection()
+        
+        return cond
     
 class ImportDialog(wx.Dialog):
     """!Dialog for bulk import of various data (base class)"""

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2011-10-13 12:06:52 UTC (rev 48774)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2011-10-13 12:09:59 UTC (rev 48775)
@@ -4221,12 +4221,16 @@
 
     def OnSeries(self, event):
         """!Define map series as condition"""
-        dialog = MapLayersDialog(parent = self, title = _("Define series of maps"))
+        dialog = MapLayersDialog(parent = self, title = _("Define series of maps"), modeler = True)
         if dialog.ShowModal() != wx.ID_OK:
             dialog.Destroy()
             return
         
-        self.condText.SetValue('map in %s' % map(lambda x: str(x), dialog.GetMapLayers()))
+        cond = dialog.GetDSeries()
+        if not cond:
+            cond = 'map in %s' % map(lambda x: str(x), dialog.GetMapLayers())
+        
+        self.condText.SetValue(cond)
                                
         dialog.Destroy()
 



More information about the grass-commit mailing list