Skip to content

Commit 3cb82a5

Browse files
authoredSep 19, 2018
Merge pull request #7959 from m-kuhn/geometryOptions
Add a new QML category "Geometry Options"
2 parents 1390198 + 9b2dff6 commit 3cb82a5

14 files changed

+124
-71
lines changed
 

‎python/core/auto_generated/qgsgeometryfixes.sip.in renamed to ‎python/core/auto_generated/qgsgeometryoptions.sip.in

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
/************************************************************************
22
* This file has been generated automatically from *
33
* *
4-
* src/core/qgsgeometryfixes.h *
4+
* src/core/qgsgeometryoptions.h *
55
* *
66
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
77
************************************************************************/
88

99

1010

1111

12-
class QgsGeometryFixes
12+
class QgsGeometryOptions
1313
{
1414
%Docstring
1515

16-
The QgsGeometryFixes class contains options to automatically adjust geometries to
16+
The QgsGeometryOptions class contains options to automatically adjust geometries to
1717
constraints on a layer.
1818

1919
.. versionadded:: 3.4
2020
%End
2121

2222
%TypeHeaderCode
23-
#include "qgsgeometryfixes.h"
23+
#include "qgsgeometryoptions.h"
2424
%End
2525
public:
2626

27-
QgsGeometryFixes();
27+
QgsGeometryOptions();
2828
%Docstring
29-
Create a new QgsGeometryFixes object.
29+
Create a new QgsGeometryOptions object.
3030
%End
3131

3232
bool removeDuplicateNodes() const;
@@ -72,6 +72,20 @@ Determines if at least one fix is enabled.
7272
%Docstring
7373
Apply any fixes configured on this class to ``geometry``.
7474

75+
.. versionadded:: 3.4
76+
%End
77+
78+
void writeXml( QDomNode &node ) const;
79+
%Docstring
80+
Write the geometry options to the ``node``.
81+
82+
.. versionadded:: 3.4
83+
%End
84+
85+
void readXml( const QDomNode &node );
86+
%Docstring
87+
Read the geometry options from ``node``.
88+
7589
.. versionadded:: 3.4
7690
%End
7791

@@ -80,7 +94,7 @@ Apply any fixes configured on this class to ``geometry``.
8094
/************************************************************************
8195
* This file has been generated automatically from *
8296
* *
83-
* src/core/qgsgeometryfixes.h *
97+
* src/core/qgsgeometryoptions.h *
8498
* *
8599
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
86100
************************************************************************/

‎python/core/auto_generated/qgsmaplayer.sip.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ This is the base class for all map layer types (vector, raster).
8989
AttributeTable,
9090
Rendering,
9191
CustomProperties,
92+
GeometryOptions,
9293
AllStyleCategories
9394
};
9495
typedef QFlags<QgsMapLayer::StyleCategory> StyleCategories;

‎python/core/auto_generated/qgsvectorlayer.sip.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2230,7 +2230,7 @@ Test if an edit command is active
22302230
.. versionadded:: 3.0
22312231
%End
22322232

2233-
QgsGeometryFixes *geometryFixes() const;
2233+
QgsGeometryOptions *geometryOptions() const;
22342234
%Docstring
22352235
Configuration and logic to apply automatically on any edit happening on this layer.
22362236

‎python/core/core_auto.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
%Include auto_generated/qgsfields.sip
5555
%Include auto_generated/qgsfileutils.sip
5656
%Include auto_generated/qgsfontutils.sip
57-
%Include auto_generated/qgsgeometryfixes.sip
57+
%Include auto_generated/qgsgeometryoptions.sip
5858
%Include auto_generated/qgsgeometrysimplifier.sip
5959
%Include auto_generated/qgshistogram.sip
6060
%Include auto_generated/qgshstoreutils.sip

