2012-09-24 02:28:15 +02:00
|
|
|
class QgsRendererCategoryV2
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgscategorizedsymbolrendererv2.h>
|
|
|
|
%End
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! takes ownership of symbol
|
2014-07-05 00:44:10 +02:00
|
|
|
QgsRendererCategoryV2( QVariant value, QgsSymbolV2* symbol /Transfer/, QString label, bool render = true );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
//! copy constructor
|
|
|
|
QgsRendererCategoryV2( const QgsRendererCategoryV2& cat );
|
|
|
|
|
|
|
|
~QgsRendererCategoryV2();
|
|
|
|
|
|
|
|
QVariant value() const;
|
2013-06-23 16:00:16 +02:00
|
|
|
QgsSymbolV2* symbol() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
QString label() const;
|
|
|
|
|
|
|
|
void setValue( const QVariant &value );
|
|
|
|
void setSymbol( QgsSymbolV2* s /Transfer/ );
|
2013-06-23 16:00:16 +02:00
|
|
|
void setLabel( const QString &label );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2014-07-04 20:49:26 +02:00
|
|
|
// @note added in 2.5
|
|
|
|
bool renderState() const;
|
|
|
|
void setRenderState( bool render );
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
// debugging
|
2013-07-22 21:41:44 +02:00
|
|
|
QString dump() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
void toSld( QDomDocument& doc, QDomElement &element, QgsStringMap props ) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef QList<QgsRendererCategoryV2> QgsCategoryList;
|
|
|
|
|
|
|
|
class QgsCategorizedSymbolRendererV2 : QgsFeatureRendererV2
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgscategorizedsymbolrendererv2.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
QgsCategorizedSymbolRendererV2( QString attrName = QString(), QgsCategoryList categories = QgsCategoryList() );
|
|
|
|
|
|
|
|
virtual ~QgsCategorizedSymbolRendererV2();
|
|
|
|
|
|
|
|
virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature );
|
|
|
|
|
2014-09-25 12:00:45 +02:00
|
|
|
virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature );
|
|
|
|
|
2015-07-22 10:46:13 +02:00
|
|
|
virtual void startRender( QgsRenderContext& context, const QgsFields& fields );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
virtual void stopRender( QgsRenderContext& context );
|
|
|
|
|
|
|
|
virtual QList<QString> usedAttributes();
|
|
|
|
|
2013-07-22 21:41:44 +02:00
|
|
|
virtual QString dump() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2014-08-30 10:16:23 -06:00
|
|
|
virtual QgsFeatureRendererV2* clone() const /Factory/;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
virtual void toSld( QDomDocument& doc, QDomElement &element ) const;
|
|
|
|
|
|
|
|
//! returns bitwise OR-ed capabilities of the renderer
|
|
|
|
virtual int capabilities();
|
|
|
|
|
|
|
|
virtual QgsSymbolV2List symbols();
|
2013-06-23 16:00:16 +02:00
|
|
|
void updateSymbols( QgsSymbolV2 * sym );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
const QgsCategoryList& categories() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
//! return index of category with specified value (-1 if not found)
|
|
|
|
int categoryIndexForValue( QVariant val );
|
|
|
|
|
2014-07-04 20:49:26 +02:00
|
|
|
//! return index of category with specified label (-1 if not found or not unique)
|
|
|
|
//! @note added in 2.5
|
|
|
|
int categoryIndexForLabel( QString val );
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
bool updateCategoryValue( int catIndex, const QVariant &value );
|
|
|
|
bool updateCategorySymbol( int catIndex, QgsSymbolV2* symbol /Transfer/ );
|
|
|
|
bool updateCategoryLabel( int catIndex, QString label );
|
|
|
|
|
2014-07-04 20:49:26 +02:00
|
|
|
//! @note added in 2.5
|
|
|
|
bool updateCategoryRenderState( int catIndex, bool render );
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
void addCategory( const QgsRendererCategoryV2 &category );
|
|
|
|
bool deleteCategory( int catIndex );
|
|
|
|
void deleteAllCategories();
|
|
|
|
|
2013-06-23 16:00:16 +02:00
|
|
|
//! Moves the category at index position from to index position to.
|
|
|
|
void moveCategory( int from, int to );
|
|
|
|
|
|
|
|
void sortByValue( Qt::SortOrder order = Qt::AscendingOrder );
|
|
|
|
void sortByLabel( Qt::SortOrder order = Qt::AscendingOrder );
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
QString classAttribute() const;
|
|
|
|
void setClassAttribute( QString attr );
|
|
|
|
|
|
|
|
//! create renderer from XML element
|
|
|
|
static QgsFeatureRendererV2* create( QDomElement& element ) /Factory/;
|
|
|
|
|
|
|
|
//! store renderer info to XML element
|
|
|
|
virtual QDomElement save( QDomDocument& doc );
|
|
|
|
|
|
|
|
//! return a list of symbology items for the legend
|
|
|
|
virtual QgsLegendSymbologyList legendSymbologyItems( QSize iconSize );
|
|
|
|
|
|
|
|
//! return a list of item text / symbol
|
2014-01-27 09:22:24 +01:00
|
|
|
//! @note not available in python bindings
|
|
|
|
// virtual QgsLegendSymbolList legendSymbolItems( double scaleDenominator = -1, QString rule = QString() );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
QgsSymbolV2* sourceSymbol();
|
|
|
|
void setSourceSymbol( QgsSymbolV2* sym /Transfer/ );
|
|
|
|
|
|
|
|
QgsVectorColorRampV2* sourceColorRamp();
|
|
|
|
void setSourceColorRamp( QgsVectorColorRampV2* ramp /Transfer/ );
|
|
|
|
|
2014-01-27 09:22:24 +01:00
|
|
|
//! @note added in 2.1
|
|
|
|
bool invertedColorRamp();
|
|
|
|
void setInvertedColorRamp( bool inverted );
|
|
|
|
|
2014-09-20 18:30:12 +12:00
|
|
|
// Update the color ramp used and all symbols colors.
|
|
|
|
//! @note added in 2.5
|
|
|
|
void updateColorRamp( QgsVectorColorRampV2* ramp, bool inverted = false );
|
|
|
|
|
2014-02-11 14:19:48 +07:00
|
|
|
void setRotationField( QString fieldOrExpression );
|
2012-09-24 02:28:15 +02:00
|
|
|
QString rotationField() const;
|
|
|
|
|
2014-02-11 14:19:48 +07:00
|
|
|
void setSizeScaleField( QString fieldOrExpression );
|
2012-09-24 02:28:15 +02:00
|
|
|
QString sizeScaleField() const;
|
|
|
|
|
|
|
|
void setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod );
|
|
|
|
QgsSymbolV2::ScaleMethod scaleMethod() const;
|
|
|
|
|
2014-07-04 20:49:26 +02:00
|
|
|
//! items of symbology items in legend should be checkable
|
2014-11-21 01:17:21 +01:00
|
|
|
//! @note added in 2.5
|
2014-07-04 20:49:26 +02:00
|
|
|
virtual bool legendSymbolItemsCheckable() const;
|
|
|
|
|
|
|
|
//! item in symbology was checked
|
|
|
|
// @note added in 2.5
|
2014-08-06 12:58:16 +07:00
|
|
|
virtual bool legendSymbolItemChecked( QString key );
|
2014-07-04 20:49:26 +02:00
|
|
|
|
|
|
|
//! item in symbology was checked
|
|
|
|
// @note added in 2.5
|
2014-08-06 12:58:16 +07:00
|
|
|
virtual void checkLegendSymbolItem( QString key, bool state = true );
|
2014-07-04 20:49:26 +02:00
|
|
|
|
2014-09-20 18:30:12 +12:00
|
|
|
//! If supported by the renderer, return classification attribute for the use in legend
|
|
|
|
//! @note added in 2.6
|
2014-11-13 23:13:13 +01:00
|
|
|
virtual QString legendClassificationAttribute() const;
|
2014-09-20 18:30:12 +12:00
|
|
|
|
2014-08-30 10:16:23 -06:00
|
|
|
//! creates a QgsCategorizedSymbolRendererV2 from an existing renderer.
|
2014-08-24 08:31:36 +08:00
|
|
|
//! @note added in 2.5
|
2014-08-30 10:16:23 -06:00
|
|
|
//! @returns a new renderer if the conversion was possible, otherwise 0.
|
|
|
|
static QgsCategorizedSymbolRendererV2* convertFromRenderer( const QgsFeatureRendererV2 *renderer ) /Factory/;
|
2014-08-24 08:31:36 +08:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
protected:
|
|
|
|
void rebuildHash();
|
|
|
|
|
|
|
|
QgsSymbolV2* symbolForValue( QVariant value );
|
2014-01-14 17:23:16 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
QgsCategorizedSymbolRendererV2( const QgsCategorizedSymbolRendererV2 & );
|
|
|
|
QgsCategorizedSymbolRendererV2 & operator=( const QgsCategorizedSymbolRendererV2 & );
|
2012-09-24 02:28:15 +02:00
|
|
|
};
|
|
|
|
|