Pārlūkot izejas kodu

wxGUI: unified grass interface (to be continued) (co-author: wenzeslaus)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53985 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 12 gadi atpakaļ
vecāks
revīzija
325e01d623

+ 61 - 0
gui/wxpython/core/giface.py

@@ -0,0 +1,61 @@
+"""!
+@package core.giface
+
+@brief GRASS interface for standalone application (without layer manager)
+
+Classes:
+ - giface::StandaloneGrassInterface
+
+(C) 2012 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 Anna Kratochvilova <kratochanna gmail.com>
+@author Vaclav Petras <wenzeslaus gmail.com>
+"""
+from core.gcmd import RunCommand
+from core.utils import CmdToTuple
+
+import grass.script as grass
+
+class StandaloneGrassInterface():
+    def RunCmd(self, command,
+               onDone = None, onPrepare = None, userData = None, **kwargs):
+        if onPrepare:
+            onPrepare(userData)
+
+        cmdTuple = CmdToTuple(command)
+        returncode = RunCommand(cmdTuple[0], **cmdTuple[1])
+
+        if onDone:
+            onDone(cmd = command, returncode = returncode)
+
+    def Help(self, entry):
+        RunCommand('g.manual', quiet = True, entry = entry)
+
+    def WriteLog(self, text, wrap = None,
+                 switchPage = False, priority = 1):
+        grass.message(text)
+
+    def WriteCmdLog(self, line, pid = None, switchPage = True):
+        grass.message(text)
+
+    def WriteWarning(self, line):
+        grass.warning(line)
+
+    def WriteError(self, line):
+        grass.error(line)
+
+    def GetLayerTree(self):
+        return None
+
+    def GetMapDisplay(self):
+        """!Get current map display.
+        """
+        return None
+
+    def GetAllMapDisplays(self):
+        """!Get list of all map displays.
+        """
+        return []

+ 19 - 18
gui/wxpython/gcp/manager.py

@@ -84,8 +84,9 @@ class GCPWizard(object):
     Start wizard here and finish wizard here
     Start wizard here and finish wizard here
     """
     """
 
 
-    def __init__(self, parent):
+    def __init__(self, parent, giface):
         self.parent = parent # GMFrame
         self.parent = parent # GMFrame
+        self._giface = giface
 
 
         #
         #
         # get environmental variables
         # get environmental variables
@@ -222,9 +223,10 @@ class GCPWizard(object):
             #
             #
             # start GCP Manager
             # start GCP Manager
             #
             #
-            self.gcpmgr = GCP(self.parent, grwiz=self, size=globalvar.MAP_WINDOW_SIZE,
-                                               toolbars=["gcpdisp"],
-                                               Map=self.SrcMap, lmgr=self.parent)
+            self.gcpmgr = GCP(self.parent, giface = self._giface, 
+                              grwiz=self, size=globalvar.MAP_WINDOW_SIZE,
+                              toolbars=["gcpdisp"],
+                              Map=self.SrcMap, lmgr=self.parent)
 
 
             # load GCPs
             # load GCPs
             self.gcpmgr.InitMapDisplay()
             self.gcpmgr.InitMapDisplay()
@@ -778,11 +780,12 @@ class GCP(MapFrame, ColumnSorterMixin):
     Manages ground control points for georectifying. Calculates RMS statistics.
     Manages ground control points for georectifying. Calculates RMS statistics.
     Calls i.rectify or v.rectify to georectify map.
     Calls i.rectify or v.rectify to georectify map.
     """
     """
-    def __init__(self, parent, grwiz = None, id = wx.ID_ANY,
+    def __init__(self, parent, giface, grwiz = None, id = wx.ID_ANY,
                  title = _("Manage Ground Control Points"),
                  title = _("Manage Ground Control Points"),
                  size = (700, 300), toolbars = ["gcpdisp"], Map = None, lmgr = None):
                  size = (700, 300), toolbars = ["gcpdisp"], Map = None, lmgr = None):
 
 
         self.grwiz = grwiz # GR Wizard
         self.grwiz = grwiz # GR Wizard
+        self._giface = giface
 
 
         if tgt_map['raster'] == '' and tgt_map['vector'] == '':
         if tgt_map['raster'] == '' and tgt_map['vector'] == '':
             self.show_target = False
             self.show_target = False
@@ -790,7 +793,7 @@ class GCP(MapFrame, ColumnSorterMixin):
             self.show_target = True
             self.show_target = True
         
         
         #wx.Frame.__init__(self, parent, id, title, size = size, name = "GCPFrame")
         #wx.Frame.__init__(self, parent, id, title, size = size, name = "GCPFrame")
-        MapFrame.__init__(self, parent = parent, title = title, size = size,
+        MapFrame.__init__(self, parent = parent, giface = self._giface, title = title, size = size,
                             Map = Map, toolbars = toolbars, lmgr = lmgr, name = 'GCPMapWindow')
                             Map = Map, toolbars = toolbars, lmgr = lmgr, name = 'GCPMapWindow')
 
 
         #
         #
@@ -1235,7 +1238,7 @@ class GCP(MapFrame, ColumnSorterMixin):
         # if event != None save also to backup file
         # if event != None save also to backup file
         if event:
         if event:
             shutil.copy(self.file['points'], self.file['points_bak'])
             shutil.copy(self.file['points'], self.file['points_bak'])
-            self.parent.goutput.WriteLog(_('POINTS file saved for group <%s>') % self.xygroup)
+            self._giface.WriteLog(_('POINTS file saved for group <%s>') % self.xygroup)
             #self.SetStatusText(_('POINTS file saved'))
             #self.SetStatusText(_('POINTS file saved'))
 
 
     def ReadGCPs(self):
     def ReadGCPs(self):
@@ -1421,8 +1424,7 @@ class GCP(MapFrame, ColumnSorterMixin):
             # georectify each vector in VREF using v.rectify
             # georectify each vector in VREF using v.rectify
             for vect in vectlist:
             for vect in vectlist:
                 self.outname = str(vect.split('@')[0]) + self.extension
                 self.outname = str(vect.split('@')[0]) + self.extension
-                print self.outname
-                self.parent.goutput.WriteLog(text = _('Transforming <%s>...') % vect,
+                self._giface.WriteLog(text = _('Transforming <%s>...') % vect,
                                              switchPage = True)
                                              switchPage = True)
                 ret = msg = ''
                 ret = msg = ''
                 
                 
@@ -1459,14 +1461,15 @@ class GCP(MapFrame, ColumnSorterMixin):
             self.VectGRList.append(self.outname)
             self.VectGRList.append(self.outname)
             print '*****vector list = ' + str(self.VectGRList)
             print '*****vector list = ' + str(self.VectGRList)
         else:
         else:
-            self.parent.goutput.WriteError(_('Georectification of vector map <%s> failed') %
-                                                   self.outname)
+            self._giface.WriteError(_('Georectification of vector map <%s> failed') %
+                                      self.outname)
 
 
          
          
     def OnSettings(self, event):
     def OnSettings(self, event):
         """!GCP Manager settings"""
         """!GCP Manager settings"""
-        dlg = GrSettingsDialog(parent=self, id=wx.ID_ANY, title=_('GCP Manager settings'))
-        
+        dlg = GrSettingsDialog(parent=self, giface=self._giface,
+                               id=wx.ID_ANY, title=_('GCP Manager settings'))
+
         if dlg.ShowModal() == wx.ID_OK:
         if dlg.ShowModal() == wx.ID_OK:
             pass
             pass
         
         
@@ -1745,9 +1748,7 @@ class GCP(MapFrame, ColumnSorterMixin):
 
 
     def OnHelp(self, event):
     def OnHelp(self, event):
         """!Show GCP Manager manual page"""
         """!Show GCP Manager manual page"""
-        cmdlist = ['g.manual', 'entry=wxGUI.GCP_Manager']
-        self.parent.goutput.RunCmd(cmdlist, compReg=False,
-                                       switchPage=False)
+        self._giface.Help(entry = 'wxGUI.GCP_Manager')
 
 
     def OnUpdateActive(self, event):
     def OnUpdateActive(self, event):
 
 
@@ -2341,7 +2342,7 @@ class EditGCP(wx.Dialog):
         return valuelist
         return valuelist
 
 
 class GrSettingsDialog(wx.Dialog):
 class GrSettingsDialog(wx.Dialog):
-    def __init__(self, parent, id, title, pos=wx.DefaultPosition, size=wx.DefaultSize,
+    def __init__(self, parent, id, giface, title, pos=wx.DefaultPosition, size=wx.DefaultSize,
                  style=wx.DEFAULT_DIALOG_STYLE):
                  style=wx.DEFAULT_DIALOG_STYLE):
         wx.Dialog.__init__(self, parent, id, title, pos, size, style)
         wx.Dialog.__init__(self, parent, id, title, pos, size, style)
         """
         """
@@ -2826,7 +2827,7 @@ class GrSettingsDialog(wx.Dialog):
         UserSettings.ReadSettingsFile(settings=fileSettings)
         UserSettings.ReadSettingsFile(settings=fileSettings)
         fileSettings['gcpman'] = UserSettings.Get(group='gcpman')
         fileSettings['gcpman'] = UserSettings.Get(group='gcpman')
         file = UserSettings.SaveToFile(fileSettings)
         file = UserSettings.SaveToFile(fileSettings)
-        self.parent.parent.goutput.WriteLog(_('GCP Manager settings saved to file \'%s\'.') % file)
+        self._giface.WriteLog(_('GCP Manager settings saved to file \'%s\'.') % file)
         #self.Close()
         #self.Close()
 
 
     def OnApply(self, event):
     def OnApply(self, event):

+ 5 - 4
gui/wxpython/gcp/mapdisplay.py

@@ -42,7 +42,7 @@ class MapFrame(SingleMapFrame):
     """!Main frame for map display window. Drawing takes place in
     """!Main frame for map display window. Drawing takes place in
     child double buffered drawing window.
     child double buffered drawing window.
     """
     """
-    def __init__(self, parent=None, title=_("GRASS GIS Manage Ground Control Points"),
+    def __init__(self, parent, giface, title=_("GRASS GIS Manage Ground Control Points"),
                  toolbars=["gcpdisp"], tree=None, notebook=None, lmgr=None,
                  toolbars=["gcpdisp"], tree=None, notebook=None, lmgr=None,
                  page=None, Map=None, auimgr=None, name = 'GCPMapWindow', **kwargs):
                  page=None, Map=None, auimgr=None, name = 'GCPMapWindow', **kwargs):
         """!Main map display window with toolbars, statusbar and
         """!Main map display window with toolbars, statusbar and
@@ -58,13 +58,14 @@ class MapFrame(SingleMapFrame):
         @param kwargs wx.Frame attribures
         @param kwargs wx.Frame attribures
         """
         """
         
         
-        SingleMapFrame.__init__(self, parent = parent, title = title,
+        SingleMapFrame.__init__(self, parent = parent, giface = giface, title = title,
                               Map = Map, auimgr = auimgr, name = name, **kwargs)
                               Map = Map, auimgr = auimgr, name = name, **kwargs)
         
         
         self._layerManager = lmgr   # Layer Manager object
         self._layerManager = lmgr   # Layer Manager object
         self.tree       = tree      # Layer Manager layer tree object
         self.tree       = tree      # Layer Manager layer tree object
         self.page       = page      # Notebook page holding the layer tree
         self.page       = page      # Notebook page holding the layer tree
         self.layerbook  = notebook  # Layer Manager layer tree notebook
         self.layerbook  = notebook  # Layer Manager layer tree notebook
+        self._giface = giface
         #
         #
         # Add toolbars
         # Add toolbars
         #
         #
@@ -113,11 +114,11 @@ class MapFrame(SingleMapFrame):
         # Init map display (buffered DC & set default cursor)
         # Init map display (buffered DC & set default cursor)
         #
         #
         self.grwiz.SwitchEnv('source')
         self.grwiz.SwitchEnv('source')
-        self.SrcMapWindow = BufferedWindow(self, id=wx.ID_ANY,
+        self.SrcMapWindow = BufferedWindow(parent=self, giface=self._giface, id=wx.ID_ANY,
                                           Map=self.SrcMap, frame = self, tree=self.tree, lmgr=self._layerManager)
                                           Map=self.SrcMap, frame = self, tree=self.tree, lmgr=self._layerManager)
 
 
         self.grwiz.SwitchEnv('target')
         self.grwiz.SwitchEnv('target')
-        self.TgtMapWindow = BufferedWindow(self, id=wx.ID_ANY,
+        self.TgtMapWindow = BufferedWindow(parent=self, giface=self._giface, id=wx.ID_ANY,
                                           Map=self.TgtMap, frame = self, tree=self.tree, lmgr=self._layerManager)
                                           Map=self.TgtMap, frame = self, tree=self.tree, lmgr=self._layerManager)
         self.MapWindow = self.SrcMapWindow
         self.MapWindow = self.SrcMapWindow
         self.Map = self.SrcMap
         self.Map = self.SrcMap

+ 5 - 16
gui/wxpython/gmodeler/frame.py

@@ -56,7 +56,7 @@ from gmodeler.pystc       import PyStc
 from grass.script import core as grass
 from grass.script import core as grass
 
 
 class ModelFrame(wx.Frame):
 class ModelFrame(wx.Frame):
-    def __init__(self, parent, id = wx.ID_ANY,
+    def __init__(self, parent, giface, id = wx.ID_ANY,
                  title = _("GRASS GIS Graphical Modeler"), **kwargs):
                  title = _("GRASS GIS Graphical Modeler"), **kwargs):
         """!Graphical modeler main window
         """!Graphical modeler main window
         
         
@@ -67,6 +67,7 @@ class ModelFrame(wx.Frame):
         @param kwargs wx.Frames' arguments
         @param kwargs wx.Frames' arguments
         """
         """
         self.parent = parent
         self.parent = parent
+        self._giface = giface
         self.searchDialog = None # module search dialog
         self.searchDialog = None # module search dialog
         self.baseTitle = title
         self.baseTitle = title
         self.modelFile = None    # loaded model
         self.modelFile = None    # loaded model
@@ -275,7 +276,7 @@ class ModelFrame(wx.Frame):
         
         
     def OnPreferences(self, event):
     def OnPreferences(self, event):
         """!Open preferences dialog"""
         """!Open preferences dialog"""
-        dlg = PreferencesDialog(parent = self)
+        dlg = PreferencesDialog(parent = self, giface = self._giface)
         dlg.CenterOnParent()
         dlg.CenterOnParent()
         
         
         dlg.ShowModal()
         dlg.ShowModal()
@@ -283,15 +284,8 @@ class ModelFrame(wx.Frame):
         
         
     def OnHelp(self, event):
     def OnHelp(self, event):
         """!Show help"""
         """!Show help"""
-        if self.parent and self.parent.GetName() == 'LayerManager':
-            log = self.parent.GetLogWindow()
-            log.RunCmd(['g.manual',
-                        'entry=wxGUI.Modeler'])
-        else:
-            RunCommand('g.manual',
-                       quiet = True,
-                       entry = 'wxGUI.Modeler')
-        
+        self._giface.Help(entry = 'wxGUI.Modeler')
+
     def OnModelProperties(self, event):
     def OnModelProperties(self, event):
         """!Model properties dialog"""
         """!Model properties dialog"""
         dlg = PropertiesDialog(parent = self)
         dlg = PropertiesDialog(parent = self)
@@ -715,11 +709,6 @@ class ModelFrame(wx.Frame):
             self.SetFocus()
             self.SetFocus()
             self.Raise()
             self.Raise()
 
 
-    def OnHelp(self, event):
-        """!Display manual page"""
-        grass.run_command('g.manual',
-                          entry = 'wxGUI.Modeler')
-
     def OnAbout(self, event):
     def OnAbout(self, event):
         """!Display About window"""
         """!Display About window"""
         info = wx.AboutDialogInfo()
         info = wx.AboutDialogInfo()

+ 2 - 1
gui/wxpython/gmodeler/g.gui.gmodeler.py

@@ -41,6 +41,7 @@ import grass.script as grass
 
 
 sys.path.append(os.path.join(os.environ['GISBASE'], "etc", "gui", "wxpython"))
 sys.path.append(os.path.join(os.environ['GISBASE'], "etc", "gui", "wxpython"))
 
 
+from core.giface import StandaloneGrassInterface
 from gmodeler.frame import ModelFrame
 from gmodeler.frame import ModelFrame
 
 
 def main():
 def main():
@@ -49,7 +50,7 @@ def main():
     
     
     app = wx.PySimpleApp()
     app = wx.PySimpleApp()
     wx.InitAllImageHandlers()
     wx.InitAllImageHandlers()
-    frame = ModelFrame(parent = None)
+    frame = ModelFrame(parent = None, giface = StandaloneGrassInterface())
     if options['file']:
     if options['file']:
         frame.LoadModelFile(options['file'])
         frame.LoadModelFile(options['file'])
     frame.Show()
     frame.Show()

+ 2 - 2
gui/wxpython/gmodeler/preferences.py

@@ -24,10 +24,10 @@ from core.settings        import UserSettings
 
 
 class PreferencesDialog(PreferencesBaseDialog):
 class PreferencesDialog(PreferencesBaseDialog):
     """!User preferences dialog"""
     """!User preferences dialog"""