‎src/app/qgsmaplayerstylecategoriesmodel.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,17 @@ QVariant QgsMapLayerStyleCategoriesModel::data( const QModelIndex &index, int ro
208208
return QgsApplication::getThemeIcon( QStringLiteral( "/mActionOptions.svg" ) );
209209
}
210210
break;
211+
case QgsMapLayer::GeometryOptions:
212+
switch ( role )
213+
{
214+
case Qt::DisplayRole:
215+
return tr( "Geometry Options" );
216+
case Qt::ToolTipRole:
217+
return tr( "Geometry constraints and validity checks" );
218+
case Qt::DecorationRole:
219+
return QgsApplication::getThemeIcon( QStringLiteral( "/propertyicons/digitizing.svg" ) );
220+
}
221+
break;
211222
case QgsMapLayer::AllStyleCategories:
212223
switch ( role )
213224
{

‎src/app/qgsvectorlayerproperties.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
#include "qgsnewauxiliaryfielddialog.h"
6161
#include "qgslabelinggui.h"
6262
#include "qgssymbollayer.h"
63-
#include "qgsgeometryfixes.h"
63+
#include "qgsgeometryoptions.h"
6464
#include "qgsvectorlayersavestyledialog.h"
6565
#include "qgsvectorlayerloadstyledialog.h"
6666

@@ -401,8 +401,8 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
401401
mRemoveDuplicateNodesCheckbox->setEnabled( true );
402402
mGeometryPrecisionSpinBox->setEnabled( true );
403403

404-
mRemoveDuplicateNodesCheckbox->setChecked( mLayer->geometryFixes()->removeDuplicateNodes() );
405-
mGeometryPrecisionSpinBox->setValue( mLayer->geometryFixes()->geometryPrecision() );
404+
mRemoveDuplicateNodesCheckbox->setChecked( mLayer->geometryOptions()->removeDuplicateNodes() );
405+
mGeometryPrecisionSpinBox->setValue( mLayer->geometryOptions()->geometryPrecision() );
406406

407407
mGeometryPrecisionSpinBox->setSuffix( QStringLiteral( " [%1]" ).arg( QgsUnitTypes::toAbbreviatedString( mLayer->crs().mapUnits() ) ) );
408408
}
@@ -751,8 +751,8 @@ void QgsVectorLayerProperties::apply()
751751
mVector3DWidget->apply();
752752
#endif
753753

754-
mLayer->geometryFixes()->setRemoveDuplicateNodes( mRemoveDuplicateNodesCheckbox->isChecked() );
755-
mLayer->geometryFixes()->setGeometryPrecision( mGeometryPrecisionSpinBox->value() );
754+
mLayer->geometryOptions()->setRemoveDuplicateNodes( mRemoveDuplicateNodesCheckbox->isChecked() );
755+
mLayer->geometryOptions()->setGeometryPrecision( mGeometryPrecisionSpinBox->value() );
756756

757757
// update symbology
758758
emit refreshLegend( mLayer->id() );

