Browse Source

wxGUI/modeler: fix bug reported at
http://gis.stackexchange.com/questions/89412/runtimeerror-from-r-viewshed-in-graphic-modeler


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@59274 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 11 years ago
parent
commit
30ebe0c00b
2 changed files with 23 additions and 11 deletions
  1. 11 5
      gui/wxpython/gmodeler/giface.py
  2. 12 6
      gui/wxpython/gui_core/gselect.py

+ 11 - 5
gui/wxpython/gmodeler/giface.py

@@ -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 @@ This program is free software under the GNU General Public License
 @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
-        
-    def __getattr__(self, name):
-        return getattr(self._giface, name)
     
+        # Signal emitted to request updating of map (TODO)
+        self.updateMap = Signal('GraphicalModelerGrassInterface.updateMap')
+        
     def GetLayerTree(self):
         return None
     
     def GetLayerList(self, prompt):
         return self._model.GetMaps(prompt)
+
+    def GetMapDisplay(self):
+        """@todo: implement connection with mapdisplay"""
+        return None

+ 12 - 6
gui/wxpython/gui_core/gselect.py

@@ -2145,10 +2145,13 @@ class CoordinatesSelect(wx.Panel):
                                                                    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 @@ class CoordinatesSelect(wx.Panel):
         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)