[GRASS-SVN] r57083 - in grass/trunk/gui/wxpython: gcp gui_core iclass mapdisp mapswipe

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jul 13 09:16:17 PDT 2013


Author: wenzeslaus
Date: 2013-07-13 09:16:17 -0700 (Sat, 13 Jul 2013)
New Revision: 57083

Modified:
   grass/trunk/gui/wxpython/gcp/mapdisplay.py
   grass/trunk/gui/wxpython/gui_core/mapdisp.py
   grass/trunk/gui/wxpython/iclass/frame.py
   grass/trunk/gui/wxpython/mapdisp/frame.py
   grass/trunk/gui/wxpython/mapswipe/frame.py
Log:
wxGUI/mapwindow: reflecting new way of handling zoom history (gcp, mapswipe and iclass were broken before r57078 for unknown reason)

Modified: grass/trunk/gui/wxpython/gcp/mapdisplay.py
===================================================================
--- grass/trunk/gui/wxpython/gcp/mapdisplay.py	2013-07-13 16:06:32 UTC (rev 57082)
+++ grass/trunk/gui/wxpython/gcp/mapdisplay.py	2013-07-13 16:16:17 UTC (rev 57083)
@@ -121,6 +121,8 @@
                                           Map=self.TgtMap, frame = self, tree=self.tree, lmgr=self._layerManager)
         self.MapWindow = self.SrcMapWindow
         self.Map = self.SrcMap
+        self._setUpMapWindow(self.SrcMapWindow)
+        self._setUpMapWindow(self.TgtMapWindow)
         self.SrcMapWindow.SetCursor(self.cursors["cross"])
         self.TgtMapWindow.SetCursor(self.cursors["cross"])
 
@@ -200,6 +202,15 @@
 
         self.decorationDialog = None # decoration/overlays
 
+    def _setUpMapWindow(self, mapWindow):
+        # enable or disable zoom history tool
+        mapWindow.zoomHistoryAvailable.connect(
+            lambda:
+            self.GetMapToolbar().Enable('zoomback', enable=True))
+        mapWindow.zoomHistoryUnavailable.connect(
+            lambda:
+            self.GetMapToolbar().Enable('zoomback', enable=False))
+
     def AddToolbar(self, name):
         """!Add defined toolbar to the window
         

Modified: grass/trunk/gui/wxpython/gui_core/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/mapdisp.py	2013-07-13 16:06:32 UTC (rev 57082)
+++ grass/trunk/gui/wxpython/gui_core/mapdisp.py	2013-07-13 16:16:17 UTC (rev 57083)
@@ -42,7 +42,9 @@
     
     If derived class enables and disables auto-rendering,
     it should override IsAutoRendered method.
-    
+
+    It is expected that derived class will call _setUpMapWindow().
+
     Derived class can has one or more map windows (and map renderes)
     but implementation of MapFrameBase expects that one window and
     one map will be current.
@@ -300,7 +302,18 @@
         
         win = self.GetWindow()
         self._prepareZoom(mapWindow = win, zoomType = -1)
-        
+
+    def _setUpMapWindow(self, mapWindow):
+        """Binds map windows' zoom history signals to map toolbar."""
+        # enable or disable zoom history tool
+        import sys
+        mapWindow.zoomHistoryAvailable.connect(
+            lambda:
+            self.GetMapToolbar().Enable('zoomBack', enable=True))
+        mapWindow.zoomHistoryUnavailable.connect(
+            lambda:
+            self.GetMapToolbar().Enable('zoomBack', enable=False))
+
     def _prepareZoom(self, mapWindow, zoomType):
         """!Prepares MapWindow for zoom, toggles toolbar
         
@@ -443,7 +456,7 @@
     when both map windows will be initialized.
     
     Drived class should have method GetMapToolbar() returns toolbar
-    which has method SetActiveMap().
+    which has methods SetActiveMap() and Enable().
     
     @note To access maps use getters only
     (when using class or when writing class itself).

Modified: grass/trunk/gui/wxpython/iclass/frame.py
===================================================================
--- grass/trunk/gui/wxpython/iclass/frame.py	2013-07-13 16:06:32 UTC (rev 57082)
+++ grass/trunk/gui/wxpython/iclass/frame.py	2013-07-13 16:16:17 UTC (rev 57083)
@@ -93,7 +93,11 @@
         self.MapWindow = self.firstMapWindow # current by default
         
         self._bindWindowsActivation()
-        
+        self._setUpMapWindow(self.firstMapWindow)
+        self._setUpMapWindow(self.secondMapWindow)
+        self.firstMapWindow.InitZoomHistory()
+        self.secondMapWindow.InitZoomHistory()
+
         self.SetSize(size)
         #
         # Add toolbars
@@ -372,6 +376,14 @@
             mapTb.SetActiveMap((win == self.secondMapWindow))
         self.StatusbarUpdate() 
 
+    def ActivateFirstMap(self, event=None):
+        DoubleMapFrame.ActivateFirstMap(self, event)
+        self.GetMapToolbar().Enable('zoomBack', enable=(len(self.MapWindow.zoomhistory) > 1))
+
+    def ActivateSecondMap(self, event=None):
+        DoubleMapFrame.ActivateSecondMap(self, event)
+        self.GetMapToolbar().Enable('zoomBack', enable=(len(self.MapWindow.zoomhistory) > 1))
+
     def GetMapToolbar(self):
         """!Returns toolbar with zooming tools"""
         return self.toolbars['iClassMap']

Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py	2013-07-13 16:06:32 UTC (rev 57082)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py	2013-07-13 16:16:17 UTC (rev 57083)
@@ -164,6 +164,8 @@
             self.UpdateTools(None))
         self.MapWindow2D.mouseHandlerUnregistered.connect(self.ResetPointer)
 
+        self.MapWindow2D.InitZoomHistory()
+
         self._giface.updateMap.connect(self.MapWindow2D.UpdateMap)
         # default is 2D display mode
         self.MapWindow = self.MapWindow2D
@@ -197,14 +199,6 @@
         # Init print module and classes
         #
         self.printopt = PrintOptions(self, self.MapWindow)
-        
-        #
-        # Init zoom history
-        #
-        self.MapWindow.ZoomHistory(self.Map.region['n'],
-                                   self.Map.region['s'],
-                                   self.Map.region['e'],
-                                   self.Map.region['w'])
 
         #
         # Re-use dialogs

Modified: grass/trunk/gui/wxpython/mapswipe/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapswipe/frame.py	2013-07-13 16:06:32 UTC (rev 57082)
+++ grass/trunk/gui/wxpython/mapswipe/frame.py	2013-07-13 16:16:17 UTC (rev 57083)
@@ -71,7 +71,9 @@
 
         self._addPanes()
         self._bindWindowsActivation()
-    
+        self._setUpMapWindow(self.firstMapWindow)
+        self._setUpMapWindow(self.secondMapWindow)
+
         self._mgr.GetPane('sliderV').Hide()
         self._mgr.GetPane('sliderH').Show()
         self.slider = self.sliderH



More information about the grass-commit mailing list