Skip to content

Commit

Permalink
[processing] Fix picking point from map always triggers a release
Browse files Browse the repository at this point in the history
event for previous map tool
  • Loading branch information
nyalldawson committed Sep 24, 2017
1 parent 6efcc2f commit 506f6d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions python/plugins/processing/gui/PointMapTool.py
Expand Up @@ -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)

Expand All @@ -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()
4 changes: 3 additions & 1 deletion python/plugins/processing/gui/PointSelectionPanel.py
Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 506f6d4

Please sign in to comment.