Skip to content

Commit

Permalink
Merge pull request #8737 from DelazJ/digitizingChecks
Browse files Browse the repository at this point in the history
Make geometry constraint configuration size fit the contents
  • Loading branch information
m-kuhn committed Dec 24, 2018
2 parents 2f64a3c + b1d8068 commit 91adb60
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 21 deletions.
23 changes: 22 additions & 1 deletion src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -407,14 +407,33 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
mGeometryPrecisionLineEdit->setEnabled( true );
mGeometryPrecisionLineEdit->setValidator( new QDoubleValidator( mGeometryPrecisionLineEdit ) );

mRemoveDuplicateNodesCheckbox->setChecked( mLayer->geometryOptions()->removeDuplicateNodes() );
double precision( mLayer->geometryOptions()->geometryPrecision() );
bool ok = true;
QString precisionStr( QLocale().toString( precision, ok ) );
if ( precision == 0.0 || ! ok )
precisionStr = QString();
mGeometryPrecisionLineEdit->setText( precisionStr );

mRemoveDuplicateNodesManuallyActivated = mLayer->geometryOptions()->removeDuplicateNodes();
mRemoveDuplicateNodesCheckbox->setChecked( mRemoveDuplicateNodesManuallyActivated );
if ( !precisionStr.isNull() )
mRemoveDuplicateNodesCheckbox->setEnabled( false );
connect( mGeometryPrecisionLineEdit, &QLineEdit::textChanged, this, [this]
{
if ( !mGeometryPrecisionLineEdit->text().isEmpty() )
{
if ( mRemoveDuplicateNodesCheckbox->isEnabled() )
mRemoveDuplicateNodesManuallyActivated = mRemoveDuplicateNodesCheckbox->isChecked();
mRemoveDuplicateNodesCheckbox->setEnabled( false );
mRemoveDuplicateNodesCheckbox->setChecked( true );
}
else
{
mRemoveDuplicateNodesCheckbox->setEnabled( true );
mRemoveDuplicateNodesCheckbox->setChecked( mRemoveDuplicateNodesManuallyActivated );
}
} );

mPrecisionUnitsLabel->setText( QStringLiteral( "[%1]" ).arg( QgsUnitTypes::toAbbreviatedString( mLayer->crs().mapUnits() ) ) );

QLayout *geometryCheckLayout = new QVBoxLayout();
Expand All @@ -428,6 +447,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
geometryCheckLayout->addWidget( cb );
}
mGeometryValidationGroupBox->setLayout( geometryCheckLayout );
mGeometryValidationGroupBox->setVisible( !geometryCheckFactories.isEmpty() );

QLayout *topologyCheckLayout = new QVBoxLayout();
const QList<QgsGeometryCheckFactory *> topologyCheckFactories = QgsAnalysis::instance()->geometryCheckRegistry()->geometryCheckFactories( mLayer, QgsGeometryCheck::LayerCheck, QgsGeometryCheck::Flag::AvailableInValidation );
Expand All @@ -440,6 +460,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
topologyCheckLayout->addWidget( cb );
}
mTopologyChecksGroupBox->setLayout( topologyCheckLayout );
mTopologyChecksGroupBox->setVisible( !topologyCheckFactories.isEmpty() );
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsvectorlayerproperties.h
Expand Up @@ -245,6 +245,8 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private

QHash<QCheckBox *, QString> mGeometryCheckFactoriesGroupBoxes;

bool mRemoveDuplicateNodesManuallyActivated = false;

private slots:
void openPanel( QgsPanelWidget *panel );

Expand Down
55 changes: 35 additions & 20 deletions src/ui/qgsvectorlayerpropertiesbase.ui
Expand Up @@ -433,8 +433,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>325</width>
<height>389</height>
<width>315</width>
<height>403</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
Expand Down Expand Up @@ -907,8 +907,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>104</width>
<height>102</height>
<width>185</width>
<height>112</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_23">
Expand Down Expand Up @@ -1504,8 +1504,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>685</width>
<height>346</height>
<width>734</width>
<height>372</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_32">
Expand Down Expand Up @@ -1961,8 +1961,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>340</width>
<height>630</height>
<width>378</width>
<height>678</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
Expand Down Expand Up @@ -2367,8 +2367,8 @@ border-radius: 2px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>651</width>
<height>804</height>
<width>658</width>
<height>800</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_20">
Expand All @@ -2377,8 +2377,15 @@ border-radius: 2px;</string>
<property name="title">
<string>Automatic Fixes</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="2" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="mRemoveDuplicateNodesCheckbox">
<property name="text">
<string>Remove duplicate nodes</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The geometry precision defines the maximum precision to of geometry coordinates that should be stored on this layer. A snap to grid algorithm will be applied on every geometry entering this layer, resulting in coordinates being rounded to multiples of this value. The operation is applied in this layer's coordinate reference system.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
Expand All @@ -2388,14 +2395,7 @@ border-radius: 2px;</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="mRemoveDuplicateNodesCheckbox">
<property name="text">
<string>Remove duplicate nodes</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_11" stretch="0,0">
<item>
<widget class="QLabel" name="mPrecisionUnitsLabel">
Expand Down Expand Up @@ -2436,6 +2436,19 @@ border-radius: 2px;</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
Expand Down Expand Up @@ -2653,6 +2666,8 @@ border-radius: 2px;</string>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
</resources>
<connections>
<connection>
Expand Down

0 comments on commit 91adb60

Please sign in to comment.