Ver código fonte

wxGUI/mapwindow: introducing mouseEntered signal and removing gcp manager code

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57114 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 11 anos atrás
pai
commit
2aae39ae88

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

@@ -125,6 +125,12 @@ class MapFrame(SingleMapFrame):
         self._setUpMapWindow(self.TgtMapWindow)
         self.SrcMapWindow.SetCursor(self.cursors["cross"])
         self.TgtMapWindow.SetCursor(self.cursors["cross"])
+        self.SrcMapWindow.mouseEntered.connect(
+            lambda:
+            self._setActiveMapWindow(self.SrcMapWindow))
+        self.TgtMapWindow.mouseEntered.connect(
+            lambda:
+            self._setActiveMapWindow(self.TgtMapWindow))
 
         #
         # initialize region values
@@ -637,3 +643,11 @@ class MapFrame(SingleMapFrame):
     def GetMapToolbar(self):
         """!Returns toolbar with zooming tools"""
         return self.toolbars['gcpdisp']
+
+    def _setActiveMapWindow(self, mapWindow):
+        if not self.MapWindow == mapWindow:
+            self.MapWindow = mapWindow
+            self.Map = mapWindow.Map
+            self.UpdateActive(mapWindow)
+            # needed for wingrass
+            self.SetFocus()

+ 0 - 1
gui/wxpython/gui_core/mapdisp.py

@@ -307,7 +307,6 @@ class MapFrameBase(wx.Frame):
     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))

+ 3 - 4
gui/wxpython/mapdisp/frame.py

@@ -391,12 +391,11 @@ class MapFrame(SingleMapFrame):
         
     def AddToolbar(self, name, fixed = False):
         """!Add defined toolbar to the window
-        
-        Currently known toolbars are:
+
+        Currently recognized toolbars are:
          - 'map'     - basic map toolbar
          - 'vdigit'  - vector digitizer
-         - 'gcpdisp' - GCP Manager 
-         
+
         @param name toolbar to add
         @param fixed fixed toolbar
         """

+ 8 - 12
gui/wxpython/mapdisp/mapwindow.py

@@ -95,6 +95,9 @@ class BufferedWindow(MapWindow, wx.Window):
         # Emitted when mouse event handler is unregistered
         self.mouseHandlerUnregistered = Signal('BufferedWindow.mouseHandlerUnregistered')
 
+        # Emitted when map enters the window
+        self.mouseEntered = Signal('BufferedWindow.mouseEntered')
+
         # event bindings
         self.Bind(wx.EVT_PAINT,           self.OnPaint)
         self.Bind(wx.EVT_SIZE,            self.OnSize)
@@ -1321,19 +1324,12 @@ class BufferedWindow(MapWindow, wx.Window):
 
     def OnMouseEnter(self, event):
         """!Mouse entered window and no mouse buttons were pressed
+
+        Emits the mouseEntered signal.
         """
-        if not self.frame.IsStandalone() and \
-                self.frame.GetLayerManager().gcpmanagement:
-            if self.frame.GetToolbar('gcpdisp'):
-                if not self.frame.MapWindow == self:
-                    self.frame.MapWindow = self
-                    self.frame.Map = self.Map
-                    self.frame.UpdateActive(self)
-                    # needed for wingrass
-                    self.SetFocus()
-        else:
-            event.Skip()
-        
+        self.mouseEntered.emit()
+        event.Skip()
+
     def OnMouseMoving(self, event):
         """!Motion event and no mouse buttons were pressed
         """