‎src/core/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ SET(QGIS_CORE_SRCS
204204
qgsfontutils.cpp
205205
qgsgeometrysimplifier.cpp
206206
qgsgeometryvalidator.cpp
207-
qgsgeometryfixes.cpp
207+
qgsgeometryoptions.cpp
208208
qgsgml.cpp
209209
qgsgmlschema.cpp
210210
qgshistogram.cpp
@@ -867,7 +867,7 @@ SET(QGIS_CORE_HDRS
867867
qgsfields.h
868868
qgsfileutils.h
869869
qgsfontutils.h
870-
qgsgeometryfixes.h
870+
qgsgeometryoptions.h
871871
qgsgeometrysimplifier.h
872872
qgshistogram.h
873873
qgshstoreutils.h
Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***************************************************************************
2-
qgsgeometryfixes.cpp
2+
qgsgeometryoptions.cpp
33
-------------------
44
begin : Aug 23, 2018
55
copyright : (C) 2018 by Matthias Kuhn
@@ -15,38 +15,56 @@
1515
* *
1616
***************************************************************************/
1717

18-
#include "qgsgeometryfixes.h"
18+
#include "qgsgeometryoptions.h"
1919

20-
bool QgsGeometryFixes::removeDuplicateNodes() const
20+
#include "qgsxmlutils.h"
21+
22+
bool QgsGeometryOptions::removeDuplicateNodes() const
2123
{
2224
return mRemoveDuplicateNodes;
2325
}
2426

25-
void QgsGeometryFixes::setRemoveDuplicateNodes( bool value )
27+
void QgsGeometryOptions::setRemoveDuplicateNodes( bool value )
2628
{
2729
mRemoveDuplicateNodes = value;
2830
}
2931

30-
double QgsGeometryFixes::geometryPrecision() const
32+
double QgsGeometryOptions::geometryPrecision() const
3133
{
3234
return mGeometryPrecision;
3335
}
3436

35-
void QgsGeometryFixes::setGeometryPrecision( double value )
37+
void QgsGeometryOptions::setGeometryPrecision( double value )
3638
{
3739
mGeometryPrecision = value;
3840
}
3941

40-
bool QgsGeometryFixes::isActive() const
42+
bool QgsGeometryOptions::isActive() const
4143
{
4244
return mGeometryPrecision != 0.0 || mRemoveDuplicateNodes;
4345
}
4446

45-
void QgsGeometryFixes::apply( QgsGeometry &geometry ) const
47+
void QgsGeometryOptions::apply( QgsGeometry &geometry ) const
4648
{
4749
if ( mGeometryPrecision != 0.0 )
4850
geometry = geometry.snappedToGrid( mGeometryPrecision, mGeometryPrecision );
4951

5052
if ( mRemoveDuplicateNodes )
5153
geometry.removeDuplicateNodes();
5254
}
55+
56+
void QgsGeometryOptions::writeXml( QDomNode &node ) const
57+
{
58+
QDomElement geometryOptionsElement = node.ownerDocument().createElement( QStringLiteral( "geometryOptions" ) );
59+
node.appendChild( geometryOptionsElement );
60+
61+
geometryOptionsElement.setAttribute( QStringLiteral( "removeDuplicateNodes" ), mRemoveDuplicateNodes ? 1 : 0 );
62+
geometryOptionsElement.setAttribute( QStringLiteral( "geometryPrecision" ), mGeometryPrecision );
63+
}
64+
65+
void QgsGeometryOptions::readXml( const QDomNode &node )
66+
{
67+
QDomElement geometryOptionsElement = node.toElement();
68+
setGeometryPrecision( geometryOptionsElement.attribute( QStringLiteral( "geometryPrecision" ), QStringLiteral( "0.0" ) ).toDouble() );
69+
setRemoveDuplicateNodes( geometryOptionsElement.attribute( QStringLiteral( "removeDuplicateNodes" ), QStringLiteral( "0" ) ).toInt() == 1 );
70+
}

‎src/core/qgsgeometryfixes.h renamed to ‎src/core/qgsgeometryoptions.h

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***************************************************************************
2-
qgsgeometryfixes.h
2+
qgsgeometryoptions.h
33
-------------------
44
begin : Aug 23, 2018
55
copyright : (C) 2018 by Matthias Kuhn
@@ -15,27 +15,29 @@
1515
* *
1616
***************************************************************************/
1717

18-
#ifndef QGSGEOMETRYFIXES_H
19-
#define QGSGEOMETRYFIXES_H
18+
#ifndef QGSGEOMETRYOPTIONS_H
19+
#define QGSGEOMETRYOPTIONS_H
2020

21+
#include "qgis_core.h"
22+
#include "qgis_sip.h"
2123
#include "qgsgeometry.h"
2224

2325
/**
2426
* \ingroup core
2527
*
26-
* The QgsGeometryFixes class contains options to automatically adjust geometries to
28+
* The QgsGeometryOptions class contains options to automatically adjust geometries to
2729
* constraints on a layer.
2830
*
2931
* \since QGIS 3.4
3032
*/
31-
class CORE_EXPORT QgsGeometryFixes
33+
class CORE_EXPORT QgsGeometryOptions
3234
{
3335
public:
3436

3537
/**
36-
* Create a new QgsGeometryFixes object.
38+
* Create a new QgsGeometryOptions object.
3739
*/
38-
QgsGeometryFixes() = default;
40+
QgsGeometryOptions() = default;
3941

4042
/**
4143
* Automatically remove duplicate nodes on all geometries which are edited on this layer.
@@ -83,6 +85,20 @@ class CORE_EXPORT QgsGeometryFixes
8385
*/
8486
void apply( QgsGeometry &geometry ) const;
8587

88+
/**
89+
* Write the geometry options to the \a node.
90+
*
91+
* \since QGIS 3.4
92+
*/
93+
void writeXml( QDomNode &node ) const;
94+
95+
/**
96+
* Read the geometry options from \a node.
97+
*
98+
* \since QGIS 3.4
99+
*/
100+
void readXml( const QDomNode &node );
101+
86102
private:
87103

88104
/**
@@ -102,4 +118,4 @@ class CORE_EXPORT QgsGeometryFixes
102118
double mGeometryPrecision = 0.0;
103119
};
104120

105-
#endif // QGSGEOMETRYFIXES_H
121+
#endif // QGSGEOMETRYOPTIONS_H

‎src/core/qgsmaplayer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,9 @@ class CORE_EXPORT QgsMapLayer : public QObject
153153
AttributeTable = 1 << 9, //!< Attribute table settings: choice and order of columns, conditional styling
154154
Rendering = 1 << 10, //!< Rendering: scale visibility, simplify method, opacity
155155
CustomProperties = 1 << 11, //!< Custom properties (by plugins for instance)
156+
GeometryOptions = 1 << 12, //!< Geometry validation configuration
156157
AllStyleCategories = LayerConfiguration | Symbology | Symbology3D | Labeling | Fields | Forms | Actions |
157-
MapTips | Diagrams | AttributeTable | Rendering | CustomProperties,
158+
MapTips | Diagrams | AttributeTable | Rendering | CustomProperties | GeometryOptions,
158159
};
159160
Q_ENUM( StyleCategory )
160161
Q_DECLARE_FLAGS( StyleCategories, StyleCategory )

‎src/core/qgsvectorlayer.cpp

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
#include "qgstaskmanager.h"
9696
#include "qgstransaction.h"
9797
#include "qgsauxiliarystorage.h"
98-
#include "qgsgeometryfixes.h"
98+
#include "qgsgeometryoptions.h"
9999

100100
#include "diagram/qgsdiagram.h"
101101

@@ -150,7 +150,7 @@ QgsVectorLayer::QgsVectorLayer( const QString &vectorLayerPath,
150150
, mAuxiliaryLayerKey( QString() )
151151
, mReadExtentFromXml( options.readExtentFromXml )
152152
{
153-
mGeometryFixes = qgis::make_unique<QgsGeometryFixes>();
153+
mGeometryOptions = qgis::make_unique<QgsGeometryOptions>();
154154
mActions = new QgsActionManager( this );
155155
mConditionalStyles = new QgsConditionalLayerStyles();
156156

@@ -947,10 +947,10 @@ bool QgsVectorLayer::addFeature( QgsFeature &feature, Flags )
947947
return false;
948948

949949

950-
if ( mGeometryFixes->isActive() )
950+
if ( mGeometryOptions->isActive() )
951951
{
952952
QgsGeometry geom = feature.geometry();
953-
mGeometryFixes->apply( geom );
953+
mGeometryOptions->apply( geom );
954954
feature.setGeometry( geom );
955955
}
956956

@@ -2064,12 +2064,9 @@ bool QgsVectorLayer::readSymbology( const QDomNode &layerNode, QString &errorMes
20642064
}
20652065
}
20662066

2067-
if ( categories.testFlag( LayerConfiguration ) )
2068-
{
2069-
QDomElement geometryOptionsElement = layerNode.namedItem( QStringLiteral( "geometryOptions" ) ).toElement();
2070-
mGeometryFixes->setGeometryPrecision( geometryOptionsElement.attribute( QStringLiteral( "geometryPrecision" ), QStringLiteral( "0.0" ) ).toDouble() );
2071-
mGeometryFixes->setRemoveDuplicateNodes( geometryOptionsElement.attribute( QStringLiteral( "removeDuplicateNodes" ), QStringLiteral( "0" ) ).toInt() == 1 );
2072-
}
2067+
if ( categories.testFlag( GeometryOptions ) )
2068+
mGeometryOptions->readXml( layerNode.namedItem( QStringLiteral( "geometryOptions" ) ) );
2069+
20732070
if ( categories.testFlag( Forms ) )
20742071
mEditFormConfig.readXml( layerNode, context );
20752072

@@ -2286,13 +2283,8 @@ bool QgsVectorLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString
22862283

22872284
( void )writeStyle( node, doc, errorMessage, context, categories );
22882285

2289-
if ( categories.testFlag( LayerConfiguration ) )
2290-
{
2291-
QDomElement geometryOptionsElement = doc.createElement( QStringLiteral( "geometryOptions" ) );
2292-
node.appendChild( geometryOptionsElement );
2293-
geometryOptionsElement.setAttribute( QStringLiteral( "removeDuplicateNodes" ), mGeometryFixes->removeDuplicateNodes() ? 1 : 0 );
2294-
geometryOptionsElement.setAttribute( QStringLiteral( "geometryPrecision" ), mGeometryFixes->geometryPrecision() );
2295-
}
2286+
if ( categories.testFlag( GeometryOptions ) )
2287+
mGeometryOptions->writeXml( node );
22962288

22972289
if ( categories.testFlag( Fields ) )
22982290
{
@@ -2593,8 +2585,8 @@ bool QgsVectorLayer::changeGeometry( QgsFeatureId fid, QgsGeometry &geom, bool s
25932585
return false;
25942586
}
25952587

2596-
if ( mGeometryFixes->isActive() )
2597-
mGeometryFixes->apply( geom );
2588+
if ( mGeometryOptions->isActive() )
2589+
mGeometryOptions->apply( geom );
25982590

25992591
updateExtents();
26002592

@@ -3058,12 +3050,12 @@ bool QgsVectorLayer::addFeatures( QgsFeatureList &features, Flags )
30583050
if ( !mEditBuffer || !mDataProvider )
30593051
return false;
30603052

3061-
if ( mGeometryFixes->isActive() )
3053+
if ( mGeometryOptions->isActive() )
30623054
{
30633055
for ( auto feature = features.begin(); feature != features.end(); ++feature )
30643056
{
30653057
QgsGeometry geom = feature->geometry();
3066-
mGeometryFixes->apply( geom );
3058+
mGeometryOptions->apply( geom );
30673059
feature->setGeometry( geom );
30683060
}
30693061
}
@@ -4849,9 +4841,9 @@ QgsAbstractVectorLayerLabeling *QgsVectorLayer::readLabelingFromCustomProperties
48494841
return labeling;
48504842
}
48514843

4852-
QgsGeometryFixes *QgsVectorLayer::geometryFixes() const
4844+
QgsGeometryOptions *QgsVectorLayer::geometryOptions() const
48534845
{
4854-
return mGeometryFixes.get();
4846+
return mGeometryOptions.get();
48554847
}
48564848

48574849
void QgsVectorLayer::setReadExtentFromXml( bool readExtentFromXml )

‎src/core/qgsvectorlayer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class QgsPoint;
7171
class QgsFeedback;
7272
class QgsAuxiliaryStorage;
7373
class QgsAuxiliaryLayer;
74-
class QgsGeometryFixes;
74+
class QgsGeometryOptions;
7575

7676
typedef QList<int> QgsAttributeList;
7777
typedef QSet<int> QgsAttributeIds;
@@ -2007,7 +2007,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
20072007
*
20082008
* \since QGIS 3.4
20092009
*/
2010-
QgsGeometryFixes *geometryFixes() const;
2010+
QgsGeometryOptions *geometryOptions() const;
20112011

20122012
public slots:
20132013

@@ -2499,7 +2499,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
24992499

25002500
QgsVectorLayerFeatureCounter *mFeatureCounter = nullptr;
25012501

2502-
std::unique_ptr<QgsGeometryFixes> mGeometryFixes;
2502+
std::unique_ptr<QgsGeometryOptions> mGeometryOptions;
25032503

25042504
friend class QgsVectorLayerFeatureSource;
25052505
};

‎src/gui/qgsmaptooladvanceddigitizing.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "qgsmapcanvas.h"
1919
#include "qgsadvanceddigitizingdockwidget.h"
2020
#include "qgsvectorlayer.h"
21-
#include "qgsgeometryfixes.h"
21+
#include "qgsgeometryoptions.h"
2222
#include "qgssnaptogridcanvasitem.h"
2323

2424
QgsMapToolAdvancedDigitizing::QgsMapToolAdvancedDigitizing( QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget )
@@ -45,7 +45,7 @@ void QgsMapToolAdvancedDigitizing::canvasPressEvent( QgsMapMouseEvent *e )
4545
QgsVectorLayer *layer = currentVectorLayer();
4646
if ( mSnapToLayerGridEnabled && layer )
4747
{
48-
e->snapToGrid( layer->geometryFixes()->geometryPrecision(), layer->crs() );
48+
e->snapToGrid( layer->geometryOptions()->geometryPrecision(), layer->crs() );
4949
}
5050

5151
cadCanvasPressEvent( e );
@@ -85,7 +85,7 @@ void QgsMapToolAdvancedDigitizing::canvasReleaseEvent( QgsMapMouseEvent *e )
8585
QgsVectorLayer *layer = currentVectorLayer();
8686
if ( mSnapToGridCanvasItem && mSnapToLayerGridEnabled && layer )
8787
{
88-
e->snapToGrid( layer->geometryFixes()->geometryPrecision(), layer->crs() );
88+
e->snapToGrid( layer->geometryOptions()->geometryPrecision(), layer->crs() );
8989
}
9090

9191
cadCanvasReleaseEvent( e );
@@ -110,7 +110,7 @@ void QgsMapToolAdvancedDigitizing::canvasMoveEvent( QgsMapMouseEvent *e )
110110
QgsVectorLayer *layer = currentVectorLayer();
111111
if ( mSnapToGridCanvasItem && mSnapToLayerGridEnabled && layer )
112112
{
113-
e->snapToGrid( layer->geometryFixes()->geometryPrecision(), layer->crs() );
113+
e->snapToGrid( layer->geometryOptions()->geometryPrecision(), layer->crs() );
114114
mSnapToGridCanvasItem->setPoint( e->mapPoint() );
115115
}
116116

@@ -127,7 +127,7 @@ void QgsMapToolAdvancedDigitizing::activate()
127127
if ( layer )
128128
{
129129
mSnapToGridCanvasItem->setCrs( currentVectorLayer()->crs() );
130-
mSnapToGridCanvasItem->setPrecision( currentVectorLayer()->geometryFixes()->geometryPrecision() );
130+
mSnapToGridCanvasItem->setPrecision( currentVectorLayer()->geometryOptions()->geometryPrecision() );
131131
}
132132
mSnapToGridCanvasItem->setEnabled( mSnapToLayerGridEnabled );
133133
}
@@ -155,7 +155,7 @@ void QgsMapToolAdvancedDigitizing::onCurrentLayerChanged()
155155
QgsVectorLayer *layer = currentVectorLayer();
156156
if ( layer && mSnapToLayerGridEnabled )
157157
{
158-
mSnapToGridCanvasItem->setPrecision( layer->geometryFixes()->geometryPrecision() );
158+
mSnapToGridCanvasItem->setPrecision( layer->geometryOptions()->geometryPrecision() );
159159
mSnapToGridCanvasItem->setCrs( layer->crs() );
160160
}
161161

‎tests/src/python/test_qgsvectorlayer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2776,36 +2776,36 @@ def testFeatureRequestWithReprojectionAndVirtualFields(self):
27762776

27772777
def testPrecision(self):
27782778
layer = QgsVectorLayer("Polygon?crs=epsg:2056&field=pk:int", "vl", "memory")
2779-
layer.geometryFixes().setGeometryPrecision(10)
2779+
layer.geometryOptions().setGeometryPrecision(10)
27802780
geom = QgsGeometry.fromWkt('Polygon ((2596411 1224654, 2596400 1224652, 2596405 1224640, 2596410 1224641, 2596411 1224654))')
27812781
feature = QgsFeature(layer.fields())
27822782
feature.setGeometry(geom)
27832783
layer.startEditing()
27842784
layer.addFeature(feature)
27852785
self.assertGeometriesEqual(QgsGeometry.fromWkt('Polygon ((2596410 1224650, 2596400 1224650, 2596410 1224640, 2596410 1224650))'), feature.geometry(), 'geometry with unsnapped nodes', 'fixed geometry')
2786-
layer.geometryFixes().setGeometryPrecision(0.0)
2786+
layer.geometryOptions().setGeometryPrecision(0.0)
27872787
feature.setGeometry(QgsGeometry.fromWkt('Polygon ((2596411 1224654, 2596400 1224652, 2596405 1224640, 2596410 1224641, 2596411 1224654))'))
27882788
layer.addFeature(feature)
27892789
self.assertGeometriesEqual(QgsGeometry.fromWkt('Polygon ((2596411 1224654, 2596400 1224652, 2596405 1224640, 2596410 1224641, 2596411 1224654))'), feature.geometry(), 'geometry with duplicates', 'unchanged geometry')
27902790

27912791
def testRemoveDuplicateNodes(self):
27922792
layer = QgsVectorLayer("Polygon?crs=epsg:2056&field=pk:int", "vl", "memory")
2793-
layer.geometryFixes().setRemoveDuplicateNodes(True)
2793+
layer.geometryOptions().setRemoveDuplicateNodes(True)
27942794
geom = QgsGeometry.fromWkt('Polygon ((70 80, 80 90, 80 90, 60 50, 70 80))')
27952795
feature = QgsFeature(layer.fields())
27962796
feature.setGeometry(geom)
27972797
layer.startEditing()
27982798
layer.addFeature(feature)
27992799
self.assertGeometriesEqual(feature.geometry(), QgsGeometry.fromWkt('Polygon ((70 80, 80 90, 60 50, 70 80))'), 'fixed geometry', 'geometry with duplicates')
2800-
layer.geometryFixes().setRemoveDuplicateNodes(False)
2800+
layer.geometryOptions().setRemoveDuplicateNodes(False)
28012801
feature.setGeometry(QgsGeometry.fromWkt('Polygon ((70 80, 80 90, 80 90, 60 50, 70 80))'))
28022802
layer.addFeature(feature)
28032803
self.assertGeometriesEqual(feature.geometry(), QgsGeometry.fromWkt('Polygon ((70 80, 80 90, 80 90, 60 50, 70 80))'), 'unchanged geometry', 'geometry with duplicates')
28042804

28052805
def testPrecisionAndDuplicateNodes(self):
28062806
layer = QgsVectorLayer("Polygon?crs=epsg:2056&field=pk:int", "vl", "memory")
2807-
layer.geometryFixes().setGeometryPrecision(10)
2808-
layer.geometryFixes().setRemoveDuplicateNodes(True)
2807+
layer.geometryOptions().setGeometryPrecision(10)
2808+
layer.geometryOptions().setRemoveDuplicateNodes(True)
28092809
geom = QgsGeometry.fromWkt('Polygon ((2596411 1224654, 2596400 1224652, 2596402 1224653, 2596405 1224640, 2596410 1224641, 2596411 1224654))')
28102810
feature = QgsFeature(layer.fields())
28112811
feature.setGeometry(geom)

0 commit comments

Comments
 (0)
Please sign in to comment.