Browse Source

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

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57128 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 11 years ago
parent
commit
2fc1550ac8
2 changed files with 29 additions and 16 deletions
  1. 18 0
      gui/wxpython/gcp/mapdisplay.py
  2. 11 16
      gui/wxpython/mapdisp/mapwindow.py

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

@@ -125,12 +125,20 @@ class MapFrame(SingleMapFrame):
         self._setUpMapWindow(self.TgtMapWindow)
         self.SrcMapWindow.SetCursor(self.cursors["cross"])
         self.TgtMapWindow.SetCursor(self.cursors["cross"])
+        # used to switch current map (combo box in toolbar)
         self.SrcMapWindow.mouseEntered.connect(
             lambda:
             self._setActiveMapWindow(self.SrcMapWindow))
         self.TgtMapWindow.mouseEntered.connect(
             lambda:
             self._setActiveMapWindow(self.TgtMapWindow))
+        # used to add or edit GCP
+        self.SrcMapWindow.mouseLeftUpPointer.connect(
+            lambda x, y:
+            self._onMouseLeftUpPointer(self.SrcMapWindow, x, y))
+        self.TgtMapWindow.mouseLeftUpPointer.connect(
+            lambda x, y:
+            self._onMouseLeftUpPointer(self.TgtMapWindow, x, y))
 
         #
         # initialize region values
@@ -651,3 +659,13 @@ class MapFrame(SingleMapFrame):
             self.UpdateActive(mapWindow)
             # needed for wingrass
             self.SetFocus()
+
+    def _onMouseLeftUpPointer(self, mapWindow, x, y):
+        if mapWindow == self.SrcMapWindow:
+            coordtype = 'source'
+        else:
+            coordtype = 'target'
+
+        coord = (x, y)
+        self._layerManager.gcpmanagement.SetGCPData(coordtype, coord, self, confirm=True)
+        mapWindow.UpdateMap(render=False, renderVector=False)

+ 11 - 16
gui/wxpython/mapdisp/mapwindow.py

@@ -97,6 +97,12 @@ class BufferedWindow(MapWindow, wx.Window):
 
         # Emitted when map enters the window
         self.mouseEntered = Signal('BufferedWindow.mouseEntered')
+        # Emitted when left mouse button is released and mouse use is 'pointer'
+        # Parameters are x and y of the mouse click in map (cell) units
+        # new and experimental, if the concept would be used widely,
+        # it could replace register and unregister mechanism
+        # and partially maybe also internal mouse use dictionary
+        self.mouseLeftUpPointer = Signal('BufferedWindow.mouseLeftUpPointer')
 
         # event bindings
         self.Bind(wx.EVT_PAINT,           self.OnPaint)
@@ -1192,21 +1198,7 @@ class BufferedWindow(MapWindow, wx.Window):
             self.polycoords.append(self.Pixel2Cell(self.mouse['end']))
             self.ClearLines(pdc = self.pdcTmp)
             self.DrawLines(pdc = self.pdcTmp)
-        
-        elif self.mouse["use"] == "pointer" and \
-                not self.frame.IsStandalone() and \
-                self.frame.GetLayerManager().gcpmanagement:
-            # -> GCP manager
-            if self.frame.GetToolbar('gcpdisp'):
-                coord = self.Pixel2Cell(self.mouse['end'])
-                if self.frame.MapWindow == self.frame.SrcMapWindow:
-                    coordtype = 'source'
-                else:
-                    coordtype = 'target'
-                
-                self.frame.GetLayerManager().gcpmanagement.SetGCPData(coordtype, coord, self, confirm = True)
-                self.UpdateMap(render = False, renderVector = False)
-            
+
         elif self.mouse["use"] == "pointer" and \
                 hasattr(self, "digit"):
             self._onLeftUp(event)
@@ -1223,7 +1215,10 @@ class BufferedWindow(MapWindow, wx.Window):
                 pass
             self.dragid = None
             self.currtxtid = None
-            
+
+            coordinates = self.Pixel2Cell(self.mouse['end'])
+            self.mouseLeftUpPointer.emit(x=coordinates[0], y=coordinates[1])
+
         elif self.mouse['use'] == 'legend':
             self.frame.dialogs['legend'].resizeBtn.SetValue(False)
             screenSize = self.GetClientSizeTuple()