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

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Apr 14 20:08:33 EDT 2010


Author: martinl
Date: 2010-04-14 20:08:32 -0400 (Wed, 14 Apr 2010)
New Revision: 41876

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
Log:
wxGUI/modeler: implement ModelRelation class
(merge r41875 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2010-04-14 23:41:10 UTC (rev 41875)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py	2010-04-15 00:08:32 UTC (rev 41876)
@@ -10,6 +10,7 @@
  - ModelSearchDialog
  - ModelData
  - ModelDataDialog
+ - ModelRelation
  - ProcessModelFile
  - WriteModelFile
 
@@ -734,7 +735,7 @@
                     self.canvas.diagram.AddShape(data)
                     data.Show(True)
                     
-                    self._addEvent(data)                    
+                    self._addEvent(data)
                     self.data.append(data)
                     
                     if p.get('age', 'old') == 'old':
@@ -767,12 +768,13 @@
         @param fromShape from
         @param toShape to
         """
-        line = ogl.LineShape()
+        line = ModelRelation()
         line.SetCanvas(self)
         line.SetPen(wx.BLACK_PEN)
         line.SetBrush(wx.BLACK_BRUSH)
         line.AddArrow(ogl.ARROW_ARROW)
         line.MakeLineControlPoints(2)
+        self._addEvent(line)
         
         fromShape.AddLine(line, toShape)
         
@@ -1193,9 +1195,10 @@
                 s.Select(False, dc)
                 
         canvas.Refresh(False)
+
+        if hasattr(shape, "GetLog"):
+            self.log.SetStatusText(shape.GetLog(), 0)
         
-        self.log.SetStatusText(shape.GetLog(), 0)
-        
     def OnLeftDoubleClick(self, x, y, keys = 0, attachment = 0):
         """!Left mouse button pressed (double-click) -> show properties"""
         self.OnProperties()
@@ -1228,15 +1231,14 @@
             self.popupID2 = wx.NewId()
             self.popupID3 = wx.NewId()
 
+        shape = self.GetShape()
         popupMenu = wx.Menu()
         
         popupMenu.Append(self.popupID1, text=_('Remove'))
         self.frame.Bind(wx.EVT_MENU, self.OnRemove, id = self.popupID1)
         
-        popupMenu.AppendSeparator()
-
-        shape = self.GetShape()
         if isinstance(shape, ModelData) and '@' not in shape.GetValue():
+            popupMenu.AppendSeparator()
             popupMenu.Append(self.popupID3, text=_('Intermediate'),
                              kind = wx.ITEM_CHECK)
             if self.GetShape().IsIntermediate():
@@ -1244,10 +1246,11 @@
             
             self.frame.Bind(wx.EVT_MENU, self.OnIntermediate, id = self.popupID3)
             
+        if isinstance(shape, ModelData) or \
+                isinstance(shape, ModelAction):
             popupMenu.AppendSeparator()
-        
-        popupMenu.Append(self.popupID2, text=_('Properties'))
-        self.frame.Bind(wx.EVT_MENU, self.OnProperties, id = self.popupID2)
+            popupMenu.Append(self.popupID2, text=_('Properties'))
+            self.frame.Bind(wx.EVT_MENU, self.OnProperties, id = self.popupID2)
 
         self.frame.PopupMenu(popupMenu)
         popupMenu.Destroy()
@@ -1262,8 +1265,13 @@
     def OnRemove(self, event):
         """!Remove shape"""
         self.frame.ModelChanged()
-        shape = self.GetShape()
-        self.frame.canvas.GetDiagram().RemoveShape(shape)
+        shapes = [self.GetShape()]
+        if isinstance(shape, ModelAction):
+            pass
+        if isinstance(shape, ModelData):
+            pass
+        for shape in shapes:
+            self.frame.canvas.GetDiagram().RemoveShape(shape)
         self.frame.canvas.Refresh()
         
 class ModelSearchDialog(wx.Dialog):
@@ -1429,6 +1437,11 @@
         self.search.SetValue('')
         self.cmd_prompt.OnCmdErase(None)
 
+class ModelRelation(ogl.LineShape):
+    """!Data - action relation"""
+    def __init__(self):
+        ogl.LineShape.__init__(self)
+    
 class ProcessModelFile:
     """!Process GRASS model file (gxm)"""
     def __init__(self, tree):



More information about the grass-commit mailing list