Graphics Reference
In-Depth Information
def removeLastVertex(self):
if not self.capturing: return
bandSize = self.rubberBand.numberOfVertices()
tempBandSize =
self.tempRubberBand.numberOfVertices()
numPoints = len(self.capturedPoints)
if bandSize < 1 or numPoints < 1:
return
self.rubberBand.removePoint(-1)
if bandSize > 1:
if tempBandSize > 1:
point = self.rubberBand.getPoint(0,
bandSize-2)
self.tempRubberBand.movePoint(tempBandSize-2,
point)
else:
self.tempRubberBand.reset(self.bandType())
del self.capturedPoints[-1]
We've now defined quite a few methods for our CaptureTool . Fortunately, there are
only two methods left. Let's now define the getCapturedGeometry() method. This
method checks whether a LineString geometry has at least two points, and whether a
Polygon geometry has at least three points. It then closes the polygon and returns the list
of points that make up the captured geometry:
def getCapturedGeometry(self):
points = self.capturedPoints
if self.captureMode == CaptureTool.CAPTURE_LINE:
if len(points) < 2:
return None
if self.captureMode == CaptureTool.CAPTURE_POLYGON:
if len(points) < 3:
return None
Search WWH ::




Custom Search