Skip to content
Permalink
Browse files

More UX

  • Loading branch information
m-kuhn committed Sep 30, 2018
1 parent d8c4473 commit cf0b3e9e7d2560621e15aff15acd9225fbd82e78
@@ -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 ) );

}
}

@@ -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 ) );
}


@@ -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 )
{
@@ -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 ) ) );
}
}
@@ -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;
@@ -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:
@@ -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:

0 comments on commit cf0b3e9

Please sign in to comment.
You can’t perform that action at this time.