Skip to content

Commit

Permalink
Add icons to geometry validation checks
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Mar 20, 2019
1 parent 9383b00 commit d97f5d4
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 11 deletions.
4 changes: 4 additions & 0 deletions images/images.qrc
Expand Up @@ -76,6 +76,10 @@
<file>north_arrows/gpsarrow2.svg</file>
<file>splash/splash.png</file>
<file>composer/missing_image.svg</file>
<file>themes/default/checks/SliverOrGap.svg</file>
<file>themes/default/checks/InvalidGeometry.svg</file>
<file>themes/default/checks/MissingVertex.svg</file>
<file>themes/default/checks/Overlap.svg</file>
<file>themes/default/algorithms/mAlgorithmAddGeometryAttributes.svg</file>
<file>themes/default/algorithms/mAlgorithmBasicStatistics.svg</file>
<file>themes/default/algorithms/mAlgorithmBuffer.svg</file>
Expand Down
1 change: 1 addition & 0 deletions images/themes/default/checks/InvalidGeometry.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/checks/MissingVertex.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/checks/Overlap.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/checks/SliverOrGap.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -77,6 +77,12 @@ Will be used to update existing errors whenever they are re-checked.



virtual QIcon icon() const;
%Docstring
Returns an icon that should be shown for this kind of error.

