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

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Sep 15 17:42:54 EDT 2011


Author: martinl
Date: 2011-09-15 14:42:53 -0700 (Thu, 15 Sep 2011)
New Revision: 48307

Modified:
   grass/trunk/gui/wxpython/gui_modules/gmodeler.py
   grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: attempt to fix #1448 (run model menu item does not seem to work)


Modified: grass/trunk/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gmodeler.py	2011-09-15 21:40:37 UTC (rev 48306)
+++ grass/trunk/gui/wxpython/gui_modules/gmodeler.py	2011-09-15 21:42:53 UTC (rev 48307)
@@ -317,15 +317,18 @@
             for rel in data['rels']:
                 actionItem = self.FindAction(rel['id'])
                 if rel['dir'] == 'from':
-                    relation = ModelRelation(dataItem, actionItem, rel['name'])
+                    relation = ModelRelation(parent = self, fromShape = dataItem,
+                                             toShape = actionItem, param = rel['name'])
                 else:
-                    relation = ModelRelation(actionItem, dataItem, rel['name'])
+                    relation = ModelRelation(parent = self, fromShape = actionItem,
+                                             toShape = dataItem, param = rel['name'])
                 relation.SetControlPoints(rel['points'])
                 actionItem.AddRelation(relation)
                 dataItem.AddRelation(relation)
-            
-            dataItem.Update()
-                   
+
+            if self.canvas:
+                dataItem.Update()
+           
         # load loops
         for loop in gxmXml.loops:
             loopItem = ModelLoop(parent = self, 
@@ -407,7 +410,7 @@
 
     def Run(self, log, onDone):
         """!Run model"""
-        for action in self.actions:
+        for action in self.GetItems(objType = ModelAction):
             if not action.IsEnabled():
                 continue
             log.RunCmd(command = action.GetLog(string = False),
@@ -1303,9 +1306,11 @@
                                                p.get('prompt', ''))
                     if data:
                         if p.get('age', 'old') == 'old':
-                            rel = ModelRelation(data, layer, p.get('name', ''))
+                            rel = ModelRelation(parent = self, fromShape = data,
+                                                toShape = layer, param = p.get('name', ''))
                         else:
-                            rel = ModelRelation(layer, data, p.get('name', ''))
+                            rel = ModelRelation(parent = self, fromShape = layer,
+                                                toShape = data, param = p.get('name', ''))
                         layer.AddRelation(rel)
                         data.AddRelation(rel)
                         self.AddLine(rel)
@@ -1320,9 +1325,11 @@
                     data.Show(True)
                                                             
                     if p.get('age', 'old') == 'old':
-                        rel = ModelRelation(data, layer, p.get('name', ''))
+                        rel = ModelRelation(parent = self, fromShape = data,
+                                            toShape = layer, param = p.get('name', ''))
                     else:
-                        rel = ModelRelation(layer, data, p.get('name', ''))
+                        rel = ModelRelation(parent = self, fromShape = layer,
+                                            toShape = data, param = p.get('name', ''))
                     layer.AddRelation(rel)
                     data.AddRelation(rel)
                     self.AddLine(rel)
@@ -1485,7 +1492,7 @@
         loop.Clear()
         
         for item in items:
-            rel = ModelRelation(parent, item)
+            rel = ModelRelation(parent = self, fromShape = parent, toShape = item)
             dx = item.GetX() - parent.GetX()
             dy = item.GetY() - parent.GetY()
             loop.AddRelation(rel)
@@ -1497,7 +1504,7 @@
         
         # close loop
         item = loop.GetItems()[-1]
-        rel = ModelRelation(item, loop)
+        rel = ModelRelation(parent = self, fromShape = item, toShape = loop)
         loop.AddRelation(rel)
         self.AddLine(rel)
         dx = (item.GetX() - loop.GetX()) + loop.GetWidth() / 2 + 50
@@ -1532,7 +1539,8 @@
         dy     = condition.GetY()
         for branch in items.keys():
             for item in items[branch]:
-                rel = ModelRelation(parent, item)
+                rel = ModelRelation(parent = self, fromShape = parent,
+                                    toShape = item)
                 condition.AddRelation(rel)
                 self.AddLine(rel)
                 rel.MakeLineControlPoints(0)
@@ -1849,8 +1857,9 @@
     def SetParameterized(self, isparameterized):
         """!Set action parameterized"""
         self.isParameterized = isparameterized
-        self._setPen()
-
+        if self.parent.GetCanvas():                
+            self._setPen()
+        
     def IsParameterized(self):
         """!Check if action is parameterized"""
         return self.isParameterized
@@ -2142,7 +2151,8 @@
                 drel['from'] = shape
             elif drel['to'] is None:
                 drel['to'] = shape
-                rel = ModelRelation(drel['from'], drel['to'])
+                rel = ModelRelation(parent = self.frame, fromShape = drel['from'],
+                                    toShape = drel['to'])
                 dlg = ModelRelationDialog(parent = self.frame,
                                           shape = rel)
                 if dlg.IsValid():
@@ -2508,14 +2518,16 @@
 
 class ModelRelation(ogl.LineShape):
     """!Data - action relation"""
-    def __init__(self, fromShape, toShape, param = ''):
+    def __init__(self, parent, fromShape, toShape, param = ''):
         self.fromShape = fromShape
         self.toShape   = toShape
         self.param     = param
+        self.parent    = parent
         
         self._points    = None
         
-        ogl.LineShape.__init__(self)
+        if self.parent.GetCanvas():        
+            ogl.LineShape.__init__(self)
     
     def __del__(self):
         self.fromShape.rels.remove(self)

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2011-09-15 21:40:37 UTC (rev 48306)
+++ grass/trunk/gui/wxpython/wxgui.py	2011-09-15 21:42:53 UTC (rev 48307)
@@ -390,7 +390,7 @@
         
         win.Show()
         
-    def OnDone(self, returncode):
+    def OnDone(self, cmd, returncode):
         """Command execution finised"""
         if hasattr(self, "model"):
             self.model.DeleteIntermediateData(log = self.goutput)



More information about the grass-commit mailing list