[GRASS-SVN] r42196 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun May 9 14:33:19 EDT 2010
Author: martinl
Date: 2010-05-09 14:33:18 -0400 (Sun, 09 May 2010)
New Revision: 42196
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
Log:
wxGUI/modeler: implement remove
merge r42195 from trunk
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py 2010-05-09 18:27:39 UTC (rev 42195)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py 2010-05-09 18:33:18 UTC (rev 42196)
@@ -340,6 +340,11 @@
if self.modelFile:
self.SetTitle(self.baseTitle + " - " + os.path.basename(self.modelFile) + '*')
+
+ def OnRemoveItem(self, event):
+ """!Remove shape
+ """
+ self.GetCanvas().RemoveSelected()
def OnCloseWindow(self, event):
"""!Close window"""
@@ -790,10 +795,6 @@
return errList
- def OnRemoveItem(self, event):
- """!Remove item from model"""
- pass
-
def OnDefineRelation(self, event):
"""!Define relation between data and action items"""
self.canvas.SetCursor(self.cursors["cross"])
@@ -1035,6 +1036,7 @@
class ModelCanvas(ogl.ShapeCanvas):
"""!Canvas where model is drawn"""
def __init__(self, parent):
+ self.parent = parent
ogl.OGLInitialize()
ogl.ShapeCanvas.__init__(self, parent)
@@ -1044,6 +1046,28 @@
self.SetScrollbars(20, 20, 1000/20, 1000/20)
+ self.Bind(wx.EVT_CHAR, self.OnChar)
+
+ def OnChar(self, event):
+ """!Key pressed"""
+ kc = event.GetKeyCode()
+ diagram = self.GetDiagram()
+ if kc == wx.WXK_DELETE:
+ self.RemoveSelected()
+
+ def RemoveSelected(self):
+ """!Remove selected shapes"""
+ self.parent.ModelChanged()
+
+ diagram = self.GetDiagram()
+ for shape in diagram.GetShapeList():
+ if not shape.Selected():
+ continue
+ shape.Select(False)
+ diagram.RemoveShape(shape)
+
+ self.Refresh()
+
class ModelAction(ogl.RectangleShape):
"""!Action class (GRASS module)"""
def __init__(self, parent, x, y, cmd = None, width = None, height = None):
@@ -1484,22 +1508,9 @@
def OnRemove(self, event):
"""!Remove shape
-
- @todo complex remove
"""
- self.frame.ModelChanged()
- shapes = [self.GetShape()]
- for shape in shapes:
- if isinstance(shape, ModelAction):
- pass
- if isinstance(shape, ModelData):
- pass
-
- shape.Select(False)
- self.frame.canvas.GetDiagram().RemoveShape(shape)
+ self.frame.GetCanvas().RemoveSelected()
- self.frame.canvas.Refresh()
-
class ModelSearchDialog(wx.Dialog):
def __init__(self, parent, id = wx.ID_ANY, title = _("Select GRASS module"),
style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
More information about the grass-commit
mailing list