From d6c3dcb035c7580c6d1ac164a9238db18d9df164 Mon Sep 17 00:00:00 2001 From: Quentin Savoye Date: Wed, 20 Nov 2024 14:12:05 +0100 Subject: [PATCH 1/4] Rubberbound replace vector of qgspoint by qgscompoundcurve --- src/core/rubberbandmodel.cpp | 105 +++++++++++++++++++++-------------- src/core/rubberbandmodel.h | 3 +- 2 files changed, 66 insertions(+), 42 deletions(-) diff --git a/src/core/rubberbandmodel.cpp b/src/core/rubberbandmodel.cpp index 80c229ee42..384ab8594a 100644 --- a/src/core/rubberbandmodel.cpp +++ b/src/core/rubberbandmodel.cpp @@ -24,28 +24,38 @@ RubberbandModel::RubberbandModel( QObject *parent ) : QObject( parent ) , mLayer( nullptr ) { - mPointList.insert( 0, QgsPoint() ); + mCompoundCurve.addVertex( QgsPoint() ); } int RubberbandModel::vertexCount() const { - return mPointList.size(); + return mCompoundCurve.vertexCount( 0, 0 ); } bool RubberbandModel::isEmpty() const { - return mPointList.isEmpty(); + return mCompoundCurve.isEmpty(); } QVector RubberbandModel::vertices() const { - return mPointList; + QgsVertexIterator vertexIterator = mCompoundCurve.curveToLine()->vertices(); + + // Create an empty QVector + QVector points; + + // Iterate over the vertices and add them to the vector + while ( vertexIterator.hasNext() ) + { + points.append( vertexIterator.next() ); + } + return points; } QVector RubberbandModel::verticesCopy( bool skipCurrentPoint ) const { QVector points; - for ( const QgsPoint &pt : mPointList ) + for ( const QgsPoint &pt : vertices() ) { points << QgsPoint( pt ); } @@ -60,7 +70,7 @@ QgsPointSequence RubberbandModel::pointSequence( const QgsCoordinateReferenceSys QgsPointSequence sequence; QgsCoordinateTransform ct( mCrs, crs, QgsProject::instance()->transformContext() ); - for ( const QgsPoint &pt : mPointList ) + for ( const QgsPoint &pt : vertices() ) { //crs transformation of XY QgsPointXY p1 = ct.transform( pt.x(), pt.y() ); @@ -97,7 +107,7 @@ QVector RubberbandModel::flatPointSequence( const QgsCoordinateRefer QgsCoordinateTransform ct( mCrs, crs, QgsProject::instance()->transformContext() ); - for ( const QgsPoint &pt : mPointList ) + for ( const QgsPoint &pt : vertices() ) { sequence.append( ct.transform( pt.x(), pt.y() ) ); } @@ -107,9 +117,10 @@ QVector RubberbandModel::flatPointSequence( const QgsCoordinateRefer void RubberbandModel::setVertex( int index, QgsPoint coordinate ) { - if ( mPointList.at( index ) != coordinate ) + QgsVertexId id = QgsVertexId( 0, 0, index ); + if ( mCompoundCurve.vertexAt( id ) != coordinate ) { - mPointList.replace( index, coordinate ); + mCompoundCurve.moveVertex( id, coordinate ); emit vertexChanged( index ); } } @@ -118,7 +129,8 @@ void RubberbandModel::insertVertices( int index, int count ) { for ( int i = 0; i < count; ++i ) { - mPointList.insert( index, currentCoordinate() ); + QgsVertexId id = QgsVertexId( 0, 0, index ); + mCompoundCurve.insertVertex( id, currentCoordinate() ); } emit verticesInserted( index, count ); @@ -127,14 +139,23 @@ void RubberbandModel::insertVertices( int index, int count ) void RubberbandModel::removeVertices( int index, int count ) { - if ( mPointList.size() <= 1 ) + if ( vertexCount() <= 1 ) return; - mPointList.remove( index, count ); + for ( int i = 0; i < count; ++i ) + { + QgsVertexId id = QgsVertexId( 0, 0, index ); + mCompoundCurve.deleteVertex( id ); + } + + if ( vertexCount() == 0 ) + { + mCompoundCurve.addVertex( QgsPoint() ); + } - if ( mCurrentCoordinateIndex >= mPointList.size() ) + if ( mCurrentCoordinateIndex >= vertexCount() ) { - setCurrentCoordinateIndex( mPointList.size() - 1 ); + setCurrentCoordinateIndex( vertexCount() - 1 ); } emit verticesRemoved( index, count ); @@ -162,8 +183,8 @@ void RubberbandModel::setCurrentCoordinateIndex( int currentCoordinateIndex ) QgsPoint RubberbandModel::currentPoint( const QgsCoordinateReferenceSystem &crs, Qgis::WkbType wkbType ) const { QgsCoordinateTransform ct( mCrs, crs, QgsProject::instance()->transformContext() ); - - QgsPoint currentPt = mPointList.at( mCurrentCoordinateIndex ); + QgsVertexId id = QgsVertexId( 0, 0, mCurrentCoordinateIndex ); + QgsPoint currentPt = mCompoundCurve.vertexAt( id ); double x = currentPt.x(); double y = currentPt.y(); double z = QgsWkbTypes::hasZ( currentPt.wkbType() ) ? currentPt.z() : 0; @@ -195,64 +216,66 @@ QgsPoint RubberbandModel::currentPoint( const QgsCoordinateReferenceSystem &crs, QgsPoint RubberbandModel::currentCoordinate() const { - return mPointList.value( mCurrentCoordinateIndex ); + QgsVertexId id = QgsVertexId( 0, 0, mCurrentCoordinateIndex ); + return mCompoundCurve.vertexAt( id ); } QgsPoint RubberbandModel::firstCoordinate() const { - if ( mPointList.isEmpty() ) + if ( mCompoundCurve.isEmpty() ) return QgsPoint(); - return mPointList.at( 0 ); + QgsVertexId id = QgsVertexId( 0, 0, 0 ); + return mCompoundCurve.vertexAt( id ); } QgsPoint RubberbandModel::lastCoordinate() const { - if ( mPointList.isEmpty() ) + if ( mCompoundCurve.isEmpty() ) return QgsPoint(); - - return mPointList.at( mCurrentCoordinateIndex > 0 ? mCurrentCoordinateIndex - 1 : 0 ); + QgsVertexId id = QgsVertexId( 0, 0, mCurrentCoordinateIndex > 0 ? mCurrentCoordinateIndex - 1 : 0 ); + return mCompoundCurve.vertexAt( id ); } QgsPoint RubberbandModel::penultimateCoordinate() const { - if ( mPointList.size() < 3 ) + if ( mCompoundCurve.vertexCount( 0, 0 ) < 3 ) return QgsPoint(); - - return mPointList.at( mCurrentCoordinateIndex > 1 ? mCurrentCoordinateIndex - 2 : 0 ); + QgsVertexId id = QgsVertexId( 0, 0, mCurrentCoordinateIndex > 1 ? mCurrentCoordinateIndex - 2 : 0 ); + return mCompoundCurve.vertexAt( id ); } void RubberbandModel::setCurrentCoordinate( const QgsPoint ¤tCoordinate ) { // play safe, but try to find out - // Q_ASSERT( mPointList.count() != 0 ); - if ( mPointList.count() == 0 ) + if ( mCompoundCurve.isEmpty() ) return; - if ( mPointList.at( mCurrentCoordinateIndex ) == currentCoordinate ) + QgsVertexId id = QgsVertexId( 0, 0, mCurrentCoordinateIndex ); + if ( mCompoundCurve.vertexAt( id ) == currentCoordinate ) return; if ( mFrozen ) return; - mPointList.replace( mCurrentCoordinateIndex, currentCoordinate ); + mCompoundCurve.moveVertex( id, currentCoordinate ); if ( !mLayer || QgsWkbTypes::hasM( mLayer->wkbType() ) ) { if ( !std::isnan( mMeasureValue ) ) { - if ( QgsWkbTypes::hasM( mPointList[mCurrentCoordinateIndex].wkbType() ) ) + if ( QgsWkbTypes::hasM( mCompoundCurve.vertexAt( id ).wkbType() ) ) { - mPointList[mCurrentCoordinateIndex].setM( mMeasureValue ); + mCompoundCurve.vertexAt( id ).setM( mMeasureValue ); } else { - mPointList[mCurrentCoordinateIndex].addMValue( mMeasureValue ); + mCompoundCurve.vertexAt( id ).addMValue( mMeasureValue ); } } else { - mPointList[mCurrentCoordinateIndex].dropMValue(); + mCompoundCurve.vertexAt( id ).dropMValue(); } } @@ -295,7 +318,7 @@ void RubberbandModel::setMeasureValue( const double measureValue ) void RubberbandModel::addVertex() { // Avoid double vertices accidentally - if ( mPointList.size() > 1 && *( mPointList.end() - 1 ) == *( mPointList.end() - 2 ) ) + if ( mCompoundCurve.vertexCount( 0, 0 ) > 1 && currentCoordinate() == penultimateCoordinate() ) { return; } @@ -318,7 +341,7 @@ void RubberbandModel::removeVertex() void RubberbandModel::reset() { - removeVertices( 0, mPointList.size() - 1 ); + removeVertices( 0, vertexCount() - 1 ); mFrozen = false; emit frozenChanged(); } @@ -331,7 +354,7 @@ void RubberbandModel::setDataFromGeometry( QgsGeometry geometry, const QgsCoordi QgsCoordinateTransform ct( crs, mCrs, QgsProject::instance()->transformContext() ); geometry.transform( ct ); - mPointList.clear(); + mCompoundCurve.clear(); const QgsAbstractGeometry *abstractGeom = geometry.constGet(); if ( !abstractGeom ) return; @@ -344,22 +367,22 @@ void RubberbandModel::setDataFromGeometry( QgsGeometry geometry, const QgsCoordi { break; } - mPointList << pt; + mCompoundCurve.addVertex( pt ); } // for polygons, remove the last vertex which is a duplicate of the first vertex if ( geometry.type() == Qgis::GeometryType::Polygon ) { - mPointList.removeLast(); + mCompoundCurve.removeDuplicateNodes(); } // insert the last point twice so the resutling rubberband's current coordinate property being modified (by e.g. // the GNSS position) will not replace the last vertex from the passed geometry - mPointList << mPointList.last(); + mCompoundCurve.addVertex( mCompoundCurve.endPoint() ); - mCurrentCoordinateIndex = mPointList.size() - 1; + mCurrentCoordinateIndex = mCompoundCurve.vertexCount( 0, 0 ) - 1; - emit verticesInserted( 0, mPointList.size() ); + emit verticesInserted( 0, mCompoundCurve.vertexCount( 0, 0 ) ); emit vertexCountChanged(); } diff --git a/src/core/rubberbandmodel.h b/src/core/rubberbandmodel.h index a6d244eda5..425c14193e 100644 --- a/src/core/rubberbandmodel.h +++ b/src/core/rubberbandmodel.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -197,7 +198,7 @@ class QFIELD_CORE_EXPORT RubberbandModel : public QObject void measureValueChanged(); private: - QVector mPointList; + QgsCompoundCurve mCompoundCurve; int mCurrentCoordinateIndex = 0; QDateTime mCurrentPositionTimestamp; Qgis::GeometryType mGeometryType = Qgis::GeometryType::Line; From 552ae4655d4012295ce9da59dd619c7d1e6fe178 Mon Sep 17 00:00:00 2001 From: Quentin Savoye Date: Wed, 20 Nov 2024 16:48:57 +0100 Subject: [PATCH 2/4] add circular string to rubberbound during digitizing --- images/images.qrc | 1 + .../qfield/nodpi/ic_line_curve_24dp.svg | 5 ++ src/core/rubberbandmodel.cpp | 72 ++++++++++++++++++- src/core/rubberbandmodel.h | 18 +++++ src/qml/DigitizingToolbar.qml | 22 +++++- src/qml/QFieldSettings.qml | 46 ++++++++++++ src/qml/qgismobileapp.qml | 59 ++++++++++++++- 7 files changed, 218 insertions(+), 5 deletions(-) create mode 100644 images/themes/qfield/nodpi/ic_line_curve_24dp.svg diff --git a/images/images.qrc b/images/images.qrc index ef2c2a7025..0c219d6291 100644 --- a/images/images.qrc +++ b/images/images.qrc @@ -171,5 +171,6 @@ themes/qfield/nodpi/ic_shutdown_24dp.svg themes/qfield/nodpi/ic_egeniouss_receiver_black_24dp.svg themes/qfield/nodpi/ic_location_tracking_white_24dp.svg + themes/qfield/nodpi/ic_line_curve_24dp.svg diff --git a/images/themes/qfield/nodpi/ic_line_curve_24dp.svg b/images/themes/qfield/nodpi/ic_line_curve_24dp.svg new file mode 100644 index 0000000000..124fba2d1d --- /dev/null +++ b/images/themes/qfield/nodpi/ic_line_curve_24dp.svg @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/src/core/rubberbandmodel.cpp b/src/core/rubberbandmodel.cpp index 384ab8594a..c1fe44b48b 100644 --- a/src/core/rubberbandmodel.cpp +++ b/src/core/rubberbandmodel.cpp @@ -39,7 +39,8 @@ bool RubberbandModel::isEmpty() const QVector RubberbandModel::vertices() const { - QgsVertexIterator vertexIterator = mCompoundCurve.curveToLine()->vertices(); + QgsVertexIterator vertexIterator = mCompoundCurve.curveToLine( QSettings().value( "/QField/Digitizing/CurveTolerance", true ).toDouble(), QgsAbstractGeometry::SegmentationToleranceType::MaximumDifference )->vertices(); + // Create an empty QVector QVector points; @@ -258,7 +259,35 @@ void RubberbandModel::setCurrentCoordinate( const QgsPoint ¤tCoordinate ) if ( mFrozen ) return; - mCompoundCurve.moveVertex( id, currentCoordinate ); + if ( mDuringCurveDrawing == false ) + { + mCompoundCurve.moveVertex( id, currentCoordinate ); + } + else + { + QgsCircularString *curve = new QgsCircularString( mLastStartCurvePoint, mLastMiddleCurvePoint, currentCoordinate ); + if ( mCompoundCurve.nCurves() != 0 ) + { + const QgsCurve *lastSegment = mCompoundCurve.curveAt( mCompoundCurve.nCurves() - 1 ); + if ( lastSegment->hasCurvedSegments() == true ) + { + mCompoundCurve.removeCurve( mCompoundCurve.nCurves() - 1 ); + } + else + { + if ( lastSegment->vertexCount( 0, 0 ) > 2 ) + { + removeVertices( mCurrentCoordinateIndex - 1, 1 ); + setCurrentCoordinateIndex( mCurrentCoordinateIndex + 1 ); + } + else + { + mCompoundCurve.removeCurve( mCompoundCurve.nCurves() - 1 ); + } + } + } + mCompoundCurve.addCurve( curve, true ); + } if ( !mLayer || QgsWkbTypes::hasM( mLayer->wkbType() ) ) { @@ -278,7 +307,7 @@ void RubberbandModel::setCurrentCoordinate( const QgsPoint ¤tCoordinate ) mCompoundCurve.vertexAt( id ).dropMValue(); } } - + mCurrentCoordinate = currentCoordinate; emit currentCoordinateChanged(); emit vertexChanged( mCurrentCoordinateIndex ); } @@ -337,6 +366,43 @@ void RubberbandModel::removeVertex() { setCurrentCoordinateIndex( mCurrentCoordinateIndex - 1 ); removeVertices( mCurrentCoordinateIndex + 1, 1 ); + if ( QSettings().value( "/QField/Digitizing/CurveEdition", true ).toBool() ) + { + mDuringCurveDrawing = !mDuringCurveDrawing; + if ( mDuringCurveDrawing == false ) + { + mCompoundCurve.addVertex( mCurrentCoordinate ); + setCurrentCoordinateIndex( vertexCount() - 1 ); + emit vertexCountChanged(); + } + } +} + +void RubberbandModel::addCurve() +{ + mDuringCurveDrawing = false; + QgsCircularString *curve = new QgsCircularString( mLastStartCurvePoint, mLastMiddleCurvePoint, mCurrentCoordinate ); + if ( mCompoundCurve.nCurves() != 0 ) + { + mCompoundCurve.removeCurve( mCompoundCurve.nCurves() - 1 ); + } + + mCompoundCurve.addCurve( curve, true ); + mCompoundCurve.addVertex( mCurrentCoordinate ); + setCurrentCoordinateIndex( vertexCount() - 1 ); + emit vertexCountChanged(); +} + +void RubberbandModel::addMiddlePointCurve() +{ + mDuringCurveDrawing = true; + mLastMiddleCurvePoint = currentCoordinate(); + mLastStartCurvePoint = lastCoordinate(); + setCurrentCoordinateIndex( mCurrentCoordinateIndex + 1 ); +} + +void RubberbandModel::removeCurve() +{ } void RubberbandModel::reset() diff --git a/src/core/rubberbandmodel.h b/src/core/rubberbandmodel.h index 425c14193e..e7cb3041a5 100644 --- a/src/core/rubberbandmodel.h +++ b/src/core/rubberbandmodel.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -155,9 +156,21 @@ class QFIELD_CORE_EXPORT RubberbandModel : public QObject //! Remove the vertex at the current index Q_INVOKABLE void removeVertex(); + //! Add a curve at the current index + Q_INVOKABLE void addCurve(); + + //! Set the middle point of the curve at the current index + Q_INVOKABLE void addMiddlePointCurve(); + + //! Remove the curve at the current index + Q_INVOKABLE void removeCurve(); + //! Reset the model, remove all vertices and restart the vertex index Q_INVOKABLE void reset(); + //! Returns whether the rubberband model is currently drawing a curve + Q_INVOKABLE bool isDuringCurveDrawing() const { return mDuringCurveDrawing; } + /** * Sets the model data to match a given \a geometry * \note rings and multiparts are discarded @@ -206,6 +219,11 @@ class QFIELD_CORE_EXPORT RubberbandModel : public QObject QgsCoordinateReferenceSystem mCrs; double mMeasureValue = std::numeric_limits::quiet_NaN(); bool mFrozen = false; + bool mDuringCurveDrawing = false; + + QgsPoint mLastStartCurvePoint; + QgsPoint mLastMiddleCurvePoint; + QgsPoint mCurrentCoordinate; }; #endif // RUBBERBANDMODEL_H diff --git a/src/qml/DigitizingToolbar.qml b/src/qml/DigitizingToolbar.qml index 0a6322e5e6..b739272d96 100644 --- a/src/qml/DigitizingToolbar.qml +++ b/src/qml/DigitizingToolbar.qml @@ -242,7 +242,19 @@ QfVisibilityFadingRow { if (Number(rubberbandModel.geometryType) === Qgis.GeometryType.Point || Number(rubberbandModel.geometryType) === Qgis.GeometryType.Null) { confirm(); } else { - addVertex(); + if (settings.valueBool("/QField/Digitizing/CurveEdition", false) == true) { + if (currentRubberband.model.isDuringCurveDrawing() == true || currentRubberband.model.vertexCount == 1) { + if (currentRubberband.model.vertexCount != 1) { + addCurve(); + } else { + addVertex(); + } + } else { + addMiddlePointCurve(); + } + } else { + addVertex(); + } } } } @@ -281,6 +293,14 @@ QfVisibilityFadingRow { addVertexButton.clicked(); } + function addCurve() { + rubberbandModel.addCurve(); + } + + function addMiddlePointCurve() { + rubberbandModel.addMiddlePointCurve(); + } + function addVertex() { digitizingLogger.addCoordinate(coordinateLocator.currentCoordinate); coordinateLocator.flash(); diff --git a/src/qml/QFieldSettings.qml b/src/qml/QFieldSettings.qml index 995228dfc7..1c1e4a292d 100644 --- a/src/qml/QFieldSettings.qml +++ b/src/qml/QFieldSettings.qml @@ -420,6 +420,52 @@ Page { delegate: listItem } + GridLayout { + Layout.fillWidth: true + Layout.leftMargin: 20 + Layout.rightMargin: 20 + Layout.topMargin: 5 + Layout.bottomMargin: 5 + + columns: 1 + columnSpacing: 0 + rowSpacing: 0 + + visible: true + + Label { + Layout.fillWidth: true + + text: qsTr('Curve tolerance') + font: Theme.defaultFont + color: Theme.mainTextColor + wrapMode: Text.WordWrap + } + + QfSlider { + Layout.fillWidth: true + value: settings ? settings.value('/QField/Digitizing/CurveTolerance', 0.02) : 0.02 + from: 0 + to: 1 + stepSize: 0.001 + suffixText: " m" + implicitHeight: 40 + + onMoved: function () { + settings.setValue('/QField/Digitizing/CurveTolerance', value); + } + } + + Label { + Layout.fillWidth: true + text: qsTr('Maximum difference between approximation and curve') + + font: Theme.tipFont + color: Theme.secondaryTextColor + wrapMode: Text.WordWrap + } + } + GridLayout { Layout.fillWidth: true Layout.leftMargin: 20 diff --git a/src/qml/qgismobileapp.qml b/src/qml/qgismobileapp.qml index 58ad5936c0..66112ccee6 100644 --- a/src/qml/qgismobileapp.qml +++ b/src/qml/qgismobileapp.qml @@ -504,7 +504,19 @@ ApplicationWindow { if (Number(currentRubberband.model.geometryType) === Qgis.GeometryType.Point || Number(currentRubberband.model.geometryType) === Qgis.GeometryType.Null) { digitizingToolbar.confirm(); } else { - digitizingToolbar.addVertex(); + if (settings.valueBool("/QField/Digitizing/CurveEdition", false) == true) { + if (currentRubberband.model.isDuringCurveDrawing() == true || currentRubberband.model.vertexCount == 1) { + if (currentRubberband.model.vertexCount != 1) { + digitizingToolbar.addCurve(); + } else { + digitizingToolbar.addVertex(); + } + } else { + digitizingToolbar.addMiddlePointCurve(); + } + } else { + digitizingToolbar.addVertex(); + } } } } else { @@ -1559,6 +1571,51 @@ ApplicationWindow { } } } + + QfToolButton { + id: curveEditionButton + width: visible ? 40 : 0 + height: visible ? 40 : 0 + padding: 2 + round: true + visible: dashBoard.activeLayer && (dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Polygon || dashBoard.activeLayer.geometryType() === Qgis.GeometryType.Line) + iconSource: Theme.getThemeVectorIcon("ic_line_curve_24dp") + iconColor: "white" + bgcolor: Theme.darkGray + + property bool curveEdition: false + state: curveEdition ? "On" : "Off" + + states: [ + State { + + name: "Off" + PropertyChanges { + target: curveEditionButton + iconColor: "white" + bgcolor: Theme.darkGraySemiOpaque + } + }, + State { + name: "On" + PropertyChanges { + target: curveEditionButton + iconColor: Theme.mainColor + bgcolor: Theme.darkGray + } + } + ] + + onClicked: { + curveEdition = !curveEdition; + displayToast(curveEdition ? qsTr("Curve edition turned on") : qsTr("Curve edition turned off")); + settings.setValue("/QField/Digitizing/CurveEdition", curveEdition); + } + + Component.onCompleted: { + curveEdition = settings.valueBool("/QField/Digitizing/CurveEdition", false); + } + } } QfToolButton { From 723d9a8af1d04308f4c22834f2eab70cd5f3e5e8 Mon Sep 17 00:00:00 2001 From: Quentin Savoye Date: Wed, 20 Nov 2024 16:50:03 +0100 Subject: [PATCH 3/4] add curve to reshape, split, erase, fill --- src/qml/geometryeditors/Erase.qml | 14 +++++++++++++- src/qml/geometryeditors/FillRing.qml | 14 +++++++++++++- src/qml/geometryeditors/Reshape.qml | 14 +++++++++++++- src/qml/geometryeditors/SplitFeature.qml | 14 +++++++++++++- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/qml/geometryeditors/Erase.qml b/src/qml/geometryeditors/Erase.qml index 5963223450..15d7709a9d 100644 --- a/src/qml/geometryeditors/Erase.qml +++ b/src/qml/geometryeditors/Erase.qml @@ -21,7 +21,19 @@ QfVisibilityFadingRow { function canvasClicked(point, type) { if (type === "stylus") { - drawPolygonToolbar.addVertex(); + if (settings.valueBool("/QField/Digitizing/CurveEdition", false) == true) { + if (drawPolygonToolbar.rubberbandModel.isDuringCurveDrawing() == true || drawPolygonToolbar.rubberbandModel.vertexCount == 1) { + if (drawPolygonToolbar.rubberbandModel.vertexCount != 1) { + drawPolygonToolbar.addCurve(); + } else { + drawPolygonToolbar.addVertex(); + } + } else { + drawPolygonToolbar.addMiddlePointCurve(); + } + } else { + drawPolygonToolbar.addVertex(); + } return true; } return false; diff --git a/src/qml/geometryeditors/FillRing.qml b/src/qml/geometryeditors/FillRing.qml index 7f857957ff..6365f70f62 100644 --- a/src/qml/geometryeditors/FillRing.qml +++ b/src/qml/geometryeditors/FillRing.qml @@ -19,7 +19,19 @@ QfVisibilityFadingRow { function canvasClicked(point, type) { if (type === "stylus") { - drawPolygonToolbar.addVertex(); + if (settings.valueBool("/QField/Digitizing/CurveEdition", false) == true) { + if (drawPolygonToolbar.rubberbandModel.isDuringCurveDrawing() == true || drawPolygonToolbar.rubberbandModel.vertexCount == 1) { + if (drawPolygonToolbar.rubberbandModel.vertexCount != 1) { + drawPolygonToolbar.addCurve(); + } else { + drawPolygonToolbar.addVertex(); + } + } else { + drawPolygonToolbar.addMiddlePointCurve(); + } + } else { + drawPolygonToolbar.addVertex(); + } return true; } return false; diff --git a/src/qml/geometryeditors/Reshape.qml b/src/qml/geometryeditors/Reshape.qml index a7baae0e57..85b06700a3 100644 --- a/src/qml/geometryeditors/Reshape.qml +++ b/src/qml/geometryeditors/Reshape.qml @@ -18,7 +18,19 @@ QfVisibilityFadingRow { function canvasClicked(point, type) { if (type === "stylus") { - drawPolygonToolbar.addVertex(); + if (settings.valueBool("/QField/Digitizing/CurveEdition", false) == true) { + if (drawPolygonToolbar.rubberbandModel.isDuringCurveDrawing() == true || drawPolygonToolbar.rubberbandModel.vertexCount == 1) { + if (drawPolygonToolbar.rubberbandModel.vertexCount != 1) { + drawPolygonToolbar.addCurve(); + } else { + drawPolygonToolbar.addVertex(); + } + } else { + drawPolygonToolbar.addMiddlePointCurve(); + } + } else { + drawPolygonToolbar.addVertex(); + } return true; } return false; diff --git a/src/qml/geometryeditors/SplitFeature.qml b/src/qml/geometryeditors/SplitFeature.qml index d5b36fa796..d47a1e51dd 100644 --- a/src/qml/geometryeditors/SplitFeature.qml +++ b/src/qml/geometryeditors/SplitFeature.qml @@ -17,7 +17,19 @@ QfVisibilityFadingRow { function canvasClicked(point, type) { if (type === "stylus") { - drawLineToolbar.addVertex(); + if (settings.valueBool("/QField/Digitizing/CurveEdition", false) == true) { + if (drawLineToolbar.rubberbandModel.isDuringCurveDrawing() == true || drawLineToolbar.rubberbandModel.vertexCount == 1) { + if (drawLineToolbar.rubberbandModel.vertexCount != 1) { + drawLineToolbar.addCurve(); + } else { + drawLineToolbar.addVertex(); + } + } else { + drawLineToolbar.addMiddlePointCurve(); + } + } else { + drawLineToolbar.addVertex(); + } return true; } return false; From a7ad6d7cfa4ca928bb30086302c1a059d0985884 Mon Sep 17 00:00:00 2001 From: Quentin Savoye Date: Thu, 21 Nov 2024 14:25:57 +0100 Subject: [PATCH 4/4] reset rubberband on confirm or cancel --- src/core/rubberbandmodel.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/rubberbandmodel.cpp b/src/core/rubberbandmodel.cpp index c1fe44b48b..2f7c0ac8a9 100644 --- a/src/core/rubberbandmodel.cpp +++ b/src/core/rubberbandmodel.cpp @@ -407,7 +407,12 @@ void RubberbandModel::removeCurve() void RubberbandModel::reset() { - removeVertices( 0, vertexCount() - 1 ); + mCompoundCurve.clear(); + mDuringCurveDrawing = false; + mCompoundCurve.addVertex( mCurrentCoordinate ); + emit verticesRemoved( 0, vertexCount() - 1 ); + setCurrentCoordinateIndex( 0 ); + emit vertexCountChanged(); mFrozen = false; emit frozenChanged(); }