Skip to content

Commit

Permalink
#8725-R: minor changes and UI update
Browse files Browse the repository at this point in the history
+ add comment about 'prepareSimplification' in constructor
+ fix comment in 'providerCanSimplify'
+ improve UI messages
  • Loading branch information
ahuarte47 authored and m-kuhn committed Jan 15, 2014
1 parent 7cb8ff7 commit 22c0c79
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 406 deletions.
15 changes: 3 additions & 12 deletions src/app/qgsoptions.cpp
Expand Up @@ -563,10 +563,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :

// Default simplify drawing configuration
mSimplifyDrawingGroupBox->setChecked( settings.value( "/qgis/simplifyDrawingHints", ( int )QgsVectorLayer::GeometrySimplification ).toInt() != QgsVectorLayer::NoSimplification );
mSimplifyDrawingSlider->setValue(( int )( 5.0f * ( settings.value( "/qgis/simplifyDrawingTol", QGis::DEFAULT_MAPTOPIXEL_THRESHOLD ).toFloat() - 1 ) ) );
mSimplifyDrawingSpinBox->setValue( settings.value( "/qgis/simplifyDrawingTol", QGis::DEFAULT_MAPTOPIXEL_THRESHOLD ).toFloat() );
mSimplifyDrawingAtProvider->setChecked( !settings.value( "/qgis/simplifyLocal", true ).toBool() );
mSimplifyDrawingPanel->setVisible( mSimplifyDrawingSlider->value() > 0 );
mSimplifyDrawingPx->setText( QString( "(%1 px)" ).arg( 1.0f + 0.2f * mSimplifyDrawingSlider->value() ) );

// Slightly awkard here at the settings value is true to use QImage,
// but the checkbox is true to use QPixmap
Expand Down Expand Up @@ -1104,10 +1102,10 @@ void QgsOptions::saveOptions()
if ( mSimplifyDrawingGroupBox->isChecked() )
{
simplifyHints |= QgsVectorLayer::GeometrySimplification;
if ( mSimplifyDrawingSlider->value() > 0 ) simplifyHints |= QgsVectorLayer::AntialiasingSimplification;
if ( mSimplifyDrawingSpinBox->value() > 1 ) simplifyHints |= QgsVectorLayer::AntialiasingSimplification;
}
settings.setValue( "/qgis/simplifyDrawingHints", simplifyHints );
settings.setValue( "/qgis/simplifyDrawingTol", 1.0f + 0.2f*mSimplifyDrawingSlider->value() );
settings.setValue( "/qgis/simplifyDrawingTol", mSimplifyDrawingSpinBox->value() );
settings.setValue( "/qgis/simplifyLocal", !mSimplifyDrawingAtProvider->isChecked() );

// project
Expand Down Expand Up @@ -2087,10 +2085,3 @@ void QgsOptions::saveDefaultDatumTransformations()

s.endGroup();
}

void QgsOptions::on_mSimplifyDrawingSlider_valueChanged( int value )
{
mSimplifyDrawingPanel->setVisible( value > 0 );
mSimplifyDrawingPx->setText( QString( "(%1 px)" ).arg( 1.0f + 0.2f * value ) );
}

2 changes: 0 additions & 2 deletions src/app/qgsoptions.h
Expand Up @@ -240,8 +240,6 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
void on_mRemoveDefaultTransformButton_clicked();
void on_mAddDefaultTransformButton_clicked();

void on_mSimplifyDrawingSlider_valueChanged( int value );

private:
QStringList i18nList();
void initContrastEnhancement( QComboBox *cbox, QString name, QString defaultVal );
Expand Down
14 changes: 3 additions & 11 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -395,9 +395,7 @@ void QgsVectorLayerProperties::syncToLayer( void )
// get simplify drawing configuration
const QgsVectorSimplifyMethod& simplifyMethod = layer->simplifyMethod();
mSimplifyDrawingGroupBox->setChecked( simplifyMethod.simplifyHints() != QgsVectorLayer::NoSimplification );
mSimplifyDrawingSlider->setValue(( int )( 5.0f * ( simplifyMethod.threshold() - 1 ) ) );
mSimplifyDrawingPanel->setVisible( mSimplifyDrawingSlider->value() > 0 );
mSimplifyDrawingPx->setText( QString( "(%1 px)" ).arg( 1.0f + 0.2f * mSimplifyDrawingSlider->value() ) );
mSimplifyDrawingSpinBox->setValue( simplifyMethod.threshold() );

