[GRASS-SVN] r41673 - in grass/trunk/gui/wxpython: . gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Apr 2 13:27:45 EDT 2010
Author: martinl
Date: 2010-04-02 13:27:44 -0400 (Fri, 02 Apr 2010)
New Revision: 41673
Modified:
grass/trunk/gui/wxpython/gui_modules/gmodeler.py
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/menuform.py
grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI/modeler: ModelDataDialog implemented
Modified: grass/trunk/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gmodeler.py 2010-04-02 15:36:18 UTC (rev 41672)
+++ grass/trunk/gui/wxpython/gui_modules/gmodeler.py 2010-04-02 17:27:44 UTC (rev 41673)
@@ -9,6 +9,7 @@
- ModelAction
- ModelSearchDialog
- ModelData
+ - ModelDataDialog
- ProcessModelFile
- WriteModelFile
@@ -44,9 +45,10 @@
import prompt
import utils
import goutput
+import gselect
from debug import Debug
from gcmd import GMessage
-
+from gdialogs import ElementDialog
from grass.script import core as grass
class ModelFrame(wx.Frame):
@@ -469,9 +471,11 @@
actionShape = self.actions[0]
if data['from'] is True:
self._addLine(dataShape, actionShape)
+ dataShape.AddAction(actionShape, direction = 'from')
elif data['from'] is False:
self._addLine(actionShape, dataShape)
-
+ dataShape.AddAction(actionShape, direction = 'to')
+
self.canvas.Refresh(True)
def WriteModelFile(self, filename):
@@ -566,6 +570,11 @@
def GetParams(self):
"""!Get dictionary of parameters"""
return self.params
+
+ def SetParams(self, params, cmd):
+ """!Set dictionary of parameters"""
+ self.params = params
+ self.cmd = cmd
class ModelData(ogl.EllipseShape):
"""!Data item class"""
@@ -574,6 +583,7 @@
self.name = name
self.value = value
self.prompt = prompt
+ self.propWin = None
self.actions = { 'from' : list(), 'to' : list() }
@@ -615,7 +625,21 @@
def GetValue(self):
"""!Get value"""
return self.value
-
+
+ def SetValue(self, value):
+ """!Set value"""
+ self.value = value
+ self.ClearText()
+ self.AddText(self.name)
+ self.AddText(self.value)
+ for direction in ('from', 'to'):
+ for action in self.actions[direction]:
+ task = menuform.GUI().ParseCommand(cmd = action.GetLog(string = False),
+ show = None)
+ task.set_param(self.name, self.value)
+ action.SetParams(params = task.get_options(),
+ cmd = task.getCmd(ignoreErrors = True))
+
def GetActions(self, direction):
"""!Get related actions
@@ -633,8 +657,61 @@
def GetPropDialog(self):
"""!Get properties dialog"""
- return None
-
+ return self.propWin
+
+ def SetPropDialog(self, win):
+ """!Get properties dialog"""
+ self.propWin = win
+
+class ModelDataDialog(ElementDialog):
+ """!Data item properties dialog"""
+ def __init__(self, parent, shape, id = wx.ID_ANY, title = _("Data properties"),
+ style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
+ self.parent = parent
+ self.shape = shape
+ prompt = shape.GetPrompt()
+
+ if prompt == 'raster':
+ label = _('Name of raster map:')
+ elif prompt == 'vector':
+ label = _('Name of vector map:')
+ else:
+ label = _('Name of element:')
+
+ ElementDialog.__init__(self, parent, title, label = label)
+
+ self.element = gselect.Select(parent = self.panel, id = wx.ID_ANY,
+ size = globalvar.DIALOG_GSELECT_SIZE,
+ type = prompt)
+
+ self.Bind(wx.EVT_BUTTON, self.OnOK, self.btnOK)
+ self.Bind(wx.EVT_BUTTON, self.OnCancel, self.btnCancel)
+
+ self.PostInit()
+
+ self._layout()
+ self.SetMinSize(self.GetSize())
+
+ def _layout(self):
+ """!Do layout"""
+ self.dataSizer.Add(self.element, proportion=0,
+ flag=wx.EXPAND | wx.ALL, border=1)
+
+ self.panel.SetSizer(self.sizer)
+ self.sizer.Fit(self)
+
+ def OnOK(self, event):
+ """!Ok pressed"""
+ self.shape.SetValue(self.GetElement())
+ self.parent.canvas.Refresh()
+ self.parent.SetStatusText('', 0)
+ self.OnCancel(event)
+
+ def OnCancel(self, event):
+ """!Cancel pressed"""
+ self.shape.SetPropDialog(None)
+ self.Destroy()
+
class ModelEvtHandler(ogl.ShapeEvtHandler):
"""!Model event handler class"""
def __init__(self, log, frame):
@@ -671,25 +748,61 @@
def OnLeftDoubleClick(self, x, y, keys = 0, attachment = 0):
"""!Left mouse button pressed (double-click) -> show properties"""
+ self.OnProperties()
+
+ def OnProperties(self, event = None):
+ """!Show properties dialog"""
self.frame.ModelChanged()
shape = self.GetShape()
win = shape.GetPropDialog()
- if isinstance(shape, ModelAction) and not win:
- module = menuform.GUI().ParseCommand(shape.cmd,
- completed = (self.frame.GetOptData, shape, None),
- parentframe = self.frame, show = True)
-
+ if not win:
+ if isinstance(shape, ModelAction):
+ module = menuform.GUI().ParseCommand(shape.cmd,
+ completed = (self.frame.GetOptData, shape, None),
+ parentframe = self.frame, show = True)
+ elif isinstance(shape, ModelData):
+ dlg = ModelDataDialog(parent = self.frame, shape = shape)
+ shape.SetPropDialog(dlg)
+ dlg.CentreOnParent()
+ dlg.Show()
+
elif win and not win.IsShown():
win.Show()
if win:
win.Raise()
-
+
def OnBeginDragLeft(self, x, y, keys = 0, attachment = 0):
+ """!Drag shape"""
self.frame.ModelChanged()
if self._previousHandler:
self._previousHandler.OnBeginDragLeft(x, y, keys, attachment)
+ def OnRightClick(self, x, y, keys = 0, attachment = 0):
+ """!Right click -> pop-up menu"""
+ if not hasattr (self, "popupID1"):
+ self.popupID1 = wx.NewId()
+ self.popupID2 = wx.NewId()
+
+ popupMenu = wx.Menu()
+
+ popupMenu.Append(self.popupID1, text=_('Remove'))
+ self.frame.Bind(wx.EVT_MENU, self.OnRemove, id = self.popupID1)
+
+ popupMenu.AppendSeparator()
+
+ popupMenu.Append(self.popupID2, text=_('Properties'))
+ self.frame.Bind(wx.EVT_MENU, self.OnProperties, id = self.popupID2)
+
+ self.frame.PopupMenu(popupMenu)
+ popupMenu.Destroy()
+
+ def OnRemove(self, event):
+ """!Remove shape"""
+ shape = self.GetShape()
+ self.frame.canvas.GetDiagram().RemoveShape(shape)
+ self.frame.canvas.Refresh()
+
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/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2010-04-02 15:36:18 UTC (rev 41672)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2010-04-02 17:27:44 UTC (rev 41673)
@@ -1258,8 +1258,7 @@
printmenu.Destroy()
def OnCloseWindow(self, event):
- """
- Window closed.
+ """!Window closed.
Also close associated layer tree page
"""
pgnum = None
@@ -1274,7 +1273,7 @@
if self.toolbars['nviz']:
self.toolbars['nviz'].OnExit()
-
+
if not self._layerManager:
self.Destroy()
elif self.page:
@@ -1283,8 +1282,7 @@
self.layerbook.DeletePage(pgnum)
def GetRender(self):
- """!
- Returns the current instance of render.Map()
+ """!Returns current instance of render.Map()
"""
return self.Map
Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py 2010-04-02 15:36:18 UTC (rev 41672)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py 2010-04-02 17:27:44 UTC (rev 41673)
@@ -485,6 +485,11 @@
key, value = opt.split('=', 1)
self.set_param(key, value)
+ def get_options(self):
+ """!Get options"""
+ return { 'flags' : self.flags,
+ 'params' : self.params }
+
class processTask:
"""!A ElementTree handler for the --interface-description output,
as defined in grass-interface.dtd. Extend or modify this and the
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2010-04-02 15:36:18 UTC (rev 41672)
+++ grass/trunk/gui/wxpython/wxgui.py 2010-04-02 17:27:44 UTC (rev 41673)
@@ -314,8 +314,7 @@
event.Skip()
def OnCBPageClosed(self, event):
- """
- Page of notebook closed
+ """!Page of notebook closed
Also close associated map display
"""
if UserSettings.Get(group='manager', key='askOnQuit', subkey='enabled'):
@@ -838,27 +837,26 @@
return True
- def OnWorkspaceClose(self, event=None):
+ def OnWorkspaceClose(self, event = None):
"""!Close file with workspace definition
-
+
If workspace has been modified ask user to save the changes.
"""
-
Debug.msg(4, "GMFrame.OnWorkspaceClose(): file=%s" % self.workspaceFile)
- self.workspaceFile = None
- self.SetTitle(self.baseTitle)
-
- displays = []
+
+ displays = list()
for page in range(0, self.gm_cb.GetPageCount()):
displays.append(self.gm_cb.GetPage(page).maptree.mapdisplay)
for display in displays:
display.OnCloseWindow(event)
+ self.workspaceFile = None
+ self.workspaceChanged = False
+ self.SetTitle(self.baseTitle)
self.disp_idx = 0
self.curr_page = None
-
def RulesCmd(self, event, cmd = ''):
"""
Launches dialog for commands that need rules
More information about the grass-commit
mailing list