[GRASS-SVN] r43354 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Aug 30 08:23:11 EDT 2010
Author: martinl
Date: 2010-08-30 12:23:11 +0000 (Mon, 30 Aug 2010)
New Revision: 43354
Modified:
grass/trunk/gui/wxpython/gui_modules/gmodeler.py
Log:
wxGUI/modeler: improvements in if-else statements
Modified: grass/trunk/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gmodeler.py 2010-08-30 11:32:15 UTC (rev 43353)
+++ grass/trunk/gui/wxpython/gui_modules/gmodeler.py 2010-08-30 12:23:11 UTC (rev 43354)
@@ -157,10 +157,12 @@
def RemoveItem(self, item):
"""!Remove item from model
-
- @return list of related items
+
+ @return list of related items to remove/update
"""
relList = list()
+ upList = list()
+
if not isinstance(item, ModelData):
self.items.remove(item)
@@ -168,8 +170,11 @@
for rel in item.GetRelations():
relList.append(rel)
data = rel.GetData()
- relList.append(data)
-
+ if len(data.GetRelations()) < 2:
+ relList.append(data)
+ else:
+ upList.append(data)
+
elif isinstance(item, ModelData):
for rel in item.GetRelations():
relList.append(rel)
@@ -178,7 +183,7 @@
else:
relList.append(rel.GetFrom())
- return relList
+ return relList, upList
def FindAction(self, aId):
"""!Find action by id"""
@@ -418,12 +423,9 @@
def Update(self):
"""!Update model"""
- for action in self.actions:
- action.Update()
+ for item in self.items:
+ item.Update()
- for data in self.data:
- data.Update()
-
def IsParameterized(self):
"""!Return True if model is parameterized"""
if self.Parameterize():
@@ -1633,11 +1635,16 @@
for shape in diagram.GetShapeList():
if not shape.Selected():
continue
- remList = self.parent.GetModel().RemoveItem(shape)
+ remList, upList = self.parent.GetModel().RemoveItem(shape)
shape.Select(False)
diagram.RemoveShape(shape)
+ del shape
for item in remList:
diagram.RemoveShape(item)
+ item.__del__()
+
+ for item in upList:
+ item.Update()
self.Refresh()
@@ -1649,6 +1656,9 @@
self.isEnabled = True
self.inBlock = None
+ def __del__(self):
+ pass
+
def GetId(self):
"""!Get id"""
return self.id
@@ -1895,9 +1905,10 @@
def FindData(self, name):
"""!Find data item by name"""
- for d in self.data:
- if name in d.GetName():
- return d
+ for rel in self.GetRelations():
+ data = rel.GetData()
+ if name == rel.GetName() and name in data.GetName():
+ return data
return None
@@ -1918,7 +1929,7 @@
class ModelData(ModelObject, ogl.EllipseShape):
def __init__(self, parent, x, y, value = '', prompt = '', width = None, height = None):
"""Data item class
-
+
@param parent window parent
@param x, y position of the shape
@param fname, tname list of parameter names from / to
@@ -1947,7 +1958,7 @@
self.SetPen(wx.BLACK_PEN)
self._setBrush()
- self.AddText(value)
+ self._setText()
def IsIntermediate(self):
"""!Checks if data item is intermediate"""
@@ -2072,7 +2083,10 @@
for rel in self.GetRelations():
name.append(rel.GetName())
self.AddText('/'.join(name))
- self.AddText(self.value)
+ if self.value:
+ self.AddText(self.value)
+ else:
+ self.AddText(_('<not defined>'))
def Update(self):
"""!Update action"""
@@ -2491,6 +2505,10 @@
ogl.LineShape.__init__(self)
+ def __del__(self):
+ self.fromShape.rels.remove(self)
+ self.toShape.rels.remove(self)
+
def GetFrom(self):
"""!Get id of 'from' shape"""
return self.fromShape
@@ -2498,7 +2516,7 @@
def GetTo(self):
"""!Get id of 'to' shape"""
return self.toShape
-
+
def GetData(self):
"""!Get related ModelData instance
More information about the grass-commit
mailing list