Skip to content
Permalink
Browse files

Merge pull request #2709 from manisandro/geom_checker_fixes

Geom snapper fixes
  • Loading branch information
manisandro committed Jan 21, 2016
2 parents c7231c3 + b00950b commit 5dca1042f4fd030ecf723dee460075dbc4a54d99
@@ -49,11 +49,13 @@ QgsGeometrySnapper::QgsGeometrySnapper( QgsVectorLayer *adjustLayer, QgsVectorLa

QFuture<void> QgsGeometrySnapper::processFeatures()
{
emit progressRangeChanged( 0, mFeatures.size() );
return QtConcurrent::map( mFeatures, ProcessFeatureWrapper( this ) );
}

void QgsGeometrySnapper::processFeature( QgsFeatureId id )
{
emit progressStep();
// Get current feature
QgsFeature feature;
if ( !getFeature( mAdjustLayer, mAdjustLayerMutex, id, feature ) )
@@ -35,6 +35,10 @@ class QgsGeometrySnapper : public QObject
QFuture<void> processFeatures();
const QStringList& getErrors() const { return mErrors; }

signals:
void progressRangeChanged( int min, int max );
void progressStep();

private:
struct ProcessFeatureWrapper
{
@@ -280,8 +280,6 @@ void QgsGeometrySnapperDialog::run()
/** Run **/
QEventLoop evLoop;
QFutureWatcher<void> futureWatcher;
connect( &futureWatcher, SIGNAL( progressRangeChanged( int, int ) ), progressBar, SLOT( setRange( int, int ) ) );
connect( &futureWatcher, SIGNAL( progressValueChanged( int ) ), progressBar, SLOT( setValue( int ) ) );
connect( &futureWatcher, SIGNAL( finished() ), &evLoop, SLOT( quit() ) );
connect( buttonBox->button( QDialogButtonBox::Abort ), SIGNAL( clicked() ), &futureWatcher, SLOT( cancel() ) );

@@ -294,6 +292,8 @@ void QgsGeometrySnapperDialog::run()
widgetInputs->setEnabled( false );

QgsGeometrySnapper snapper( layer, referenceLayer, selectedOnly, doubleSpinBoxMaxDistance->value(), &mIface->mapCanvas()->mapSettings() );
connect( &snapper, SIGNAL( progressRangeChanged( int, int ) ), progressBar, SLOT( setRange( int, int ) ) );
connect( &snapper, SIGNAL( progressStep() ), this, SLOT( progressStep() ) );
futureWatcher.setFuture( snapper.processFeatures() );
evLoop.exec();

@@ -317,3 +317,8 @@ void QgsGeometrySnapperDialog::run()
hide() ;
}

void QgsGeometrySnapperDialog::progressStep()
{
progressBar->setValue( progressBar->value() + 1 );
}

@@ -46,6 +46,7 @@ class QgsGeometrySnapperDialog: public QDialog, private Ui::QgsGeometrySnapperDi
void updateLayers();
void validateInput();
void selectOutputFile();
void progressStep();
};

#endif // QGS_GEOMETRY_SNAPPER_DIALOG_H
@@ -309,7 +309,7 @@ void QgsSnapIndex::addGeometry( const QgsAbstractGeometryV2* geom )
{
for ( int iPart = 0, nParts = geom->partCount(); iPart < nParts; ++iPart )
{
for ( int iRing = 0, nRings = geom->ringCount( iRing ); iRing < nRings; ++iRing )
for ( int iRing = 0, nRings = geom->ringCount( iPart ); iRing < nRings; ++iRing )
{
for ( int iVert = 0, nVerts = geom->vertexCount( iPart, iRing ) - 1; iVert < nVerts; ++iVert )
{

0 comments on commit 5dca104

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