[GRASS-SVN] r59274 - in grass/trunk/gui/wxpython: gmodeler gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Mar 17 06:48:31 PDT 2014


Author: martinl
Date: 2014-03-17 06:48:30 -0700 (Mon, 17 Mar 2014)
New Revision: 59274

Modified:
   grass/trunk/gui/wxpython/gmodeler/giface.py
   grass/trunk/gui/wxpython/gui_core/gselect.py
Log:
wxGUI/modeler: fix bug reported at
               http://gis.stackexchange.com/questions/89412/runtimeerror-from-r-viewshed-in-graphic-modeler


Modified: grass/trunk/gui/wxpython/gmodeler/giface.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/giface.py	2014-03-16 16:58:53 UTC (rev 59273)
+++ grass/trunk/gui/wxpython/gmodeler/giface.py	2014-03-17 13:48:30 UTC (rev 59274)
@@ -6,7 +6,7 @@
 Classes:
  - giface::GraphicalModelerGrassInterface
 
-(C) 2013 by the GRASS Development Team
+(C) 2013-2014 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.
@@ -14,16 +14,22 @@
 @author Martin Landa <landa.martin gmail.com>
 """
 
-class GraphicalModelerGrassInterface(object):
+from grass.pydispatch.signal import Signal
+
+class GraphicalModelerGrassInterface():
     """!@implements core::giface::GrassInterface"""
     def __init__(self, model):
         self._model = model
+    
+        # Signal emitted to request updating of map (TODO)
+        self.updateMap = Signal('GraphicalModelerGrassInterface.updateMap')
         
-    def __getattr__(self, name):
-        return getattr(self._giface, name)
-    
     def GetLayerTree(self):
         return None
     
     def GetLayerList(self, prompt):
         return self._model.GetMaps(prompt)
+
+    def GetMapDisplay(self):
+        """@todo: implement connection with mapdisplay"""
+        return None

Modified: grass/trunk/gui/wxpython/gui_core/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/gselect.py	2014-03-16 16:58:53 UTC (rev 59273)
+++ grass/trunk/gui/wxpython/gui_core/gselect.py	2014-03-17 13:48:30 UTC (rev 59274)
@@ -2145,10 +2145,13 @@
                                                                    size=globalvar.DIALOG_COLOR_SIZE)
         self.registered = False
         self.buttonInsCoords.Bind(wx.EVT_BUTTON, self._onClick)
-        switcher = self._giface.GetMapDisplay().GetToolSwitcher()
-        switcher.AddCustomToolToGroup(group='mouseUse',
-                                      btnId=self.buttonInsCoords.GetId(), 
-                                      toggleHandler=self.buttonInsCoords.SetValue)
+
+        mapdisp = self._giface.GetMapDisplay()
+        if mapdisp:
+            switcher = mapdisp.GetToolSwitcher()
+            switcher.AddCustomToolToGroup(group='mouseUse',
+                                          btnId=self.buttonInsCoords.GetId(), 
+                                          toggleHandler=self.buttonInsCoords.SetValue)
         self._doLayout()
         self.coordsField.Bind(wx.EVT_TEXT, lambda event : self._draw(delay=1))
         
@@ -2239,8 +2242,11 @@
         self.drawCleanUp()
         self._giface.updateMap.emit(render=False, renderVector=False)
  
-        switcher = self._giface.GetMapDisplay().GetToolSwitcher()
-        switcher.RemoveCustomToolFromGroup(self.buttonInsCoords.GetId())
+        mapdisp = self._giface.GetMapDisplay()
+        if mapdisp:
+            switcher = mapdisp.GetToolSwitcher()
+            switcher.RemoveCustomToolFromGroup(self.buttonInsCoords.GetId())
+        
         if self.mapWin and self.registered:
             self.mapWin.UnregisterMouseEventHandler(wx.EVT_LEFT_DOWN,  
                                                     self._onMapClickHandler)



More information about the grass-commit mailing list