mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-08 00:05:09 -04:00
Comments and API improvements of simplification (no functional changes)
- moved QgsVectorLayer::SimplifyHint enum to QgsVectorSimplifyMethod - use QFlags instead of int for hints - added few notes about simplification being added in 2.2
This commit is contained in:
parent
10f2ac92ac
commit
da1ebc2693
@ -65,7 +65,10 @@ class QgsFeatureRequest
|
|||||||
QgsFeatureRequest& setSubsetOfAttributes( const QStringList& attrNames, const QgsFields& fields );
|
QgsFeatureRequest& setSubsetOfAttributes( const QStringList& attrNames, const QgsFields& fields );
|
||||||
|
|
||||||
//! Set a simplification method for geometries that will be fetched
|
//! Set a simplification method for geometries that will be fetched
|
||||||
|
//! @note added in 2.2
|
||||||
QgsFeatureRequest& setSimplifyMethod( const QgsSimplifyMethod& simplifyMethod );
|
QgsFeatureRequest& setSimplifyMethod( const QgsSimplifyMethod& simplifyMethod );
|
||||||
|
//! Get simplification method for geometries that will be fetched
|
||||||
|
//! @note added in 2.2
|
||||||
const QgsSimplifyMethod& simplifyMethod() const;
|
const QgsSimplifyMethod& simplifyMethod() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
/** This class contains information about how to simplify geometries fetched from a QgsFeatureIterator */
|
/** This class contains information about how to simplify geometries fetched from a QgsFeatureIterator
|
||||||
|
* @note added in 2.2
|
||||||
|
*/
|
||||||
class QgsSimplifyMethod
|
class QgsSimplifyMethod
|
||||||
{
|
{
|
||||||
%TypeHeaderCode
|
%TypeHeaderCode
|
||||||
|
@ -1025,21 +1025,20 @@ class QgsVectorLayer : QgsMapLayer
|
|||||||
/** @note not available in python bindings */
|
/** @note not available in python bindings */
|
||||||
// inline QgsGeometryCache* cache();
|
// inline QgsGeometryCache* cache();
|
||||||
|
|
||||||
/** Simplification flags for fast rendering of features */
|
/** Set the simplification settings for fast rendering of features
|
||||||
enum SimplifyHint
|
* @note added in 2.2
|
||||||
{
|
*/
|
||||||
NoSimplification = 0, //!< No simplification can be applied
|
|
||||||
GeometrySimplification = 1, //!< The geometries can be simplified using the current map2pixel context state
|
|
||||||
AntialiasingSimplification = 2, //!< The geometries can be rendered with 'AntiAliasing' disabled because of it is '1-pixel size'
|
|
||||||
FullSimplification = 3, //!< All simplification hints can be applied ( Geometry + AA-disabling )
|
|
||||||
};
|
|
||||||
/** Set the simplification settings for fast rendering of features */
|
|
||||||
void setSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod );
|
void setSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod );
|
||||||
/** Returns the simplification settings for fast rendering of features */
|
/** Returns the simplification settings for fast rendering of features
|
||||||
|
* @note added in 2.2
|
||||||
|
*/
|
||||||
const QgsVectorSimplifyMethod& simplifyMethod() const;
|
const QgsVectorSimplifyMethod& simplifyMethod() const;
|
||||||
|
|
||||||
/** Returns whether the VectorLayer can apply the specified simplification hint */
|
/** Returns whether the VectorLayer can apply the specified simplification hint
|
||||||
bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, int simplifyHint ) const;
|
* @note Do not use in 3rd party code - may be removed in future version!
|
||||||
|
* @note added in 2.2
|
||||||
|
*/
|
||||||
|
bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
/** This class contains information how to simplify geometries fetched from a vector layer */
|
/** This class contains information how to simplify geometries fetched from a vector layer
|
||||||
|
* @note added in 2.2
|
||||||
|
*/
|
||||||
class QgsVectorSimplifyMethod
|
class QgsVectorSimplifyMethod
|
||||||
{
|
{
|
||||||
%TypeHeaderCode
|
%TypeHeaderCode
|
||||||
@ -12,10 +14,20 @@ class QgsVectorSimplifyMethod
|
|||||||
//! copy constructor
|
//! copy constructor
|
||||||
QgsVectorSimplifyMethod( const QgsVectorSimplifyMethod& rh );
|
QgsVectorSimplifyMethod( const QgsVectorSimplifyMethod& rh );
|
||||||
|
|
||||||
|
/** Simplification flags for fast rendering of features */
|
||||||
|
enum SimplifyHint
|
||||||
|
{
|
||||||
|
NoSimplification = 0, //!< No simplification can be applied
|
||||||
|
GeometrySimplification = 1, //!< The geometries can be simplified using the current map2pixel context state
|
||||||
|
AntialiasingSimplification = 2, //!< The geometries can be rendered with 'AntiAliasing' disabled because of it is '1-pixel size'
|
||||||
|
FullSimplification = 3, //!< All simplification hints can be applied ( Geometry + AA-disabling )
|
||||||
|
};
|
||||||
|
typedef QFlags<QgsVectorSimplifyMethod::SimplifyHint> SimplifyHints;
|
||||||
|
|
||||||
/** Sets the simplification hints of the vector layer managed */
|
/** Sets the simplification hints of the vector layer managed */
|
||||||
void setSimplifyHints( int simplifyHints );
|
void setSimplifyHints( QFlags<QgsVectorSimplifyMethod::SimplifyHint> simplifyHints );
|
||||||
/** Gets the simplification hints of the vector layer managed */
|
/** Gets the simplification hints of the vector layer managed */
|
||||||
int simplifyHints() const;
|
QFlags<QgsVectorSimplifyMethod::SimplifyHint> simplifyHints() const;
|
||||||
|
|
||||||
/** Sets the simplification threshold of the vector layer managed */
|
/** Sets the simplification threshold of the vector layer managed */
|
||||||
void setThreshold( float threshold );
|
void setThreshold( float threshold );
|
||||||
@ -32,3 +44,5 @@ class QgsVectorSimplifyMethod
|
|||||||
/** Gets the maximum scale at which the layer should be simplified */
|
/** Gets the maximum scale at which the layer should be simplified */
|
||||||
float maximumScale() const;
|
float maximumScale() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QFlags<QgsVectorSimplifyMethod::SimplifyHint> operator|( QgsVectorSimplifyMethod::SimplifyHint f1, QFlags<QgsVectorSimplifyMethod::SimplifyHint> f2 );
|
||||||
|
@ -569,7 +569,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
|
|||||||
chkUseRenderCaching->setChecked( settings.value( "/qgis/enable_render_caching", false ).toBool() );
|
chkUseRenderCaching->setChecked( settings.value( "/qgis/enable_render_caching", false ).toBool() );
|
||||||
|
|
||||||
// Default simplify drawing configuration
|
// Default simplify drawing configuration
|
||||||
mSimplifyDrawingGroupBox->setChecked( settings.value( "/qgis/simplifyDrawingHints", ( int )QgsVectorLayer::GeometrySimplification ).toInt() != QgsVectorLayer::NoSimplification );
|
mSimplifyDrawingGroupBox->setChecked( settings.value( "/qgis/simplifyDrawingHints", ( int )QgsVectorSimplifyMethod::GeometrySimplification ).toInt() != QgsVectorSimplifyMethod::NoSimplification );
|
||||||
mSimplifyDrawingSpinBox->setValue( settings.value( "/qgis/simplifyDrawingTol", QGis::DEFAULT_MAPTOPIXEL_THRESHOLD ).toFloat() );
|
mSimplifyDrawingSpinBox->setValue( settings.value( "/qgis/simplifyDrawingTol", QGis::DEFAULT_MAPTOPIXEL_THRESHOLD ).toFloat() );
|
||||||
mSimplifyDrawingAtProvider->setChecked( !settings.value( "/qgis/simplifyLocal", true ).toBool() );
|
mSimplifyDrawingAtProvider->setChecked( !settings.value( "/qgis/simplifyLocal", true ).toBool() );
|
||||||
|
|
||||||
@ -1110,13 +1110,13 @@ void QgsOptions::saveOptions()
|
|||||||
settings.setValue( "/qgis/capitaliseLayerName", capitaliseCheckBox->isChecked() );
|
settings.setValue( "/qgis/capitaliseLayerName", capitaliseCheckBox->isChecked() );
|
||||||
|
|
||||||
// Default simplify drawing configuration
|
// Default simplify drawing configuration
|
||||||
int simplifyHints = QgsVectorLayer::NoSimplification;
|
QgsVectorSimplifyMethod::SimplifyHints simplifyHints = QgsVectorSimplifyMethod::NoSimplification;
|
||||||
if ( mSimplifyDrawingGroupBox->isChecked() )
|
if ( mSimplifyDrawingGroupBox->isChecked() )
|
||||||
{
|
{
|
||||||
simplifyHints |= QgsVectorLayer::GeometrySimplification;
|
simplifyHints |= QgsVectorSimplifyMethod::GeometrySimplification;
|
||||||
if ( mSimplifyDrawingSpinBox->value() > 1 ) simplifyHints |= QgsVectorLayer::AntialiasingSimplification;
|
if ( mSimplifyDrawingSpinBox->value() > 1 ) simplifyHints |= QgsVectorSimplifyMethod::AntialiasingSimplification;
|
||||||
}
|
}
|
||||||
settings.setValue( "/qgis/simplifyDrawingHints", simplifyHints );
|
settings.setValue( "/qgis/simplifyDrawingHints", ( int ) simplifyHints );
|
||||||
settings.setValue( "/qgis/simplifyDrawingTol", mSimplifyDrawingSpinBox->value() );
|
settings.setValue( "/qgis/simplifyDrawingTol", mSimplifyDrawingSpinBox->value() );
|
||||||
settings.setValue( "/qgis/simplifyLocal", !mSimplifyDrawingAtProvider->isChecked() );
|
settings.setValue( "/qgis/simplifyLocal", !mSimplifyDrawingAtProvider->isChecked() );
|
||||||
settings.setValue( "/qgis/simplifyMaxScale", 1.0 / mSimplifyMaximumScaleComboBox->scale() );
|
settings.setValue( "/qgis/simplifyMaxScale", 1.0 / mSimplifyMaximumScaleComboBox->scale() );
|
||||||
|
@ -393,7 +393,7 @@ void QgsVectorLayerProperties::syncToLayer( void )
|
|||||||
|
|
||||||
// get simplify drawing configuration
|
// get simplify drawing configuration
|
||||||
const QgsVectorSimplifyMethod& simplifyMethod = layer->simplifyMethod();
|
const QgsVectorSimplifyMethod& simplifyMethod = layer->simplifyMethod();
|
||||||
mSimplifyDrawingGroupBox->setChecked( simplifyMethod.simplifyHints() != QgsVectorLayer::NoSimplification );
|
mSimplifyDrawingGroupBox->setChecked( simplifyMethod.simplifyHints() != QgsVectorSimplifyMethod::NoSimplification );
|
||||||
mSimplifyDrawingSpinBox->setValue( simplifyMethod.threshold() );
|
mSimplifyDrawingSpinBox->setValue( simplifyMethod.threshold() );
|
||||||
|
|
||||||
if ( !( layer->dataProvider()->capabilities() & QgsVectorDataProvider::SimplifyGeometries ) )
|
if ( !( layer->dataProvider()->capabilities() & QgsVectorDataProvider::SimplifyGeometries ) )
|
||||||
@ -558,11 +558,11 @@ void QgsVectorLayerProperties::apply()
|
|||||||
layer->setMetadataUrlFormat( mLayerMetadataUrlFormatComboBox->currentText() );
|
layer->setMetadataUrlFormat( mLayerMetadataUrlFormatComboBox->currentText() );
|
||||||
|
|
||||||
//layer simplify drawing configuration
|
//layer simplify drawing configuration
|
||||||
int simplifyHints = QgsVectorLayer::NoSimplification;
|
QgsVectorSimplifyMethod::SimplifyHints simplifyHints = QgsVectorSimplifyMethod::NoSimplification;
|
||||||
if ( mSimplifyDrawingGroupBox->isChecked() )
|
if ( mSimplifyDrawingGroupBox->isChecked() )
|
||||||
{
|
{
|
||||||
simplifyHints |= QgsVectorLayer::GeometrySimplification;
|
simplifyHints |= QgsVectorSimplifyMethod::GeometrySimplification;
|
||||||
if ( mSimplifyDrawingSpinBox->value() > 1 ) simplifyHints |= QgsVectorLayer::AntialiasingSimplification;
|
if ( mSimplifyDrawingSpinBox->value() > 1 ) simplifyHints |= QgsVectorSimplifyMethod::AntialiasingSimplification;
|
||||||
}
|
}
|
||||||
QgsVectorSimplifyMethod simplifyMethod = layer->simplifyMethod();
|
QgsVectorSimplifyMethod simplifyMethod = layer->simplifyMethod();
|
||||||
simplifyMethod.setSimplifyHints( simplifyHints );
|
simplifyMethod.setSimplifyHints( simplifyHints );
|
||||||
|
@ -123,7 +123,10 @@ class CORE_EXPORT QgsFeatureRequest
|
|||||||
QgsFeatureRequest& setSubsetOfAttributes( const QStringList& attrNames, const QgsFields& fields );
|
QgsFeatureRequest& setSubsetOfAttributes( const QStringList& attrNames, const QgsFields& fields );
|
||||||
|
|
||||||
//! Set a simplification method for geometries that will be fetched
|
//! Set a simplification method for geometries that will be fetched
|
||||||
|
//! @note added in 2.2
|
||||||
QgsFeatureRequest& setSimplifyMethod( const QgsSimplifyMethod& simplifyMethod );
|
QgsFeatureRequest& setSimplifyMethod( const QgsSimplifyMethod& simplifyMethod );
|
||||||
|
//! Get simplification method for geometries that will be fetched
|
||||||
|
//! @note added in 2.2
|
||||||
const QgsSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
|
const QgsSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +20,7 @@ class QgsAbstractGeometrySimplifier;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains information about how to simplify geometries fetched from a QgsFeatureIterator
|
* This class contains information about how to simplify geometries fetched from a QgsFeatureIterator
|
||||||
|
* @note added in 2.2
|
||||||
*/
|
*/
|
||||||
class CORE_EXPORT QgsSimplifyMethod
|
class CORE_EXPORT QgsSimplifyMethod
|
||||||
{
|
{
|
||||||
|
@ -186,7 +186,7 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,
|
|||||||
|
|
||||||
// Default simplify drawing settings
|
// Default simplify drawing settings
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
mSimplifyMethod.setSimplifyHints( settings.value( "/qgis/simplifyDrawingHints", mSimplifyMethod.simplifyHints() ).toInt() );
|
mSimplifyMethod.setSimplifyHints( ( QgsVectorSimplifyMethod::SimplifyHints ) settings.value( "/qgis/simplifyDrawingHints", ( int ) mSimplifyMethod.simplifyHints() ).toInt() );
|
||||||
mSimplifyMethod.setThreshold( settings.value( "/qgis/simplifyDrawingTol", mSimplifyMethod.threshold() ).toFloat() );
|
mSimplifyMethod.setThreshold( settings.value( "/qgis/simplifyDrawingTol", mSimplifyMethod.threshold() ).toFloat() );
|
||||||
mSimplifyMethod.setForceLocalOptimization( settings.value( "/qgis/simplifyLocal", mSimplifyMethod.forceLocalOptimization() ).toBool() );
|
mSimplifyMethod.setForceLocalOptimization( settings.value( "/qgis/simplifyLocal", mSimplifyMethod.forceLocalOptimization() ).toBool() );
|
||||||
mSimplifyMethod.setMaximumScale( settings.value( "/qgis/simplifyMaxScale", mSimplifyMethod.maximumScale() ).toFloat() );
|
mSimplifyMethod.setMaximumScale( settings.value( "/qgis/simplifyMaxScale", mSimplifyMethod.maximumScale() ).toFloat() );
|
||||||
@ -704,7 +704,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
|
|||||||
.setSubsetOfAttributes( attributes );
|
.setSubsetOfAttributes( attributes );
|
||||||
|
|
||||||
// enable the simplification of the geometries (Using the current map2pixel context) before send it to renderer engine.
|
// enable the simplification of the geometries (Using the current map2pixel context) before send it to renderer engine.
|
||||||
if ( simplifyDrawingCanbeApplied( rendererContext, QgsVectorLayer::GeometrySimplification ) )
|
if ( simplifyDrawingCanbeApplied( rendererContext, QgsVectorSimplifyMethod::GeometrySimplification ) )
|
||||||
{
|
{
|
||||||
QPainter* p = rendererContext.painter();
|
QPainter* p = rendererContext.painter();
|
||||||
double dpi = ( p->device()->logicalDpiX() + p->device()->logicalDpiY() ) / 2;
|
double dpi = ( p->device()->logicalDpiX() + p->device()->logicalDpiY() ) / 2;
|
||||||
@ -1290,7 +1290,7 @@ bool QgsVectorLayer::setSubsetString( QString subset )
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QgsVectorLayer::simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, int simplifyHint ) const
|
bool QgsVectorLayer::simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const
|
||||||
{
|
{
|
||||||
if ( mDataProvider && !mEditBuffer && ( hasGeometryType() && geometryType() != QGis::Point ) && ( mSimplifyMethod.simplifyHints() & simplifyHint ) && renderContext.useRenderingOptimization() )
|
if ( mDataProvider && !mEditBuffer && ( hasGeometryType() && geometryType() != QGis::Point ) && ( mSimplifyMethod.simplifyHints() & simplifyHint ) && renderContext.useRenderingOptimization() )
|
||||||
{
|
{
|
||||||
@ -1907,7 +1907,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the simplification drawing settings
|
// get the simplification drawing settings
|
||||||
mSimplifyMethod.setSimplifyHints( e.attribute( "simplifyDrawingHints", "1" ).toInt() );
|
mSimplifyMethod.setSimplifyHints( ( QgsVectorSimplifyMethod::SimplifyHints ) e.attribute( "simplifyDrawingHints", "1" ).toInt() );
|
||||||
mSimplifyMethod.setThreshold( e.attribute( "simplifyDrawingTol", "1" ).toFloat() );
|
mSimplifyMethod.setThreshold( e.attribute( "simplifyDrawingTol", "1" ).toFloat() );
|
||||||
mSimplifyMethod.setForceLocalOptimization( e.attribute( "simplifyLocal", "1" ).toInt() );
|
mSimplifyMethod.setForceLocalOptimization( e.attribute( "simplifyLocal", "1" ).toInt() );
|
||||||
mSimplifyMethod.setMaximumScale( e.attribute( "simplifyMaxScale", "1" ).toFloat() );
|
mSimplifyMethod.setMaximumScale( e.attribute( "simplifyMaxScale", "1" ).toFloat() );
|
||||||
|
@ -1376,21 +1376,20 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
|||||||
/** @note not available in python bindings */
|
/** @note not available in python bindings */
|
||||||
inline QgsGeometryCache* cache() { return mCache; }
|
inline QgsGeometryCache* cache() { return mCache; }
|
||||||
|
|
||||||
/** Simplification flags for fast rendering of features */
|
/** Set the simplification settings for fast rendering of features
|
||||||
enum SimplifyHint
|
* @note added in 2.2
|
||||||
{
|
*/
|
||||||
NoSimplification = 0, //!< No simplification can be applied
|
|
||||||
GeometrySimplification = 1, //!< The geometries can be simplified using the current map2pixel context state
|
|
||||||
AntialiasingSimplification = 2, //!< The geometries can be rendered with 'AntiAliasing' disabled because of it is '1-pixel size'
|
|
||||||
FullSimplification = 3, //!< All simplification hints can be applied ( Geometry + AA-disabling )
|
|
||||||
};
|
|
||||||
/** Set the simplification settings for fast rendering of features */
|
|
||||||
void setSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
|
void setSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
|
||||||
/** Returns the simplification settings for fast rendering of features */
|
/** Returns the simplification settings for fast rendering of features
|
||||||
|
* @note added in 2.2
|
||||||
|
*/
|
||||||
inline const QgsVectorSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
|
inline const QgsVectorSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
|
||||||
|
|
||||||
/** Returns whether the VectorLayer can apply the specified simplification hint */
|
/** Returns whether the VectorLayer can apply the specified simplification hint
|
||||||
bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, int simplifyHint ) const;
|
* @note Do not use in 3rd party code - may be removed in future version!
|
||||||
|
* @note added in 2.2
|
||||||
|
*/
|
||||||
|
bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "qgsvectorlayer.h"
|
#include "qgsvectorlayer.h"
|
||||||
|
|
||||||
QgsVectorSimplifyMethod::QgsVectorSimplifyMethod()
|
QgsVectorSimplifyMethod::QgsVectorSimplifyMethod()
|
||||||
: mSimplifyHints( QGis::DEFAULT_MAPTOPIXEL_THRESHOLD > 1 ? QgsVectorLayer::FullSimplification : QgsVectorLayer::GeometrySimplification )
|
: mSimplifyHints( QGis::DEFAULT_MAPTOPIXEL_THRESHOLD > 1 ? QgsVectorSimplifyMethod::FullSimplification : QgsVectorSimplifyMethod::GeometrySimplification )
|
||||||
, mThreshold( QGis::DEFAULT_MAPTOPIXEL_THRESHOLD )
|
, mThreshold( QGis::DEFAULT_MAPTOPIXEL_THRESHOLD )
|
||||||
, mLocalOptimization( true )
|
, mLocalOptimization( true )
|
||||||
, mMaximumScale( 1 )
|
, mMaximumScale( 1 )
|
||||||
|
@ -16,7 +16,11 @@
|
|||||||
#ifndef QGSVECTORSIMPLIFYMETHOD_H
|
#ifndef QGSVECTORSIMPLIFYMETHOD_H
|
||||||
#define QGSVECTORSIMPLIFYMETHOD_H
|
#define QGSVECTORSIMPLIFYMETHOD_H
|
||||||
|
|
||||||
/** This class contains information how to simplify geometries fetched from a vector layer */
|
#include <QFlags>
|
||||||
|
|
||||||
|
/** This class contains information how to simplify geometries fetched from a vector layer
|
||||||
|
* @note added in 2.2
|
||||||
|
*/
|
||||||
class CORE_EXPORT QgsVectorSimplifyMethod
|
class CORE_EXPORT QgsVectorSimplifyMethod
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -27,10 +31,20 @@ class CORE_EXPORT QgsVectorSimplifyMethod
|
|||||||
//! assignment operator
|
//! assignment operator
|
||||||
QgsVectorSimplifyMethod& operator=( const QgsVectorSimplifyMethod& rh );
|
QgsVectorSimplifyMethod& operator=( const QgsVectorSimplifyMethod& rh );
|
||||||
|
|
||||||
|
/** Simplification flags for fast rendering of features */
|
||||||
|
enum SimplifyHint
|
||||||
|
{
|
||||||
|
NoSimplification = 0, //!< No simplification can be applied
|
||||||
|
GeometrySimplification = 1, //!< The geometries can be simplified using the current map2pixel context state
|
||||||
|
AntialiasingSimplification = 2, //!< The geometries can be rendered with 'AntiAliasing' disabled because of it is '1-pixel size'
|
||||||
|
FullSimplification = 3, //!< All simplification hints can be applied ( Geometry + AA-disabling )
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS( SimplifyHints, SimplifyHint )
|
||||||
|
|
||||||
/** Sets the simplification hints of the vector layer managed */
|
/** Sets the simplification hints of the vector layer managed */
|
||||||
void setSimplifyHints( int simplifyHints ) { mSimplifyHints = simplifyHints; }
|
void setSimplifyHints( SimplifyHints simplifyHints ) { mSimplifyHints = simplifyHints; }
|
||||||
/** Gets the simplification hints of the vector layer managed */
|
/** Gets the simplification hints of the vector layer managed */
|
||||||
inline int simplifyHints() const { return mSimplifyHints; }
|
inline SimplifyHints simplifyHints() const { return mSimplifyHints; }
|
||||||
|
|
||||||
/** Sets the simplification threshold of the vector layer managed */
|
/** Sets the simplification threshold of the vector layer managed */
|
||||||
void setThreshold( float threshold ) { mThreshold = threshold; }
|
void setThreshold( float threshold ) { mThreshold = threshold; }
|
||||||
@ -49,7 +63,7 @@ class CORE_EXPORT QgsVectorSimplifyMethod
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/** Simplification hints for fast rendering of features of the vector layer managed */
|
/** Simplification hints for fast rendering of features of the vector layer managed */
|
||||||
int mSimplifyHints;
|
SimplifyHints mSimplifyHints;
|
||||||
/** Simplification threshold */
|
/** Simplification threshold */
|
||||||
float mThreshold;
|
float mThreshold;
|
||||||
/** Simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries */
|
/** Simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries */
|
||||||
@ -58,4 +72,6 @@ class CORE_EXPORT QgsVectorSimplifyMethod
|
|||||||
float mMaximumScale;
|
float mMaximumScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsVectorSimplifyMethod::SimplifyHints )
|
||||||
|
|
||||||
#endif // QGSVECTORSIMPLIFYMETHOD_H
|
#endif // QGSVECTORSIMPLIFYMETHOD_H
|
||||||
|
@ -188,7 +188,7 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
|
|||||||
p->setPen( context.selected() ? mSelPen : mPen );
|
p->setPen( context.selected() ? mSelPen : mPen );
|
||||||
|
|
||||||
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #2 points).
|
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #2 points).
|
||||||
if ( points.size() <= 2 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( context.renderContext(), QgsVectorLayer::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
|
if ( points.size() <= 2 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( context.renderContext(), QgsVectorSimplifyMethod::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
|
||||||
{
|
{
|
||||||
p->setRenderHint( QPainter::Antialiasing, false );
|
p->setRenderHint( QPainter::Antialiasing, false );
|
||||||
p->drawPolyline( points );
|
p->drawPolyline( points );
|
||||||
|
@ -388,7 +388,7 @@ void QgsFillSymbolLayerV2::_renderPolygon( QPainter* p, const QPolygonF& points,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #5 points).
|
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #5 points).
|
||||||
if ( points.size() <= 5 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( context.renderContext(), QgsVectorLayer::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
|
if ( points.size() <= 5 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( context.renderContext(), QgsVectorSimplifyMethod::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
|
||||||
{
|
{
|
||||||
p->setRenderHint( QPainter::Antialiasing, false );
|
p->setRenderHint( QPainter::Antialiasing, false );
|
||||||
p->drawRect( points.boundingRect() );
|
p->drawRect( points.boundingRect() );
|
||||||
|
@ -81,7 +81,7 @@ void TestQgsAtlasComposition::initTestCase()
|
|||||||
"ogr" );
|
"ogr" );
|
||||||
|
|
||||||
QgsVectorSimplifyMethod simplifyMethod;
|
QgsVectorSimplifyMethod simplifyMethod;
|
||||||
simplifyMethod.setSimplifyHints( QgsVectorLayer::NoSimplification );
|
simplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
|
||||||
mVectorLayer->setSimplifyMethod( simplifyMethod );
|
mVectorLayer->setSimplifyMethod( simplifyMethod );
|
||||||
|
|
||||||
QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << mVectorLayer );
|
QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << mVectorLayer );
|
||||||
|
@ -89,7 +89,7 @@ void TestQgsBlendModes::initTestCase()
|
|||||||
myPolyFileInfo.completeBaseName(), "ogr" );
|
myPolyFileInfo.completeBaseName(), "ogr" );
|
||||||
|
|
||||||
QgsVectorSimplifyMethod simplifyMethod;
|
QgsVectorSimplifyMethod simplifyMethod;
|
||||||
simplifyMethod.setSimplifyHints( QgsVectorLayer::NoSimplification );
|
simplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
|
||||||
|
|
||||||
mpPolysLayer->setSimplifyMethod( simplifyMethod );
|
mpPolysLayer->setSimplifyMethod( simplifyMethod );
|
||||||
QgsMapLayerRegistry::instance()->addMapLayers(
|
QgsMapLayerRegistry::instance()->addMapLayers(
|
||||||
|
@ -96,7 +96,7 @@ void TestQgsGradients::initTestCase()
|
|||||||
myPolyFileInfo.completeBaseName(), "ogr" );
|
myPolyFileInfo.completeBaseName(), "ogr" );
|
||||||
|
|
||||||
QgsVectorSimplifyMethod simplifyMethod;
|
QgsVectorSimplifyMethod simplifyMethod;
|
||||||
simplifyMethod.setSimplifyHints( QgsVectorLayer::NoSimplification );
|
simplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
|
||||||
mpPolysLayer->setSimplifyMethod( simplifyMethod );
|
mpPolysLayer->setSimplifyMethod( simplifyMethod );
|
||||||
|
|
||||||
// Register the layer with the registry
|
// Register the layer with the registry
|
||||||
@ -250,7 +250,7 @@ void TestQgsGradients::gradientSymbolFromQml()
|
|||||||
mReport += "<h2>Gradient symbol from QML test</h2>\n";
|
mReport += "<h2>Gradient symbol from QML test</h2>\n";
|
||||||
QVERIFY( setQml( "gradient" ) );
|
QVERIFY( setQml( "gradient" ) );
|
||||||
QgsVectorSimplifyMethod simplifyMethod;
|
QgsVectorSimplifyMethod simplifyMethod;
|
||||||
simplifyMethod.setSimplifyHints( QgsVectorLayer::NoSimplification );
|
simplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
|
||||||
mpPolysLayer->setSimplifyMethod( simplifyMethod );
|
mpPolysLayer->setSimplifyMethod( simplifyMethod );
|
||||||
QVERIFY( imageCheck( "gradient_from_qml" ) );
|
QVERIFY( imageCheck( "gradient_from_qml" ) );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user