.. versionadded:: 3.8
%End
protected:
QgsGeometryCheckError( const QgsGeometryCheck *check,
const QString &layerId,
Expand Down
Expand Up @@ -16,6 +16,7 @@
***************************************************************************/

#include "qgsgeometrycheckerror.h"
#include "qgsapplication.h"

QgsGeometryCheckError::QgsGeometryCheckError( const QgsGeometryCheck *check,
const QString &layerId,
Expand Down Expand Up @@ -186,6 +187,14 @@ QMap<QString, QgsFeatureIds> QgsGeometryCheckError::involvedFeatures() const
return QMap<QString, QSet<QgsFeatureId> >();
}

QIcon QgsGeometryCheckError::icon() const
{
if ( status() == QgsGeometryCheckError::StatusFixed )
return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCheckGeometry.svg" ) );
else
return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmLineIntersections.svg" ) );
}

void QgsGeometryCheckError::update( const QgsGeometryCheckError *other )
{
Q_ASSERT( mCheck == other->mCheck );
Expand Down
6 changes: 6 additions & 0 deletions src/analysis/vector/geometry_checker/qgsgeometrycheckerror.h
Expand Up @@ -102,6 +102,12 @@ class ANALYSIS_EXPORT QgsGeometryCheckError
*/
virtual QMap<QString, QgsFeatureIds > involvedFeatures() const SIP_SKIP;

/**
* Returns an icon that should be shown for this kind of error.
*
* \since QGIS 3.8
*/
virtual QIcon icon() const;
protected:
// Users of this constructor must ensure geometry and errorLocation are in map coordinates
QgsGeometryCheckError( const QgsGeometryCheck *check,
Expand Down
10 changes: 10 additions & 0 deletions src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp
Expand Up @@ -20,6 +20,7 @@
#include "qgsfeaturepool.h"
#include "qgsvectorlayer.h"
#include "qgsfeedback.h"
#include "qgsapplication.h"

#include "geos_c.h"

Expand Down Expand Up @@ -329,3 +330,12 @@ QMap<QString, QgsFeatureIds> QgsGeometryGapCheckError::involvedFeatures() const
{
return mNeighbors;
}

QIcon QgsGeometryGapCheckError::icon() const
{

if ( status() == QgsGeometryCheckError::StatusFixed )
return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCheckGeometry.svg" ) );
else
return QgsApplication::getThemeIcon( QStringLiteral( "/checks/SliverOrGap.svg" ) );
}
2 changes: 2 additions & 0 deletions src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h
Expand Up @@ -50,6 +50,8 @@ class ANALYSIS_EXPORT QgsGeometryGapCheckError : public QgsGeometryCheckError

QMap<QString, QgsFeatureIds > involvedFeatures() const override;

QIcon icon() const override;

private:
QMap<QString, QgsFeatureIds> mNeighbors;
QgsRectangle mGapAreaBBox;
Expand Down
Expand Up @@ -23,6 +23,7 @@
#include "qgslinestring.h"
#include "qgsgeometryengine.h"
#include "qgsgeometryutils.h"
#include "qgsapplication.h"

QgsGeometryMissingVertexCheck::QgsGeometryMissingVertexCheck( const QgsGeometryCheckContext *context, const QVariantMap &geometryCheckConfiguration )
: QgsGeometryCheck( context, geometryCheckConfiguration )
Expand Down Expand Up @@ -288,3 +289,12 @@ void QgsGeometryMissingVertexCheckError::setInvolvedFeatures( const QMap<QString
{
mInvolvedFeatures = involvedFeatures;
}

QIcon QgsGeometryMissingVertexCheckError::icon() const
{

if ( status() == QgsGeometryCheckError::StatusFixed )
return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCheckGeometry.svg" ) );
else
return QgsApplication::getThemeIcon( QStringLiteral( "/checks/MissingVertex.svg" ) );
}
Expand Up @@ -66,6 +66,8 @@ class ANALYSIS_EXPORT QgsGeometryMissingVertexCheckError : public QgsGeometryChe
*/
void setInvolvedFeatures( const QMap<QString, QgsFeatureIds> &involvedFeatures );

QIcon icon() const override;

private:
QgsRectangle mAffectedAreaBBox;
QMap<QString, QgsFeatureIds> mInvolvedFeatures;
Expand Down
10 changes: 10 additions & 0 deletions src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.cpp
Expand Up @@ -19,6 +19,7 @@
#include "qgsfeaturepool.h"
#include "qgsvectorlayer.h"
#include "qgsfeedback.h"
#include "qgsapplication.h"

QgsGeometryOverlapCheck::QgsGeometryOverlapCheck( const QgsGeometryCheckContext *context, const QVariantMap &configuration )
: QgsGeometryCheck( context, configuration )
Expand Down Expand Up @@ -310,3 +311,12 @@ QMap<QString, QgsFeatureIds> QgsGeometryOverlapCheckError::involvedFeatures() co
features[mOverlappedFeature.layerId()].insert( mOverlappedFeature.featureId() );
return features;
}

QIcon QgsGeometryOverlapCheckError::icon() const
{

if ( status() == QgsGeometryCheckError::StatusFixed )
return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCheckGeometry.svg" ) );
else
return QgsApplication::getThemeIcon( QStringLiteral( "/checks/Overlap.svg" ) );
}
Expand Up @@ -63,6 +63,7 @@ class ANALYSIS_EXPORT QgsGeometryOverlapCheckError : public QgsGeometryCheckErro
QString description() const override;

QMap<QString, QgsFeatureIds > involvedFeatures() const override;
QIcon icon() const override;

private:
OverlappedFeature mOverlappedFeature;
Expand Down
13 changes: 2 additions & 11 deletions src/app/qgsgeometryvalidationmodel.cpp
Expand Up @@ -70,10 +70,7 @@ QVariant QgsGeometryValidationModel::data( const QModelIndex &index, int role )
switch ( role )
{
case Qt::DecorationRole:
if ( topologyError->status() == QgsGeometryCheckError::StatusFixed )
return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCheckGeometry.svg" ) );
else
return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmLineIntersections.svg" ) );
return topologyError->icon();

case Qt::DisplayRole:
case DetailsRole:
Expand Down Expand Up @@ -164,13 +161,7 @@ QVariant QgsGeometryValidationModel::data( const QModelIndex &index, int role )

case Qt::DecorationRole:
{
#if 0
if ( mGeometryValidationService->validationActive( mCurrentLayer, featureItem.fid ) )
return QgsApplication::getThemeIcon( "/mActionTracing.svg" );
else
return QVariant();
#endif
break;
return QgsApplication::getThemeIcon( "/checks/InvalidGeometry.svg" );
}

case GeometryCheckErrorRole:
Expand Down

0 comments on commit d97f5d4

Please sign in to comment.