Bläddra i källkod

wxGUI/mapwindow: reflecting new way of handling zoom history (gcp, mapswipe and iclass were broken before https://trac.osgeo.org/grass/changeset/57078 for unknown reason)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57083 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 11 år sedan
förälder
incheckning
d3eccb7c73

+ 11 - 0
gui/wxpython/gcp/mapdisplay.py

@@ -121,6 +121,8 @@ class MapFrame(SingleMapFrame):
                                           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
+        self._setUpMapWindow(self.SrcMapWindow)
+        self._setUpMapWindow(self.TgtMapWindow)
         self.SrcMapWindow.SetCursor(self.cursors["cross"])
         self.SrcMapWindow.SetCursor(self.cursors["cross"])
         self.TgtMapWindow.SetCursor(self.cursors["cross"])
         self.TgtMapWindow.SetCursor(self.cursors["cross"])
 
 
@@ -200,6 +202,15 @@ class MapFrame(SingleMapFrame):
 
 
         self.decorationDialog = None # decoration/overlays
         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):
     def AddToolbar(self, name):
         """!Add defined toolbar to the window
         """!Add defined toolbar to the window
         
         

+ 16 - 3
gui/wxpython/gui_core/mapdisp.py

@@ -42,7 +42,9 @@ class MapFrameBase(wx.Frame):
     
     
     If derived class enables and disables auto-rendering,
     If derived class enables and disables auto-rendering,
     it should override IsAutoRendered method.
     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)
     Derived class can has one or more map windows (and map renderes)
     but implementation of MapFrameBase expects that one window and
     but implementation of MapFrameBase expects that one window and
     one map will be current.
     one map will be current.
@@ -300,7 +302,18 @@ class MapFrameBase(wx.Frame):
         
         
         win = self.GetWindow()
         win = self.GetWindow()
         self._prepareZoom(mapWindow = win, zoomType = -1)
         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):
     def _prepareZoom(self, mapWindow, zoomType):
         """!Prepares MapWindow for zoom, toggles toolbar
         """!Prepares MapWindow for zoom, toggles toolbar
         
         
@@ -443,7 +456,7 @@ class DoubleMapFrame(MapFrameBase):
     when both map windows will be initialized.
     when both map windows will be initialized.
     
     
     Drived class should have method GetMapToolbar() returns toolbar
     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
     @note To access maps use getters only
     (when using class or when writing class itself).
     (when using class or when writing class itself).

+ 13 - 1
gui/wxpython/iclass/frame.py

@@ -93,7 +93,11 @@ class IClassMapFrame(DoubleMapFrame):
         self.MapWindow = self.firstMapWindow # current by default
         self.MapWindow = self.firstMapWindow # current by default
         
         
         self._bindWindowsActivation()
         self._bindWindowsActivation()
-        
+        self._setUpMapWindow(self.firstMapWindow)
+        self._setUpMapWindow(self.secondMapWindow)
+        self.firstMapWindow.InitZoomHistory()
+        self.secondMapWindow.InitZoomHistory()
+
         self.SetSize(size)
         self.SetSize(size)
         #
         #
         # Add toolbars
         # Add toolbars
@@ -372,6 +376,14 @@ class IClassMapFrame(DoubleMapFrame):
             mapTb.SetActiveMap((win == self.secondMapWindow))
             mapTb.SetActiveMap((win == self.secondMapWindow))
         self.StatusbarUpdate() 
         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):
     def GetMapToolbar(self):
         """!Returns toolbar with zooming tools"""
         """!Returns toolbar with zooming tools"""
         return self.toolbars['iClassMap']
         return self.toolbars['iClassMap']

+ 2 - 8
gui/wxpython/mapdisp/frame.py

@@ -164,6 +164,8 @@ class MapFrame(SingleMapFrame):
             self.UpdateTools(None))
             self.UpdateTools(None))
         self.MapWindow2D.mouseHandlerUnregistered.connect(self.ResetPointer)
         self.MapWindow2D.mouseHandlerUnregistered.connect(self.ResetPointer)
 
 
+        self.MapWindow2D.InitZoomHistory()
+
         self._giface.updateMap.connect(self.MapWindow2D.UpdateMap)
         self._giface.updateMap.connect(self.MapWindow2D.UpdateMap)
         # default is 2D display mode
         # default is 2D display mode
         self.MapWindow = self.MapWindow2D
         self.MapWindow = self.MapWindow2D
@@ -197,14 +199,6 @@ class MapFrame(SingleMapFrame):
         # Init print module and classes
         # Init print module and classes
         #
         #
         self.printopt = PrintOptions(self, self.MapWindow)
         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
         # Re-use dialogs

+ 3 - 1
gui/wxpython/mapswipe/frame.py

@@ -71,7 +71,9 @@ class SwipeMapFrame(DoubleMapFrame):
 
 
         self._addPanes()
         self._addPanes()
         self._bindWindowsActivation()
         self._bindWindowsActivation()
-    
+        self._setUpMapWindow(self.firstMapWindow)
+        self._setUpMapWindow(self.secondMapWindow)
+
         self._mgr.GetPane('sliderV').Hide()
         self._mgr.GetPane('sliderV').Hide()
         self._mgr.GetPane('sliderH').Show()
         self._mgr.GetPane('sliderH').Show()
         self.slider = self.sliderH
         self.slider = self.sliderH