Skip to content

Commit cd33ee7

Browse files
committedMar 18, 2019
Make geometry validation automatic resolutions experimental
The automatic resolutions work unreliably (mostly due to geometry precision) and therefore cannot be use reliably. Therefore they should rather be treated as a technology preview which can be opted into for the moment.
1 parent 4e9c4b5 commit cd33ee7

File tree

7 files changed

+95
-11
lines changed

7 files changed

+95
-11
lines changed
 

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,24 @@ Write the geometry options to the ``node``.
116116
Read the geometry options from ``node``.
117117

118118
.. versionadded:: 3.4
119+
%End
120+
121+
bool automaticProblemResolutionEnabled() const;
122+
%Docstring
123+
Automatic problem resolution offers strategies to fix errors with
124+
a single click.
125+
This is currently experimental
126+
127+
.. versionadded:: 3.8
128+
%End
129+
130+
void setAutomaticProblemResolutionEnabled( bool automaticProblemResolutionEnabled );
131+
%Docstring
132+
Automatic problem resolution offers strategies to fix errors with
133+
a single click.
134+
This is currently experimental
135+
136+
.. versionadded:: 3.8
119137
%End
120138

121139
signals:
@@ -148,6 +166,11 @@ Geometries which are edited on this layer will be rounded to multiples of this v
148166
Set to 0.0 to disable.
149167

150168
.. versionadded:: 3.4
169+
%End
170+
171+
void automaticProblemResolutionEnabledChanged();
172+
%Docstring
173+
Defines if the automatic fixes
151174
%End
152175

153176
};

‎src/app/qgsgeometryvalidationdock.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ void QgsGeometryValidationDock::onRowsInserted()
164164
setUserVisible( true );
165165
}
166166

167+
void QgsGeometryValidationDock::updateResolutionWidgetVisibility()
168+
{
169+
if ( !mCurrentLayer )
170+
return;
171+
172+
mResolutionWidget->setVisible( mCurrentLayer->geometryOptions()->automaticProblemResolutionEnabled() );
173+
}
174+
167175
QgsGeometryValidationService *QgsGeometryValidationDock::geometryValidationService() const
168176
{
169177
return mGeometryValidationService;
@@ -275,6 +283,8 @@ void QgsGeometryValidationDock::onCurrentLayerChanged( QgsMapLayer *layer )
275283
disconnect( mCurrentLayer, &QgsVectorLayer::editingStarted, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
276284
disconnect( mCurrentLayer, &QgsVectorLayer::editingStopped, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
277285
disconnect( mCurrentLayer, &QgsVectorLayer::destroyed, this, &QgsGeometryValidationDock::onLayerDestroyed );
286+
disconnect( mCurrentLayer->geometryOptions(), &QgsGeometryOptions::automaticProblemResolutionEnabledChanged, this, &QgsGeometryValidationDock::updateResolutionWidgetVisibility );
287+
updateResolutionWidgetVisibility();
278288
}
279289

280290
mCurrentLayer = qobject_cast<QgsVectorLayer *>( layer );
@@ -284,6 +294,7 @@ void QgsGeometryValidationDock::onCurrentLayerChanged( QgsMapLayer *layer )
284294
connect( mCurrentLayer, &QgsVectorLayer::editingStarted, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
285295
connect( mCurrentLayer, &QgsVectorLayer::editingStopped, this, &QgsGeometryValidationDock::onLayerEditingStatusChanged );
286296
connect( mCurrentLayer, &QgsVectorLayer::destroyed, this, &QgsGeometryValidationDock::onLayerDestroyed );
297+
connect( mCurrentLayer->geometryOptions(), &QgsGeometryOptions::automaticProblemResolutionEnabledChanged, this, &QgsGeometryValidationDock::updateResolutionWidgetVisibility );
287298
}
288299

289300
onLayerEditingStatusChanged();

‎src/app/qgsgeometryvalidationdock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class QgsGeometryValidationDock : public QgsDockWidget, public Ui_QgsGeometryVal
5757
void updateLayerTransform();
5858
void onDataChanged( const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles );
5959
void onRowsInserted();
60+
void updateResolutionWidgetVisibility();
6061

6162
private:
6263

‎src/app/qgsvectorlayerproperties.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,14 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
463463
}
464464
mTopologyChecksGroupBox->setLayout( topologyCheckLayout );
465465
mTopologyChecksGroupBox->setVisible( !topologyCheckFactories.isEmpty() );
466+
mAutomaticProblemResolutionCheckbox->setChecked( mLayer->geometryOptions()->automaticProblemResolutionEnabled() );
466467
}
467468
else
468469
{
469470
mRemoveDuplicateNodesCheckbox->setEnabled( false );
470471
mGeometryPrecisionLineEdit->setEnabled( false );
471472
mGeometryAutoFixesGroupBox->setEnabled( false );
473+
mAutomaticProblemResolutionCheckbox->setEnabled( false );
472474
}
473475

474476
mOptsPage_Information->setProperty( "helpPage", QStringLiteral( "working_with_vector/vector_properties.html#information-properties" ) );
@@ -839,6 +841,7 @@ void QgsVectorLayerProperties::apply()
839841
activeChecks << it.value();
840842
}
841843
mLayer->geometryOptions()->setGeometryChecks( activeChecks );
844+
mLayer->geometryOptions()->setAutomaticProblemResolutionEnabled( mAutomaticProblemResolutionCheckbox->isChecked() );
842845

843846
mLayer->triggerRepaint();
844847
// notify the project we've made a change

