Browse Source

wxGUI major code reorganization (more fixes)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@49361 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 13 years ago
parent
commit
1a47754032

+ 0 - 2
gui/wxpython/core/utils.py

@@ -50,8 +50,6 @@ def GetTempfile(pref=None):
 
     @return Path to file name (string) or None
     """
-    from core import cmd as gcmd
-    
     ret = RunCommand('g.tempfile',
                      read = True,
                      pid = os.getpid())

+ 2 - 3
gui/wxpython/gcp/manager.py

@@ -39,11 +39,10 @@ from core              import globalvar
 from core              import utils
 from core.render       import Map
 from gui_core.gselect  import Select, LocationSelect, MapsetSelect
-from gui_core.gdialogs import GroupDialog
+from gui_core.dialogs  import GroupDialog
 from core.gcmd         import RunCommand, GMessage, GError, GWarning
 from core.settings     import UserSettings
-from gcp.mapdisp       import MapFrame
-from mapdisp.window    import BufferedWindow
+from gcp.mapdisplay    import MapFrame
 
 from location_wizard.wizard   import TitledPage as TitledPage
 

+ 9 - 9
gui/wxpython/gcp/mapdisp.py

@@ -22,15 +22,15 @@ from core import globalvar
 import wx
 import wx.aui
 
-from core.render      import EVT_UPDATE_PRGBAR
-from mapdisp.toolbars import MapToolbar
-from gcp.toolbars     import GCPDisplayToolbar, GCPManToolbar
-from mapdisp.gprint   import PrintOptions
-from core.gcmd        import GMessage
-from gui_core.dialogs import GetImageHandlers, ImageSizeDialog
-from gui_core.mapdisp import MapFrameBase
-from core.settings    import UserSettings
-from mapdisp.window   import BufferedWindow
+from core.render       import EVT_UPDATE_PRGBAR
+from mapdisp.toolbars  import MapToolbar
+from gcp.toolbars      import GCPDisplayToolbar, GCPManToolbar
+from mapdisp.gprint    import PrintOptions
+from core.gcmd         import GMessage
+from gui_core.dialogs  import GetImageHandlers, ImageSizeDialog
+from gui_core.mapdisp  import MapFrameBase
+from core.settings     import UserSettings
+from mapdisp.mapwindow import BufferedWindow
 
 import mapdisp.statusbar as sb
 

+ 3 - 1
gui/wxpython/gmodeler/dialogs.py

@@ -24,10 +24,12 @@ import os
 import wx
 
 from core                 import globalvar
+from core                 import utils
 from gui_core.widgets     import GNotebook
 from core.gcmd            import GError, EncodeString
 from gui_core.dialogs     import ElementDialog, MapLayersDialog
 from gui_core.ghelp       import SearchModuleWindow
+from gui_core.prompt      import GPromptSTC
 
 from grass.script import task as gtask
 
@@ -124,7 +126,7 @@ class ModelSearchDialog(wx.Dialog):
         self.cmdBox = wx.StaticBox(parent = self.panel, id = wx.ID_ANY,
                                    label=" %s " % _("Command"))
         
-        self.cmd_prompt = prompt.GPromptSTC(parent = self)
+        self.cmd_prompt = GPromptSTC(parent = self)
         self.search = SearchModuleWindow(parent = self.panel, cmdPrompt = self.cmd_prompt, showTip = True)
         wx.CallAfter(self.cmd_prompt.SetFocus)
         

+ 9 - 724
gui/wxpython/gmodeler/frame.py

@@ -7,20 +7,13 @@ Classes:
  - ModelToolbar
  - ModelFrame
  - ModelCanvas
- - ModelObject
- - ModelAction
- - ModelData
  - ModelEvtHandler
- - ModelRelation
  - ModelListCtrl
  - VariablePanel
  - ValiableListCtrl
- - ModelItem
- - ModelLoop
  - ItemPanel
  - ItemListCtrl
  - ItemCheckListCtrl
- - ModelCondition
 
 (C) 2010-2011 by the GRASS Development Team
 This program is free software under the GNU General Public License
@@ -39,7 +32,7 @@ import copy
 import re
 
 import wx
-import wx.lib.ogl             as ogl
+from wx.lib import ogl
 import wx.lib.flatnotebook    as FN
 import wx.lib.mixins.listctrl as listmix
 
@@ -53,6 +46,13 @@ from gui_core.preferences import PreferencesBaseDialog
 from core.settings        import UserSettings
 from core.menudata        import MenuData
 from gui_core.toolbars    import BaseToolbar
+from gui_core.menu        import Menu
+from gmodeler.menudata    import ModelerData
+from icons.icon           import Icons
+from gui_core.forms       import GUI
+
+from gmodeler.model       import *
+from gmodeler.dialogs     import *
 
 from grass.script import core as grass
 
@@ -1073,497 +1073,7 @@ class ModelCanvas(ogl.ShapeCanvas):
                 item.Update()
         
         self.Refresh()
-        
-class ModelObject:
-    def __init__(self, id = -1):
-        self.id   = id
-        self.rels = list() # list of ModelRelations
-        
-        self.isEnabled = True
-        self.inBlock   = list() # list of related loops/conditions
-        
-    def __del__(self):
-        pass
-    
-    def GetId(self):
-        """!Get id"""
-        return self.id
-    
-    def AddRelation(self, rel):
-        """!Record new relation
-        """
-        self.rels.append(rel)
-
-    def GetRelations(self, fdir = None):
-        """!Get list of relations
-        
-        @param fdir True for 'from'
-        """
-        if fdir is None:
-            return self.rels
-        
-        result = list()
-        for rel in self.rels:
-            if fdir == 'from':
-                if rel.GetFrom() == self:
-                    result.append(rel)
-            else:
-                if rel.GetTo() == self:
-                    result.append(rel)
-        
-        return result
-    
-    def IsEnabled(self):
-        """!Get True if action is enabled, otherwise False"""
-        return self.isEnabled
-    
-    def Enable(self, enabled = True):
-        """!Enable/disable action"""
-        self.isEnabled = enabled
-        self.Update()
-
-    def Update(self):
-        pass
-
-    def SetBlock(self, item):
-        """!Add object to the block (loop/condition)
-
-        @param item reference to ModelLoop or ModelCondition which
-        defines loops/condition
-        """
-        if item not in self.inBlock:
-            self.inBlock.append(item)
-        
-    def UnSetBlock(self, item):
-        """!Remove object from the block (loop/consition)
-
-        @param item reference to ModelLoop or ModelCondition which
-        defines loops/codition
-        """
-        if item in self.inBlock:
-            self.inBlock.remove(item)
-        
-    def GetBlock(self):
-        """!Get list of related ModelObject(s) which defines block
-        (loop/condition)
-
-        @return list of ModelObjects
-        """
-        return self.inBlock
-    
-    def GetBlockId(self):
-        """!Get list of related ids which defines block
-
-        @return list of ids
-        """
-        ret = list()
-        for mo in self.inBlock:
-            ret.append(mo.GetId())
-        
-        return ret
-    
-class ModelAction(ModelObject, ogl.RectangleShape):
-    """!Action class (GRASS module)"""
-    def __init__(self, parent, x, y, id = -1, cmd = None, task = None, width = None, height = None):
-        ModelObject.__init__(self, id)
-        
-        self.parent  = parent
-        self.task    = task
-        
-        if not width:
-            width = UserSettings.Get(group='modeler', key='action', subkey=('size', 'width'))
-        if not height:
-            height = UserSettings.Get(group='modeler', key='action', subkey=('size', 'height'))
-        
-        if cmd:
-            self.task = GUI(show = None).ParseCommand(cmd = cmd)
-        else:
-            if task:
-                self.task = task
-            else:
-                self.task = None
-        
-        self.propWin = None
-        
-        self.data = list()   # list of connected data items
-        
-        self.isValid = False
-        self.isParameterized = False
-        
-        if self.parent.GetCanvas():
-            ogl.RectangleShape.__init__(self, width, height)
-            
-            self.SetCanvas(self.parent)
-            self.SetX(x)
-            self.SetY(y)
-            self.SetPen(wx.BLACK_PEN)
-            self._setPen()
-            self._setBrush()
-            self.SetId(id)
-        
-        if self.task:
-            self.SetValid(self.task.get_options())
-        
-    def _setBrush(self, running = False):
-        """!Set brush"""
-        if running:
-            color = UserSettings.Get(group='modeler', key='action',
-                                     subkey=('color', 'running'))
-        elif not self.isEnabled:
-            color = UserSettings.Get(group='modeler', key='disabled',
-                                     subkey='color')
-        elif self.isValid:
-            color = UserSettings.Get(group='modeler', key='action',
-                                     subkey=('color', 'valid'))
-        else:
-            color = UserSettings.Get(group='modeler', key='action',
-                                     subkey=('color', 'invalid'))
-        
-        wxColor = wx.Color(color[0], color[1], color[2])
-        self.SetBrush(wx.Brush(wxColor))
-        
-    def _setPen(self):
-        """!Set pen"""
-        if self.isParameterized:
-            width = int(UserSettings.Get(group='modeler', key='action',
-                                         subkey=('width', 'parameterized')))
-        else:
-            width = int(UserSettings.Get(group='modeler', key='action',
-                                         subkey=('width', 'default')))
-        pen = self.GetPen()
-        pen.SetWidth(width)
-        self.SetPen(pen)
-
-    def SetId(self, id):
-        """!Set id"""
-        self.id = id
-        cmd = self.task.get_cmd(ignoreErrors = True)
-        if cmd and len(cmd) > 0:
-            self.ClearText()
-            self.AddText('(%d) %s' % (self.id, cmd[0]))
-        else:
-            self.AddText('(%d) <<%s>>' % (self.id, _("unknown")))
-        
-    def SetProperties(self, params, propwin):
-        """!Record properties dialog"""
-        self.task.params = params['params']
-        self.task.flags  = params['flags']
-        self.propWin = propwin
-
-    def GetPropDialog(self):
-        """!Get properties dialog"""
-        return self.propWin
-
-    def GetLog(self, string = True, substitute = None):
-        """!Get logging info
-
-        @param string True to get cmd as a string otherwise a list
-        @param substitute dictionary of parameter to substitute or None
-        """
-        cmd = self.task.get_cmd(ignoreErrors = True, ignoreRequired = True,
-                                ignoreDefault = False)
-        
-        # substitute variables
-        if substitute:
-            variables = []
-            if 'variables' in substitute:
-                for p in substitute['variables']['params']:
-                    variables.append(p.get('name', ''))
-            else:
-                variables = self.parent.GetVariables()
-            for variable in variables:
-                pattern= re.compile('%' + variable)
-                value = ''
-                if substitute and 'variables' in substitute:
-                    for p in substitute['variables']['params']:
-                        if variable == p.get('name', ''):
-                            if p.get('type', 'string') == 'string':
-                                value = p.get('value', '')
-                            else:
-                                value = str(p.get('value', ''))
-                            break
-                    
-                if not value:
-                    value = variables[variable].get('value', '')
-                
-                if not value:
-                    continue
-                
-                for idx in range(len(cmd)):
-                    if pattern.search(cmd[idx]):
-                        cmd[idx] = pattern.sub(value, cmd[idx])
-                        break
-                    idx += 1
-        
-        if string:
-            if cmd is None:
-                return ''
-            else:
-                return ' '.join(cmd)
-        
-        return cmd
-    
-    def GetName(self):
-        """!Get name"""
-        cmd = self.task.get_cmd(ignoreErrors = True)
-        if cmd and len(cmd) > 0:
-            return cmd[0]
-        
-        return _('unknown')
-
-    def GetParams(self, dcopy = False):
-        """!Get dictionary of parameters"""
-        if dcopy:
-            return copy.deepcopy(self.task.get_options())
-        
-        return self.task.get_options()
-
-    def GetTask(self):
-        """!Get grassTask instance"""
-        return self.task
-    
-    def SetParams(self, params):
-        """!Set dictionary of parameters"""
-        self.task.params = params['params']
-        self.task.flags  = params['flags']
-        
-    def MergeParams(self, params):
-        """!Merge dictionary of parameters"""
-        if 'flags' in params:
-            for f in params['flags']:
-                self.task.set_flag(f['name'],
-                                   f.get('value', False))
-        if 'params' in params:
-            for p in params['params']:
-                self.task.set_param(p['name'],
-                                    p.get('value', ''))
-        
-    def SetValid(self, options):
-        """!Set validity for action
-        
-        @param options dictionary with flags and params (gtask)
-        """
-        self.isValid = True
-        self.isParameterized = False
-        
-        for f in options['flags']:
-            if f.get('parameterized', False):
-                self.IsParameterized = True
-                break
-        
-        for p in options['params']:
-            if self.isValid and p.get('required', False) and \
-                    p.get('value', '') == '' and \
-                    p.get('default', '') == '':
-                self.isValid = False
-            if not self.isParameterized and p.get('parameterized', False):
-                self.isParameterized = True
-        
-        if self.parent.GetCanvas():
-            self._setBrush()
-            self._setPen()
-        
-    def IsValid(self):
-        """!Check validity (all required parameters set)"""
-        return self.isValid
-    
-    def IsParameterized(self):
-        """!Check if action is parameterized"""
-        return self.isParameterized
-    
-    def FindData(self, name):
-        """!Find data item by name"""
-        for rel in self.GetRelations():
-            data = rel.GetData()
-            if name == rel.GetName() and name in data.GetName():
-                return data
-        
-        return None
-
-    def Update(self, running = False):
-        """!Update action"""
-        if running:
-            self._setBrush(running = True)
-        else:
-            self._setBrush()
-        self._setPen()
-
-    def OnDraw(self, dc):
-        """!Draw action in canvas"""
-        self._setBrush()
-        self._setPen()
-        ogl.RectangleShape.OnDraw(self, dc)
-
-class ModelData(ModelObject, ogl.EllipseShape):
-    def __init__(self, parent, x, y, value = '', prompt = '', width = None, height = None):
-        """Data item class
-        
-        @param parent window parent
-        @param x, y   position of the shape
-        @param fname, tname list of parameter names from / to
-        @param value  value
-        @param prompt type of GIS element
-        @param width,height dimension of the shape
-        """
-        ModelObject.__init__(self)
-        
-        self.parent  = parent
-        self.value   = value
-        self.prompt  = prompt
-        self.intermediate = False
-        self.propWin = None
-        if not width:
-            width = UserSettings.Get(group='modeler', key='data', subkey=('size', 'width'))
-        if not height:
-            height = UserSettings.Get(group='modeler', key='data', subkey=('size', 'height'))
-        
-        if self.parent.GetCanvas():
-            ogl.EllipseShape.__init__(self, width, height)
-            
-            self.SetCanvas(self.parent)
-            self.SetX(x)
-            self.SetY(y)
-            self.SetPen(wx.BLACK_PEN)
-            self._setBrush()
-            
-            self._setText()
-            
-    def IsIntermediate(self):
-        """!Checks if data item is intermediate"""
-        return self.intermediate
-    
-    def SetIntermediate(self, im):
-        """!Set intermediate flag"""
-        self.intermediate = im
   
-    def OnDraw(self, dc):
-        pen = self.GetPen()
-        pen.SetWidth(1)
-        if self.intermediate:
-            pen.SetStyle(wx.SHORT_DASH)
-        else:
-            pen.SetStyle(wx.SOLID)
-        self.SetPen(pen)
-        
-        ogl.EllipseShape.OnDraw(self, dc)
-        
-    def GetLog(self, string = True):
-        """!Get logging info"""
-        name = list()
-        for rel in self.GetRelations():
-            name.append(rel.GetName())
-        if name:
-            return '/'.join(name) + '=' + self.value + ' (' + self.prompt + ')'
-        else:
-            return self.value + ' (' + self.prompt + ')'
-
-    def GetName(self):
-        """!Get list of names"""
-        name = list()
-        for rel in self.GetRelations():
-            name.append(rel.GetName())
-        
-        return name
-    
-    def GetPrompt(self):
-        """!Get prompt"""
-        return self.prompt
-
-    def SetPrompt(self, prompt):
-        """!Set prompt
-        
-        @param prompt
-        """
-        self.prompt = prompt
-        
-    def GetValue(self):
-        """!Get value"""
-        return self.value
-
-    def SetValue(self, value):
-        """!Set value
-
-        @param value
-        """
-        self.value = value
-        self._setText()
-        for direction in ('from', 'to'):
-            for rel in self.GetRelations(direction):
-                if direction == 'from':
-                    action = rel.GetTo()
-                else:
-                    action = rel.GetFrom()
-                
-                task = GUI(show = None).ParseCommand(cmd = action.GetLog(string = False))
-                task.set_param(rel.GetName(), self.value)
-                action.SetParams(params = task.get_options())
-        
-    def GetPropDialog(self):
-        """!Get properties dialog"""
-        return self.propWin
-
-    def SetPropDialog(self, win):
-        """!Get properties dialog"""
-        self.propWin = win
-
-    def _setBrush(self):
-        """!Set brush"""
-        if self.prompt == 'raster':
-            color = UserSettings.Get(group = 'modeler', key = 'data',
-                                     subkey = ('color', 'raster'))
-        elif self.prompt == 'raster3d':
-            color = UserSettings.Get(group = 'modeler', key = 'data',
-                                     subkey = ('color', 'raster3d'))
-        elif self.prompt == 'vector':
-            color = UserSettings.Get(group = 'modeler', key = 'data',
-                                     subkey = ('color', 'vector'))
-        else:
-            color = UserSettings.Get(group = 'modeler', key = 'action',
-                                     subkey = ('color', 'invalid'))
-        wxColor = wx.Color(color[0], color[1], color[2])
-        self.SetBrush(wx.Brush(wxColor))
-        
-    def _setPen(self):
-        """!Set pen"""
-        isParameterized = False
-        for rel in self.GetRelations('from'):
-            if rel.GetTo().IsParameterized():
-                isParameterized = True
-                break
-        if not isParameterized:
-            for rel in self.GetRelations('to'):
-                if rel.GetFrom().IsParameterized():
-                    isParameterized = True
-                    break
-
-        if isParameterized:
-            width = int(UserSettings.Get(group = 'modeler', key = 'action',
-                                         subkey = ('width', 'parameterized')))
-        else:
-            width = int(UserSettings.Get(group = 'modeler', key = 'action',
-                                         subkey = ('width', 'default')))
-        pen = self.GetPen()
-        pen.SetWidth(width)
-        self.SetPen(pen)
-        
-    def _setText(self):
-        """!Update text"""
-        self.ClearText()
-        name = []
-        for rel in self.GetRelations():
-            name.append(rel.GetName())
-        self.AddText('/'.join(name))
-        if self.value:
-            self.AddText(self.value)
-        else:
-            self.AddText(_('<not defined>'))
-        
-    def Update(self):
-        """!Update action"""
-        self._setBrush()
-        self._setPen()
-        self._setText()
-       
 class ModelEvtHandler(ogl.ShapeEvtHandler):
     """!Model event handler class"""
     def __init__(self, log, frame):
@@ -1815,80 +1325,7 @@ class ModelEvtHandler(ogl.ShapeEvtHandler):
         """
         self.frame.GetCanvas().RemoveSelected()
         self.frame.itemPanel.Update()
-        
-class ModelRelation(ogl.LineShape):
-    """!Data - action relation"""
-    def __init__(self, parent, fromShape, toShape, param = ''):
-        self.fromShape = fromShape
-        self.toShape   = toShape
-        self.param     = param
-        self.parent    = parent
-        
-        self._points    = None
-        
-        if self.parent.GetCanvas():        
-            ogl.LineShape.__init__(self)
-    
-    def __del__(self):
-        if self in self.fromShape.rels:
-            self.fromShape.rels.remove(self)
-        if self in self.toShape.rels:
-            self.toShape.rels.remove(self)
-        
-    def GetFrom(self):
-        """!Get id of 'from' shape"""
-        return self.fromShape
-    
-    def GetTo(self):
-        """!Get id of 'to' shape"""
-        return self.toShape
-    
-    def GetData(self):
-        """!Get related ModelData instance
-
-        @return ModelData instance
-        @return None if not found
-        """
-        if isinstance(self.fromShape, ModelData):
-            return self.fromShape
-        elif isinstance(self.toShape, ModelData):
-            return self.toShape
-        
-        return None
-    
-    def GetName(self):
-        """!Get parameter name"""
-        return self.param
-    
-    def ResetShapes(self):
-        """!Reset related objects"""
-        self.fromShape.ResetControlPoints()
-        self.toShape.ResetControlPoints()
-        self.ResetControlPoints()
-        
-    def SetControlPoints(self, points):
-        """!Set control points"""
-        self._points = points
-        
-    def GetControlPoints(self):
-        """!Get list of control points"""
-        return self._points
-    
-    def _setPen(self):
-        """!Set pen"""
-        pen = self.GetPen()
-        pen.SetWidth(1)
-        pen.SetStyle(wx.SOLID)
-        self.SetPen(pen)
-        
-    def OnDraw(self, dc):
-        """!Draw relation"""
-        self._setPen()
-        ogl.LineShape.OnDraw(self, dc)
-    
-    def SetName(self, param):
-        self.param = param
-        
+       
 class ModelListCtrl(wx.ListCtrl,
                     listmix.ListCtrlAutoWidthMixin,
                     listmix.TextEditMixin,
@@ -2209,104 +1646,6 @@ class VariableListCtrl(ModelListCtrl):
         
         self.PopupMenu(menu)
         menu.Destroy()
-        
-class ModelItem(ModelObject):
-    def __init__(self, parent, x, y, id = -1, width = None, height = None, text = '', items = []):
-        """!Abstract class for loops and conditions"""
-        ModelObject.__init__(self, id)
-        self.parent  = parent
-        self.text    = text
-        self.items   = items  # list of items in the loop
-        
-    def GetText(self):
-        """!Get loop text"""
-        return self.text
-
-    def GetItems(self):
-        """!Get items (id)"""
-        return self.items
-
-    def SetId(self, id):
-        """!Set loop id"""
-        self.id = id
-
-    def SetText(self, cond):
-        """!Set loop text (condition)"""
-        self.text = cond
-        self.ClearText()
-        self.AddText('(' + str(self.id) + ') ' + self.text)
-
-    def GetLog(self):
-        """!Get log info"""
-        if self.text:
-            return _("Condition: ") + self.text
-        else:
-            return _("Condition: not defined")
-
-    def AddRelation(self, rel):
-        """!Record relation"""
-        self.rels.append(rel)
-        
-    def Clear(self):
-        """!Clear object, remove rels"""
-        self.rels = list()
-   
-class ModelLoop(ModelItem, ogl.RectangleShape):
-    def __init__(self, parent, x, y, id = -1, width = None, height = None, text = '', items = []):
-        """!Defines a loop"""
-        ModelItem.__init__(self, parent, x, y, id, width, height, text, items)
-        
-        if not width:
-            width = UserSettings.Get(group='modeler', key='loop', subkey=('size', 'width'))
-        if not height:
-            height = UserSettings.Get(group='modeler', key='loop', subkey=('size', 'height'))
-        
-        if self.parent.GetCanvas():
-            ogl.RectangleShape.__init__(self, width, height)
-            
-            self.SetCanvas(self.parent)
-            self.SetX(x)
-            self.SetY(y)
-            self.SetPen(wx.BLACK_PEN)
-            self.SetCornerRadius(100)
-            if text:
-                self.AddText('(' + str(self.id) + ') ' + text)
-            else:
-                self.AddText('(' + str(self.id) + ')')
-        
-        self._setBrush()
-        
-    def _setBrush(self):
-        """!Set brush"""
-        if not self.isEnabled:
-            color = UserSettings.Get(group='modeler', key='disabled',
-                                     subkey='color')
-        else:
-            color = UserSettings.Get(group='modeler', key='loop',
-                                     subkey=('color', 'valid'))
-        
-        wxColor = wx.Color(color[0], color[1], color[2])
-        self.SetBrush(wx.Brush(wxColor))
-
-    def Enable(self, enabled = True):
-        """!Enable/disable action"""
-        for item in self.items:
-            if not isinstance(item, ModelAction):
-                continue
-            item.Enable(enabled)
-        
-        ModelObject.Enable(self, enabled)
-        
-    def Update(self):
-        self._setBrush()
-        
-    def GetName(self):
-        """!Get name"""
-        return _("loop")
-    
-    def SetItems(self, items):
-        """!Set items (id)"""
-        self.items = items
 
 class ItemPanel(wx.Panel):
     def __init__(self, parent, id = wx.ID_ANY,
@@ -2575,60 +1914,6 @@ class ItemCheckListCtrl(ItemListCtrl, listmix.CheckListCtrlMixin):
                 self.CheckItem(i, flag)
                 break
         
-class ModelCondition(ModelItem, ogl.PolygonShape):
-    def __init__(self, parent, x, y, id = -1, width = None, height = None, text = '',
-                 items = { 'if' : [], 'else' : [] }):
-        """!Defines a if-else condition"""
-        ModelItem.__init__(self, parent, x, y, id, width, height, text, items)
-        
-        if not width:
-            self.width = UserSettings.Get(group='modeler', key='if-else', subkey=('size', 'width'))
-        else:
-            self.width = width
-        if not height:
-            self.height = UserSettings.Get(group='modeler', key='if-else', subkey=('size', 'height'))
-        else:
-            self.height = height
-        
-        if self.parent.GetCanvas():
-            ogl.PolygonShape.__init__(self)
-            
-            points = [(0, - self.height / 2),
-                      (self.width / 2, 0),
-                      (0, self.height / 2),
-                      (- self.width / 2, 0)]
-            self.Create(points)
-            
-            self.SetCanvas(self.parent)
-            self.SetX(x)
-            self.SetY(y)
-            self.SetPen(wx.BLACK_PEN)
-            if text:
-                self.AddText('(' + str(self.id) + ') ' + text)
-            else:
-                self.AddText('(' + str(self.id) + ')')
-
-    def GetName(self):
-        """!Get name"""
-        return _("if-else")
-
-    def GetWidth(self):
-        """!Get object width"""
-        return self.width
-
-    def GetHeight(self):
-        """!Get object height"""
-        return self.height
-
-    def SetItems(self, items, branch = 'if'):
-        """!Set items (id)
-
-        @param items list of items
-        @param branch 'if' / 'else'
-        """
-        if branch in ['if', 'else']:
-            self.items[branch] = items
-        
 def main():
     import gettext
     gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)

+ 726 - 2
gui/wxpython/gmodeler/model.py

@@ -5,6 +5,13 @@
 
 Classes:
  - Model
+ - ModelObject
+ - ModelAction
+ - ModelData
+ - ModelRelation
+ - ModelItem
+ - ModelLoop
+ - ModelCondition
 
 (C) 2010-2011 by the GRASS Development Team
 This program is free software under the GNU General Public License
@@ -23,9 +30,11 @@ except ImportError:
     import elementtree.ElementTree as etree # Python <= 2.4
 
 import wx
+from wx.lib import ogl
 
-from core.globalvar import ETCWXDIR
-from core.gcmd      import GMessage, GException, GError, RunCommand
+from core.globalvar   import ETCWXDIR
+from core.gcmd        import GMessage, GException, GError, RunCommand
+from gmodeler.dialogs import ModelParamDialog
 
 from grass.script import core as grass
 from grass.script import task as gtask
@@ -729,3 +738,718 @@ class Model(object):
         self.variablesParams = result # record parameters
         
         return result
+
+class ModelObject:
+    def __init__(self, id = -1):
+        self.id   = id
+        self.rels = list() # list of ModelRelations
+        
+        self.isEnabled = True
+        self.inBlock   = list() # list of related loops/conditions
+        
+    def __del__(self):
+        pass
+    
+    def GetId(self):
+        """!Get id"""
+        return self.id
+    
+    def AddRelation(self, rel):
+        """!Record new relation
+        """
+        self.rels.append(rel)
+
+    def GetRelations(self, fdir = None):
+        """!Get list of relations
+        
+        @param fdir True for 'from'
+        """
+        if fdir is None:
+            return self.rels
+        
+        result = list()
+        for rel in self.rels:
+            if fdir == 'from':
+                if rel.GetFrom() == self:
+                    result.append(rel)
+            else:
+                if rel.GetTo() == self:
+                    result.append(rel)
+        
+        return result
+    
+    def IsEnabled(self):
+        """!Get True if action is enabled, otherwise False"""
+        return self.isEnabled
+    
+    def Enable(self, enabled = True):
+        """!Enable/disable action"""
+        self.isEnabled = enabled
+        self.Update()
+
+    def Update(self):
+        pass
+
+    def SetBlock(self, item):
+        """!Add object to the block (loop/condition)
+
+        @param item reference to ModelLoop or ModelCondition which
+        defines loops/condition
+        """
+        if item not in self.inBlock:
+            self.inBlock.append(item)
+        
+    def UnSetBlock(self, item):
+        """!Remove object from the block (loop/consition)
+
+        @param item reference to ModelLoop or ModelCondition which
+        defines loops/codition
+        """
+        if item in self.inBlock:
+            self.inBlock.remove(item)
+        
+    def GetBlock(self):
+        """!Get list of related ModelObject(s) which defines block
+        (loop/condition)
+
+        @return list of ModelObjects
+        """
+        return self.inBlock
+    
+    def GetBlockId(self):
+        """!Get list of related ids which defines block
+
+        @return list of ids
+        """
+        ret = list()
+        for mo in self.inBlock:
+            ret.append(mo.GetId())
+        
+        return ret
+    
+class ModelAction(ModelObject, ogl.RectangleShape):
+    """!Action class (GRASS module)"""
+    def __init__(self, parent, x, y, id = -1, cmd = None, task = None, width = None, height = None):
+        ModelObject.__init__(self, id)
+        
+        self.parent  = parent
+        self.task    = task
+        
+        if not width:
+            width = UserSettings.Get(group='modeler', key='action', subkey=('size', 'width'))
+        if not height:
+            height = UserSettings.Get(group='modeler', key='action', subkey=('size', 'height'))
+        
+        if cmd:
+            self.task = GUI(show = None).ParseCommand(cmd = cmd)
+        else:
+            if task:
+                self.task = task
+            else:
+                self.task = None
+        
+        self.propWin = None
+        
+        self.data = list()   # list of connected data items
+        
+        self.isValid = False
+        self.isParameterized = False
+        
+        if self.parent.GetCanvas():
+            ogl.RectangleShape.__init__(self, width, height)
+            
+            self.SetCanvas(self.parent)
+            self.SetX(x)
+            self.SetY(y)
+            self.SetPen(wx.BLACK_PEN)
+            self._setPen()
+            self._setBrush()
+            self.SetId(id)
+        
+        if self.task:
+            self.SetValid(self.task.get_options())
+        
+    def _setBrush(self, running = False):
+        """!Set brush"""
+        if running:
+            color = UserSettings.Get(group='modeler', key='action',
+                                     subkey=('color', 'running'))
+        elif not self.isEnabled:
+            color = UserSettings.Get(group='modeler', key='disabled',
+                                     subkey='color')
+        elif self.isValid:
+            color = UserSettings.Get(group='modeler', key='action',
+                                     subkey=('color', 'valid'))
+        else:
+            color = UserSettings.Get(group='modeler', key='action',
+                                     subkey=('color', 'invalid'))
+        
+        wxColor = wx.Color(color[0], color[1], color[2])
+        self.SetBrush(wx.Brush(wxColor))
+        
+    def _setPen(self):
+        """!Set pen"""
+        if self.isParameterized:
+            width = int(UserSettings.Get(group='modeler', key='action',
+                                         subkey=('width', 'parameterized')))
+        else:
+            width = int(UserSettings.Get(group='modeler', key='action',
+                                         subkey=('width', 'default')))
+        pen = self.GetPen()
+        pen.SetWidth(width)
+        self.SetPen(pen)
+
+    def SetId(self, id):
+        """!Set id"""
+        self.id = id
+        cmd = self.task.get_cmd(ignoreErrors = True)
+        if cmd and len(cmd) > 0:
+            self.ClearText()
+            self.AddText('(%d) %s' % (self.id, cmd[0]))
+        else:
+            self.AddText('(%d) <<%s>>' % (self.id, _("unknown")))
+        
+    def SetProperties(self, params, propwin):
+        """!Record properties dialog"""
+        self.task.params = params['params']
+        self.task.flags  = params['flags']
+        self.propWin = propwin
+
+    def GetPropDialog(self):
+        """!Get properties dialog"""
+        return self.propWin
+
+    def GetLog(self, string = True, substitute = None):
+        """!Get logging info
+
+        @param string True to get cmd as a string otherwise a list
+        @param substitute dictionary of parameter to substitute or None
+        """
+        cmd = self.task.get_cmd(ignoreErrors = True, ignoreRequired = True,
+                                ignoreDefault = False)
+        
+        # substitute variables
+        if substitute:
+            variables = []
+            if 'variables' in substitute:
+                for p in substitute['variables']['params']:
+                    variables.append(p.get('name', ''))
+            else:
+                variables = self.parent.GetVariables()
+            for variable in variables:
+                pattern= re.compile('%' + variable)
+                value = ''
+                if substitute and 'variables' in substitute:
+                    for p in substitute['variables']['params']:
+                        if variable == p.get('name', ''):
+                            if p.get('type', 'string') == 'string':
+                                value = p.get('value', '')
+                            else:
+                                value = str(p.get('value', ''))
+                            break
+                    
+                if not value:
+                    value = variables[variable].get('value', '')
+                
+                if not value:
+                    continue
+                
+                for idx in range(len(cmd)):
+                    if pattern.search(cmd[idx]):
+                        cmd[idx] = pattern.sub(value, cmd[idx])
+                        break
+                    idx += 1
+        
+        if string:
+            if cmd is None:
+                return ''
+            else:
+                return ' '.join(cmd)
+        
+        return cmd
+    
+    def GetName(self):
+        """!Get name"""
+        cmd = self.task.get_cmd(ignoreErrors = True)
+        if cmd and len(cmd) > 0:
+            return cmd[0]
+        
+        return _('unknown')
+
+    def GetParams(self, dcopy = False):
+        """!Get dictionary of parameters"""
+        if dcopy:
+            return copy.deepcopy(self.task.get_options())
+        
+        return self.task.get_options()
+
+    def GetTask(self):
+        """!Get grassTask instance"""
+        return self.task
+    
+    def SetParams(self, params):
+        """!Set dictionary of parameters"""
+        self.task.params = params['params']
+        self.task.flags  = params['flags']
+        
+    def MergeParams(self, params):
+        """!Merge dictionary of parameters"""
+        if 'flags' in params:
+            for f in params['flags']:
+                self.task.set_flag(f['name'],
+                                   f.get('value', False))
+        if 'params' in params:
+            for p in params['params']:
+                self.task.set_param(p['name'],
+                                    p.get('value', ''))
+        
+    def SetValid(self, options):
+        """!Set validity for action
+        
+        @param options dictionary with flags and params (gtask)
+        """
+        self.isValid = True
+        self.isParameterized = False
+        
+        for f in options['flags']:
+            if f.get('parameterized', False):
+                self.IsParameterized = True
+                break
+        
+        for p in options['params']:
+            if self.isValid and p.get('required', False) and \
+                    p.get('value', '') == '' and \
+                    p.get('default', '') == '':
+                self.isValid = False
+            if not self.isParameterized and p.get('parameterized', False):
+                self.isParameterized = True
+        
+        if self.parent.GetCanvas():
+            self._setBrush()
+            self._setPen()
+        
+    def IsValid(self):
+        """!Check validity (all required parameters set)"""
+        return self.isValid
+    
+    def IsParameterized(self):
+        """!Check if action is parameterized"""
+        return self.isParameterized
+    
+    def FindData(self, name):
+        """!Find data item by name"""
+        for rel in self.GetRelations():
+            data = rel.GetData()
+            if name == rel.GetName() and name in data.GetName():
+                return data
+        
+        return None
+
+    def Update(self, running = False):
+        """!Update action"""
+        if running:
+            self._setBrush(running = True)
+        else:
+            self._setBrush()
+        self._setPen()
+
+    def OnDraw(self, dc):
+        """!Draw action in canvas"""
+        self._setBrush()
+        self._setPen()
+        ogl.RectangleShape.OnDraw(self, dc)
+
+class ModelData(ModelObject, ogl.EllipseShape):
+    def __init__(self, parent, x, y, value = '', prompt = '', width = None, height = None):
+        """Data item class
+        
+        @param parent window parent
+        @param x, y   position of the shape
+        @param fname, tname list of parameter names from / to
+        @param value  value
+        @param prompt type of GIS element
+        @param width,height dimension of the shape
+        """
+        ModelObject.__init__(self)
+        
+        self.parent  = parent
+        self.value   = value
+        self.prompt  = prompt
+        self.intermediate = False
+        self.propWin = None
+        if not width:
+            width = UserSettings.Get(group='modeler', key='data', subkey=('size', 'width'))
+        if not height:
+            height = UserSettings.Get(group='modeler', key='data', subkey=('size', 'height'))
+        
+        if self.parent.GetCanvas():
+            ogl.EllipseShape.__init__(self, width, height)
+            
+            self.SetCanvas(self.parent)
+            self.SetX(x)
+            self.SetY(y)
+            self.SetPen(wx.BLACK_PEN)
+            self._setBrush()
+            
+            self._setText()
+            
+    def IsIntermediate(self):
+        """!Checks if data item is intermediate"""
+        return self.intermediate
+    
+    def SetIntermediate(self, im):
+        """!Set intermediate flag"""
+        self.intermediate = im
+  
+    def OnDraw(self, dc):
+        pen = self.GetPen()
+        pen.SetWidth(1)
+        if self.intermediate:
+            pen.SetStyle(wx.SHORT_DASH)
+        else:
+            pen.SetStyle(wx.SOLID)
+        self.SetPen(pen)
+        
+        ogl.EllipseShape.OnDraw(self, dc)
+        
+    def GetLog(self, string = True):
+        """!Get logging info"""
+        name = list()
+        for rel in self.GetRelations():
+            name.append(rel.GetName())
+        if name:
+            return '/'.join(name) + '=' + self.value + ' (' + self.prompt + ')'
+        else:
+            return self.value + ' (' + self.prompt + ')'
+
+    def GetName(self):
+        """!Get list of names"""
+        name = list()
+        for rel in self.GetRelations():
+            name.append(rel.GetName())
+        
+        return name
+    
+    def GetPrompt(self):
+        """!Get prompt"""
+        return self.prompt
+
+    def SetPrompt(self, prompt):
+        """!Set prompt
+        
+        @param prompt
+        """
+        self.prompt = prompt
+        
+    def GetValue(self):
+        """!Get value"""
+        return self.value
+
+    def SetValue(self, value):
+        """!Set value
+
+        @param value
+        """
+        self.value = value
+        self._setText()
+        for direction in ('from', 'to'):
+            for rel in self.GetRelations(direction):
+                if direction == 'from':
+                    action = rel.GetTo()
+                else:
+                    action = rel.GetFrom()
+                
+                task = GUI(show = None).ParseCommand(cmd = action.GetLog(string = False))
+                task.set_param(rel.GetName(), self.value)
+                action.SetParams(params = task.get_options())
+        
+    def GetPropDialog(self):
+        """!Get properties dialog"""
+        return self.propWin
+
+    def SetPropDialog(self, win):
+        """!Get properties dialog"""
+        self.propWin = win
+
+    def _setBrush(self):
+        """!Set brush"""
+        if self.prompt == 'raster':
+            color = UserSettings.Get(group = 'modeler', key = 'data',
+                                     subkey = ('color', 'raster'))
+        elif self.prompt == 'raster3d':
+            color = UserSettings.Get(group = 'modeler', key = 'data',
+                                     subkey = ('color', 'raster3d'))
+        elif self.prompt == 'vector':
+            color = UserSettings.Get(group = 'modeler', key = 'data',
+                                     subkey = ('color', 'vector'))
+        else:
+            color = UserSettings.Get(group = 'modeler', key = 'action',
+                                     subkey = ('color', 'invalid'))
+        wxColor = wx.Color(color[0], color[1], color[2])
+        self.SetBrush(wx.Brush(wxColor))
+        
+    def _setPen(self):
+        """!Set pen"""
+        isParameterized = False
+        for rel in self.GetRelations('from'):
+            if rel.GetTo().IsParameterized():
+                isParameterized = True
+                break
+        if not isParameterized:
+            for rel in self.GetRelations('to'):
+                if rel.GetFrom().IsParameterized():
+                    isParameterized = True
+                    break
+
+        if isParameterized:
+            width = int(UserSettings.Get(group = 'modeler', key = 'action',
+                                         subkey = ('width', 'parameterized')))
+        else:
+            width = int(UserSettings.Get(group = 'modeler', key = 'action',
+                                         subkey = ('width', 'default')))
+        pen = self.GetPen()
+        pen.SetWidth(width)
+        self.SetPen(pen)
+        
+    def _setText(self):
+        """!Update text"""
+        self.ClearText()
+        name = []
+        for rel in self.GetRelations():
+            name.append(rel.GetName())
+        self.AddText('/'.join(name))
+        if self.value:
+            self.AddText(self.value)
+        else:
+            self.AddText(_('<not defined>'))
+        
+    def Update(self):
+        """!Update action"""
+        self._setBrush()
+        self._setPen()
+        self._setText()
+
+class ModelRelation(ogl.LineShape):
+    """!Data - action relation"""
+    def __init__(self, parent, fromShape, toShape, param = ''):
+        self.fromShape = fromShape
+        self.toShape   = toShape
+        self.param     = param
+        self.parent    = parent
+        
+        self._points    = None
+        
+        if self.parent.GetCanvas():        
+            ogl.LineShape.__init__(self)
+    
+    def __del__(self):
+        if self in self.fromShape.rels:
+            self.fromShape.rels.remove(self)
+        if self in self.toShape.rels:
+            self.toShape.rels.remove(self)
+        
+    def GetFrom(self):
+        """!Get id of 'from' shape"""
+        return self.fromShape
+    
+    def GetTo(self):
+        """!Get id of 'to' shape"""
+        return self.toShape
+    
+    def GetData(self):
+        """!Get related ModelData instance
+
+        @return ModelData instance
+        @return None if not found
+        """
+        if isinstance(self.fromShape, ModelData):
+            return self.fromShape
+        elif isinstance(self.toShape, ModelData):
+            return self.toShape
+        
+        return None
+    
+    def GetName(self):
+        """!Get parameter name"""
+        return self.param
+    
+    def ResetShapes(self):
+        """!Reset related objects"""
+        self.fromShape.ResetControlPoints()
+        self.toShape.ResetControlPoints()
+        self.ResetControlPoints()
+        
+    def SetControlPoints(self, points):
+        """!Set control points"""
+        self._points = points
+        
+    def GetControlPoints(self):
+        """!Get list of control points"""
+        return self._points
+    
+    def _setPen(self):
+        """!Set pen"""
+        pen = self.GetPen()
+        pen.SetWidth(1)
+        pen.SetStyle(wx.SOLID)
+        self.SetPen(pen)
+        
+    def OnDraw(self, dc):
+        """!Draw relation"""
+        self._setPen()
+        ogl.LineShape.OnDraw(self, dc)
+    
+    def SetName(self, param):
+        self.param = param
+
+class ModelItem(ModelObject):
+    def __init__(self, parent, x, y, id = -1, width = None, height = None, text = '', items = []):
+        """!Abstract class for loops and conditions"""
+        ModelObject.__init__(self, id)
+        self.parent  = parent
+        self.text    = text
+        self.items   = items  # list of items in the loop
+        
+    def GetText(self):
+        """!Get loop text"""
+        return self.text
+
+    def GetItems(self):
+        """!Get items (id)"""
+        return self.items
+
+    def SetId(self, id):
+        """!Set loop id"""
+        self.id = id
+
+    def SetText(self, cond):
+        """!Set loop text (condition)"""
+        self.text = cond
+        self.ClearText()
+        self.AddText('(' + str(self.id) + ') ' + self.text)
+
+    def GetLog(self):
+        """!Get log info"""
+        if self.text:
+            return _("Condition: ") + self.text
+        else:
+            return _("Condition: not defined")
+
+    def AddRelation(self, rel):
+        """!Record relation"""
+        self.rels.append(rel)
+        
+    def Clear(self):
+        """!Clear object, remove rels"""
+        self.rels = list()
+   
+class ModelLoop(ModelItem, ogl.RectangleShape):
+    def __init__(self, parent, x, y, id = -1, width = None, height = None, text = '', items = []):
+        """!Defines a loop"""
+        ModelItem.__init__(self, parent, x, y, id, width, height, text, items)
+        
+        if not width:
+            width = UserSettings.Get(group='modeler', key='loop', subkey=('size', 'width'))
+        if not height:
+            height = UserSettings.Get(group='modeler', key='loop', subkey=('size', 'height'))
+        
+        if self.parent.GetCanvas():
+            ogl.RectangleShape.__init__(self, width, height)
+            
+            self.SetCanvas(self.parent)
+            self.SetX(x)
+            self.SetY(y)
+            self.SetPen(wx.BLACK_PEN)
+            self.SetCornerRadius(100)
+            if text:
+                self.AddText('(' + str(self.id) + ') ' + text)
+            else:
+                self.AddText('(' + str(self.id) + ')')
+        
+        self._setBrush()
+        
+    def _setBrush(self):
+        """!Set brush"""
+        if not self.isEnabled:
+            color = UserSettings.Get(group='modeler', key='disabled',
+                                     subkey='color')
+        else:
+            color = UserSettings.Get(group='modeler', key='loop',
+                                     subkey=('color', 'valid'))
+        
+        wxColor = wx.Color(color[0], color[1], color[2])
+        self.SetBrush(wx.Brush(wxColor))
+
+    def Enable(self, enabled = True):
+        """!Enable/disable action"""
+        for item in self.items:
+            if not isinstance(item, ModelAction):
+                continue
+            item.Enable(enabled)
+        
+        ModelObject.Enable(self, enabled)
+        
+    def Update(self):
+        self._setBrush()
+        
+    def GetName(self):
+        """!Get name"""
+        return _("loop")
+    
+    def SetItems(self, items):
+        """!Set items (id)"""
+        self.items = items
+
+class ModelCondition(ModelItem, ogl.PolygonShape):
+    def __init__(self, parent, x, y, id = -1, width = None, height = None, text = '',
+                 items = { 'if' : [], 'else' : [] }):
+        """!Defines a if-else condition"""
+        ModelItem.__init__(self, parent, x, y, id, width, height, text, items)
+        
+        if not width:
+            self.width = UserSettings.Get(group='modeler', key='if-else', subkey=('size', 'width'))
+        else:
+            self.width = width
+        if not height:
+            self.height = UserSettings.Get(group='modeler', key='if-else', subkey=('size', 'height'))
+        else:
+            self.height = height
+        
+        if self.parent.GetCanvas():
+            ogl.PolygonShape.__init__(self)
+            
+            points = [(0, - self.height / 2),
+                      (self.width / 2, 0),
+                      (0, self.height / 2),
+                      (- self.width / 2, 0)]
+            self.Create(points)
+            
+            self.SetCanvas(self.parent)
+            self.SetX(x)
+            self.SetY(y)
+            self.SetPen(wx.BLACK_PEN)
+            if text:
+                self.AddText('(' + str(self.id) + ') ' + text)
+            else:
+                self.AddText('(' + str(self.id) + ')')
+
+    def GetName(self):
+        """!Get name"""
+        return _("if-else")
+
+    def GetWidth(self):
+        """!Get object width"""
+        return self.width
+
+    def GetHeight(self):
+        """!Get object height"""
+        return self.height
+
+    def SetItems(self, items, branch = 'if'):
+        """!Set items (id)
+
+        @param items list of items
+        @param branch 'if' / 'else'
+        """
+        if branch in ['if', 'else']:
+            self.items[branch] = items

+ 1 - 1
gui/wxpython/gui_core/dialogs.py

@@ -1,5 +1,5 @@
 """!
-@package gui_core.gdialogs
+@package gui_core.dialogs
 
 @brief Various dialogs used in wxGUI.
 

+ 2 - 0
gui/wxpython/psmap/frame.py

@@ -42,6 +42,8 @@ from psmap.toolbars   import PsMapToolbar
 from icon             import Icons, MetaIcon, iconSet
 from core.gcmd        import RunCommand, GError, GMessage
 from gui_core.forms   import GUI
+from psmap.menudata   import PsMapData
+
 from psmap.dialogs    import *
 
 class PsMapFrame(wx.Frame):

+ 17 - 26
gui/wxpython/psmap/menudata.py

@@ -1,39 +1,30 @@
 """!
-@package core.menudata
+@package ps.menudata
 
-@brief Complex list for menu entries for wxGUI
+@brief wxPsMap - menu entries
 
 Classes:
- - MenuData
+ - PsMapData
 
-Usage:
-@code
-python menudata.py [action] [manager|modeler]
-@endcode
-
-where <i>action</i>:
- - strings (default)
- - tree
- - commands
- - dump
-
-(C) 2007-2011 by the GRASS Development Team
+(C) 2011 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 Michael Barton (Arizona State University)
-@author Yann Chemin <yann.chemin gmail.com>
-@author Martin Landa <landa.martin gmail.com>
-@author Glynn Clements
 @author Anna Kratochvilova <kratochanna gmail.com>
 """
 
 import os
-import sys
-import pprint
-try:
-    import xml.etree.ElementTree as etree
-except ImportError:
-    import elementtree.ElementTree as etree # Python <= 2.4
 
-import wx
+from core                 import globalvar
+from core.menudata        import MenuData
+
+class PsMapData(MenuData):
+    def __init__(self, path = None):
+        """!Menu for Cartographic Composer (psmap.py)
+        
+        @path path to XML to be read (None for menudata_psmap.xml)
+        """
+        if not path:
+            path = os.path.join(globalvar.ETCWXDIR, 'xml', 'menudata_psmap.xml')
+        
+        MenuData.__init__(self, path)

+ 2 - 2
gui/wxpython/psmap/toolbars.py

@@ -30,7 +30,7 @@ class PsMapToolbar(BaseToolbar):
         
         @param parent parent window
         """
-        AbstractToolbar.__init__(self, parent)
+        BaseToolbar.__init__(self, parent)
         
         self.InitToolbar(self._toolbarData())
         
@@ -41,7 +41,7 @@ class PsMapToolbar(BaseToolbar):
                                'bind' : self.parent.OnPointer }
         self.OnTool(None)
         
-        from psmap import havePILImage
+        from psmap.frame import havePILImage
         if not havePILImage:
             self.EnableTool(self.preview, False)
         

+ 1 - 1
gui/wxpython/wxgui.py

@@ -351,7 +351,7 @@ class GMFrame(wx.Frame):
 
     def OnGModeler(self, event):
         """!Launch Graphical Modeler"""
-        win = gmodeler.ModelFrame(parent = self)
+        win = ModelFrame(parent = self)
         win.CentreOnScreen()
         
         win.Show()