[processing] Fix picking point from map always triggers a release

event for previous map tool
This commit is contained in:
Nyall Dawson 2017-09-15 17:19:03 +10:00
parent 6efcc2fe86
commit 506f6d40b7
2 changed files with 8 additions and 5 deletions

View File

@ -25,13 +25,15 @@ __copyright__ = '(C) 2016, Alexander Bruy'
__revision__ = '$Format:%H$'
from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtCore import Qt, pyqtSignal
from qgis.gui import QgsMapToolEmitPoint
class PointMapTool(QgsMapToolEmitPoint):
complete = pyqtSignal()
def __init__(self, canvas):
QgsMapToolEmitPoint.__init__(self, canvas)
@ -41,6 +43,5 @@ class PointMapTool(QgsMapToolEmitPoint):
def activate(self):
self.canvas.setCursor(self.cursor)
def canvasPressEvent(self, event):
pnt = self.toMapCoordinates(event.pos())
self.canvasClicked.emit(pnt, event.button())
def canvasReleaseEvent(self, event):
self.complete.emit()

View File

@ -59,6 +59,7 @@ class PointSelectionPanel(BASE, WIDGET):
self.tool = PointMapTool(canvas)
self.tool.canvasClicked.connect(self.updatePoint)
self.tool.complete.connect(self.pointPicked)
else:
self.prevMapTool = None
self.tool = None
@ -81,8 +82,9 @@ class PointSelectionPanel(BASE, WIDGET):
def updatePoint(self, point, button):
s = '{},{}'.format(point.x(), point.y())
self.crs = QgsProject.instance().crs()
self.leText.setText(s)
def pointPicked(self):
canvas = iface.mapCanvas()
canvas.setMapTool(self.prevMapTool)
self.dialog.showNormal()