[GRASS-SVN] r41593 - in grass/branches/develbranch_6/gui:
icons/grass2 wxpython/gui_modules wxpython/icons
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Mar 28 10:45:32 EDT 2010
Author: martinl
Date: 2010-03-28 10:45:32 -0400 (Sun, 28 Mar 2010)
New Revision: 41593
Added:
grass/branches/develbranch_6/gui/icons/grass2/layer-add.png
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
grass/branches/develbranch_6/gui/wxpython/icons/grass2_icons.py
grass/branches/develbranch_6/gui/wxpython/icons/grass_icons.py
grass/branches/develbranch_6/gui/wxpython/icons/icon.py
grass/branches/develbranch_6/gui/wxpython/icons/silk_icons.py
Log:
wxGUI/modeler: add action implemented
(merge r41590, r41591, r41592 from trunk)
Copied: grass/branches/develbranch_6/gui/icons/grass2/layer-add.png (from rev 41591, grass/trunk/gui/icons/grass2/layer-add.png)
===================================================================
(Binary files differ)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py 2010-03-28 14:42:42 UTC (rev 41592)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gdialogs.py 2010-03-28 14:45:32 UTC (rev 41593)
@@ -946,9 +946,9 @@
self.inputTitle = _("Input directory")
self.inputBox = wx.StaticBox(parent=self.panel, id=wx.ID_ANY,
- label=" %s " % self.inputTitle)
+ label=" %s " % self.inputTitle)
self.layerBox = wx.StaticBox(parent=self.panel, id=wx.ID_ANY,
- label=_(" List of %s layers ") % self.inputType.upper())
+ label=_(" List of %s layers ") % self.inputType.upper())
#
# input
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py 2010-03-28 14:42:42 UTC (rev 41592)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gmodeler.py 2010-03-28 14:45:32 UTC (rev 41593)
@@ -6,6 +6,8 @@
Classes:
- ModelFrame
- ModelCanvas
+ - ModelAction
+ - ModelSearchDialog
(C) 2010 by the GRASS Development Team
This program is free software under the GNU General Public License
@@ -15,6 +17,7 @@
"""
import os
+import shlex
import globalvar
if not os.getenv("GRASS_WXBUNDLED"):
@@ -25,6 +28,8 @@
import menu
import menudata
import toolbars
+import menuform
+import prompt
from grass.script import core as grass
@@ -40,7 +45,10 @@
"""
self.parent = parent
+ self.actions = list() # list of recoreded actions
+
wx.Frame.__init__(self, parent = parent, id = id, title = title, **kwargs)
+ self.SetName("Modeler")
self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
self.menubar = menu.Menu(parent = self, data = menudata.ModelerData())
@@ -57,7 +65,7 @@
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
self._layout()
- self.SetMinSize((400, 300))
+ self.SetMinSize((640, 480))
def _layout(self):
"""!Do layout"""
@@ -94,8 +102,30 @@
def OnAddAction(self, event):
"""!Add action to model"""
- pass
-
+ dlg = ModelSearchDialog(self)
+ dlg.CentreOnParent()
+
+ if dlg.ShowModal() == wx.CANCEL:
+ dlg.Destroy()
+ return
+
+ cmd = dlg.GetCmd()
+ dlg.Destroy()
+
+ action = ModelAction(self, cmd = cmd, x = 100, y = 100)
+ self.canvas.diagram.AddShape(action)
+ action.Show(True)
+
+ evthandler = ModelEvtHandler(self.statusbar,
+ self)
+ evthandler.SetShape(action)
+ evthandler.SetPreviousHandler(action.GetEventHandler())
+ action.SetEventHandler(evthandler)
+
+ self.actions.append(action)
+
+ self.canvas.Refresh()
+
def OnHelp(self, event):
"""!Display manual page"""
grass.run_command('g.manual',
@@ -111,10 +141,131 @@
self.SetDiagram(self.diagram)
self.diagram.SetCanvas(self)
+ self.SetScrollbars(20, 20, 1000/20, 1000/20)
+
+class ModelAction(ogl.RectangleShape):
+ """!Action class (GRASS module)"""
+ def __init__(self, parent, x, y, cmd = None, width = 100, height = 50):
+ self.parent = parent
+
+ ogl.RectangleShape.__init__(self, width, height)
+
+ # self.Draggable(True)
+ self.SetCanvas(self.parent)
+ self.SetX(x)
+ self.SetY(y)
+ self.SetPen(wx.BLACK_PEN)
+ self.SetBrush(wx.LIGHT_GREY_BRUSH)
+ if cmd and len(cmd) > 0:
+ self.AddText(cmd[0])
+ else:
+ self.AddText('<<module>>')
+
+class ModelEvtHandler(ogl.ShapeEvtHandler):
+ """!Model event handler class"""
+ def __init__(self, log, frame):
+ ogl.ShapeEvtHandler.__init__(self)
+ self.log = log
+ self.frame = frame
+
+ def OnLeftClick(self, x, y, keys = 0, attachment = 0):
+ """!Left mouse button pressed -> update statusbar"""
+ shape = self.GetShape()
+
+ def OnLeftDoubleClick(self, x, y, keys = 0, attachment = 0):
+ """!Left mouse button pressed (double-click) -> show properties"""
+ shape = self.GetShape()
+ module = menuform.GUI()
+ # module.ParseCommand(['r.buffer'],
+ # completed = (None , None, None),
+ # parentframe = self.frame, show = True)
+
+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):
+ """!Graphical modeler module search window
+
+ @param parent parent window
+ @param id window id
+ @param title window title
+
+ @param kwargs wx.Dialogs' arguments
+ """
+ self.parent = parent
+
+ wx.Dialog.__init__(self, parent = parent, id = id, title = title, **kwargs)
+ self.SetName("ModelerDialog")
+ self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
+
+ self.panel = wx.Panel(parent = self, id = wx.ID_ANY)
+
+ self.searchBy = wx.Choice(parent = self.panel, id = wx.ID_ANY,
+ choices = [_("description"),
+ _("keywords")])
+ self.search = wx.TextCtrl(parent = self.panel, id = wx.ID_ANY,
+ value = "", size = (-1, 25))
+ self.cmd_prompt = prompt.GPromptSTC(parent = self)
+
+ self.btnCancel = wx.Button(self.panel, wx.ID_CANCEL)
+ self.btnOk = wx.Button(self.panel, wx.ID_OK)
+ self.btnOk.SetDefault()
+
+ self._layout()
+
+ def _layout(self):
+ btnSizer = wx.StdDialogButtonSizer()
+ btnSizer.AddButton(self.btnCancel)
+ btnSizer.AddButton(self.btnOk)
+ btnSizer.Realize()
+
+ bodyBox = wx.StaticBox(parent=self.panel, id=wx.ID_ANY,
+ label=" %s " % _("Find GRASS module"))
+ bodySizer = wx.StaticBoxSizer(bodyBox, wx.VERTICAL)
+ searchSizer = wx.BoxSizer(wx.HORIZONTAL)
+
+ searchSizer.Add(item = self.searchBy,
+ proportion = 0, flag = wx.LEFT, border = 3)
+ searchSizer.Add(item = self.search,
+ proportion = 1, flag = wx.LEFT | wx.EXPAND, border = 3)
+
+ bodySizer.Add(item=searchSizer, proportion=0,
+ flag=wx.EXPAND | wx.ALL, border=1)
+ bodySizer.Add(item=self.cmd_prompt, proportion=1,
+ flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, border=3)
+
+ mainSizer = wx.BoxSizer(wx.VERTICAL)
+ mainSizer.Add(item=bodySizer, proportion=1,
+ flag=wx.EXPAND | wx.ALL, border=5)
+ mainSizer.Add(item=btnSizer, proportion=0,
+ flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5)
+
+ self.panel.SetSizer(mainSizer)
+ mainSizer.Fit(self.panel)
+
+ def GetPanel(self):
+ """!Get dialog panel"""
+ return self.panel
+
+ def GetCmd(self):
+ """!Get command"""
+ line = self.cmd_prompt.GetCurLine()[0].strip()
+ if len(line) == 0:
+ list()
+
+ try:
+ cmd = shlex.split(str(line))
+ except UnicodeError:
+ cmd = shlex.split(utils.EncodeString((line)))
+
+ return cmd
+
+ def OnOk(self, event):
+ self.Close()
+
def main():
app = wx.PySimpleApp()
frame = ModelFrame(parent = None)
- frame.CenterOnScreen()
+ # frame.CentreOnScreen()
frame.Show()
app.MainLoop()
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py 2010-03-28 14:42:42 UTC (rev 41592)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py 2010-03-28 14:45:32 UTC (rev 41593)
@@ -473,14 +473,17 @@
self.parent = parent # GMConsole
self.panel = self.parent.GetPanel()
- if self.parent.parent.GetName() != "LayerManager":
+ if self.parent.parent.GetName() not in ("LayerManager", "Modeler"):
self.standAlone = True
else:
self.standAlone = False
# dictionary of modules (description, keywords, ...)
if not self.standAlone:
- self.moduleDesc = parent.parent.menubar.GetData().GetModules()
+ if self.parent.parent.GetName() == 'Modeler':
+ self.moduleDesc = menudata.ManagerData().GetModules()
+ else:
+ self.moduleDesc = parent.parent.menubar.GetData().GetModules()
self.moduleList = self._getListOfModules()
self.mapList = self._getListOfMaps()
else:
@@ -748,7 +751,7 @@
usage, description = self.GetCommandUsage(cmd)
- self.CallTipSetBackground("PALE GREEN")
+ self.CallTipSetBackground("#f4f4d1")
self.CallTipSetForeground("BLACK")
self.CallTipShow(pos, usage + '\n\n' + description)
@@ -838,7 +841,12 @@
self.InsertText(pos,txt)
self.LineEnd()
- elif event.GetKeyCode() == wx.WXK_RETURN and self.AutoCompActive() == False:
+ elif event.GetKeyCode() == wx.WXK_RETURN and \
+ self.AutoCompActive() == False:
+ if self.parent.GetName() == "ModelerDialog":
+ self.parent.OnOk(None)
+ return
+
# Run command on line when <return> is pressed
# find the command to run
@@ -852,7 +860,7 @@
except UnicodeError:
cmd = shlex.split(utils.EncodeString((line)))
- #send the command list to the processor
+ # send the command list to the processor
self.parent.RunCmd(cmd)
# add command to history
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py 2010-03-28 14:42:42 UTC (rev 41592)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py 2010-03-28 14:45:32 UTC (rev 41593)
@@ -1387,6 +1387,7 @@
self.new = wx.NewId()
self.open = wx.NewId()
self.save = wx.NewId()
+ self.action = wx.NewId()
self.quit = wx.NewId()
# tool, label, bitmap, kind, shortHelp, longHelp, handler
@@ -1401,6 +1402,10 @@
wx.ITEM_NORMAL, Icons['modelSave'].GetLabel(), Icons['modelSave'].GetDesc(),
self.parent.OnModelSave),
('', '', '', '', '', '', ''),
+ (self.action, 'action', Icons['modelActionAdd'].GetBitmap(),
+ wx.ITEM_NORMAL, Icons['modelActionAdd'].GetLabel(), Icons['modelActionAdd'].GetDesc(),
+ self.parent.OnAddAction),
+ ('', '', '', '', '', '', ''),
(self.quit, 'quit', Icons['quit'].GetBitmap(),
wx.ITEM_NORMAL, Icons['quit'].GetLabel(), Icons['quit'].GetDesc(),
self.parent.OnCloseWindow),
Modified: grass/branches/develbranch_6/gui/wxpython/icons/grass2_icons.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/icons/grass2_icons.py 2010-03-28 14:42:42 UTC (rev 41592)
+++ grass/branches/develbranch_6/gui/wxpython/icons/grass2_icons.py 2010-03-28 14:45:32 UTC (rev 41593)
@@ -1,6 +1,7 @@
"""
New GRASS icon set
http://robert.szczepanek.pl/icons.php
+https://svn.osgeo.org/osgeo/graphics/toolbar-icons/24x24/
"""
__author__ = "Robert Szczepanek"
@@ -102,4 +103,6 @@
"grSettings" : 'settings.png',
# nviz
"nvizSettings" : 'settings.png',
+ # modeler
+ "modelActionAdd" : 'layer-add.png',
}
Modified: grass/branches/develbranch_6/gui/wxpython/icons/grass_icons.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/icons/grass_icons.py 2010-03-28 14:42:42 UTC (rev 41592)
+++ grass/branches/develbranch_6/gui/wxpython/icons/grass_icons.py 2010-03-28 14:45:32 UTC (rev 41593)
@@ -104,5 +104,7 @@
"grGcpReload" : 'gui-redraw.gif',
"grSettings" : 'edit-color.gif',
# nviz
- "nvizSettings" : 'edit-color.gif',
+ "nvizSettings" : 'edit-color.gif',
+ # modeler
+ "modelActionAdd" : wx.ART_ERROR,
}
Modified: grass/branches/develbranch_6/gui/wxpython/icons/icon.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/icons/icon.py 2010-03-28 14:42:42 UTC (rev 41592)
+++ grass/branches/develbranch_6/gui/wxpython/icons/icon.py 2010-03-28 14:45:32 UTC (rev 41593)
@@ -341,6 +341,8 @@
label=_("Load model from file (Ctrl+O)")),
"modelSave" : MetaIcon (img=Icons["fileSave"],
label=_("Save current model to file (Ctrl+S)")),
+ "modelActionAdd" : MetaIcon (img=Icons["modelActionAdd"],
+ label=_("Add action (GRASS module) to model")),
}
# testing ...
Modified: grass/branches/develbranch_6/gui/wxpython/icons/silk_icons.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/icons/silk_icons.py 2010-03-28 14:42:42 UTC (rev 41592)
+++ grass/branches/develbranch_6/gui/wxpython/icons/silk_icons.py 2010-03-28 14:45:32 UTC (rev 41593)
@@ -104,4 +104,6 @@
"grSettings" : 'color_swatch.png',
# nviz
"nvizSettings" : 'color_swatch.png',
+ # modeler
+ "modelActionAdd" : wx.ART_ERROR,
}
Property changes on: grass/branches/develbranch_6/gui/wxpython/icons/silk_icons.py
___________________________________________________________________
Modified: svn:mergeinfo
- /grass/trunk/gui/wxpython/icons/silk_icons.py:41584
+ /grass/trunk/gui/wxpython/icons/silk_icons.py:41584,41586-41587,41590-41592
More information about the grass-commit
mailing list