Skip to content
Permalink
Browse files

Setter for GeometryOptions and not individual props

  • Loading branch information
m-kuhn committed Aug 22, 2018
1 parent 8f03681 commit 5435b193a2421cea6765df5a811dfc70e836c783
@@ -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
@@ -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() ) ) );
}
@@ -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() );
@@ -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;
@@ -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:

@@ -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.
*/

0 comments on commit 5435b19

Please sign in to comment.
You can’t perform that action at this time.