def canvasPressEvent(self, event): geom = self.band.asGeometry() if not geom: return point = point_from_event(event, self.snapping) if self.editmode: layer = self.currentVectorLayer() event.snapToGrid(layer.geometryOptions().geometryPrecision(), layer.crs()) tol = QgsTolerance.vertexSearchRadius(self.canvas.mapSettings()) loc = self.canvas.snappingUtils().locatorForLayer(layer) matches = loc.verticesInRect(point, tol) if matches: for match in matches: if match.featureId() != self.feature.id(): continue self.editpart = 0 self.editvertex = match.vertexIndex() break else: self.editvertex = None self.editpart = 0
def vertex_at_point(self, point): layer = self.currentVectorLayer() tol = QgsTolerance.vertexSearchRadius(self.canvas.mapSettings()) loc = self.canvas.snappingUtils().locatorForLayer(layer) matches = loc.verticesInRect(point, tol) return matches