Skip to content
Permalink
Browse files

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

event for previous map tool
  • Loading branch information
nyalldawson committed Sep 24, 2017
1 parent 6efcc2f commit 506f6d40b720eab1ad09723c2f376286e58bb3d9
@@ -25,13 +25,15 @@

__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 @@ def __init__(self, canvas):
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()
@@ -59,6 +59,7 @@ def __init__(self, dialog, default=None):

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 @@ def selectOnCanvas(self):
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()

0 comments on commit 506f6d4

Please sign in to comment.
You can’t perform that action at this time.