[Qgis-developer] Python Snapping

Maurício de Paulo mauricio.dev at gmail.com
Thu Nov 12 11:06:23 EST 2009

I've been working on the QgsAzimuth plugin and recently some users told me
of a limitation on the code I wrote.
The snapping is not with enough precision.
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?

 def canvasPressEvent(self,event):
    if len(snapped[1])>0:
        #transforming pixels to x,y
        transform = self.canvas.getCoordinateTransform()
        xy = transform.toMapCoordinates(pixels) #captures the clicked
coordinate and transform
    self.emit(SIGNAL("finished(PyQt_PyObject)"),xy)     #return QgsPoint in
a signal

Thanks in advance.
Mauricio de Paulo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20091112/133c7df5/attachment.html

More information about the Qgis-developer mailing list