Skip to content

Commit

Permalink
More UX
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Oct 15, 2018
1 parent d8c4473 commit cf0b3e9
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 24 deletions.
Expand Up @@ -124,7 +124,6 @@ void QgsGeometryGapCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &
// Add error
double area = gapGeom->area();
errors.append( new QgsGeometryGapCheckError( this, QString(), QgsGeometry( gapGeom.release() ), neighboringIds, area, gapAreaBBox ) );

}
}

Expand Down
57 changes: 39 additions & 18 deletions src/app/qgsgeometryvalidationdock.cpp
Expand Up @@ -42,15 +42,18 @@ QgsGeometryValidationDock::QgsGeometryValidationDock( const QString &title, QgsM
mErrorRubberband = new QgsRubberBand( mMapCanvas );
mErrorLocationRubberband = new QgsRubberBand( mMapCanvas );

double scaleFactor = mMapCanvas->fontMetrics().xHeight() * .2;
double scaleFactor = mMapCanvas->fontMetrics().xHeight() * .4;

mFeatureRubberband->setColor( QColor( 250, 180, 180, 100 ) );
mFeatureRubberband->setWidth( scaleFactor );
mFeatureRubberband->setStrokeColor( QColor( 100, 255, 100, 100 ) );

mErrorRubberband->setColor( QColor( 180, 250, 180, 100 ) );
mErrorRubberband->setWidth( scaleFactor );

mErrorLocationRubberband->setIcon( QgsRubberBand::ICON_X );
mErrorLocationRubberband->setWidth( scaleFactor * 3 );
mErrorLocationRubberband->setColor( QColor( 180, 180, 250, 100 ) );
mErrorLocationRubberband->setWidth( scaleFactor );
mErrorLocationRubberband->setIconSize( scaleFactor * 5 );
mErrorLocationRubberband->setColor( QColor( 50, 255, 50, 255 ) );
}


Expand Down Expand Up @@ -150,20 +153,7 @@ void QgsGeometryValidationDock::onCurrentErrorChanged( const QModelIndex &curren
}
}

QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mMapCanvas->currentLayer() );
if ( vlayer )
{
QgsGeometry featureGeometry = current.data( QgsGeometryValidationModel::FeatureGeometryRole ).value<QgsGeometry>();
QgsGeometry errorGeometry = current.data( QgsGeometryValidationModel::ErrorGeometryRole ).value<QgsGeometry>();
QgsPointXY locationGeometry = current.data( QgsGeometryValidationModel::ErrorLocationGeometryRole ).value<QgsPointXY>();
qDebug() << "feature geom : " << featureGeometry.asWkt();
qDebug() << "error geom : " << errorGeometry.asWkt();
qDebug() << "locationgeom : " << QgsGeometry( new QgsPoint( locationGeometry ) ).asWkt();

mFeatureRubberband->setToGeometry( featureGeometry );
mErrorRubberband->setToGeometry( errorGeometry );
mErrorLocationRubberband->setToGeometry( QgsGeometry( new QgsPoint( locationGeometry ) ) );
}
showHighlight( current );

switch ( mLastZoomToAction )
{
Expand All @@ -176,3 +166,34 @@ void QgsGeometryValidationDock::onCurrentErrorChanged( const QModelIndex &curren
break;
}
}

void QgsGeometryValidationDock::showHighlight( const QModelIndex &current )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mMapCanvas->currentLayer() );
if ( vlayer )
{
QgsGeometry featureGeometry = current.data( QgsGeometryValidationModel::FeatureGeometryRole ).value<QgsGeometry>();
QgsGeometry errorGeometry = current.data( QgsGeometryValidationModel::ErrorGeometryRole ).value<QgsGeometry>();
QgsPointXY locationGeometry = current.data( QgsGeometryValidationModel::ErrorLocationGeometryRole ).value<QgsPointXY>();

mFeatureRubberband->setToGeometry( featureGeometry );


QPropertyAnimation *animation = new QPropertyAnimation( mFeatureRubberband, "fillColor" );
animation->setEasingCurve( QEasingCurve::OutQuad );
connect( animation, &QPropertyAnimation::finished, animation, &QPropertyAnimation::deleteLater );
connect( animation, &QPropertyAnimation::valueChanged, this, [this]
{
mFeatureRubberband->update();
} );

animation->setDuration( 2000 );
animation->setStartValue( QColor( 100, 255, 100, 255 ) );
animation->setEndValue( QColor( 100, 255, 100, 0 ) );

animation->start();

// mErrorRubberband->setToGeometry( errorGeometry );
mErrorLocationRubberband->setToGeometry( QgsGeometry( new QgsPoint( locationGeometry ) ) );
}
}
4 changes: 4 additions & 0 deletions src/app/qgsgeometryvalidationdock.h
Expand Up @@ -50,11 +50,15 @@ class QgsGeometryValidationDock : public QgsDockWidget, public Ui_QgsGeometryVal
void updateLayerTransform();

private:

enum ZoomToAction
{
ZoomToFeature,
ZoomToProblem
};

void showHighlight( const QModelIndex &current );

ZoomToAction mLastZoomToAction = ZoomToFeature;
QgsGeometryValidationModel *mGeometryValidationModel = nullptr;
QgsGeometryValidationService *mGeometryValidationService = nullptr;
Expand Down
17 changes: 12 additions & 5 deletions src/app/qgsgeometryvalidationmodel.cpp
Expand Up @@ -56,11 +56,17 @@ QVariant QgsGeometryValidationModel::data( const QModelIndex &index, int role )
const QgsFeatureId fid = topologyError->featureId();
const QgsFeature feature = mCurrentLayer->getFeature( fid ); // TODO: this should be cached!
mExpressionContext.setFeature( feature );
QString featureTitle = mDisplayExpression.evaluate( &mExpressionContext ).toString();
if ( featureTitle.isEmpty() )
featureTitle = fid;
const QVariant featureTitle = mDisplayExpression.evaluate( &mExpressionContext );

if ( featureTitle.isNull() )
{
return topologyError->description();
}
else
{
return tr( "%1: %2" ).arg( featureTitle.toString(), topologyError->description() );
}

return tr( "%1: %2" ).arg( featureTitle, topologyError->description() );
}

case FeatureExtentRole:
Expand All @@ -77,7 +83,8 @@ QVariant QgsGeometryValidationModel::data( const QModelIndex &index, int role )

case ErrorGeometryRole:
{
return topologyError->geometry();
// TODO: save as QgsGeometry already in the error
return QgsGeometry( topologyError->geometry()->clone() );
}

case FeatureGeometryRole:
Expand Down

0 comments on commit cf0b3e9

Please sign in to comment.