QGIS/python/core/symbology-ng/qgscategorizedsymbolrenderer.sip

201 lines
6.8 KiB
Plaintext
Raw Normal View History

2016-08-06 11:01:42 +02:00
class QgsRendererCategory
{
%TypeHeaderCode
#include <qgscategorizedsymbolrenderer.h>
%End
public:
//! takes ownership of symbol
2016-08-06 11:01:42 +02:00
QgsRendererCategory( const QVariant& value, QgsSymbol* symbol /Transfer/, const QString& label, bool render = true );
//! copy constructor
2016-08-06 11:01:42 +02:00
QgsRendererCategory( const QgsRendererCategory& cat );
2016-08-06 11:01:42 +02:00
~QgsRendererCategory();
QVariant value() const;
2016-08-05 08:09:43 +02:00
QgsSymbol* symbol() const;
QString label() const;
void setValue( const QVariant &value );
2016-08-05 08:09:43 +02:00
void setSymbol( QgsSymbol* s /Transfer/ );
2013-06-23 16:00:16 +02:00
void setLabel( const QString &label );
// @note added in 2.5
bool renderState() const;
void setRenderState( bool render );
// debugging
QString dump() const;
void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const;
protected:
2016-08-06 11:01:42 +02:00
void swap( QgsRendererCategory & other );
};
2016-08-06 11:01:42 +02:00
typedef QList<QgsRendererCategory> QgsCategoryList;
2016-08-06 11:01:42 +02:00
class QgsCategorizedSymbolRenderer : QgsFeatureRenderer
{
%TypeHeaderCode
#include <qgscategorizedsymbolrenderer.h>
%End
public:
2016-08-06 11:01:42 +02:00
QgsCategorizedSymbolRenderer( const QString& attrName = QString(), const QgsCategoryList& categories = QgsCategoryList() );
2016-08-06 11:01:42 +02:00
virtual ~QgsCategorizedSymbolRenderer();
//! @note available in python as symbolForFeature2
virtual QgsSymbol* symbolForFeature( QgsFeature& feature, QgsRenderContext& context );
//! @note available in python as originalSymbolForFeature2
virtual QgsSymbol* originalSymbolForFeature( QgsFeature& feature, QgsRenderContext& context );
virtual void startRender( QgsRenderContext& context, const QgsFields& fields );
virtual void stopRender( QgsRenderContext& context );
virtual QSet<QString> usedAttributes() const;
virtual QString dump() const;
2016-08-06 11:01:42 +02:00
virtual QgsCategorizedSymbolRenderer* clone() const /Factory/;
virtual void toSld( QDomDocument& doc, QDomElement &element ) const;
//! returns bitwise OR-ed capabilities of the renderer
2016-08-06 11:01:42 +02:00
virtual QgsFeatureRenderer::Capabilities capabilities();
virtual QString filter( const QgsFields& fields = QgsFields() );
//! @note available in python as symbols2
virtual QgsSymbolList symbols( QgsRenderContext& context );
/** Update all the symbols but leave categories and colors. This method also sets the source
* symbol for the renderer.
* @param sym source symbol to use for categories. Ownership is not transferred.
* @see setSourceSymbol()
2016-02-14 03:50:23 +01:00
*/
2016-08-05 08:09:43 +02:00
void updateSymbols( QgsSymbol * sym );
2014-05-27 23:22:50 +02:00
const QgsCategoryList& categories() const;
//! return index of category with specified value (-1 if not found)
int categoryIndexForValue( const QVariant& val );
//! return index of category with specified label (-1 if not found or not unique)
//! @note added in 2.5
int categoryIndexForLabel( const QString& val );
bool updateCategoryValue( int catIndex, const QVariant &value );
2016-08-05 08:09:43 +02:00
bool updateCategorySymbol( int catIndex, QgsSymbol* symbol /Transfer/ );
bool updateCategoryLabel( int catIndex, const QString& label );
//! @note added in 2.5
bool updateCategoryRenderState( int catIndex, bool render );
2016-08-06 11:01:42 +02:00
void addCategory( const QgsRendererCategory &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 );
QString classAttribute() const;
void setClassAttribute( const QString& attr );
//! create renderer from XML element
2016-08-06 11:01:42 +02:00
static QgsFeatureRenderer* 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, const QString& rule = QString() );
//! @note added in 2.10
QgsLegendSymbolListV2 legendSymbolItemsV2() const;
virtual QSet< QString > legendKeysForFeature( QgsFeature& feature, QgsRenderContext& context );
/** Returns the renderer's source symbol, which is the base symbol used for the each categories' symbol before applying
* the categories' color.
* @see setSourceSymbol()
* @see sourceColorRamp()
*/
2016-08-05 08:09:43 +02:00
QgsSymbol* sourceSymbol();
/** Sets the source symbol for the renderer, which is the base symbol used for the each categories' symbol before applying
* the categories' color.
* @param sym source symbol, ownership is transferred to the renderer
* @see sourceSymbol()
* @see setSourceColorRamp()
*/
2016-08-05 08:09:43 +02:00
void setSourceSymbol( QgsSymbol* sym /Transfer/ );
/** Returns the source color ramp, from which each categories' color is derived.
* @see setSourceColorRamp()
* @see sourceSymbol()
*/
QgsColorRamp* sourceColorRamp();
2015-09-01 16:06:35 +10:00
/** Sets the source color ramp.
* @param ramp color ramp. Ownership is transferred to the renderer
* @see sourceColorRamp()
* @see setSourceSymbol()
2015-09-01 16:06:35 +10:00
*/
void setSourceColorRamp( QgsColorRamp* ramp /Transfer/ );
2015-09-01 16:06:35 +10:00
/** Update the color ramp used and all symbols colors.
* @param ramp color ramp. Ownership is transferred to the renderer
* @note added in 2.5
*/
void updateColorRamp( QgsColorRamp* ramp /Transfer/ );
//! items of symbology items in legend should be checkable
2014-11-21 01:17:21 +01:00
//! @note added in 2.5
virtual bool legendSymbolItemsCheckable() const;
//! item in symbology was checked
// @note added in 2.5
virtual bool legendSymbolItemChecked( const QString& key );
2016-08-05 08:09:43 +02:00
virtual void setLegendSymbolItem( const QString& key, QgsSymbol* symbol /Transfer/ );
//! item in symbology was checked
// @note added in 2.5
virtual void checkLegendSymbolItem( const QString& key, bool state = true );
//! 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;
2016-08-06 11:01:42 +02:00
//! creates a QgsCategorizedSymbolRenderer from an existing renderer.
2014-08-24 08:31:36 +08:00
//! @note added in 2.5
//! @returns a new renderer if the conversion was possible, otherwise 0.
2016-08-06 11:01:42 +02:00
static QgsCategorizedSymbolRenderer* convertFromRenderer( const QgsFeatureRenderer *renderer ) /Factory/;
2014-08-24 08:31:36 +08:00
protected:
void rebuildHash();
2016-08-05 08:09:43 +02:00
QgsSymbol* skipRender();
2016-08-05 08:09:43 +02:00
QgsSymbol* symbolForValue( const QVariant& value );
private:
2016-08-06 11:01:42 +02:00
QgsCategorizedSymbolRenderer( const QgsCategorizedSymbolRenderer & );
QgsCategorizedSymbolRenderer & operator=( const QgsCategorizedSymbolRenderer & );
};