Skip to content
Permalink
Browse files

#8725-R: minor changes and UI update

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

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

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

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

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

0 comments on commit 22c0c79

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