[GRASS-SVN] r58518 - in grass/trunk/gui/wxpython: gmodeler gui_core
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Dec 24 04:07:21 PST 2013
Author: martinl
Date: 2013-12-24 04:07:21 -0800 (Tue, 24 Dec 2013)
New Revision: 58518
Added:
grass/trunk/gui/wxpython/gmodeler/giface.py
Modified:
grass/trunk/gui/wxpython/gmodeler/dialogs.py
grass/trunk/gui/wxpython/gmodeler/frame.py
grass/trunk/gui/wxpython/gmodeler/model.py
grass/trunk/gui/wxpython/gui_core/forms.py
Log:
wxGUI/modeler: implement GrassInterface class (just few issues related to forms.py)
Modified: grass/trunk/gui/wxpython/gmodeler/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/dialogs.py 2013-12-24 11:13:20 UTC (rev 58517)
+++ grass/trunk/gui/wxpython/gmodeler/dialogs.py 2013-12-24 12:07:21 UTC (rev 58518)
@@ -36,7 +36,6 @@
from core.gcmd import GError, EncodeString
from gui_core.dialogs import SimpleDialog, MapLayersDialogForModeler
from gui_core.prompt import GPromptSTC
-from gui_core.forms import CmdPanel
from gui_core.gselect import Select, ElementSelect
from gmodeler.model import *
from lmgr.menudata import LayerManagerMenuData
Modified: grass/trunk/gui/wxpython/gmodeler/frame.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/frame.py 2013-12-24 11:13:20 UTC (rev 58517)
+++ grass/trunk/gui/wxpython/gmodeler/frame.py 2013-12-24 12:07:21 UTC (rev 58518)
@@ -51,7 +51,7 @@
from gmodeler.toolbars import ModelerToolbar
from core.giface import Notification
from gui_core.pystc import PyStc
-
+from gmodeler.giface import GraphicalModelerGrassInterface
from gmodeler.model import *
from gmodeler.dialogs import *
@@ -1108,8 +1108,10 @@
self.frame.ModelChanged()
shape = self.GetShape()
if isinstance(shape, ModelAction):
- module = GUI(parent = self.frame, show = True).ParseCommand(shape.GetLog(string = False),
- completed = (self.frame.GetOptData, shape, shape.GetParams()))
+ gmodule = GUI(parent = self.frame, show = True,
+ giface = GraphicalModelerGrassInterface(self.frame.GetModel()))
+ module = gmodule.ParseCommand(shape.GetLog(string = False),
+ completed = (self.frame.GetOptData, shape, shape.GetParams()))
elif isinstance(shape, ModelData):
dlg = ModelDataDialog(parent = self.frame, shape = shape)
Added: grass/trunk/gui/wxpython/gmodeler/giface.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/giface.py (rev 0)
+++ grass/trunk/gui/wxpython/gmodeler/giface.py 2013-12-24 12:07:21 UTC (rev 58518)
@@ -0,0 +1,29 @@
+"""!
+ at package gmodeler.giface
+
+ at brief wxGUI Graphical Modeler GRASS interface
+
+Classes:
+ - giface::GraphicalModelerGrassInterface
+
+(C) 2013 by the GRASS Development Team
+
+This program is free software under the GNU General Public License
+(>=v2). Read the file COPYING that comes with GRASS for details.
+
+ at author Martin Landa <landa.martin gmail.com>
+"""
+
+class GraphicalModelerGrassInterface(object):
+ """!@implements core::giface::GrassInterface"""
+ def __init__(self, model):
+ self._model = model
+
+ def __getattr__(self, name):
+ return getattr(self._giface, name)
+
+ def GetLayerTree(self):
+ return None
+
+ def GetLayerList(self, prompt):
+ return self._model.GetMaps(prompt)
Property changes on: grass/trunk/gui/wxpython/gmodeler/giface.py
___________________________________________________________________
Added: svn:mime-type
+ text/x-python
Added: svn:eol-style
+ native
Modified: grass/trunk/gui/wxpython/gmodeler/model.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/model.py 2013-12-24 11:13:20 UTC (rev 58517)
+++ grass/trunk/gui/wxpython/gmodeler/model.py 2013-12-24 12:07:21 UTC (rev 58518)
@@ -48,6 +48,7 @@
from core.settings import UserSettings
from gui_core.forms import GUI, CmdPanel
from gui_core.widgets import GNotebook
+from gmodeler.giface import GraphicalModelerGrassInterface
from grass.script import core as grass
from grass.script import task as gtask
@@ -2285,7 +2286,8 @@
task.flags = params['flags']
task.params = params['params']
- panel = CmdPanel(parent = self, id = wx.ID_ANY, task = task)
+ panel = CmdPanel(parent = self, id = wx.ID_ANY, task = task,
+ giface = GraphicalModelerGrassInterface(self.parent.GetModel()))
self.tasks.append(task)
return panel
Modified: grass/trunk/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/forms.py 2013-12-24 11:13:20 UTC (rev 58517)
+++ grass/trunk/gui/wxpython/gui_core/forms.py 2013-12-24 12:07:21 UTC (rev 58518)
@@ -392,10 +392,6 @@
self.task = task_description
self.parent = parent # LayerTree | Modeler | None | ...
self._giface = giface
- if parent and parent.GetName() == 'Modeler':
- self.modeler = self.parent
- else:
- self.modeler = None
self.dialogClosing = Signal('TaskFrame.dialogClosing')
@@ -549,7 +545,7 @@
accelTable = wx.AcceleratorTable(accelTableList)
self.SetAcceleratorTable(accelTable)
- if self.parent and not self.modeler:
+ if self._giface and self._giface.GetLayerTree():
addLayer = False
for p in self.task.params:
if p.get('age', 'old') == 'new' and \
@@ -671,7 +667,7 @@
def OnApply(self, event):
"""!Apply the command"""
- if self.modeler:
+ if self._giface and hasattr(self._giface, "_model"):
cmd = self.createCmd(ignoreErrors = True, ignoreRequired = True)
else:
cmd = self.createCmd()
@@ -887,7 +883,7 @@
f['wxId'] = [ chk.GetId(), ]
chk.Bind(wx.EVT_CHECKBOX, self.OnSetValue)
- if self.parent.GetName() == 'MainFrame' and self.parent.modeler:
+ if self.parent.GetName() == 'MainFrame' and (self._giface and hasattr(self._giface, "_model")):
parChk = wx.CheckBox(parent = which_panel, id = wx.ID_ANY,
label = _("Parameterized in model"))
parChk.SetName('ModelParam')
@@ -1182,8 +1178,8 @@
element_dict = {'rast': 'strds', 'vect': 'stvds', 'rast3d': 'str3ds'}
elem = element_dict[type_param.get('default')]
- if self.parent.modeler:
- extraItems = {_('Graphical Modeler') : self.parent.modeler.GetModel().GetMaps(p.get('prompt'))}
+ if self._giface and hasattr(self._giface, "_model"):
+ extraItems = {_('Graphical Modeler') : self._giface.GetLayerList(p.get('prompt'))}
else:
extraItems = None
selection = gselect.Select(parent = which_panel, id = wx.ID_ANY,
@@ -1594,7 +1590,7 @@
if p.get('guidependency', ''):
cb.Bind(wx.EVT_COMBOBOX, self.OnUpdateSelection)
- if self.parent.GetName() == 'MainFrame' and self.parent.modeler:
+ if self.parent.GetName() == 'MainFrame' and (self._giface and hasattr(self._giface, "_model")):
parChk = wx.CheckBox(parent = which_panel, id = wx.ID_ANY,
label = _("Parameterized in model"))
parChk.SetName('ModelParam')
More information about the grass-commit
mailing list