[GRASS-SVN] r42282 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Tue May 18 05:42:20 EDT 2010


Author: martinl
Date: 2010-05-18 05:42:19 -0400 (Tue, 18 May 2010)
New Revision: 42282

Modified:
   grass/trunk/gui/wxpython/gui_modules/gmodeler.py
Log:
wxGUI/modeler: minor bugs in parametrization fixed


Modified: grass/trunk/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gmodeler.py	2010-05-18 09:42:14 UTC (rev 42281)
+++ grass/trunk/gui/wxpython/gui_modules/gmodeler.py	2010-05-18 09:42:19 UTC (rev 42282)
@@ -97,6 +97,13 @@
         """!Add data to the model"""
         self.data.append(item)
 
+    def RemoveItem(self, item):
+        """!Remove item from model"""
+        if isinstance(item, ModelAction):
+            self.actions.remove(item)
+        elif isinstance(item, ModelData):
+            self.data.remove(item)
+        
     def FindAction(self, id):
         """!Find action by id"""
         for action in self.actions:
@@ -257,6 +264,7 @@
     def Parametrize(self):
         """!Return parametrized options"""
         result = dict()
+        idx = 0
         for action in self.actions:
             name   = action.GetName()
             params = action.GetParams()
@@ -264,14 +272,17 @@
                 if f.get('parametrized', False):
                     if not result.has_key(name):
                         result[name] = { 'flags' : list(),
-                                         'params': list() }
+                                         'params': list(),
+                                         'idx'   : idx }
                     result[name]['flags'].append(f)
             for p in params['params']:
                 if p.get('parametrized', False):
                     if not result.has_key(name):
                         result[name] = { 'flags' : list(),
-                                         'params': list() }
+                                         'params': list(),
+                                         'idx'   : idx }
                     result[name]['params'].append(p)
+            idx += 1
         
         return result
     
@@ -589,7 +600,8 @@
                      message = _('Model is empty. Nothing to run.'),
                      msgType = 'info')
             return
-    
+        
+        # validation
         errList = self._validateModel()
         if errList:
             dlg = wx.MessageDialog(parent = self,
@@ -602,6 +614,7 @@
             if ret != wx.ID_YES:
                 return
         
+        # parametrization
         params = self.model.Parametrize()
         if params:
             dlg = ModelParamDialog(parent = self,
@@ -1122,9 +1135,11 @@
         for shape in diagram.GetShapeList():
             if not shape.Selected():
                 continue
+            self.parent.GetModel().RemoveItem(shape)
             shape.Select(False)
             diagram.RemoveShape(shape)
-        
+            
+            
         self.Refresh()
         
 class ModelAction(ogl.RectangleShape):
@@ -1138,7 +1153,7 @@
             height = UserSettings.Get(group='modeler', key='action', subkey=('size', 'height'))
         
         if cmd:
-            self.task = menuform.GUI().ParseCommand(cmd = self.cmd,
+            self.task = menuform.GUI().ParseCommand(cmd = cmd,
                                                     show = None)
         else:
             if task:
@@ -1161,7 +1176,7 @@
             self.SetY(y)
             self.SetPen(wx.BLACK_PEN)
             self._setBrush(False)
-            cmd = self.task.getCmd(ignoreErrors = False)
+            cmd = self.task.getCmd(ignoreErrors = True)
             if cmd and len(cmd) > 0:
                 self.AddText(cmd[0])
             else:
@@ -2385,10 +2400,14 @@
         
     def _createPages(self):
         """!Create for each parametrized module its own page"""
+        nameOrdered = [''] * len(self.params.keys())
         for name, params in self.params.iteritems():
+            nameOrdered[params['idx']] =  name
+        for name in nameOrdered:
+            params = self.params[name]
             panel = self._createPage(name, params)
             self.notebook.AddPage(panel, text = name)
-    
+        
         return panel
     
     def _createPage(self, name, params):



More information about the grass-commit mailing list