Hi,<br>I've been working on the QgsAzimuth plugin and recently some users told me of a limitation on the code I wrote.<br>The snapping is not with enough precision.<br>The following code is the event that I wrote that tries to use snap and if not possible, use the captured pixel as coordinate. Is it the right way of implementing a snap tool?<br>
<br> def canvasPressEvent(self,event):<br> pixels=event.pos()<br> snapper=QgsMapCanvasSnapper(self.canvas)<br> snapped=snapper.snapToBackgroundLayers(pixels)<br> if len(snapped[1])>0:<br> xy=snapped[1][0].afterVertex<br>
else:<br> #transforming pixels to x,y<br> transform = self.canvas.getCoordinateTransform()<br> xy = transform.toMapCoordinates(pixels) #captures the clicked coordinate and transform<br> self.emit(SIGNAL("finished(PyQt_PyObject)"),xy) #return QgsPoint in a signal<br>
<br>Thanks in advance.<br>Mauricio de Paulo<br>