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

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Sep 25 14:17:55 EDT 2010


Author: martinl
Date: 2010-09-25 18:17:55 +0000 (Sat, 25 Sep 2010)
New Revision: 43685

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
Log:
wxGUI/modeler: fix if/else statement objects


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2010-09-25 10:20:45 UTC (rev 43684)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2010-09-25 18:17:55 UTC (rev 43685)
@@ -1400,7 +1400,7 @@
             for p in params['params']:
                 if p.get('prompt', '') in ('raster', 'vector', 'raster3d') and \
                         (p.get('value', None) or \
-                             p.get('age', 'old') != 'old'):
+                             (p.get('age', 'old') != 'old' and p.get('required', 'no') == 'yes')):
                     data = layer.FindData(p.get('name', ''))
                     if data:
                         data.SetValue(p.get('value', ''))
@@ -1635,12 +1635,21 @@
         for rel in condition.GetRelations():
             self.canvas.GetDiagram().RemoveShape(rel)
         condition.Clear()
-
+        dxIf   = condition.GetX() + condition.GetWidth() / 2
+        dxElse = condition.GetX() - condition.GetWidth() / 2
+        dy     = condition.GetY()
         for branch in items.keys():
             for item in items[branch]:
                 rel = ModelRelation(parent, item)
                 condition.AddRelation(rel)
                 self.AddLine(rel)
+                rel.MakeLineControlPoints(0)
+                if branch == 'if':
+                    rel.InsertLineControlPoint(point = wx.RealPoint(item.GetX() - item.GetWidth() / 2, item.GetY()))
+                    rel.InsertLineControlPoint(point = wx.RealPoint(dxIf, dy))
+                else:
+                    rel.InsertLineControlPoint(point = wx.RealPoint(dxElse, dy))
+                    rel.InsertLineControlPoint(point = wx.RealPoint(item.GetX() - item.GetWidth() / 2, item.GetY()))
                 parent = item
         
         self.canvas.Refresh()
@@ -3619,14 +3628,14 @@
                     listmix.ListCtrlAutoWidthMixin,
                     listmix.TextEditMixin,
                     listmix.ColumnSorterMixin):
-    def __init__(self, parent, columns, excludeId = [], id = wx.ID_ANY,
+    def __init__(self, parent, columns, id = wx.ID_ANY,
                  style = wx.LC_REPORT | wx.BORDER_NONE |
                  wx.LC_SORT_ASCENDING |wx.LC_HRULES |
                  wx.LC_VRULES, **kwargs):
         """!List of model variables"""
         self.parent = parent
         self.columns = columns
-        self.excludeId = excludeId
+        self.shape = None
         try:
             self.frame  = parent.parent
         except AttributeError:
@@ -3987,7 +3996,7 @@
                                           window = self,
                                           columns = [_("ID"), _("Name"),
                                                      _("Command")],
-                                          excludeId = [shape.GetId()])
+                                          shape = shape)
         self.itemList.Populate(self.parent.GetModel().GetItems())
         
         self.btnCancel = wx.Button(parent = self.panel, id = wx.ID_CANCEL)
@@ -4116,12 +4125,11 @@
         self.list.OnReload(None)
         
 class ItemListCtrl(ModelListCtrl):
-    def __init__(self, parent, columns, excludeId = [], disablePopup = False, **kwargs):
+    def __init__(self, parent, columns, disablePopup = False, **kwargs):
         """!List of model actions"""
         self.disablePopup = disablePopup
-        self.excludeId = excludeId
-        
-        ModelListCtrl.__init__(self, parent, columns, excludeId, **kwargs)
+                
+        ModelListCtrl.__init__(self, parent, columns, **kwargs)
         self.SetColumnWidth(1, 100)
         self.SetColumnWidth(2, 65)
         
@@ -4136,30 +4144,36 @@
     def Populate(self, data):
         """!Populate the list"""
         self.itemDataMap = dict()
+        if self.shape:
+            if isinstance(self.shape, ModelCondition):
+                if self.GetName() == 'ElseBlockList':
+                    shapeItems = map(lambda x: x.GetId(), self.shape.GetItems()['else'])
+                else:
+                    shapeItems = map(lambda x: x.GetId(), self.shape.GetItems()['if'])
+            else:
+                shapeItems = map(lambda x: x.GetId(), self.shape.GetItems())
+        else:
+            shapeItems = list()
         i = 0
         if len(self.columns) == 3: # ItemCheckList
             checked = list()
         for action in data:
-            if action.GetId() in self.excludeId:
-                continue
             if len(self.columns) == 3:
                 self.itemDataMap[i] = [str(action.GetId()),
                                        action.GetName(),
                                        action.GetLog()]
                 aId = action.GetBlockId()
-                if len(aId) > 0:
-                    if aId[0] not in self.excludeId:
-                        aId = None
+                if action.GetId() in shapeItems:
+                    checked.append(aId)
                 else:
-                    aId = None
-                checked.append(aId)
+                    checked.append(None)
             else:
                 bId = action.GetBlockId()
                 if not bId:
                     bId = ''
                 self.itemDataMap[i] = [str(action.GetId()),
                                        action.GetName(),
-                                       str(bId),
+                                       ','.join(map(str, bId)),
                                        action.GetLog()]
             
             i += 1
@@ -4293,14 +4307,16 @@
         self.frame.ModelChanged()
 
 class ItemCheckListCtrl(ItemListCtrl, listmix.CheckListCtrlMixin):
-    def __init__(self, parent, columns, window = None, excludeId = [], **kwargs):
+    def __init__(self, parent, shape, columns, window = None, **kwargs):
         self.parent = parent
         self.window = window
         
-        ItemListCtrl.__init__(self, parent, columns, excludeId, disablePopup = True, **kwargs)
+        ItemListCtrl.__init__(self, parent, columns, disablePopup = True, **kwargs)
         listmix.CheckListCtrlMixin.__init__(self)
         self.SetColumnWidth(0, 50)
         
+        self.shape  = shape
+        
     def OnBeginEdit(self, event):
         """!Disable editing"""
         event.Veto()
@@ -4406,7 +4422,7 @@
                                               window = self,
                                               columns = [_("ID"), _("Name"),
                                                          _("Command")],
-                                              excludeId = [shape.GetId()])
+                                              shape = shape)
         self.itemListElse.SetName('ElseBlockList')
         self.itemListElse.Populate(self.parent.GetModel().GetItems())
         



More information about the grass-commit mailing list