Skip to content

Commit

Permalink
Merge pull request #9320 from m-kuhn/geometry-validation-icons
Browse files Browse the repository at this point in the history
Geometry validation icons
  • Loading branch information
m-kuhn authored Mar 20, 2019
2 parents 638650a + dbc8135 commit 13a74ae
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,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
Loading
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
Loading
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
Loading
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,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,
Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,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:

/**
Expand Down
10 changes: 10 additions & 0 deletions src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp
Original file line number Diff line number Diff line change
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 @@ -328,3 +329,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
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,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
Original file line number Diff line number Diff line change
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 @@ -289,3 +290,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" ) );
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 @@ -312,3 +313,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" ) );
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,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
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,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 @@ -166,13 +163,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 13a74ae

Please sign in to comment.