Graphics Reference
In-Depth Information
self.mapCanvas.refresh()
self.setPanMode()
self.adjustActions()
To finish off these two actions, we'll need to implement the clearMemoryLayer()
method and initialize the curStartPt and curEndPt instance variables so that the
program knows when these variables are set for the first time.
Here is the implementation for the clearMemoryLayer() method:
def clearMemoryLayer(self, layer):
featureIDs = []
provider = layer.dataProvider()
for feature in
provider.getFeatures(QgsFeatureRequest()):
featureIDs.append(feature.id())
provider.deleteFeatures(featureIDs)
We simply obtain a list of all the features in the given memory layer, and then ask the data
provider to delete them. Since this data is transient and held in memory, deleting all the
features is no big deal.
Finally, let's initialize those two instance variables. Add the following to the end of your
ForestTrailsWindow.__init__() method:
self.curStartPt = None
self.curEndPt = None
With all this implemented, the user can now click on a vertex to set the starting or ending
point, as shown in the following screenshot:
Search WWH ::




Custom Search