Graphics Reference
In-Depth Information
self.dragging = False
self.feature = None
As you can see, we subclass QgsMapToolIdentify for this map tool. This lets us use
the identify() method to find the geometry that the user clicked on, just like we did
in the SelectTool , which we implemented earlier in this chapter.
Notice that our canvasMoveEvent() method keeps track of the user's current mouse
position. It also updates the feature's geometry by calling lay-
er.changeGeometry() to remember the changed mouse position as the user moves
the point around. The canvasPressEvent() enables dragging if and only if the user
clicked on a Point, and the canvasReleaseEvent() method tidies up so that the user
can move another point by clicking on it.
If you are writing a standalone PyQGIS application that includes a point-based Qg-
sVectorLayer , you can use the AddPointTool and MovePointTool classes we
defined here to allow the user to add and edit Point features within your vector layer. The
only thing missing (for Point geometries) is the ability to remove points. Let's implement
this now.
Search WWH ::




Custom Search