From 66b71f30bb9bb04eacb88b7d3a51dae169de38de Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Tue, 4 Jun 2019 13:54:57 +0200 Subject: [PATCH 1/3] Update QgsAttributeForm to API 3 Fix #32 --- src/tools/qgepmaptooladdfeature.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tools/qgepmaptooladdfeature.py b/src/tools/qgepmaptooladdfeature.py index da2646a1..b66c9d8e 100644 --- a/src/tools/qgepmaptooladdfeature.py +++ b/src/tools/qgepmaptooladdfeature.py @@ -31,6 +31,7 @@ from builtins import range from qgis.gui import ( QgsAttributeForm, + QgsAttributeEditorContext, QgsMapToolAdvancedDigitizing, QgsMapTool, QgsRubberBand, @@ -150,7 +151,7 @@ def right_clicked(self, _): f = QgsFeature(self.layer.fields()) f.setGeometry(self.rubberband.asGeometry()) dlg = self.iface.getFeatureForm(self.layer, f) - dlg.setMode(QgsAttributeForm.AddFeatureMode) + dlg.setMode(QgsAttributeEditorContext.AddFeatureMode) dlg.exec_() self.rubberband.reset3D() self.temp_rubberband.reset() @@ -332,7 +333,7 @@ def right_clicked(self, _): f.setAttribute(level_field_index, self.rubberband.points[pt_idx].z()) dlg = self.iface.getFeatureForm(self.layer, f) - dlg.setMode(QgsAttributeForm.AddFeatureMode) + dlg.setMode(QgsAttributeEditorContext.AddFeatureMode) dlg.exec_() self.rubberband.reset3D() From 0056ea9d9bed17513bf805a18852a4bb7242d54d Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Wed, 5 Jun 2019 11:19:36 +0200 Subject: [PATCH 2/3] Yet another QGIS 3 update --- src/tools/qgepmaptooladdfeature.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/qgepmaptooladdfeature.py b/src/tools/qgepmaptooladdfeature.py index b66c9d8e..638be41c 100644 --- a/src/tools/qgepmaptooladdfeature.py +++ b/src/tools/qgepmaptooladdfeature.py @@ -275,7 +275,7 @@ def snap(self, event): req = QgsFeatureRequest(match.featureId()) f = next(match.layer().getFeatures(req)) assert f.isValid() - if match.layer().wkbType() == QgsWkbTypes.WKBPoint25D: + if match.layer().geometryType() == QgsWkbTypes.PointGeometry: point = QgsPoint(f.geometry().geometry()) else: (ok, vertex_id) = f.geometry().vertexIdFromVertexNr(match.vertexIndex()) From cc87de31fc387fc1e3242b7794942add3bad6156 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Wed, 5 Jun 2019 14:24:22 +0200 Subject: [PATCH 3/3] Further adjustments --- src/tools/qgepmaptooladdfeature.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/qgepmaptooladdfeature.py b/src/tools/qgepmaptooladdfeature.py index 638be41c..ccb5f8ac 100644 --- a/src/tools/qgepmaptooladdfeature.py +++ b/src/tools/qgepmaptooladdfeature.py @@ -276,11 +276,11 @@ def snap(self, event): f = next(match.layer().getFeatures(req)) assert f.isValid() if match.layer().geometryType() == QgsWkbTypes.PointGeometry: - point = QgsPoint(f.geometry().geometry()) + point = QgsPoint(f.geometry().constGet()) else: (ok, vertex_id) = f.geometry().vertexIdFromVertexNr(match.vertexIndex()) assert ok - point = f.geometry().geometry().vertexAt(vertex_id) + point = f.geometry().constGet().vertexAt(vertex_id) assert type(point) == QgsPoint return point, match else: