[GRASS-SVN] r54006 - in grass/trunk/gui/wxpython: core gui_core lmgr scripts

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Nov 24 01:33:18 PST 2012


Author: annakrat
Date: 2012-11-24 01:33:17 -0800 (Sat, 24 Nov 2012)
New Revision: 54006

Modified:
   grass/trunk/gui/wxpython/core/gconsole.py
   grass/trunk/gui/wxpython/gui_core/forms.py
   grass/trunk/gui/wxpython/gui_core/gselect.py
   grass/trunk/gui/wxpython/lmgr/frame.py
   grass/trunk/gui/wxpython/lmgr/giface.py
   grass/trunk/gui/wxpython/scripts/vkrige.py
Log:
wxGUI: use interface for CoordinatesSelect (co-author: wenzeslaus)

Modified: grass/trunk/gui/wxpython/core/gconsole.py
===================================================================
--- grass/trunk/gui/wxpython/core/gconsole.py	2012-11-24 09:30:39 UTC (rev 54005)
+++ grass/trunk/gui/wxpython/core/gconsole.py	2012-11-24 09:33:17 UTC (rev 54006)
@@ -330,7 +330,7 @@
 class GConsole(wx.EvtHandler):
     """!
     """
-    def __init__(self, guiparent=None, lmgr=None, ignoredCmdPattern=None):
+    def __init__(self, guiparent=None, giface=None, ignoredCmdPattern=None):
         """!
         @param guiparent parent window for created GUI objects
         @param lmgr layer manager window (TODO: replace by giface)
@@ -340,7 +340,7 @@
         wx.EvtHandler.__init__(self)
 
         self._guiparent = guiparent
-        self._lmgr = lmgr
+        self._giface = giface
         self._ignoredCmdPattern = ignoredCmdPattern
 
         # create queues
@@ -504,7 +504,7 @@
                         command[0] != 'v.krige':
                     # no arguments given
                     try:
-                        GUI(parent = self._guiparent, lmgr = self._lmgr).ParseCommand(command)
+                        GUI(parent=self._guiparent, giface=self._giface).ParseCommand(command)
                     except GException, e:
                         print >> sys.stderr, e
                     return
@@ -548,7 +548,7 @@
 
             if task:
                 # process GRASS command without argument
-                GUI(parent=self._guiparent, lmgr=self._lmgr).ParseCommand(command)
+                GUI(parent=self._guiparent, giface=self._giface).ParseCommand(command)
             else:
                 self.cmdThread.RunCmd(command,
                                       stdout=self.cmdStdOut,

Modified: grass/trunk/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/forms.py	2012-11-24 09:30:39 UTC (rev 54005)
+++ grass/trunk/gui/wxpython/gui_core/forms.py	2012-11-24 09:33:17 UTC (rev 54006)
@@ -360,14 +360,14 @@
     The command is checked and sent to the clipboard when clicking
     'Copy'.
     """
-    def __init__(self, parent, task_description, id = wx.ID_ANY,
+    def __init__(self, parent, giface, task_description, id = wx.ID_ANY,
                  get_dcmd = None, layer = None,
-                 style = wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL, lmgr = None, **kwargs):
+                 style = wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL, **kwargs):
         self.get_dcmd = get_dcmd
         self.layer    = layer
         self.task     = task_description
         self.parent   = parent             # LayerTree | Modeler | None | ...
-        self.lmgr     = lmgr  
+        self._giface  = giface
         if parent and parent.GetName() == 'Modeler':
             self.modeler = self.parent
         else:
@@ -432,8 +432,8 @@
         self.Layout()
         
         # notebooks
-        self.notebookpanel = CmdPanel(parent = self.panel, task = self.task,
-                                      frame = self, lmgr = self.lmgr)
+        self.notebookpanel = CmdPanel(parent = self.panel, giface = self._giface, task = self.task,
+                                      frame = self)
         self._gconsole = self.notebookpanel._gconsole
         self.goutput = self.notebookpanel.goutput
         self.notebookpanel.OnUpdateValues = self.updateValuesHook
@@ -753,12 +753,13 @@
     """!A panel containing a notebook dividing in tabs the different
     guisections of the GRASS cmd.
     """
-    def __init__(self, parent, task, id = wx.ID_ANY, frame = None, lmgr = None, *args, **kwargs):
+    def __init__(self, parent, giface, task, id = wx.ID_ANY, frame = None, *args, **kwargs):
         if frame:
             self.parent = frame
         else:
             self.parent = parent
         self.task = task
+        self._giface = giface
         
         wx.Panel.__init__(self, parent, id = id, *args, **kwargs)
         
@@ -1444,9 +1445,9 @@
                 # interactive inserting of coordinates from map window
                 elif prompt == 'coords':
                     # interactive inserting if layer manager is accessible
-                    if lmgr:
-                        win = gselect.CoordinatesSelect(parent = which_panel, 
-                                                        lmgr = lmgr, 
+                    if self._giface:
+                        win = gselect.CoordinatesSelect(parent = which_panel,
+                                                        giface = self._giface,
                                                         multiple =  p.get('multiple', False),
                                                         param = p)
                         p['wxId'] = [win.GetTextWin().GetId()]
@@ -2057,15 +2058,15 @@
 
 
 class GUI:
-    def __init__(self, parent = None, show = True, modal = False,
-                 centreOnParent = False, checkError = False, lmgr = None):
+    def __init__(self, parent = None, giface = None, show = True, modal = False,
+                 centreOnParent = False, checkError = False):
         """!Parses GRASS commands when module is imported and used from
         Layer Manager.
         """
         self.parent = parent
         self.show   = show
         self.modal  = modal
-        self.lmgr   = lmgr
+        self._giface = giface
         self.centreOnParent = centreOnParent
         self.checkError     = checkError
         
@@ -2169,10 +2170,9 @@
             cmd = cmd_validated
         
         if self.show is not None:
-            self.mf = TaskFrame(parent = self.parent,
+            self.mf = TaskFrame(parent = self.parent, giface = self._giface,
                                 task_description = self.grass_task,
-                                get_dcmd = get_dcmd, layer = layer,
-                                lmgr = self.lmgr)
+                                get_dcmd = get_dcmd, layer = layer)
         else:
             self.mf = None
         
@@ -2244,7 +2244,7 @@
                         _('Try to set up GRASS_ADDON_PATH or GRASS_ADDON_BASE variable.'))
             return True
         
