Skip to content

Commit

Permalink
Setter for GeometryOptions and not individual props
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Aug 22, 2018
1 parent 8f03681 commit 5435b19
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 58 deletions.
33 changes: 6 additions & 27 deletions python/core/auto_generated/qgsvectorlayer.sip.in
Expand Up @@ -2235,39 +2235,18 @@ Test if an edit command is active
.. versionadded:: 3.0
%End

bool removeDuplicateNodes() const;
GeometryOptions geometryOptions() const;
%Docstring
If the `removeDuplicateNodes` property is set on a layer, whenever a new feature enters
the edit buffer or the geometry of an existing feature is changed, duplicate nodes will
automatically be removed without any user intervention.
The geometry options applied to this layer contain information about
how geomtries should be preprocessed when added to or edited on this layer.

.. versionadded:: 3.4
%End

void setRemoveDuplicateNodes( bool removeDuplicateNodes );
void setGeometryOptions( const GeometryOptions &geometryOptions );
%Docstring
If the `removeDuplicateNodes` property is set on a layer, whenever a new feature enters
the edit buffer or the geometry of an existing feature is changed, duplicate nodes will
automatically be removed without any user intervention.

.. versionadded:: 3.4
%End


double geometryPrecision() const;
%Docstring
The `geometryPrecision` property of a layer will enable an automatic snap to grid operation
on a layer whenever a new feature is added or the geometry of an existing feature is changed.
If it is set to 0.0, this feature is disabled.

.. versionadded:: 3.4
%End

void setGeometryPrecision( double geometryPrecision );
%Docstring
The `geometryPrecision` property of a layer will enable an automatic snap to grid
on a layer whenever a new feature is added or the geometry of an existing feature is changed.
If it is set to 0.0, this feature is disabled.
The geometry options applied to this layer contain information about
how geomtries should be preprocessed when added to or edited on this layer.

.. versionadded:: 3.4
%End
Expand Down
11 changes: 7 additions & 4 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -423,13 +423,14 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(

updateAuxiliaryStoragePage();

QgsVectorLayer::GeometryOptions geomOps = mLayer->geometryOptions();
if ( mLayer->isSpatial() )
{
mRemoveDuplicateVerticeCheckbox->setEnabled( true );
mGeometryPrecisionSpinBox->setEnabled( true );

mRemoveDuplicateVerticeCheckbox->setChecked( mLayer->removeDuplicateNodes() );
mGeometryPrecisionSpinBox->setValue( mLayer->geometryPrecision() );
mRemoveDuplicateVerticeCheckbox->setChecked( geomOps.removeDuplicateNodes() );
mGeometryPrecisionSpinBox->setValue( geomOps.geometryPrecision() );

mGeometryPrecisionSpinBox->setSuffix( QStringLiteral( " [%1]" ).arg( QgsUnitTypes::toAbbreviatedString( mLayer->crs().mapUnits() ) ) );
}
Expand Down Expand Up @@ -777,8 +778,10 @@ void QgsVectorLayerProperties::apply()
mVector3DWidget->apply();
#endif

mLayer->setRemoveDuplicateNodes( mRemoveDuplicateVerticeCheckbox->isChecked() );
mLayer->setGeometryPrecision( mGeometryPrecisionSpinBox->value() );
QgsVectorLayer::GeometryOptions geomOps;
geomOps.removeDuplicateNodes = mRemoveDuplicateVerticeCheckbox->isChecked();
geomOps.geometryPrecision = mGeometryPrecisionSpinBox->value();
mLayer->setGeometryOptions( geomOps );

// update symbology
emit refreshLegend( mLayer->id() );
Expand Down
10 changes: 10 additions & 0 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -4790,6 +4790,16 @@ QgsAbstractVectorLayerLabeling *QgsVectorLayer::readLabelingFromCustomProperties
return labeling;
}

QgsVectorLayer::GeometryOptions QgsVectorLayer::geometryOptions() const
{
return mGeometryOptions;
}

void QgsVectorLayer::setGeometryOptions( const GeometryOptions &geometryOptions )
{
mGeometryOptions = geometryOptions;
}

double QgsVectorLayer::geometryPrecision() const
{
return mGeometryOptions.geometryPrecision;
Expand Down
34 changes: 7 additions & 27 deletions src/core/qgsvectorlayer.h
Expand Up @@ -2019,41 +2019,20 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
bool isEditCommandActive() const { return mEditCommandActive; }

/**
* If the `removeDuplicateNodes` property is set on a layer, whenever a new feature enters
* the edit buffer or the geometry of an existing feature is changed, duplicate nodes will
* automatically be removed without any user intervention.
* The geometry options applied to this layer contain information about
* how geomtries should be preprocessed when added to or edited on this layer.
*
* \since QGIS 3.4
*/
bool removeDuplicateNodes() const;
GeometryOptions geometryOptions() const;

/**
* If the `removeDuplicateNodes` property is set on a layer, whenever a new feature enters
* the edit buffer or the geometry of an existing feature is changed, duplicate nodes will
* automatically be removed without any user intervention.
* The geometry options applied to this layer contain information about
* how geomtries should be preprocessed when added to or edited on this layer.
*
* \since QGIS 3.4
*/
void setRemoveDuplicateNodes( bool removeDuplicateNodes );


/**
* The `geometryPrecision` property of a layer will enable an automatic snap to grid operation
* on a layer whenever a new feature is added or the geometry of an existing feature is changed.
* If it is set to 0.0, this feature is disabled.
*
* \since QGIS 3.4
*/
double geometryPrecision() const;

/**
* The `geometryPrecision` property of a layer will enable an automatic snap to grid
* on a layer whenever a new feature is added or the geometry of an existing feature is changed.
* If it is set to 0.0, this feature is disabled.
*
* \since QGIS 3.4
*/
void setGeometryPrecision( double geometryPrecision );
void setGeometryOptions( const GeometryOptions &geometryOptions );

public slots:

Expand Down Expand Up @@ -2387,6 +2366,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
void setExtent( const QgsRectangle &rect ) override;

private: // Private methods

/**
* Applies automatic fixes to geometries added to or edited on this layer.
*/
Expand Down

0 comments on commit 5435b19

Please sign in to comment.