[GRASS-SVN] r41669 - in grass/branches/develbranch_6/gui/wxpython:
gui_modules xml
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Apr 2 09:05:36 EDT 2010
Author: martinl
Date: 2010-04-02 09:05:36 -0400 (Fri, 02 Apr 2010)
New Revision: 41669
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
grass/branches/develbranch_6/gui/wxpython/xml/menudata_modeler.xml
Log:
wxGUI/modeler: close model, track changes in model
(merge r41668 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-02 12:58:07 UTC (rev 41668)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py 2010-04-02 13:05:36 UTC (rev 41669)
@@ -65,6 +65,7 @@
self.data = list() # list of recorded data items
self.baseTitle = title
self.modelFile = None # loaded model
+ self.modelChanged = False
wx.Frame.__init__(self, parent = parent, id = id, title = title, **kwargs)
self.SetName("Modeler")
@@ -94,7 +95,8 @@
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
self._layout()
- self.SetMinSize((640, 480))
+ self.SetMinSize((350, 200))
+ self.SetSize((640, 480))
def _layout(self):
"""!Do layout"""
@@ -116,7 +118,15 @@
evthandler.SetShape(item)
evthandler.SetPreviousHandler(item.GetEventHandler())
item.SetEventHandler(evthandler)
+
+ def ModelChanged(self):
+ """!Update window title"""
+ if not self.modelChanged:
+ self.modelChanged = True
+ if self.modelFile:
+ self.SetTitle(self.baseTitle + " - " + os.path.basename(self.modelFile) + '*')
+
def OnCloseWindow(self, event):
"""!Close window"""
self.Destroy()
@@ -201,7 +211,20 @@
self.modelFile = filename
self.SetTitle(self.baseTitle + " - " + os.path.basename(self.modelFile))
self.SetStatusText(_('File <%s> saved') % self.modelFile, 0)
+
+ def OnModelClose(self, event):
+ """!Close model file"""
+ Debug.msg(4, "ModelFrame.OnModelClose(): file=%s" % self.modelFile)
+ self.modelFile = None
+ self.SetTitle(self.baseTitle)
+ self.canvas.GetDiagram().DeleteAllShapes()
+
+ self.actions = list()
+ self.data = list()
+
+ self.canvas.Refresh()
+
def OnRunModel(self, event):
"""!Run entire model"""
if len(self.actions) < 1:
@@ -282,6 +305,8 @@
cmd = self.searchDialog.GetCmd()
self.searchDialog.Hide()
+ self.ModelChanged()
+
# add action to canvas
width, height = self.canvas.GetSize()
action = ModelAction(self, cmd = cmd, x = width/2, y = height/2)
@@ -404,6 +429,9 @@
"Invalid file, unable to parse XML document.") % filename)
return
+ self.modelFile = filename
+ self.SetTitle(self.baseTitle + " - " + os.path.basename(self.modelFile))
+
busy = wx.BusyInfo(message=_("Please wait, loading model..."),
parent=self)
wx.Yield()
@@ -643,6 +671,7 @@
def OnLeftDoubleClick(self, x, y, keys = 0, attachment = 0):
"""!Left mouse button pressed (double-click) -> show properties"""
+ self.frame.ModelChanged()
shape = self.GetShape()
win = shape.GetPropDialog()
if isinstance(shape, ModelAction) and not win:
@@ -655,7 +684,12 @@
if win:
win.Raise()
-
+
+ def OnBeginDragLeft(self, x, y, keys = 0, attachment = 0):
+ self.frame.ModelChanged()
+ if self._previousHandler:
+ self._previousHandler.OnBeginDragLeft(x, y, keys, attachment)
+
class ModelSearchDialog(wx.Dialog):
def __init__(self, parent, id = wx.ID_ANY, title = _("Find GRASS module"),
style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
Modified: grass/branches/develbranch_6/gui/wxpython/xml/menudata_modeler.xml
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/xml/menudata_modeler.xml 2010-04-02 12:58:07 UTC (rev 41668)
+++ grass/branches/develbranch_6/gui/wxpython/xml/menudata_modeler.xml 2010-04-02 13:05:36 UTC (rev 41669)
@@ -26,6 +26,11 @@
<help>Save model to file</help>
<handler>OnModelSaveAs</handler>
</menuitem>
+ <menuitem>
+ <label>Close</label>
+ <help>Close model file</help>
+ <handler>OnModelClose</handler>
+ </menuitem>
<separator />
<menuitem>
<label>Close modeler</label>
More information about the grass-commit
mailing list