123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- """!
- @package gmodeler.py
- @brief Graphical modeler to create edit, and manage models
- Classes:
- - ModelFrame
- - ModelCanvas
- (C) 2010 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.
- @author Martin Landa <landa.martin gmail.com>
- """
- import os
- import globalvar
- if not os.getenv("GRASS_WXBUNDLED"):
- globalvar.CheckForWx()
- import wx
- import wx.lib.ogl as ogl
- import menu
- import menudata
- import toolbars
- from grass.script import core as grass
- class ModelFrame(wx.Frame):
- def __init__(self, parent, id = wx.ID_ANY, title = _("Graphical modeler (under development)"), **kwargs):
- """!Graphical modeler main window
-
- @param parent parent window
- @param id window id
- @param title window title
- @param kwargs wx.Frames' arguments
- """
- self.parent = parent
-
- wx.Frame.__init__(self, parent = parent, id = id, title = title, **kwargs)
- self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
-
- self.menubar = menu.Menu(parent = self, data = menudata.ModelerData())
- self.SetMenuBar(self.menubar)
-
- self.toolbar = toolbars.ModelToolbar(parent = self)
- self.SetToolBar(self.toolbar)
- self.statusbar = self.CreateStatusBar(number = 1)
-
- self.canvas = ModelCanvas(self)
- self.canvas.SetBackgroundColour(wx.WHITE)
-
- self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
-
- self._layout()
- self.SetMinSize((400, 300))
-
- def _layout(self):
- """!Do layout"""
- sizer = wx.BoxSizer(wx.VERTICAL)
- sizer.Add(item = self.canvas, proportion = 1,
- flag = wx.EXPAND)
-
- self.SetAutoLayout(True)
- self.SetSizer(sizer)
- sizer.Fit(self)
-
- self.Layout()
-
- def OnCloseWindow(self, event):
- """!Close window"""
- self.Destroy()
- def OnModelNew(self, event):
- """!Create new model"""
- pass
- def OnModelOpen(self, event):
- """!Load model from file"""
- pass
- def OnModelSave(self, event):
- """!Save model to file"""
- pass
- def OnModelSaveAs(self, event):
- """!Create model to file as"""
- pass
- def OnAddAction(self, event):
- """!Add action to model"""
- pass
- def OnHelp(self, event):
- """!Display manual page"""
- grass.run_command('g.manual',
- entry = 'wxGUI.Modeler')
-
- class ModelCanvas(ogl.ShapeCanvas):
- """!Canvas where model is drawn"""
- def __init__(self, parent):
- ogl.OGLInitialize()
- ogl.ShapeCanvas.__init__(self, parent)
-
- self.diagram = ogl.Diagram()
- self.SetDiagram(self.diagram)
- self.diagram.SetCanvas(self)
-
- def main():
- app = wx.PySimpleApp()
- frame = ModelFrame(parent = None)
- frame.CenterOnScreen()
- frame.Show()
-
- app.MainLoop()
-
- if __name__ == "__main__":
- main()
|