-    def __init__(self, parent, settings = UserSettings,
+    def __init__(self, parent, giface, settings = UserSettings,
                  title = _("Modeler settings")):
                  title = _("Modeler settings")):
         
         
-        PreferencesBaseDialog.__init__(self, parent = parent, title = title,
+        PreferencesBaseDialog.__init__(self, parent = parent, giface = giface, title = title,
                                        settings = settings)
                                        settings = settings)
         
         
         # create notebook pages
         # create notebook pages

+ 6 - 7
gui/wxpython/gui_core/dialogs.py

@@ -1787,13 +1787,14 @@ class ImportDialog(wx.Dialog):
         pass
         pass
 
 
 class GdalImportDialog(ImportDialog):
 class GdalImportDialog(ImportDialog):
-    def __init__(self, parent, ogr = False, link = False):
+    def __init__(self, parent, giface, ogr = False, link = False):
         """!Dialog for bulk import of various raster/vector data
         """!Dialog for bulk import of various raster/vector data
 
 
         @param parent parent window
         @param parent parent window
         @param ogr True for OGR (vector) otherwise GDAL (raster)
         @param ogr True for OGR (vector) otherwise GDAL (raster)
         @param link True for linking data otherwise importing data
         @param link True for linking data otherwise importing data
         """
         """
+        self._giface = giface
         self.link = link
         self.link = link
         self.ogr  = ogr
         self.ogr  = ogr
         
         
@@ -1899,8 +1900,7 @@ class GdalImportDialog(ImportDialog):
                 cmd.append('--overwrite')
                 cmd.append('--overwrite')
             
             
             # run in Layer Manager
             # run in Layer Manager
-            self.parent.goutput.RunCmd(cmd, switchPage = True,
-                                       onDone = self.AddLayers)
+            self._giface.RunCmd(cmd, switchPage = True, onDone = self.AddLayers)
         
         
         if popOGR:
         if popOGR:
             os.environ.pop('GRASS_VECTOR_OGR')
             os.environ.pop('GRASS_VECTOR_OGR')
@@ -2023,10 +2023,10 @@ class GdalOutputDialog(wx.Dialog):
         
         
 class DxfImportDialog(ImportDialog):
 class DxfImportDialog(ImportDialog):
     """!Dialog for bulk import of DXF layers""" 
     """!Dialog for bulk import of DXF layers""" 
-    def __init__(self, parent):
+    def __init__(self, parent, giface):
         ImportDialog.__init__(self, parent, itype = 'dxf',
         ImportDialog.__init__(self, parent, itype = 'dxf',
                               title = _("Import DXF layers"))
                               title = _("Import DXF layers"))
