I just tried the plugin on a big project (around 40 vector layers), and it is unusable. It takes about 1 sec to display the coordinates.
I believe the problem is in the snapping.
Not sure if it might solve this, but instead of doing 4 snapping, you might want to use QgsSnapper instead of QgsMapCanvasSnapper.
Hence, you should be able to run it only once, and with you proper settings (without changing the project snapping settings).
Here is an example:
def updateSnapperList(self, dummy=None):
self.snapperList = []
tolerance = self.settings.value("selectTolerance")
units = self.settings.value("selectUnits")
scale = self.iface.mapCanvas().mapRenderer().scale()
for layer in self.iface.mapCanvas().layers():
if layer.type() == QgsMapLayer.VectorLayer and layer.hasGeometryType():
if not layer.hasScaleBasedVisibility() or layer.minimumScale() < scale <= layer.maximumScale():
snapLayer = QgsSnapper.SnapLayer()
snapLayer.mLayer = layer
snapLayer.mSnapTo = QgsSnapper.SnapToVertex
snapLayer.mTolerance = tolerance
if units == "map":
snapLayer.mUnitType = QgsTolerance.MapUnits
else:
snapLayer.mUnitType = QgsTolerance.Pixels
self.snapperList.append(snapLayer)
def snapToLayers(self, pixPoint, initPoint=None):
self.snapping = self.settings.value("obsDistanceSnapping")
if len(self.snapperList) == 0:
return initPoint
snapper = QgsSnapper(self.mapCanvas.mapRenderer())
snapper.setSnapLayers(self.snapperList)
snapper.setSnapMode(QgsSnapper.SnapWithResultsWithinTolerances)
ok, snappingResults = snapper.snapPoint(pixPoint, [])
self.displaySnapInfo(snappingResults)
if ok == 0 and len(snappingResults) > 0:
return QgsPoint(snappingResults[0].snappedVertex)
else:
return initPoint
I just tried the plugin on a big project (around 40 vector layers), and it is unusable. It takes about 1 sec to display the coordinates.
I believe the problem is in the snapping.
Not sure if it might solve this, but instead of doing 4 snapping, you might want to use QgsSnapper instead of QgsMapCanvasSnapper. Hence, you should be able to run it only once, and with you proper settings (without changing the project snapping settings).
Here is an example: