2017-01-18 22:47:55 +10:00
|
|
|
class QgsPropertyTransformer
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsproperty.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
%ConvertToSubClassCode
|
2017-01-19 18:54:16 +10:00
|
|
|
if (sipCpp->transformerType() == QgsPropertyTransformer::SizeScaleTransformer)
|
2017-01-18 22:47:55 +10:00
|
|
|
sipType = sipType_QgsSizeScaleTransformer;
|
2017-01-19 18:54:16 +10:00
|
|
|
else if (sipCpp->transformerType() == QgsPropertyTransformer::ColorRampTransformer)
|
2017-01-18 22:47:55 +10:00
|
|
|
sipType = sipType_QgsColorRampTransformer;
|
|
|
|
else
|
|
|
|
sipType = sipType_QgsPropertyTransformer;
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! Transformer types
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
SizeScaleTransformer, /*!< Size scaling transformer (QgsSizeScaleTransformer) */
|
|
|
|
ColorRampTransformer, /*!< Color ramp transformer (QgsColorRampTransformer) */
|
|
|
|
};
|
|
|
|
|
|
|
|
static QgsPropertyTransformer* create( Type type ) /Factory/;
|
|
|
|
|
|
|
|
QgsPropertyTransformer( double minValue = 0.0, double maxValue = 1.0 );
|
|
|
|
|
|
|
|
virtual ~QgsPropertyTransformer();
|
|
|
|
|
|
|
|
virtual Type transformerType() const = 0;
|
|
|
|
|
|
|
|
virtual QgsPropertyTransformer* clone() = 0 /Factory/;
|
|
|
|
|
|
|
|
virtual bool readXml( const QDomElement& transformerElem, const QDomDocument& doc );
|
|
|
|
|
|
|
|
virtual bool writeXml( QDomElement& transformerElem, QDomDocument& doc ) const;
|
|
|
|
|
|
|
|
double minValue() const;
|
|
|
|
|
|
|
|
void setMinValue( double min );
|
|
|
|
|
|
|
|
double maxValue() const;
|
|
|
|
|
|
|
|
void setMaxValue( double max );
|
|
|
|
|
|
|
|
virtual QVariant transform( const QgsExpressionContext& context, const QVariant& value ) const = 0;
|
2017-02-05 20:19:12 +10:00
|
|
|
virtual QString toExpression( const QString& baseExpression ) const = 0;
|
2017-01-18 22:47:55 +10:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class QgsSizeScaleTransformer : QgsPropertyTransformer
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsproperty.h>
|
|
|
|
%End
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! Size scaling methods
|
|
|
|
enum ScaleType
|
|
|
|
{
|
|
|
|
Linear, /*!< Linear scaling */
|
|
|
|
Area, /*!< Area based scaling */
|
|
|
|
Flannery, /*!< Flannery scaling method */
|
|
|
|
Exponential, /*!< Scale using set exponent */
|
|
|
|
};
|
|
|
|
|
|
|
|
QgsSizeScaleTransformer( ScaleType type = Linear,
|
|
|
|
double minValue = 0.0,
|
|
|
|
double maxValue = 1.0,
|
|
|
|
double minSize = 0.0,
|
|
|
|
double maxSize = 1.0,
|
|
|
|
double nullSize = 0.0,
|
|
|
|
double exponent = 1.0 );
|
|
|
|
|
|
|
|
virtual Type transformerType() const;
|
|
|
|
virtual QgsSizeScaleTransformer* clone() /Factory/;
|
|
|
|
virtual bool writeXml( QDomElement& transformerElem, QDomDocument& doc ) const;
|
|
|
|
virtual bool readXml( const QDomElement& transformerElem, const QDomDocument& doc );
|
|
|
|
virtual QVariant transform( const QgsExpressionContext& context, const QVariant& value ) const;
|
2017-02-05 20:19:12 +10:00
|
|
|
virtual QString toExpression( const QString& baseExpression ) const;
|
2017-01-18 22:47:55 +10:00
|
|
|
|
|
|
|
double size( double value ) const;
|
|
|
|
|
|
|
|
double minSize() const;
|
|
|
|
|
|
|
|
void setMinSize( double size );
|
|
|
|
|
|
|
|
double maxSize() const;
|
|
|
|
|
|
|
|
void setMaxSize( double size );
|
|
|
|
|
|
|
|
double nullSize() const;
|
|
|
|
|
|
|
|
void setNullSize( double size );
|
|
|
|
|
|
|
|
double exponent() const;
|
|
|
|
|
|
|
|
void setExponent( double exponent );
|
|
|
|
|
|
|
|
ScaleType type() const;
|
|
|
|
|
|
|
|
void setType( ScaleType type );
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class QgsColorRampTransformer : QgsPropertyTransformer
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsproperty.h>
|
|
|
|
%End
|
|
|
|
public:
|
|
|
|
|
|
|
|
QgsColorRampTransformer( double minValue = 0.0,
|
|
|
|
double maxValue = 1.0,
|
|
|
|
QgsColorRamp* ramp /Transfer/ = 0,
|
|
|
|
const QColor& nullColor = QColor( 0, 0, 0, 0 ) );
|
|
|
|
|
|
|
|
QgsColorRampTransformer( const QgsColorRampTransformer& other );
|
|
|
|
|
|
|
|
//QgsColorRampTransformer& operator=( const QgsColorRampTransformer& other );
|
|
|
|
|
|
|
|
~QgsColorRampTransformer();
|
|
|
|
|
|
|
|
virtual Type transformerType() const;
|
|
|
|
virtual QgsColorRampTransformer* clone() /Factory/;
|
|
|
|
virtual bool writeXml( QDomElement& transformerElem, QDomDocument& doc ) const;
|
|
|
|
virtual bool readXml( const QDomElement& transformerElem, const QDomDocument& doc );
|
|
|
|
virtual QVariant transform( const QgsExpressionContext& context, const QVariant& value ) const;
|
2017-02-05 20:19:12 +10:00
|
|
|
virtual QString toExpression( const QString& baseExpression ) const;
|
2017-01-18 22:47:55 +10:00
|
|
|
|
|
|
|
QColor color( double value ) const;
|
|
|
|
|
|
|
|
QgsColorRamp* colorRamp() const;
|
|
|
|
|
|
|
|
void setColorRamp( QgsColorRamp* ramp /Transfer/ );
|
|
|
|
|
|
|
|
QColor nullColor() const;
|
|
|
|
|
|
|
|
void setNullColor( const QColor& color );
|
|
|
|
|
2017-02-05 20:19:12 +10:00
|
|
|
QString rampName() const;
|
|
|
|
|
|
|
|
void setRampName( const QString& name );
|
|
|
|
|
2017-01-18 22:47:55 +10:00
|
|
|
};
|
|
|
|
|