if ( !( layer->dataProvider()->capabilities() & QgsVectorDataProvider::SimplifyGeometries ) )
{
Expand Down Expand Up @@ -553,11 +551,11 @@ void QgsVectorLayerProperties::apply()
if ( mSimplifyDrawingGroupBox->isChecked() )
{
simplifyHints |= QgsVectorLayer::GeometrySimplification;
if ( mSimplifyDrawingSlider->value() > 0 ) simplifyHints |= QgsVectorLayer::AntialiasingSimplification;
if ( mSimplifyDrawingSpinBox->value() > 1 ) simplifyHints |= QgsVectorLayer::AntialiasingSimplification;
}
QgsVectorSimplifyMethod simplifyMethod = layer->simplifyMethod();
simplifyMethod.setSimplifyHints( simplifyHints );
simplifyMethod.setThreshold( 1.0f + 0.2f*mSimplifyDrawingSlider->value() );
simplifyMethod.setThreshold( mSimplifyDrawingSpinBox->value() );
simplifyMethod.setForceLocalOptimization( !mSimplifyDrawingAtProvider->isChecked() );
layer->setSimplifyMethod( simplifyMethod );

Expand Down Expand Up @@ -1100,12 +1098,6 @@ void QgsVectorLayerProperties::on_mMaximumScaleSetCurrentPushButton_clicked()
cbMaximumScale->setScale( 1.0 / QgisApp::instance()->mapCanvas()->mapRenderer()->scale() );
}

void QgsVectorLayerProperties::on_mSimplifyDrawingSlider_valueChanged( int value )
{
mSimplifyDrawingPanel->setVisible( value > 0 );
mSimplifyDrawingPx->setText( QString( "(%1 px)" ).arg( 1.0f + 0.2f * value ) );
}

void QgsVectorLayerProperties::on_mSimplifyDrawingGroupBox_toggled( bool checked )
{
if ( !( layer->dataProvider()->capabilities() & QgsVectorDataProvider::SimplifyGeometries ) )
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsvectorlayerproperties.h
Expand Up @@ -119,7 +119,6 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private
void on_mMinimumScaleSetCurrentPushButton_clicked();
void on_mMaximumScaleSetCurrentPushButton_clicked();

void on_mSimplifyDrawingSlider_valueChanged( int value );
void on_mSimplifyDrawingGroupBox_toggled( bool checked );

signals:
Expand Down
6 changes: 5 additions & 1 deletion src/core/qgsfeatureiterator.cpp
Expand Up @@ -83,7 +83,11 @@ bool QgsAbstractFeatureIterator::nextFeatureFilterFids( QgsFeature& f )

void QgsAbstractFeatureIterator::ref()
{
// prepare if required the simplification of geometries to fetch
// Prepare if required the simplification of geometries to fetch:
// This code runs here because of 'prepareSimplification()' is virtual and it can be overrided
// in inherited iterators who change the default behavior.
// It would be better to call this method in the constructor enabling virtual-calls as it is described by example at:
// http://www.parashift.com/c%2B%2B-faq-lite/calling-virtuals-from-ctor-idiom.html
if ( refs == 0 )
{
prepareSimplification( mRequest.simplifyMethod() );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsfeatureiterator.h
Expand Up @@ -96,7 +96,7 @@ class CORE_EXPORT QgsAbstractFeatureIterator
//! this iterator runs local simplification
bool mLocalSimplification;

//! returns whether the iterator can simplify on provider side the geometries to fetch using the specified method type
//! returns whether the iterator supports simplify geometries on provider side
virtual bool providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const;

//! simplify the specified geometry if it was configured
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayerfeatureiterator.h
Expand Up @@ -122,7 +122,7 @@ class CORE_EXPORT QgsVectorLayerFeatureIterator : public QgsAbstractFeatureItera
//! optional object to locally simplify edited (changed or added) geometries fetched by this feature iterator
QgsAbstractGeometrySimplifier* mEditGeometrySimplifier;

//! returns whether the iterator can simplify on provider side the geometries to fetch using the specified method type
//! returns whether the iterator supports simplify geometries on provider side
virtual bool providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const;
};

Expand Down
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrfeatureiterator.h
Expand Up @@ -65,7 +65,7 @@ class QgsOgrFeatureIterator : public QgsAbstractFeatureIterator
//! optional object to simplify OGR-geometries fecthed by this feature iterator
QgsOgrAbstractGeometrySimplifier* mGeometrySimplifier;

//! returns whether the iterator can simplify on provider side the geometries to fetch using the specified method type
//! returns whether the iterator supports simplify geometries on provider side
virtual bool providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const;
};

Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresfeatureiterator.h
Expand Up @@ -70,7 +70,7 @@ class QgsPostgresFeatureIterator : public QgsAbstractFeatureIterator
static const int sFeatureQueueSize;

private:
//! returns whether the iterator can simplify on provider side the geometries to fetch using the specified method type
//! returns whether the iterator supports simplify geometries on provider side
virtual bool providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const;
};

Expand Down

0 comments on commit 22c0c79

Please sign in to comment.