-        self.mf = TaskFrame(parent = None, task_description = self.grass_task)
+        self.mf = TaskFrame(parent = None, giface = None, task_description = self.grass_task)
         self.mf.CentreOnScreen()
         self.mf.Show(True)
         self.SetTopWindow(self.mf)

Modified: grass/trunk/gui/wxpython/gui_core/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/gselect.py	2012-11-24 09:30:39 UTC (rev 54005)
+++ grass/trunk/gui/wxpython/gui_core/gselect.py	2012-11-24 09:33:17 UTC (rev 54006)
@@ -1969,14 +1969,14 @@
             return 'boundary'
 
 class CoordinatesSelect(wx.Panel):
-    def __init__(self, parent, lmgr = None, multiple = False, **kwargs):
+    def __init__(self, parent, giface, multiple = False, **kwargs):
         """!Widget to get coordinates from map window  by mouse click
         
         @param parent parent window
-        @param lmgr layer manager 
+        @param giface GRASS interface
         @param multiple - True if it is possible to insert more coordinates
         """
-        self.lmgr     = lmgr
+        self._giface = giface
         self.multiple = multiple
         self.mapWin   = None
         
@@ -2003,8 +2003,8 @@
         
     def _onClick(self, event):
         """!Button for interacitve inserting of coordinates clicked"""
-        if self.buttonInsCoords.GetToggle() and self.lmgr.GetLayerTree():   
-            self.mapWin = self.lmgr.GetLayerTree().GetMapDisplay().GetWindow()            
+        self.mapWin = self._giface.GetMapWindow()
+        if self.buttonInsCoords.GetToggle() and self.mapWin:
             if self.mapWin.RegisterMouseEventHandler(wx.EVT_LEFT_DOWN, 
                                                      self._onMapClickHandler,
                                                      wx.StockCursor(wx.CURSOR_CROSS)) == False:
@@ -2012,7 +2012,7 @@
                 return
             
             self.registered = True
-            self.lmgr.GetLayerTree().GetMapDisplay().Raise()
+            self._giface.GetMapDisplay().Raise()
         else:
             if self.mapWin and \
                     self.mapWin.UnregisterMouseEventHandler(wx.EVT_LEFT_DOWN,  

Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py	2012-11-24 09:30:39 UTC (rev 54005)
+++ grass/trunk/gui/wxpython/lmgr/frame.py	2012-11-24 09:33:17 UTC (rev 54006)
@@ -266,7 +266,7 @@
         self.notebook.AddPage(page = self.notebookLayers, text = _("Map layers"), name = 'layers')
         
         # create 'command output' text area
-        self._gconsole = GConsole(guiparent = self, lmgr = self,
+        self._gconsole = GConsole(guiparent = self, giface = self._giface,
                                   ignoredCmdPattern = '^d\..*|^r[3]?\.mapcalc$')
         self.goutput = GConsoleWindow(parent = self, gconsole = self._gconsole,
                                       gcstyle = GC_SEARCH | GC_PROMPT)

Modified: grass/trunk/gui/wxpython/lmgr/giface.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/giface.py	2012-11-24 09:30:39 UTC (rev 54005)
+++ grass/trunk/gui/wxpython/lmgr/giface.py	2012-11-24 09:33:17 UTC (rev 54006)
@@ -14,6 +14,7 @@
 @author Anna Kratochvilova <kratochanna gmail.com>
 @author Vaclav Petras <wenzeslaus gmail.com>
 """
+
 class LayerManagerGrassInterface:
     def __init__(self, lmgr):
         self.lmgr = lmgr
@@ -48,11 +49,17 @@
         @return MapFrame instance
         @return None no mapdisplay open
         """
-        return self.lmgr.GetMapDisplay(onlyCurrent = True)
+        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)
\ No newline at end of file
+        return self.lmgr.GetMapDisplay(onlyCurrent=False)
+
+    def GetMapWindow(self):
+        if self.lmgr.GetMapDisplay(onlyCurrent=True):
+            return self.lmgr.GetMapDisplay(onlyCurrent=True).GetMapWindow()
+        else:
+            return None

Modified: grass/trunk/gui/wxpython/scripts/vkrige.py
===================================================================
--- grass/trunk/gui/wxpython/scripts/vkrige.py	2012-11-24 09:30:39 UTC (rev 54005)
+++ grass/trunk/gui/wxpython/scripts/vkrige.py	2012-11-24 09:33:17 UTC (rev 54006)
@@ -99,7 +99,7 @@
             self.CreatePage(package = Rpackage, Rinstance = Rinstance, controller = controller)
         
         ## Command output. From menuform module, cmdPanel class
-        self._console = gconsole.GConsole(guiparent = self, lmgr = None)
+        self._console = gconsole.GConsole(guiparent = self)
         self.goutput = goutput.GConsoleWindow(parent = self, gconsole = self._gconsole, margin = False,
                                               gcstyle = goutput.GC_SEARCH | goutput.GC_PROMPT)
         self.goutputId = self.RPackagesBook.GetPageCount()



More information about the grass-commit mailing list