‎src/core/qgsgeometryoptions.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,15 @@ void QgsGeometryOptions::readXml( const QDomNode &node )
115115
const QVariant checkConfiguration = QgsXmlUtils::readVariant( checkConfigurationElem );
116116
mCheckConfiguration = checkConfiguration.toMap();
117117
}
118+
119+
bool QgsGeometryOptions::automaticProblemResolutionEnabled() const
120+
{
121+
return mAutomaticProblemResolutionEnabled;
122+
}
123+
124+
void QgsGeometryOptions::setAutomaticProblemResolutionEnabled( bool automaticFixesEnabled )
125+
{
126+
if ( automaticFixesEnabled != mAutomaticProblemResolutionEnabled )
127+
mAutomaticProblemResolutionEnabled = automaticFixesEnabled;
128+
emit automaticProblemResolutionEnabledChanged();
129+
}

‎src/core/qgsgeometryoptions.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,24 @@ class CORE_EXPORT QgsGeometryOptions : public QObject
131131
*/
132132
void readXml( const QDomNode &node );
133133

134+
/**
135+
* Automatic problem resolution offers strategies to fix errors with
136+
* a single click.
137+
* This is currently experimental
138+
*
139+
* \since QGIS 3.8
140+
*/
141+
bool automaticProblemResolutionEnabled() const;
142+
143+
/**
144+
* Automatic problem resolution offers strategies to fix errors with
145+
* a single click.
146+
* This is currently experimental
147+
*
148+
* \since QGIS 3.8
149+
*/
150+
void setAutomaticProblemResolutionEnabled( bool automaticProblemResolutionEnabled );
151+
134152
signals:
135153

136154
/**
@@ -163,6 +181,11 @@ class CORE_EXPORT QgsGeometryOptions : public QObject
163181
*/
164182
void geometryPrecisionChanged();
165183

184+
/**
185+
* Defines if the automatic fixes
186+
*/
187+
void automaticProblemResolutionEnabledChanged();
188+
166189
private:
167190

168191
/**
@@ -183,6 +206,7 @@ class CORE_EXPORT QgsGeometryOptions : public QObject
183206

184207
QStringList mGeometryChecks;
185208
QVariantMap mCheckConfiguration;
209+
bool mAutomaticProblemResolutionEnabled = false;
186210
};
187211

188212
#endif // QGSGEOMETRYOPTIONS_H

‎src/ui/qgsvectorlayerpropertiesbase.ui

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,8 @@
436436
<rect>
437437
<x>0</x>
438438
<y>0</y>
439-
<width>662</width>
440-
<height>804</height>
439+
<width>315</width>
440+
<height>403</height>
441441
</rect>
442442
</property>
443443
<layout class="QVBoxLayout" name="verticalLayout_9">
@@ -724,8 +724,8 @@ border-radius: 2px;</string>
724724
<rect>
725725
<x>0</x>
726726
<y>0</y>
727-
<width>662</width>
728-
<height>804</height>
727+
<width>100</width>
728+
<height>30</height>
729729
</rect>
730730
</property>
731731
<layout class="QVBoxLayout" name="verticalLayout_18">
@@ -910,8 +910,8 @@ border-radius: 2px;</string>
910910
<rect>
911911
<x>0</x>
912912
<y>0</y>
913-
<width>662</width>
914-
<height>804</height>
913+
<width>113</width>
914+
<height>110</height>
915915
</rect>
916916
</property>
917917
<layout class="QVBoxLayout" name="verticalLayout_23">
@@ -1305,8 +1305,8 @@ border-radius: 2px;</string>
13051305
<rect>
13061306
<x>0</x>
13071307
<y>0</y>
1308-
<width>662</width>
1309-
<height>804</height>
1308+
<width>100</width>
1309+
<height>30</height>
13101310
</rect>
13111311
</property>
13121312
<layout class="QVBoxLayout" name="verticalLayout_21">
@@ -1508,7 +1508,7 @@ border-radius: 2px;</string>
15081508
<x>0</x>
15091509
<y>0</y>
15101510
<width>734</width>
1511-
<height>790</height>
1511+
<height>372</height>
15121512
</rect>
15131513
</property>
15141514
<layout class="QVBoxLayout" name="verticalLayout_32">
@@ -1964,8 +1964,8 @@ border-radius: 2px;</string>
19641964
<rect>
19651965
<x>0</x>
19661966
<y>0</y>
1967-
<width>662</width>
1968-
<height>804</height>
1967+
<width>378</width>
1968+
<height>678</height>
19691969
</rect>
19701970
</property>
19711971
<layout class="QVBoxLayout" name="verticalLayout_13">
@@ -2439,6 +2439,16 @@ border-radius: 2px;</string>
24392439
</property>
24402440
</widget>
24412441
</item>
2442+
<item>
2443+
<widget class="QCheckBox" name="mAutomaticProblemResolutionCheckbox">
2444+
<property name="toolTip">
2445+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This enables additional buttons for check results that will automatically fix problems.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Experimental&lt;/span&gt;&lt;/p&gt;&lt;p&gt;This functionality is tagged as experimental since some of the automatic fixes do not work completely reliable.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
2446+
</property>
2447+
<property name="text">
2448+
<string>Offer automatic problem resolution (Experimental)</string>
2449+
</property>
2450+
</widget>
2451+
</item>
24422452
<item>
24432453
<spacer name="verticalSpacer_4">
24442454
<property name="orientation">

0 commit comments

Comments
 (0)
Please sign in to comment.