-        
+        self._giface = giface
         self.dsnInput = filebrowse.FileBrowseButton(parent = self.panel, id = wx.ID_ANY, 
         self.dsnInput = filebrowse.FileBrowseButton(parent = self.panel, id = wx.ID_ANY, 
                                                     size = globalvar.DIALOG_GSELECT_SIZE, labelText = '',
                                                     size = globalvar.DIALOG_GSELECT_SIZE, labelText = '',
                                                     dialogTitle = _('Choose DXF file to import'),
                                                     dialogTitle = _('Choose DXF file to import'),
@@ -2069,8 +2069,7 @@ class DxfImportDialog(ImportDialog):
                 cmd.append('--overwrite')
                 cmd.append('--overwrite')
             
             
             # run in Layer Manager
             # run in Layer Manager
-            self.parent.goutput.RunCmd(cmd, switchPage = True,
-                                       onDone = self.AddLayers)
+            self._giface.RunCmd(cmd, switchPage = True, onDone = self.AddLayers)
         
         
         self.OnCancel()
         self.OnCancel()
 
 

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

@@ -381,7 +381,7 @@ class SingleMapFrame(MapFrameBase):
     @note To access maps use getters only
     @note To access maps use getters only
     (when using class or when writing class itself).
     (when using class or when writing class itself).
     """
     """
-    def __init__(self, parent = None, id = wx.ID_ANY, title = None,
+    def __init__(self, parent = None, giface = None, id = wx.ID_ANY, title = None,
                  style = wx.DEFAULT_FRAME_STYLE,
                  style = wx.DEFAULT_FRAME_STYLE,
                  Map = None,
                  Map = None,
                  auimgr = None, name = None, **kwargs):
                  auimgr = None, name = None, **kwargs):

+ 2 - 1
gui/wxpython/gui_core/mapwindow.py

@@ -36,13 +36,14 @@ class MapWindow(object):
      - Pixel2Cell
      - Pixel2Cell
      - Cell2Pixel (if it is possible)
      - Cell2Pixel (if it is possible)
     """
     """
-    def __init__(self, parent, Map, frame,
+    def __init__(self, parent, giface, Map, frame,
                  id = wx.ID_ANY, tree = None, lmgr = None, **kwargs):
                  id = wx.ID_ANY, tree = None, lmgr = None, **kwargs):
         self.parent = parent # MapFrame
         self.parent = parent # MapFrame
         self.Map    = Map
         self.Map    = Map
         self.frame = frame
         self.frame = frame
         self.tree   = tree
         self.tree   = tree
         self.lmgr   = lmgr
         self.lmgr   = lmgr
+        self._giface = giface
         
         
         # mouse attributes -- position on the screen, begin and end of
         # mouse attributes -- position on the screen, begin and end of
         # dragging, and type of drawing
         # dragging, and type of drawing

+ 7 - 8
gui/wxpython/gui_core/preferences.py

@@ -55,13 +55,14 @@ wxSettingsChanged, EVT_SETTINGS_CHANGED = NewEvent()
 
 
 class PreferencesBaseDialog(wx.Dialog):
 class PreferencesBaseDialog(wx.Dialog):
     """!Base preferences dialog"""
     """!Base preferences dialog"""
-    def __init__(self, parent, settings, title = _("User settings"),
+    def __init__(self, parent, giface, settings, title = _("User settings"),
                  size = (500, 475),
                  size = (500, 475),
                  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
                  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
         self.parent = parent # ModelerFrame
         self.parent = parent # ModelerFrame
         self.title  = title
         self.title  = title
         self.size   = size
         self.size   = size
         self.settings = settings
         self.settings = settings
+        self._giface = giface
         
         
         wx.Dialog.__init__(self, parent = parent, id = wx.ID_ANY, title = title,
         wx.Dialog.__init__(self, parent = parent, id = wx.ID_ANY, title = title,
                            style = style)
                            style = style)
@@ -148,7 +149,7 @@ class PreferencesBaseDialog(wx.Dialog):
         Posts event EVT_SETTINGS_CHANGED.
         Posts event EVT_SETTINGS_CHANGED.
         """
         """
         if self._updateSettings():
         if self._updateSettings():
-            self.parent.goutput.WriteLog(_('Settings applied to current session but not saved'))
+            self._giface.WriteLog(_('Settings applied to current session but not saved'))
             event = wxSettingsChanged()
             event = wxSettingsChanged()
             wx.PostEvent(self, event)
             wx.PostEvent(self, event)
             self.Close()
             self.Close()
@@ -175,7 +176,7 @@ class PreferencesBaseDialog(wx.Dialog):
                 self.settings.Set(group = 'language', key = 'locale', subkey = 'lc_all', value = 'C')
                 self.settings.Set(group = 'language', key = 'locale', subkey = 'lc_all', value = 'C')
                 lang = 'C'
                 lang = 'C'
             self.settings.SaveToFile()
             self.settings.SaveToFile()
-            self.parent.goutput.WriteLog(_('Settings saved to file \'%s\'.') % self.settings.filePath)
+            self._giface.WriteLog(_('Settings saved to file \'%s\'.') % self.settings.filePath)
             if lang:
             if lang:
                 StoreEnvVariable(key = 'LANG', value = lang)
                 StoreEnvVariable(key = 'LANG', value = lang)
             else:
             else:
@@ -243,8 +244,7 @@ class PreferencesBaseDialog(wx.Dialog):
             size = self.parent.GetSize()
             size = self.parent.GetSize()
             dim = '%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
             dim = '%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
             # opened displays
             # opened displays
-            for page in range(0, self.parent.GetLayerNotebook().GetPageCount()):
-                mapdisp = self.parent.GetLayerNotebook().GetPage(page).maptree.GetMapDisplay()
+            for mapdisp in self._giface.GetAllMapDisplays():
                 pos  = mapdisp.GetPosition()
                 pos  = mapdisp.GetPosition()
                 size = mapdisp.GetSize()
                 size = mapdisp.GetSize()
 
 
@@ -258,10 +258,9 @@ class PreferencesBaseDialog(wx.Dialog):
 
 
 class PreferencesDialog(PreferencesBaseDialog):
 class PreferencesDialog(PreferencesBaseDialog):
     """!User preferences dialog"""
     """!User preferences dialog"""
-    def __init__(self, parent, title = _("GUI Settings"),
+    def __init__(self, parent, giface, title = _("GUI Settings"),
                  settings = UserSettings):
                  settings = UserSettings):
-        
-        PreferencesBaseDialog.__init__(self, parent = parent, title = title,
+        PreferencesBaseDialog.__init__(self, parent = parent, giface = giface, title = title,
                                        settings = settings)
                                        settings = settings)
         
         
         # create notebook pages
         # create notebook pages

+ 2 - 2
gui/wxpython/iclass/digit.py

@@ -28,7 +28,7 @@ except ImportError:
 
 
 class IClassVDigitWindow(VDigitWindow):
 class IClassVDigitWindow(VDigitWindow):
     """! Class similar to VDigitWindow but specialized for wxIClass."""
     """! Class similar to VDigitWindow but specialized for wxIClass."""
-    def __init__(self, parent, map, frame):
+    def __init__(self, parent, giface, map, frame):
         """!
         """!
         
         
         @a parent should has toolbar providing current class (category).
         @a parent should has toolbar providing current class (category).
@@ -36,7 +36,7 @@ class IClassVDigitWindow(VDigitWindow):
         @param parent gui parent
         @param parent gui parent
         @param map map renderer instance
         @param map map renderer instance
         """
         """
-        VDigitWindow.__init__(self, parent = parent, Map = map, frame = frame)
+        VDigitWindow.__init__(self, parent = parent, giface = giface, Map = map, frame = frame)
         
         
     def _onLeftDown(self, event):
     def _onLeftDown(self, event):
         action = self.toolbar.GetAction()
         action = self.toolbar.GetAction()

+ 7 - 6
gui/wxpython/iclass/frame.py

@@ -69,7 +69,7 @@ class IClassMapFrame(DoubleMapFrame):
     
     
     It is wxGUI counterpart of old i.class module.
     It is wxGUI counterpart of old i.class module.
     """
     """
-    def __init__(self, parent = None, title = _("Supervised Classification Tool"),
+    def __init__(self, parent = None, giface = None, title = _("Supervised Classification Tool"),
                  toolbars = ["iClassMisc", "iClassMap", "vdigit", "iClass"],
                  toolbars = ["iClassMisc", "iClassMap", "vdigit", "iClass"],
                  size = (875, 600), name = 'IClassWindow', **kwargs):
                  size = (875, 600), name = 'IClassWindow', **kwargs):
         """!
         """!
@@ -82,9 +82,11 @@ class IClassMapFrame(DoubleMapFrame):
                                 name = name,
                                 name = name,
                                 firstMap = Map(), secondMap = Map(),
                                 firstMap = Map(), secondMap = Map(),
                                 **kwargs)
                                 **kwargs)
-        
-        self.firstMapWindow = IClassVDigitWindow(self, map = self.firstMap, frame = self)
-        self.secondMapWindow = BufferedWindow(self, Map = self.secondMap, frame = self)
+        self._giface = giface
+        self.firstMapWindow = IClassVDigitWindow(parent = self, giface = self._giface,
+                                                 map = self.firstMap, frame = self)
+        self.secondMapWindow = BufferedWindow(parent = self, giface = self._giface,
+                                              Map = self.secondMap, frame = self)
         self.MapWindow = self.firstMapWindow # current by default
         self.MapWindow = self.firstMapWindow # current by default
         
         
         self._bindWindowsActivation()
         self._bindWindowsActivation()
@@ -188,8 +190,7 @@ class IClassMapFrame(DoubleMapFrame):
             
             
     def OnHelp(self, event):
     def OnHelp(self, event):
         """!Show help page"""
         """!Show help page"""
-        grass.run_command('g.manual',
-                          entry = 'wxGUI.IClass')
+        self._giface.Help(entry = 'wxGUI.IClass')
         
         
     def CreateTempVector(self):
     def CreateTempVector(self):
         """!Create temporary vector map for training areas"""
         """!Create temporary vector map for training areas"""

+ 25 - 26
gui/wxpython/lmgr/frame.py

@@ -66,6 +66,7 @@ from modules.extensions    import InstallExtensionWindow, UninstallExtensionWind
 from lmgr.toolbars         import LMWorkspaceToolbar, LMDataToolbar, LMToolsToolbar
 from lmgr.toolbars         import LMWorkspaceToolbar, LMDataToolbar, LMToolsToolbar
 from lmgr.toolbars         import LMMiscToolbar, LMVectorToolbar, LMNvizToolbar
 from lmgr.toolbars         import LMMiscToolbar, LMVectorToolbar, LMNvizToolbar
 from lmgr.pyshell          import PyShellWindow
 from lmgr.pyshell          import PyShellWindow
+from lmgr.giface           import LayerManagerGrassInterface
 from gui_core.forms        import GUI
 from gui_core.forms        import GUI
 from gcp.manager           import GCPWizard
 from gcp.manager           import GCPWizard
 from nviz.main             import haveNviz
 from nviz.main             import haveNviz
@@ -91,6 +92,8 @@ class GMFrame(wx.Frame):
 
 
         self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
         self.SetIcon(wx.Icon(os.path.join(globalvar.ETCICONDIR, 'grass.ico'), wx.BITMAP_TYPE_ICO))
 
 
+        self._giface = LayerManagerGrassInterface(self)
+
         self._auimgr = wx.aui.AuiManager(self)
         self._auimgr = wx.aui.AuiManager(self)
 
 
         # initialize variables
         # initialize variables
@@ -390,11 +393,11 @@ class GMFrame(wx.Frame):
     def OnGCPManager(self, event):
     def OnGCPManager(self, event):
         """!Launch georectifier module
         """!Launch georectifier module
         """
         """
-        GCPWizard(self)
+        GCPWizard(self, self._giface)
 
 
     def OnGModeler(self, event):
     def OnGModeler(self, event):
         """!Launch Graphical Modeler"""
         """!Launch Graphical Modeler"""
-        win = ModelFrame(parent = self)
+        win = ModelFrame(parent = self, giface = self._giface)
         win.CentreOnScreen()
         win.CentreOnScreen()
         
         
         win.Show()
         win.Show()
@@ -577,11 +580,11 @@ class GMFrame(wx.Frame):
             return
             return
         
         
         if layertype == 'barscale':
         if layertype == 'barscale':
-            self.GetLayerTree().GetMapDisplay().OnAddBarscale(None)
+            self.GetMapDisplay().OnAddBarscale(None)
         elif layertype == 'rastleg':
         elif layertype == 'rastleg':
-            self.GetLayerTree().GetMapDisplay().OnAddLegend(None)
+            self.GetMapDisplay().OnAddLegend(None)
         elif layertype == 'redraw':
         elif layertype == 'redraw':
-            self.GetLayerTree().GetMapDisplay().OnRender(None)
+            self.GetMapDisplay().OnRender(None)
         else:
         else:
             # add layer into layer tree
             # add layer into layer tree
             lname, found = GetLayerNameFromCmd(command, fullyQualified = True,
             lname, found = GetLayerNameFromCmd(command, fullyQualified = True,
@@ -625,9 +628,7 @@ class GMFrame(wx.Frame):
                 mlist.append(self.notebookLayers.GetPage(idx).maptree.GetMapDisplay())
                 mlist.append(self.notebookLayers.GetPage(idx).maptree.GetMapDisplay())
             
             
             return mlist
             return mlist
-        
-        return None
-    
+
     def GetLogWindow(self):
     def GetLogWindow(self):
         """!Get widget for command output"""
         """!Get widget for command output"""
         return self.goutput
         return self.goutput
@@ -1282,10 +1283,7 @@ class GMFrame(wx.Frame):
         """!Close all open map display windows
         """!Close all open map display windows
         """
         """
         displays = list()
         displays = list()
-        for page in range(0, self.notebookLayers.GetPageCount()):
-            displays.append(self.notebookLayers.GetPage(page).maptree.GetMapDisplay())
-        
-        for display in displays:
+        for display in self.GetMapDisplay(onlyCurrent = False):
             display.OnCloseWindow(event)
             display.OnCloseWindow(event)
         
         
     def OnRenameDisplay(self, event):
     def OnRenameDisplay(self, event):
@@ -1340,7 +1338,7 @@ class GMFrame(wx.Frame):
         """!General GUI preferences/settings
         """!General GUI preferences/settings
         """
         """
         if not self.dialogs['preferences']:
         if not self.dialogs['preferences']:
-            dlg = PreferencesDialog(parent = self)
+            dlg = PreferencesDialog(parent = self, giface = self._giface)
             self.dialogs['preferences'] = dlg
             self.dialogs['preferences'] = dlg
             self.dialogs['preferences'].CenterOnScreen()
             self.dialogs['preferences'].CenterOnScreen()
             
             
@@ -1436,31 +1434,31 @@ class GMFrame(wx.Frame):
     
     
     def OnImportDxfFile(self, event, cmd = None):
     def OnImportDxfFile(self, event, cmd = None):
         """!Convert multiple DXF layers to GRASS vector map layers"""
         """!Convert multiple DXF layers to GRASS vector map layers"""
-        dlg = DxfImportDialog(parent = self)
+        dlg = DxfImportDialog(parent = self, giface = self._giface)
         dlg.CentreOnScreen()
         dlg.CentreOnScreen()
         dlg.Show()
         dlg.Show()
 
 
     def OnImportGdalLayers(self, event, cmd = None):
     def OnImportGdalLayers(self, event, cmd = None):
         """!Convert multiple GDAL layers to GRASS raster map layers"""
         """!Convert multiple GDAL layers to GRASS raster map layers"""
-        dlg = GdalImportDialog(parent = self)
+        dlg = GdalImportDialog(parent = self, giface = self._giface)
         dlg.CentreOnScreen()
         dlg.CentreOnScreen()
         dlg.Show()
         dlg.Show()
 
 
     def OnLinkGdalLayers(self, event, cmd = None):
     def OnLinkGdalLayers(self, event, cmd = None):
         """!Link multiple GDAL layers to GRASS raster map layers"""
         """!Link multiple GDAL layers to GRASS raster map layers"""
-        dlg = GdalImportDialog(parent = self, link = True)
+        dlg = GdalImportDialog(parent = self, giface = self._giface, link = True)
         dlg.CentreOnScreen()
         dlg.CentreOnScreen()
         dlg.Show()
         dlg.Show()
         
         
     def OnImportOgrLayers(self, event, cmd = None):
     def OnImportOgrLayers(self, event, cmd = None):
         """!Convert multiple OGR layers to GRASS vector map layers"""
         """!Convert multiple OGR layers to GRASS vector map layers"""
-        dlg = GdalImportDialog(parent = self, ogr = True)
+        dlg = GdalImportDialog(parent = self, giface = self._giface, ogr = True)
         dlg.CentreOnScreen()
         dlg.CentreOnScreen()
         dlg.Show()
         dlg.Show()
         
         
     def OnLinkOgrLayers(self, event, cmd = None):
     def OnLinkOgrLayers(self, event, cmd = None):
         """!Links multiple OGR layers to GRASS vector map layers"""
         """!Links multiple OGR layers to GRASS vector map layers"""
-        dlg = GdalImportDialog(parent = self, ogr = True, link = True)
+        dlg = GdalImportDialog(parent = self, giface = self._giface, ogr = True, link = True)
         dlg.CentreOnScreen()
         dlg.CentreOnScreen()
         dlg.Show()
         dlg.Show()
         
         
@@ -1569,7 +1567,8 @@ class GMFrame(wx.Frame):
         self.currentPage = self.notebookLayers.GetCurrentPage()
         self.currentPage = self.notebookLayers.GetCurrentPage()
         
         
         # create layer tree (tree control for managing GIS layers)  and put on new notebook page
         # create layer tree (tree control for managing GIS layers)  and put on new notebook page
-        self.currentPage.maptree = LayerTree(self.currentPage, id = wx.ID_ANY, pos = wx.DefaultPosition,
+        self.currentPage.maptree = LayerTree(self.currentPage, giface = self._giface,
+                                             id = wx.ID_ANY, pos = wx.DefaultPosition,
                                              size = wx.DefaultSize, style = wx.TR_HAS_BUTTONS |
                                              size = wx.DefaultSize, style = wx.TR_HAS_BUTTONS |
                                              wx.TR_LINES_AT_ROOT| wx.TR_HIDE_ROOT |
                                              wx.TR_LINES_AT_ROOT| wx.TR_HIDE_ROOT |
                                              wx.TR_DEFAULT_STYLE| wx.NO_BORDER | wx.FULL_REPAINT_ON_RESIZE,
                                              wx.TR_DEFAULT_STYLE| wx.NO_BORDER | wx.FULL_REPAINT_ON_RESIZE,
@@ -1678,7 +1677,7 @@ class GMFrame(wx.Frame):
         if not self.currentPage:
         if not self.currentPage:
             self.AddMaps([mapName], grassType, check = True)
             self.AddMaps([mapName], grassType, check = True)
         else:
         else:
-            display = self.GetLayerTree().GetMapDisplay()
+            display = self.GetMapDisplay()
             mapLayers = map(lambda x: x.GetName(),
             mapLayers = map(lambda x: x.GetName(),
                             display.GetMap().GetListOfLayers(l_type = ltype))
                             display.GetMap().GetListOfLayers(l_type = ltype))
             if mapName in mapLayers:
             if mapName in mapLayers:
@@ -1784,12 +1783,12 @@ class GMFrame(wx.Frame):
     def OnAddRasterArrow(self, event):
     def OnAddRasterArrow(self, event):
         """!Add flow arrows raster map to the current layer tree"""
         """!Add flow arrows raster map to the current layer tree"""
         self.notebook.SetSelectionByName('layers')
         self.notebook.SetSelectionByName('layers')
-        tree = self.GetLayerTree()
-        resolution = tree.GetMapDisplay().GetProperty('resolution')
+        mapdisplay = self.GetMapDisplay()
+        resolution = mapdisplay.GetProperty('resolution')
         if not resolution:
         if not resolution:
             dlg = self.MsgDisplayResolution()
             dlg = self.MsgDisplayResolution()
             if dlg.ShowModal() == wx.ID_YES:
             if dlg.ShowModal() == wx.ID_YES:
-                tree.GetMapDisplay().SetProperty('resolution', True)
+                mapdisplay.SetProperty('resolution', True)
             dlg.Destroy()
             dlg.Destroy()
 
 
         self.GetLayerTree().AddLayer('rastarrow')
         self.GetLayerTree().AddLayer('rastarrow')
@@ -1797,14 +1796,14 @@ class GMFrame(wx.Frame):
     def OnAddRasterNum(self, event):
     def OnAddRasterNum(self, event):
         """!Add cell number raster map to the current layer tree"""
         """!Add cell number raster map to the current layer tree"""
         self.notebook.SetSelectionByName('layers')
         self.notebook.SetSelectionByName('layers')
-        tree = self.GetLayerTree()
-        resolution = tree.GetMapDisplay().GetProperty('resolution')
+        mapdisplay = self.GetMapDisplay()
+        resolution = mapdisplay.GetProperty('resolution')
         if not resolution:
         if not resolution:
             limitText = _("Note that cell values can only be displayed for "
             limitText = _("Note that cell values can only be displayed for "
                           "regions of less than 10,000 cells.")
                           "regions of less than 10,000 cells.")
             dlg = self.MsgDisplayResolution(limitText)
             dlg = self.MsgDisplayResolution(limitText)
             if dlg.ShowModal() == wx.ID_YES:
             if dlg.ShowModal() == wx.ID_YES:
-                tree.GetMapDisplay().SetProperty('resolution', True)
+                mapdisplay.SetProperty('resolution', True)
             dlg.Destroy()
             dlg.Destroy()
 
 
         # region = tree.GetMap().GetCurrentRegion()
         # region = tree.GetMap().GetCurrentRegion()

+ 58 - 0
gui/wxpython/lmgr/giface.py

@@ -0,0 +1,58 @@
+"""!
+@package lmgr.giface
+
+@brief Layer Manager GRASS interface
+
+Classes:
+ - giface::LayerManagerGrassInterface
+
+(C) 2012 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 Anna Kratochvilova <kratochanna gmail.com>
+@author Vaclav Petras <wenzeslaus gmail.com>
+"""
+class LayerManagerGrassInterface:
+    def __init__(self, lmgr):
+        self.lmgr = lmgr
+
+    def RunCmd(self, *args, **kwargs):
+        self.lmgr.goutput.RunCmd(*args, **kwargs)
+
+    def Help(self, entry):
+        cmdlist = ['g.manual', 'entry=%s' % entry]
+        self.RunCmd(cmdlist, compReg = False, switchPage = False)
+
+    def WriteLog(self, text, wrap = None,
+                 switchPage = False, priority = 1):
+        self.lmgr.goutput.WriteLog(text = text, wrap = wrap, switchPage = switchPage,
+                                   priority = priority)
+
+    def WriteCmdLog(self, line, pid = None, switchPage = True):
+        self.lmgr.goutput.WriteCmdLog(line = line, pid = pid, switchPage = switchPage)
+
+    def WriteWarning(self, line):
+        self.lmgr.goutput.WriteWarning(line = line)
+
+    def WriteError(self, line):
+        self.lmgr.goutput.WriteError(line = line)
+
+    def GetLayerTree(self):
+        return self.lmgr.GetLayerTree()
+
+    def GetMapDisplay(self):
+        """!Get current map display.
+
+        @return MapFrame instance
+        @return None no mapdisplay open
+        """
+        return self.lmgr.GetMapDisplay(onlyCurrent = True)
+
+    def GetAllMapDisplays(self):
+        """!Get list of all map displays.
+
+        @return list of MapFrame instances
+        """
+        return self.lmgr.GetMapDisplay(onlyCurrent = False)

+ 14 - 12
gui/wxpython/lmgr/layertree.py

@@ -98,7 +98,7 @@ LMIcons = {
 class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
 class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
     """!Creates layer tree structure
     """!Creates layer tree structure
     """
     """
-    def __init__(self, parent,
+    def __init__(self, parent, giface,
                  id = wx.ID_ANY, style = wx.SUNKEN_BORDER,
                  id = wx.ID_ANY, style = wx.SUNKEN_BORDER,
                  ctstyle = CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT |
                  ctstyle = CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT |
                  CT.TR_HIDE_ROOT | CT.TR_ROW_LINES | CT.TR_FULL_ROW_HIGHLIGHT |
                  CT.TR_HIDE_ROOT | CT.TR_ROW_LINES | CT.TR_FULL_ROW_HIGHLIGHT |
@@ -115,6 +115,8 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
         del kwargs['notebook']
         del kwargs['notebook']
         showMapDisplay = kwargs['showMapDisplay']
         showMapDisplay = kwargs['showMapDisplay']
         del kwargs['showMapDisplay']
         del kwargs['showMapDisplay']
+
+        self._giface = giface
         self.treepg = parent                 # notebook page holding layer tree
         self.treepg = parent                 # notebook page holding layer tree
         self.Map = Map()                     # instance of render.Map to be associated with display
         self.Map = Map()                     # instance of render.Map to be associated with display
         self.root = None                     # ID of layer tree root node
         self.root = None                     # ID of layer tree root node
@@ -149,7 +151,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
         
         
         # init associated map display
         # init associated map display
         pos = wx.Point((self.displayIndex + 1) * 25, (self.displayIndex + 1) * 25)
         pos = wx.Point((self.displayIndex + 1) * 25, (self.displayIndex + 1) * 25)
-        self.mapdisplay = MapFrame(self, id = wx.ID_ANY, pos = pos,
+        self.mapdisplay = MapFrame(self, giface = self._giface, id = wx.ID_ANY, pos = pos,
                                    size = globalvar.MAP_WINDOW_SIZE,
                                    size = globalvar.MAP_WINDOW_SIZE,
                                    style = wx.DEFAULT_FRAME_STYLE,
                                    style = wx.DEFAULT_FRAME_STYLE,
                                    tree = self, notebook = self.notebook,
                                    tree = self, notebook = self.notebook,
@@ -488,14 +490,14 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
 
 
         self.PopupMenu(self.popupMenu)
         self.PopupMenu(self.popupMenu)
         self.popupMenu.Destroy()
         self.popupMenu.Destroy()
-        
+
     def OnTopology(self, event):
     def OnTopology(self, event):
         """!Rebuild topology of selected vector map"""
         """!Rebuild topology of selected vector map"""
         mapLayer = self.GetPyData(self.layer_selected)[0]['maplayer']
         mapLayer = self.GetPyData(self.layer_selected)[0]['maplayer']
         cmd = ['v.build',
         cmd = ['v.build',
                'map=%s' % mapLayer.GetName()]
                'map=%s' % mapLayer.GetName()]
-        self.lmgr.goutput.RunCmd(cmd, switchPage = True)
-        
+        self._giface.RunCmd(cmd, switchPage = True)
+
     def OnSqlQuery(self, event):
     def OnSqlQuery(self, event):
         """!Show SQL query window for PostGIS layers
         """!Show SQL query window for PostGIS layers
         """
         """
@@ -517,7 +519,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
         cmd.append('map=%s' % mapLayer.GetName())
         cmd.append('map=%s' % mapLayer.GetName())
 
 
         # print output to command log area
         # print output to command log area
-        self.lmgr.goutput.RunCmd(cmd, switchPage = True)
+        self._giface.RunCmd(cmd, switchPage = True)
 
 
     def OnSetCompRegFromRaster(self, event):
     def OnSetCompRegFromRaster(self, event):
         """!Set computational region from selected raster map (ignore NULLs)"""
         """!Set computational region from selected raster map (ignore NULLs)"""
@@ -528,8 +530,8 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
                'zoom=%s' % mapLayer.GetName()]
                'zoom=%s' % mapLayer.GetName()]
         
         
         # print output to command log area
         # print output to command log area
-        self.lmgr.goutput.RunCmd(cmd)
-         
+        self._giface.RunCmd(cmd)
+
     def OnSetCompRegFromMap(self, event):
     def OnSetCompRegFromMap(self, event):
         """!Set computational region from selected raster/vector map
         """!Set computational region from selected raster/vector map
         """
         """
@@ -561,8 +563,8 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
         # print output to command log area
         # print output to command log area
         if len(cmd) > 1:
         if len(cmd) > 1:
             cmd.append('-p')
             cmd.append('-p')
-            self.lmgr.goutput.RunCmd(cmd, compReg = False)
-        
+            self._giface.RunCmd(cmd, compReg = False)
+
     def OnProfile(self, event):
     def OnProfile(self, event):
         """!Plot profile of given raster map layer"""
         """!Plot profile of given raster map layer"""
         mapLayer = self.GetPyData(self.layer_selected)[0]['maplayer']
         mapLayer = self.GetPyData(self.layer_selected)[0]['maplayer']
@@ -621,8 +623,8 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
     def OnUnivariateStats(self, event):
     def OnUnivariateStats(self, event):
         """!Univariate raster statistics"""
         """!Univariate raster statistics"""
         name = self.GetPyData(self.layer_selected)[0]['maplayer'].GetName()
         name = self.GetPyData(self.layer_selected)[0]['maplayer'].GetName()
-        self.lmgr.goutput.RunCmd(['r.univar', 'map=%s' % name], switchPage = True)
-        
+        self._giface.RunCmd(['r.univar', 'map=%s' % name], switchPage = True)
+
     def OnStartEditing(self, event):
     def OnStartEditing(self, event):
         """!Start editing vector map layer requested by the user
         """!Start editing vector map layer requested by the user
         """
         """

+ 23 - 22
gui/wxpython/mapdisp/frame.py

@@ -62,7 +62,7 @@ class MapFrame(SingleMapFrame):
     """!Main frame for map display window. Drawing takes place in
     """!Main frame for map display window. Drawing takes place in
     child double buffered drawing window.
     child double buffered drawing window.
     """
     """
-    def __init__(self, parent = None, title = _("GRASS GIS - Map display"),
+    def __init__(self, parent, giface, title = _("GRASS GIS - Map display"),
                  toolbars = ["map"], tree = None, notebook = None, lmgr = None,
                  toolbars = ["map"], tree = None, notebook = None, lmgr = None,
                  page = None, Map = None, auimgr = None, name = 'MapWindow', **kwargs):
                  page = None, Map = None, auimgr = None, name = 'MapWindow', **kwargs):
         """!Main map display window with toolbars, statusbar and
         """!Main map display window with toolbars, statusbar and
@@ -81,6 +81,7 @@ class MapFrame(SingleMapFrame):
         SingleMapFrame.__init__(self, parent = parent, title = title,
         SingleMapFrame.__init__(self, parent = parent, title = title,
                               Map = Map, auimgr = auimgr, name = name, **kwargs)
                               Map = Map, auimgr = auimgr, name = name, **kwargs)
         
         
+        self._giface = giface
         self._layerManager = lmgr   # Layer Manager object
         self._layerManager = lmgr   # Layer Manager object
         self.tree       = tree      # Layer Manager layer tree object
         self.tree       = tree      # Layer Manager layer tree object
         self.page       = page      # Notebook page holding the layer tree
         self.page       = page      # Notebook page holding the layer tree
@@ -128,7 +129,7 @@ class MapFrame(SingleMapFrame):
         #
         #
         # Init map display (buffered DC & set default cursor)
         # Init map display (buffered DC & set default cursor)
         #
         #
-        self.MapWindow2D = BufferedWindow(self, id = wx.ID_ANY,
+        self.MapWindow2D = BufferedWindow(self, giface = self._giface, id = wx.ID_ANY,
                                           Map = self.Map, frame = self, tree = self.tree, lmgr = self._layerManager)
                                           Map = self.Map, frame = self, tree = self.tree, lmgr = self._layerManager)
         # default is 2D display mode
         # default is 2D display mode
         self.MapWindow = self.MapWindow2D
         self.MapWindow = self.MapWindow2D
@@ -208,7 +209,8 @@ class MapFrame(SingleMapFrame):
         
         
         if not self.MapWindowVDigit:
         if not self.MapWindowVDigit:
             from vdigit.mapwindow import VDigitWindow
             from vdigit.mapwindow import VDigitWindow
-            self.MapWindowVDigit = VDigitWindow(self, id = wx.ID_ANY, frame = self,
+            self.MapWindowVDigit = VDigitWindow(parent = self, giface = self._giface,
+                                                id = wx.ID_ANY, frame = self,
                                                 Map = self.Map, tree = self.tree,
                                                 Map = self.Map, tree = self.tree,
                                                 lmgr = self._layerManager)
                                                 lmgr = self._layerManager)
             self.MapWindowVDigit.Show()
             self.MapWindowVDigit.Show()
@@ -278,13 +280,13 @@ class MapFrame(SingleMapFrame):
         # erase map window
         # erase map window
         self.MapWindow.EraseMap()
         self.MapWindow.EraseMap()
         
         
-        self._layerManager.goutput.WriteCmdLog(_("Starting 3D view mode..."),
-                                               switchPage = False)
+        self._giface.WriteCmdLog(_("Starting 3D view mode..."),
+                                 switchPage = False)
         self.SetStatusText(_("Please wait, loading data..."), 0)
         self.SetStatusText(_("Please wait, loading data..."), 0)
         
         
         # create GL window
         # create GL window
         if not self.MapWindow3D:
         if not self.MapWindow3D:
-            self.MapWindow3D = GLWindow(self, id = wx.ID_ANY, frame = self,
+            self.MapWindow3D = GLWindow(self, giface = self._giface, id = wx.ID_ANY, frame = self,
                                         Map = self.Map, tree = self.tree, lmgr = self._layerManager)
                                         Map = self.Map, tree = self.tree, lmgr = self._layerManager)
             self.MapWindow = self.MapWindow3D
             self.MapWindow = self.MapWindow3D
             self.MapWindow.SetCursor(self.cursors["default"])
             self.MapWindow.SetCursor(self.cursors["default"])
@@ -341,8 +343,8 @@ class MapFrame(SingleMapFrame):
                                                        key = 'statusbarMode',
                                                        key = 'statusbarMode',
                                                        subkey = 'selection'))
                                                        subkey = 'selection'))
         self.SetStatusText(_("Please wait, unloading data..."), 0)
         self.SetStatusText(_("Please wait, unloading data..."), 0)
-        self._layerManager.goutput.WriteCmdLog(_("Switching back to 2D view mode..."),
-                                               switchPage = False)
+        self._giface.WriteCmdLog(_("Switching back to 2D view mode..."),
+                                  switchPage = False)
         if self.MapWindow3D:
         if self.MapWindow3D:
             self.MapWindow3D.OnClose(event = None)
             self.MapWindow3D.OnClose(event = None)
         # switch from MapWindowGL to MapWindow
         # switch from MapWindowGL to MapWindow
@@ -731,12 +733,12 @@ class MapFrame(SingleMapFrame):
                 lmap = digitToolbar.GetLayer().GetName()
                 lmap = digitToolbar.GetLayer().GetName()
                 for name in vect:
                 for name in vect:
                     if lmap == name:
                     if lmap == name:
-                        self._layerManager.goutput.WriteWarning(_("Vector map <%s> "
+                        self._giface.WriteWarning(_("Vector map <%s> "
                                                                   "opened for editing - skipped.") % map)
                                                                   "opened for editing - skipped.") % map)
                         vect.remove(name)
                         vect.remove(name)
             
             
             if len(vect) < 1:
             if len(vect) < 1:
-                self._layerManager.goutput.WriteCmdLog(_("Nothing to query."))
+                self._giface.WriteCmdLog(_("Nothing to query."))
                 return
                 return
             
             
             vcmd.append('-a')
             vcmd.append('-a')
@@ -750,12 +752,11 @@ class MapFrame(SingleMapFrame):
         # parse query command(s)
         # parse query command(s)
 
 
         if rast and not self.IsPaneShown('3d'):
         if rast and not self.IsPaneShown('3d'):
-            self._layerManager.goutput.RunCmd(rcmd,
-                                              compReg = False,
-                                              onDone  =  self._QueryMapDone)
+            self._giface.RunCmd(rcmd,
+                                compReg = False,
+                                onDone  =  self._QueryMapDone)
         if vect:
         if vect:
-            self._layerManager.goutput.RunCmd(vcmd,
-                                              onDone = self._QueryMapDone)
+            self._giface.RunCmd(vcmd, onDone = self._QueryMapDone)
         
         
     def _QueryMapDone(self, cmd, returncode):
     def _QueryMapDone(self, cmd, returncode):
         """!Restore settings after querying (restore GRASS_REGION)
         """!Restore settings after querying (restore GRASS_REGION)
@@ -805,7 +806,7 @@ class MapFrame(SingleMapFrame):
                 self.dialogs['attributes'].UpdateDialog(query = ((east, north), qdist),
                 self.dialogs['attributes'].UpdateDialog(query = ((east, north), qdist),
                                                         action = mode)
                                                         action = mode)
         if not self.dialogs['attributes'].IsFound():
         if not self.dialogs['attributes'].IsFound():
-            self._layerManager.goutput.WriteLog(_('Nothing found.'))
+            self._giface.WriteLog(_('Nothing found.'))
         
         
         cats = self.dialogs['attributes'].GetCats()
         cats = self.dialogs['attributes'].GetCats()
         
         
@@ -936,16 +937,16 @@ class MapFrame(SingleMapFrame):
         
         
         # initiating output
         # initiating output
         style = self._layerManager.goutput.cmdOutput.StyleWarning
         style = self._layerManager.goutput.cmdOutput.StyleWarning
-        self._layerManager.goutput.WriteLog(_('Click and drag with left mouse button '
+        self._giface.WriteLog(_('Click and drag with left mouse button '
                                               'to measure.%s'
                                               'to measure.%s'
                                               'Double click with left button to clear.') % \
                                               'Double click with left button to clear.') % \
                                                 (os.linesep), style)
                                                 (os.linesep), style)
         if self.Map.projinfo['proj'] != 'xy':
         if self.Map.projinfo['proj'] != 'xy':
             units = self.Map.projinfo['units']
             units = self.Map.projinfo['units']
-            self._layerManager.goutput.WriteCmdLog(_('Measuring distance') + ' ('
-                                                   + units + '):')
+            self._giface.WriteCmdLog(_('Measuring distance') + ' ('
+                                      + units + '):')
         else:
         else:
-            self._layerManager.goutput.WriteCmdLog(_('Measuring distance:'))
+            self._giface.WriteCmdLog(_('Measuring distance:'))
         
         
         if self.Map.projinfo['proj'] == 'll':
         if self.Map.projinfo['proj'] == 'll':
             try:
             try:
@@ -955,7 +956,7 @@ class MapFrame(SingleMapFrame):
 
 
                 gislib.G_begin_distance_calculations()
                 gislib.G_begin_distance_calculations()
             except ImportError, e:
             except ImportError, e:
-                self._layerManager.goutput.WriteWarning(_('Geodesic distance is not yet '
+                self._giface.WriteWarning(_('Geodesic distance is not yet '
                                                           'supported by this tool.\n'
                                                           'supported by this tool.\n'
                                                           'Reason: %s' % e))
                                                           'Reason: %s' % e))
         
         
@@ -993,7 +994,7 @@ class MapFrame(SingleMapFrame):
                    _('total distance'), strtotdist, tdunits,
                    _('total distance'), strtotdist, tdunits,
                    '-' * 60)
                    '-' * 60)
         
         
-        self._layerManager.goutput.WriteLog(mstring)
+        self._giface.WriteLog(mstring)
         
         
         return dist
         return dist
 
 

+ 2 - 2
gui/wxpython/mapdisp/mapwindow.py

@@ -51,10 +51,10 @@ class BufferedWindow(MapWindow, wx.Window):
     can also save the drawing to file by calling the
     can also save the drawing to file by calling the
     SaveToFile() method.
     SaveToFile() method.
     """
     """
-    def __init__(self, parent, Map, frame,
+    def __init__(self, parent, giface, Map, frame,
                  id = wx.ID_ANY, tree = None, lmgr = None,
                  id = wx.ID_ANY, tree = None, lmgr = None,
                  style = wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs):
                  style = wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs):
-        MapWindow.__init__(self, parent = parent, id = id, Map = Map,
+        MapWindow.__init__(self, parent = parent, giface = giface, id = id, Map = Map,
                            frame = frame, tree = tree, lmgr = lmgr, **kwargs)
                            frame = frame, tree = tree, lmgr = lmgr, **kwargs)
         wx.Window.__init__(self, parent = parent, id = id, style = style, **kwargs)
         wx.Window.__init__(self, parent = parent, id = id, style = style, **kwargs)
         
         

+ 8 - 7
gui/wxpython/mapswipe/frame.py

@@ -35,7 +35,8 @@ from mapswipe.dialogs   import SwipeMapDialog
 
 
 
 
 class SwipeMapFrame(DoubleMapFrame):
 class SwipeMapFrame(DoubleMapFrame):
-    def __init__(self, parent  = None, title = _("GRASS GIS Map Swipe"), name = "swipe", **kwargs):
+    def __init__(self, parent  = None, giface = None, 
+                 title = _("GRASS GIS Map Swipe"), name = "swipe", **kwargs):
         DoubleMapFrame.__init__(self, parent = parent, title = title, name = name,
         DoubleMapFrame.__init__(self, parent = parent, title = title, name = name,
                                 firstMap = Map(), secondMap = Map(), **kwargs)
                                 firstMap = Map(), secondMap = Map(), **kwargs)
         Debug.msg (1, "SwipeMapFrame.__init__()")
         Debug.msg (1, "SwipeMapFrame.__init__()")
@@ -50,7 +51,7 @@ class SwipeMapFrame(DoubleMapFrame):
             self.AddToolbar(toolbars.pop(0))
             self.AddToolbar(toolbars.pop(0))
         for toolb in toolbars:
         for toolb in toolbars:
             self.AddToolbar(toolb)
             self.AddToolbar(toolb)
-
+        self._giface = giface
         #
         #
         # create widgets
         # create widgets
         #
         #
@@ -59,8 +60,10 @@ class SwipeMapFrame(DoubleMapFrame):
         self.sliderH = wx.Slider(self, id = wx.ID_ANY, style = wx.SL_HORIZONTAL)
         self.sliderH = wx.Slider(self, id = wx.ID_ANY, style = wx.SL_HORIZONTAL)
         self.sliderV = wx.Slider(self, id = wx.ID_ANY, style = wx.SL_VERTICAL)
         self.sliderV = wx.Slider(self, id = wx.ID_ANY, style = wx.SL_VERTICAL)
         
         
-        self.firstMapWindow = SwipeBufferedWindow(parent = self.splitter, Map = self.firstMap, frame = self)
-        self.secondMapWindow = SwipeBufferedWindow(parent = self.splitter, Map = self.secondMap, frame = self)
+        self.firstMapWindow = SwipeBufferedWindow(parent = self.splitter, giface = self._giface,
+                                                  Map = self.firstMap, frame = self)
+        self.secondMapWindow = SwipeBufferedWindow(parent = self.splitter, giface = self._giface,
+                                                   Map = self.secondMap, frame = self)
         self.MapWindow = self.firstMapWindow # current by default
         self.MapWindow = self.firstMapWindow # current by default
         self.firstMap.region = self.secondMap.region
         self.firstMap.region = self.secondMap.region
         self.firstMapWindow.zoomhistory = self.secondMapWindow.zoomhistory
         self.firstMapWindow.zoomhistory = self.secondMapWindow.zoomhistory
@@ -459,9 +462,7 @@ class SwipeMapFrame(DoubleMapFrame):
         return True
         return True
 
 
     def OnHelp(self, event):
     def OnHelp(self, event):
-        RunCommand('g.manual',
-                   quiet = True,
-                   entry = 'wxGUI.MapSwipe')
+        self._giface.Help(entry = 'wxGUI.MapSwipe')
 
 
     def OnCloseWindow(self, event):
     def OnCloseWindow(self, event):
         self.GetFirstMap().Clean()
         self.GetFirstMap().Clean()

+ 3 - 2
gui/wxpython/mapswipe/g.gui.mapswipe.py

@@ -45,7 +45,8 @@ import grass.script as grass
 if __name__ == '__main__':
 if __name__ == '__main__':
     sys.path.append(os.path.join(os.environ['GISBASE'], "etc", "gui", "wxpython"))
     sys.path.append(os.path.join(os.environ['GISBASE'], "etc", "gui", "wxpython"))
 
 
-from core.settings  import UserSettings
+from core.settings import UserSettings
+from core.giface import StandaloneGrassInterface
 from mapswipe.frame import SwipeMapFrame
 from mapswipe.frame import SwipeMapFrame
 
 
 
 
@@ -72,7 +73,7 @@ def main():
     app = wx.PySimpleApp()
     app = wx.PySimpleApp()
     wx.InitAllImageHandlers()
     wx.InitAllImageHandlers()
 
 
-    frame = SwipeMapFrame()
+    frame = SwipeMapFrame(parent = None, giface = StandaloneGrassInterface())
     
     
     if first:
     if first:
         frame.SetFirstRaster(first)
         frame.SetFirstRaster(first)

+ 3 - 2
gui/wxpython/mapswipe/mapwindow.py

@@ -35,9 +35,10 @@ class SwipeBufferedWindow(BufferedWindow):
     Enables to draw the image translated.
     Enables to draw the image translated.
     Special mouse events with changed coordinates are used.
     Special mouse events with changed coordinates are used.
     """
     """
-    def __init__(self, parent, Map, frame,
+    def __init__(self, parent, giface, Map, frame,
                  tree = None, lmgr = None, **kwargs):
                  tree = None, lmgr = None, **kwargs):
-        BufferedWindow.__init__(self, parent = parent, Map = Map, frame = frame, tree = tree, lmgr = lmgr, **kwargs)
+        BufferedWindow.__init__(self, parent = parent, giface = giface,
+                                Map = Map, frame = frame, tree = tree, lmgr = lmgr, **kwargs)
         Debug.msg(2, "SwipeBufferedWindow.__init__()")
         Debug.msg(2, "SwipeBufferedWindow.__init__()")
 
 
         self.specialSize = super(SwipeBufferedWindow, self).GetClientSize()
         self.specialSize = super(SwipeBufferedWindow, self).GetClientSize()

+ 2 - 2
gui/wxpython/nviz/mapwindow.py

@@ -67,12 +67,12 @@ class NvizThread(Thread):
 
 
 class GLWindow(MapWindow, glcanvas.GLCanvas):
 class GLWindow(MapWindow, glcanvas.GLCanvas):
     """!OpenGL canvas for Map Display Window"""
     """!OpenGL canvas for Map Display Window"""
-    def __init__(self, parent, id = wx.ID_ANY, frame = None,
+    def __init__(self, parent, giface, id = wx.ID_ANY, frame = None,
                  Map = None, tree = None, lmgr = None):
                  Map = None, tree = None, lmgr = None):
         self.parent = parent # MapFrame
         self.parent = parent # MapFrame
         
         
         glcanvas.GLCanvas.__init__(self, parent, id)
         glcanvas.GLCanvas.__init__(self, parent, id)
-        MapWindow.__init__(self, parent = parent, id = id, frame = frame,
+        MapWindow.__init__(self, parent = parent, giface = giface, id = id, frame = frame,
                            Map = Map, tree = tree, lmgr = lmgr)
                            Map = Map, tree = tree, lmgr = lmgr)
         self.Hide()
         self.Hide()
         
         

+ 2 - 2
gui/wxpython/vdigit/mapwindow.py

@@ -28,10 +28,10 @@ from vdigit.dialogs import VDigitCategoryDialog, VDigitZBulkDialog, VDigitDuplic
 class VDigitWindow(BufferedWindow):
 class VDigitWindow(BufferedWindow):
     """!A Buffered window extended for vector digitizer.
     """!A Buffered window extended for vector digitizer.
     """
     """
-    def __init__(self, parent, Map, frame,
+    def __init__(self, parent, giface, Map, frame,
                  id = wx.ID_ANY, tree = None, lmgr = None,
                  id = wx.ID_ANY, tree = None, lmgr = None,
                  style = wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs):
                  style = wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs):
-        BufferedWindow.__init__(self, parent = parent, id = id, Map = Map,
+        BufferedWindow.__init__(self, parent = parent, giface = giface, id = id, Map = Map,
                                 frame = frame, tree = tree, lmgr = lmgr, style = style, **kwargs)
                                 frame = frame, tree = tree, lmgr = lmgr, style = style, **kwargs)
         
         
         self.pdcVector = wx.PseudoDC()
         self.pdcVector = wx.PseudoDC()