QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
|
#include <qgscategorizedsymbolrenderer.h>
Public Member Functions | |
QgsCategorizedSymbolRenderer (const QString &attrName=QString(), const QgsCategoryList &categories=QgsCategoryList()) | |
Constructor for QgsCategorizedSymbolRenderer. More... | |
~QgsCategorizedSymbolRenderer () override | |
bool | accept (QgsStyleEntityVisitorInterface *visitor) const override |
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer. More... | |
void | addCategory (const QgsRendererCategory &category) |
Adds a new category to the renderer. More... | |
QgsFeatureRenderer::Capabilities | capabilities () override |
Returns details about internals of this renderer. More... | |
const QgsCategoryList & | categories () const |
Returns a list of all categories recognized by the renderer. More... | |
int | categoryIndexForLabel (const QString &val) |
Returns the index of the category with the specified label (or -1 if the label was not found, or is not unique). More... | |
int | categoryIndexForValue (const QVariant &val) |
Returns the index for the category with the specified value (or -1 if not found). More... | |
void | checkLegendSymbolItem (const QString &key, bool state=true) override |
item in symbology was checked More... | |
QString | classAttribute () const |
Returns the class attribute for the renderer, which is the field name or expression string from the layer which will be matched against the renderer categories. More... | |
QgsCategorizedSymbolRenderer * | clone () const override |
Create a deep copy of this renderer. More... | |
QgsDataDefinedSizeLegend * | dataDefinedSizeLegend () const |
Returns configuration of appearance of legend when using data-defined size for marker symbols. More... | |
void | deleteAllCategories () |
Deletes all existing categories from the renderer. More... | |
bool | deleteCategory (int catIndex) |
Deletes the category with the specified index from the renderer. More... | |
QString | dump () const override |
Returns debug information about this renderer. More... | |
QString | filter (const QgsFields &fields=QgsFields()) override |
If a renderer does not require all the features this method may be overridden and return an expression used as where clause. More... | |
bool | filterNeedsGeometry () const override |
Returns true if this renderer requires the geometry to apply the filter. More... | |
QString | legendClassificationAttribute () const override |
If supported by the renderer, return classification attribute for the use in legend. More... | |
QSet< QString > | legendKeysForFeature (const QgsFeature &feature, QgsRenderContext &context) const override |
Returns legend keys matching a specified feature. More... | |
QString | legendKeyToExpression (const QString &key, QgsVectorLayer *layer, bool &ok) const override |
Attempts to convert the specified legend rule key to a QGIS expression matching the features displayed using that key. More... | |
bool | legendSymbolItemChecked (const QString &key) override |
items of symbology items in legend is checked More... | |
QgsLegendSymbolList | legendSymbolItems () const override |
Returns a list of symbology items for the legend. More... | |
bool | legendSymbolItemsCheckable () const override |
items of symbology items in legend should be checkable More... | |
int | matchToSymbols (QgsStyle *style, Qgis::SymbolType type, QVariantList &unmatchedCategories, QStringList &unmatchedSymbols, bool caseSensitive=true, bool useTolerantMatch=false) |
Replaces category symbols with the symbols from a style that have a matching name and symbol type. More... | |
void | moveCategory (int from, int to) |
Moves an existing category at index position from to index position to. More... | |
QgsSymbol * | originalSymbolForFeature (const QgsFeature &feature, QgsRenderContext &context) const override |
Returns symbol for feature. More... | |
QDomElement | save (QDomDocument &doc, const QgsReadWriteContext &context) override |
Stores renderer properties to an XML element. More... | |
void | setClassAttribute (const QString &attr) |
Sets the class attribute for the renderer, which is the field name or expression string from the layer which will be matched against the renderer categories. More... | |
void | setDataDefinedSizeLegend (QgsDataDefinedSizeLegend *settings) |
Configures appearance of legend when renderer is configured to use data-defined size for marker symbols. More... | |
void | setLegendSymbolItem (const QString &key, QgsSymbol *symbol) override |
Sets the symbol to be used for a legend symbol item. More... | |
void | setSourceColorRamp (QgsColorRamp *ramp) |
Sets the source color ramp. More... | |
void | setSourceSymbol (QgsSymbol *sym) |
Sets the source symbol for the renderer, which is the base symbol used for the each categories' symbol before applying the categories' color. More... | |
void | sortByLabel (Qt::SortOrder order=Qt::AscendingOrder) |
Sorts the existing categories by their label. More... | |
void | sortByValue (Qt::SortOrder order=Qt::AscendingOrder) |
Sorts the existing categories by their value. More... | |
QgsColorRamp * | sourceColorRamp () |
Returns the source color ramp, from which each categories' color is derived. More... | |
const QgsColorRamp * | sourceColorRamp () const |
Returns the source color ramp, from which each categories' color is derived. More... | |
QgsSymbol * | sourceSymbol () |
Returns the renderer's source symbol, which is the base symbol used for the each categories' symbol before applying the categories' color. More... | |
const QgsSymbol * | sourceSymbol () const |
Returns the renderer's source symbol, which is the base symbol used for the each categories' symbol before applying the categories' color. More... | |
void | startRender (QgsRenderContext &context, const QgsFields &fields) override |
Must be called when a new render cycle is started. More... | |
void | stopRender (QgsRenderContext &context) override |
Must be called when a render cycle has finished, to allow the renderer to clean up. More... | |
QgsSymbol * | symbolForFeature (const QgsFeature &feature, QgsRenderContext &context) const override |
To be overridden. More... | |
QgsSymbolList | symbols (QgsRenderContext &context) const override |
Returns list of symbols used by the renderer. More... | |
void | toSld (QDomDocument &doc, QDomElement &element, const QVariantMap &props=QVariantMap()) const override |
used from subclasses to create SLD Rule elements following SLD v1.1 specs More... | |
bool | updateCategoryLabel (int catIndex, const QString &label) |
Changes the label for the category with the specified index. More... | |
bool | updateCategoryRenderState (int catIndex, bool render) |
Changes the render state for the category with the specified index. More... | |
bool | updateCategorySymbol (int catIndex, QgsSymbol *symbol) |
Changes the symbol for the category with the specified index. More... | |
bool | updateCategoryValue (int catIndex, const QVariant &value) |
Changes the value for the category with the specified index. More... | |
void | updateColorRamp (QgsColorRamp *ramp) |
Update the color ramp used and all symbols colors. More... | |
void | updateSymbols (QgsSymbol *sym) |
Update all the symbols but leave categories and colors. More... | |
QSet< QString > | usedAttributes (const QgsRenderContext &context) const override |
Returns a list of attributes required by this renderer. More... | |
Public Member Functions inherited from QgsFeatureRenderer | |
virtual | ~QgsFeatureRenderer () |
virtual bool | accept (QgsStyleEntityVisitorInterface *visitor) const |
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer. More... | |
virtual QgsFeatureRenderer::Capabilities | capabilities () |
Returns details about internals of this renderer. More... | |
virtual void | checkLegendSymbolItem (const QString &key, bool state=true) |
item in symbology was checked More... | |
virtual QgsFeatureRenderer * | clone () const =0 |
Create a deep copy of this renderer. More... | |
void | copyRendererData (QgsFeatureRenderer *destRenderer) const |
Clones generic renderer data to another renderer. More... | |
virtual QString | dump () const |
Returns debug information about this renderer. More... | |
virtual const QgsFeatureRenderer * | embeddedRenderer () const |
Returns the current embedded renderer (subrenderer) for this feature renderer. More... | |
virtual QString | filter (const QgsFields &fields=QgsFields()) |
If a renderer does not require all the features this method may be overridden and return an expression used as where clause. More... | |
virtual bool | filterNeedsGeometry () const |
Returns true if this renderer requires the geometry to apply the filter. More... | |
bool | forceRasterRender () const |
Returns whether the renderer must render as a raster. More... | |
virtual QString | legendClassificationAttribute () const |
If supported by the renderer, return classification attribute for the use in legend. More... | |
virtual QSet< QString > | legendKeysForFeature (const QgsFeature &feature, QgsRenderContext &context) const |
Returns legend keys matching a specified feature. More... | |
virtual QString | legendKeyToExpression (const QString &key, QgsVectorLayer *layer, bool &ok) const |
Attempts to convert the specified legend rule key to a QGIS expression matching the features displayed using that key. More... | |
virtual bool | legendSymbolItemChecked (const QString &key) |
items of symbology items in legend is checked More... | |
virtual QgsLegendSymbolList | legendSymbolItems () const |
Returns a list of symbology items for the legend. More... | |
virtual bool | legendSymbolItemsCheckable () const |
items of symbology items in legend should be checkable More... | |
virtual void | modifyRequestExtent (QgsRectangle &extent, QgsRenderContext &context) |
Allows for a renderer to modify the extent of a feature request prior to rendering. More... | |
QgsFeatureRequest::OrderBy | orderBy () const |
Gets the order in which features shall be processed by this renderer. More... | |
bool | orderByEnabled () const |
Returns whether custom ordering will be applied before features are processed by this renderer. More... | |
virtual QgsSymbol * | originalSymbolForFeature (const QgsFeature &feature, QgsRenderContext &context) const |
Returns symbol for feature. More... | |
virtual QgsSymbolList | originalSymbolsForFeature (const QgsFeature &feature, QgsRenderContext &context) const |
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbols per feature - similar to symbolsForFeature() More... | |
QgsPaintEffect * | paintEffect () const |
Returns the current paint effect for the renderer. More... | |
double | referenceScale () const |
Returns the symbology reference scale. More... | |
virtual bool | renderFeature (const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false) SIP_THROW(QgsCsException) |
Render a feature using this renderer in the given context. More... | |
virtual QDomElement | save (QDomDocument &doc, const QgsReadWriteContext &context) |
Stores renderer properties to an XML element. More... | |
virtual void | setEmbeddedRenderer (QgsFeatureRenderer *subRenderer) |
Sets an embedded renderer (subrenderer) for this feature renderer. More... | |
void | setForceRasterRender (bool forceRaster) |
Sets whether the renderer should be rendered to a raster destination. More... | |
virtual void | setLegendSymbolItem (const QString &key, QgsSymbol *symbol) |
Sets the symbol to be used for a legend symbol item. More... | |
void | setOrderBy (const QgsFeatureRequest::OrderBy &orderBy) |
Define the order in which features shall be processed by this renderer. More... | |
void | setOrderByEnabled (bool enabled) |
Sets whether custom ordering should be applied before features are processed by this renderer. More... | |
void | setPaintEffect (QgsPaintEffect *effect) |
Sets the current paint effect for the renderer. More... | |
void | setReferenceScale (double scale) |
Sets the symbology reference scale. More... | |
void | setUsingSymbolLevels (bool usingSymbolLevels) |
void | setVertexMarkerAppearance (Qgis::VertexMarkerType type, double size) |
Sets type and size of editing vertex markers for subsequent rendering. More... | |
virtual void | startRender (QgsRenderContext &context, const QgsFields &fields) |
Must be called when a new render cycle is started. More... | |
virtual void | stopRender (QgsRenderContext &context) |
Must be called when a render cycle has finished, to allow the renderer to clean up. More... | |
virtual QgsSymbol * | symbolForFeature (const QgsFeature &feature, QgsRenderContext &context) const =0 |
To be overridden. More... | |
virtual QgsSymbolList | symbols (QgsRenderContext &context) const |
Returns list of symbols used by the renderer. More... | |
virtual QgsSymbolList | symbolsForFeature (const QgsFeature &feature, QgsRenderContext &context) const |
Returns list of symbols used for rendering the feature. More... | |
virtual void | toSld (QDomDocument &doc, QDomElement &element, const QVariantMap &props=QVariantMap()) const |
used from subclasses to create SLD Rule elements following SLD v1.1 specs More... | |
QString | type () const |
virtual QSet< QString > | usedAttributes (const QgsRenderContext &context) const =0 |
Returns a list of attributes required by this renderer. More... | |
virtual bool | usesEmbeddedSymbols () const |
Returns true if the renderer uses embedded symbols for features. More... | |
bool | usingSymbolLevels () const |
virtual bool | willRenderFeature (const QgsFeature &feature, QgsRenderContext &context) const |
Returns whether the renderer will render a feature or not. More... | |
virtual QDomElement | writeSld (QDomDocument &doc, const QString &styleName, const QVariantMap &props=QVariantMap()) const |
create the SLD UserStyle element following the SLD v1.1 specs with the given name More... | |
Static Public Member Functions | |
static QgsCategorizedSymbolRenderer * | convertFromRenderer (const QgsFeatureRenderer *renderer, QgsVectorLayer *layer=nullptr) |
Creates a new QgsCategorizedSymbolRenderer from an existing renderer. More... | |
static QgsFeatureRenderer * | create (QDomElement &element, const QgsReadWriteContext &context) |
Creates a categorized renderer from an XML element. More... | |
static QgsCategoryList | createCategories (const QVariantList &values, const QgsSymbol *symbol, QgsVectorLayer *layer=nullptr, const QString &fieldName=QString()) |
Create categories for a list of values. More... | |
static QString | displayString (const QVariant &value, int precision=-1) |
Returns a localized representation of value with the given precision, if precision is -1 then precision is guessed from the default QVariant::toString output. More... | |
Static Public Member Functions inherited from QgsFeatureRenderer | |
static QgsFeatureRenderer * | defaultRenderer (QgsWkbTypes::GeometryType geomType) |
Returns a new renderer - used by default in vector layers. More... | |
static QgsFeatureRenderer * | load (QDomElement &symbologyElem, const QgsReadWriteContext &context) |
create a renderer from XML element More... | |
static QgsFeatureRenderer * | loadSld (const QDomNode &node, QgsWkbTypes::GeometryType geomType, QString &errorMessage) |
Create a new renderer according to the information contained in the UserStyle element of a SLD style document. More... | |
Protected Member Functions | |
void | rebuildHash () |
Q_DECL_DEPRECATED QgsSymbol * | skipRender () |
Q_DECL_DEPRECATED QgsSymbol * | symbolForValue (const QVariant &value) const |
Returns the matching symbol corresponding to an attribute value. More... | |
QgsSymbol * | symbolForValue (const QVariant &value, bool &foundMatchingSymbol) const |
Returns the matching symbol corresponding to an attribute value. More... | |
Protected Member Functions inherited from QgsFeatureRenderer | |
QgsFeatureRenderer (const QString &type) | |
void | renderFeatureWithSymbol (const QgsFeature &feature, QgsSymbol *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker) SIP_THROW(QgsCsException) |
Render the feature with the symbol using context. More... | |
void | renderVertexMarker (QPointF pt, QgsRenderContext &context) |
render editing vertex marker at specified point More... | |
void | renderVertexMarkerPolygon (QPolygonF &pts, QList< QPolygonF > *rings, QgsRenderContext &context) |
render editing vertex marker for a polygon More... | |
void | renderVertexMarkerPolyline (QPolygonF &pts, QgsRenderContext &context) |
render editing vertex marker for a polyline More... | |
void | saveRendererData (QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context) |
Saves generic renderer data into the specified element. More... | |
Protected Attributes | |
QString | mAttrName |
int | mAttrNum = -1 |
attribute index (derived from attribute name in startRender) More... | |
QgsCategoryList | mCategories |
bool | mCounting = false |
std::unique_ptr< QgsDataDefinedSizeLegend > | mDataDefinedSizeLegend |
std::unique_ptr< QgsExpression > | mExpression |
std::unique_ptr< QgsColorRamp > | mSourceColorRamp |
std::unique_ptr< QgsSymbol > | mSourceSymbol |
QHash< QString, QgsSymbol * > | mSymbolHash |
hashtable for faster access to symbols More... | |
Protected Attributes inherited from QgsFeatureRenderer | |
double | mCurrentVertexMarkerSize = 2 |
The current size of editing marker. More... | |
Qgis::VertexMarkerType | mCurrentVertexMarkerType = Qgis::VertexMarkerType::Cross |
The current type of editing marker. More... | |
bool | mForceRaster = false |
QgsFeatureRequest::OrderBy | mOrderBy |
bool | mOrderByEnabled = false |
QgsPaintEffect * | mPaintEffect = nullptr |
double | mReferenceScale = -1.0 |
QString | mType |
bool | mUsingSymbolLevels = false |
Additional Inherited Members | |
Public Types inherited from QgsFeatureRenderer | |
enum | Capability { SymbolLevels = 1 , MoreSymbolsPerFeature = 1 << 2 , Filter = 1 << 3 , ScaleDependent = 1 << 4 } |
Used to specify details about a renderer. More... | |
Static Protected Member Functions inherited from QgsFeatureRenderer | |
static QPointF | _getPoint (QgsRenderContext &context, const QgsPoint &point) |
Creates a point in screen coordinates from a wkb string in map coordinates. More... | |
static void | convertSymbolRotation (QgsSymbol *symbol, const QString &field) |
static void | convertSymbolSizeScale (QgsSymbol *symbol, Qgis::ScaleMethod method, const QString &field) |
Definition at line 164 of file qgscategorizedsymbolrenderer.h.
QgsCategorizedSymbolRenderer::QgsCategorizedSymbolRenderer | ( | const QString & | attrName = QString() , |
const QgsCategoryList & | categories = QgsCategoryList() |
||
) |
Constructor for QgsCategorizedSymbolRenderer.
The attrName argument specifies the layer's field name, or expression, which the categories will be matched against.
A list of renderer categories can optionally be specified. If no categories are specified in the constructor, they can be added later by calling addCategory().
Definition at line 171 of file qgscategorizedsymbolrenderer.cpp.
|
overridedefault |
|
overridevirtual |
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer.
Returns true
if the visitor should continue visiting other objects, or false
if visiting should be canceled.
Reimplemented from QgsFeatureRenderer.
Definition at line 640 of file qgscategorizedsymbolrenderer.cpp.
void QgsCategorizedSymbolRenderer::addCategory | ( | const QgsRendererCategory & | category | ) |
Adds a new category to the renderer.
Definition at line 346 of file qgscategorizedsymbolrenderer.cpp.
|
inlineoverridevirtual |
Returns details about internals of this renderer.
E.g. if you only want to deal with visible features:
Reimplemented from QgsFeatureRenderer.
Definition at line 188 of file qgscategorizedsymbolrenderer.h.
|
inline |
Returns a list of all categories recognized by the renderer.
Definition at line 204 of file qgscategorizedsymbolrenderer.h.
int QgsCategorizedSymbolRenderer::categoryIndexForLabel | ( | const QString & | val | ) |
Returns the index of the category with the specified label (or -1 if the label was not found, or is not unique).
Definition at line 298 of file qgscategorizedsymbolrenderer.cpp.
int QgsCategorizedSymbolRenderer::categoryIndexForValue | ( | const QVariant & | val | ) |
Returns the index for the category with the specified value (or -1 if not found).
Definition at line 288 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
item in symbology was checked
Reimplemented from QgsFeatureRenderer.
Definition at line 1272 of file qgscategorizedsymbolrenderer.cpp.
|
inline |
Returns the class attribute for the renderer, which is the field name or expression string from the layer which will be matched against the renderer categories.
Definition at line 312 of file qgscategorizedsymbolrenderer.h.
|
overridevirtual |
Create a deep copy of this renderer.
Should be implemented by all subclasses and generate a proper subclass.
Implements QgsFeatureRenderer.
Definition at line 501 of file qgscategorizedsymbolrenderer.cpp.
|
static |
Creates a new QgsCategorizedSymbolRenderer from an existing renderer.
Since QGIS 3.20, the optional layer parameter is required for conversions of some renderer types.
nullptr
. Definition at line 1280 of file qgscategorizedsymbolrenderer.cpp.
|
static |
Creates a categorized renderer from an XML element.
Definition at line 659 of file qgscategorizedsymbolrenderer.cpp.
|
static |
Create categories for a list of values.
The returned symbols in the category list will be a modification of symbol.
If layer and fieldName are specified it will try to find nicer values to represent the description for the categories based on the respective field configuration.
Definition at line 1423 of file qgscategorizedsymbolrenderer.cpp.
QgsDataDefinedSizeLegend * QgsCategorizedSymbolRenderer::dataDefinedSizeLegend | ( | ) | const |
Returns configuration of appearance of legend when using data-defined size for marker symbols.
Will return nullptr
if the functionality is disabled.
Definition at line 1356 of file qgscategorizedsymbolrenderer.cpp.
void QgsCategorizedSymbolRenderer::deleteAllCategories | ( | ) |
Deletes all existing categories from the renderer.
Definition at line 366 of file qgscategorizedsymbolrenderer.cpp.
bool QgsCategorizedSymbolRenderer::deleteCategory | ( | int | catIndex | ) |
Deletes the category with the specified index from the renderer.
Definition at line 357 of file qgscategorizedsymbolrenderer.cpp.
|
static |
Returns a localized representation of value with the given precision, if precision is -1 then precision is guessed from the default QVariant::toString output.
Definition at line 927 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
Returns debug information about this renderer.
Reimplemented from QgsFeatureRenderer.
Definition at line 493 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
If a renderer does not require all the features this method may be overridden and return an expression used as where clause.
This will be called once after startRender() and before the first call to renderFeature(). By default this returns a null string and all features will be requested. You do not need to specify the extent in here, this is taken care of separately and will be combined with a filter returned from this method.
Reimplemented from QgsFeatureRenderer.
Definition at line 528 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
Returns true
if this renderer requires the geometry to apply the filter.
Reimplemented from QgsFeatureRenderer.
Definition at line 480 of file qgscategorizedsymbolrenderer.cpp.
|
inlineoverridevirtual |
If supported by the renderer, return classification attribute for the use in legend.
Reimplemented from QgsFeatureRenderer.
Definition at line 393 of file qgscategorizedsymbolrenderer.h.
|
overridevirtual |
Returns legend keys matching a specified feature.
Reimplemented from QgsFeatureRenderer.
Definition at line 1087 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
Attempts to convert the specified legend rule key to a QGIS expression matching the features displayed using that key.
key | legend key |
layer | associated vector layer |
ok | will be set to true if legend key was successfully converted to a filter expression |
Reimplemented from QgsFeatureRenderer.
Definition at line 1135 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
items of symbology items in legend is checked
Reimplemented from QgsFeatureRenderer.
Definition at line 1252 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
Returns a list of symbology items for the legend.
Reimplemented from QgsFeatureRenderer.
Definition at line 1047 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
items of symbology items in legend should be checkable
Reimplemented from QgsFeatureRenderer.
Definition at line 1247 of file qgscategorizedsymbolrenderer.cpp.
int QgsCategorizedSymbolRenderer::matchToSymbols | ( | QgsStyle * | style, |
Qgis::SymbolType | type, | ||
QVariantList & | unmatchedCategories, | ||
QStringList & | unmatchedSymbols, | ||
bool | caseSensitive = true , |
||
bool | useTolerantMatch = false |
||
) |
Replaces category symbols with the symbols from a style that have a matching name and symbol type.
The unmatchedCategories list will be filled with all existing categories which could not be matched to a symbol in style.
The unmatchedSymbols list will be filled with all symbol names from style which were not matched to an existing category.
If caseSensitive is false
, then a case-insensitive match will be performed. If useTolerantMatch is true
, then non-alphanumeric characters in style and category names will be ignored during the match.
Returns the count of symbols matched.
Definition at line 1361 of file qgscategorizedsymbolrenderer.cpp.
void QgsCategorizedSymbolRenderer::moveCategory | ( | int | from, |
int | to | ||
) |
Moves an existing category at index position from to index position to.
Definition at line 371 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
Returns symbol for feature.
The difference compared to symbolForFeature() is that it returns original symbol which can be used as an identifier for renderer's rule - the former may return a temporary replacement of a symbol for use in rendering.
Reimplemented from QgsFeatureRenderer.
Definition at line 270 of file qgscategorizedsymbolrenderer.cpp.
|
protected |
Definition at line 190 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
Stores renderer properties to an XML element.
Subclasses which override this method should call saveRendererData() as part of their implementation in order to store all common base class properties in the returned DOM element.
Reimplemented from QgsFeatureRenderer.
Definition at line 809 of file qgscategorizedsymbolrenderer.cpp.
|
inline |
Sets the class attribute for the renderer, which is the field name or expression string from the layer which will be matched against the renderer categories.
Definition at line 321 of file qgscategorizedsymbolrenderer.h.
void QgsCategorizedSymbolRenderer::setDataDefinedSizeLegend | ( | QgsDataDefinedSizeLegend * | settings | ) |
Configures appearance of legend when renderer is configured to use data-defined size for marker symbols.
This allows configuring for which values (symbol sizes) should be shown in the legend, whether to display different symbol sizes collapsed in one legend node or separated across multiple legend nodes etc.
When renderer does not use data-defined size or does not use marker symbols, these settings will be ignored. Takes ownership of the passed settings objects. nullptr
is a valid input that disables data-defined size legend.
Definition at line 1351 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
Sets the symbol to be used for a legend symbol item.
key | rule key for legend symbol |
symbol | new symbol for legend item. Ownership is transferred to renderer. |
Reimplemented from QgsFeatureRenderer.
Definition at line 1262 of file qgscategorizedsymbolrenderer.cpp.
void QgsCategorizedSymbolRenderer::setSourceColorRamp | ( | QgsColorRamp * | ramp | ) |
Sets the source color ramp.
ramp | color ramp. Ownership is transferred to the renderer |
Definition at line 1207 of file qgscategorizedsymbolrenderer.cpp.
void QgsCategorizedSymbolRenderer::setSourceSymbol | ( | QgsSymbol * | sym | ) |
Sets the source symbol for the renderer, which is the base symbol used for the each categories' symbol before applying the categories' color.
sym | source symbol, ownership is transferred to the renderer |
Definition at line 1192 of file qgscategorizedsymbolrenderer.cpp.
|
protected |
Definition at line 212 of file qgscategorizedsymbolrenderer.cpp.
void QgsCategorizedSymbolRenderer::sortByLabel | ( | Qt::SortOrder | order = Qt::AscendingOrder | ) |
Sorts the existing categories by their label.
Definition at line 408 of file qgscategorizedsymbolrenderer.cpp.
void QgsCategorizedSymbolRenderer::sortByValue | ( | Qt::SortOrder | order = Qt::AscendingOrder | ) |
Sorts the existing categories by their value.
Definition at line 386 of file qgscategorizedsymbolrenderer.cpp.
QgsColorRamp * QgsCategorizedSymbolRenderer::sourceColorRamp | ( | ) |
Returns the source color ramp, from which each categories' color is derived.
Definition at line 1197 of file qgscategorizedsymbolrenderer.cpp.
const QgsColorRamp * QgsCategorizedSymbolRenderer::sourceColorRamp | ( | ) | const |
Returns the source color ramp, from which each categories' color is derived.
Definition at line 1202 of file qgscategorizedsymbolrenderer.cpp.
QgsSymbol * QgsCategorizedSymbolRenderer::sourceSymbol | ( | ) |
Returns the renderer's source symbol, which is the base symbol used for the each categories' symbol before applying the categories' color.
Definition at line 1182 of file qgscategorizedsymbolrenderer.cpp.
const QgsSymbol * QgsCategorizedSymbolRenderer::sourceSymbol | ( | ) | const |
Returns the renderer's source symbol, which is the base symbol used for the each categories' symbol before applying the categories' color.
Definition at line 1187 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
Must be called when a new render cycle is started.
A call to startRender() must always be followed by a corresponding call to stopRender() after all features have been rendered.
context | Additional information passed to the renderer about the job which will be rendered |
fields | The fields available for rendering |
Reimplemented from QgsFeatureRenderer.
Definition at line 420 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
Must be called when a render cycle has finished, to allow the renderer to clean up.
Calls to stopRender() must always be preceded by a call to startRender().
Reimplemented from QgsFeatureRenderer.
Definition at line 443 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
To be overridden.
Must be called between startRender() and stopRender() calls.
feature | feature |
context | render context |
Implements QgsFeatureRenderer.
Definition at line 247 of file qgscategorizedsymbolrenderer.cpp.
|
protected |
Returns the matching symbol corresponding to an attribute value.
Definition at line 217 of file qgscategorizedsymbolrenderer.cpp.
|
protected |
Returns the matching symbol corresponding to an attribute value.
Will return nullptr
if no matching symbol was found for value, or if the category corresponding to value is currently disabled (see QgsRendererCategory::renderState()).
If foundMatchingSymbol is specified then it will be set to true
if a matching category was found. This can be used to differentiate between nullptr
returned as a result of no matching category vs NULLPTR as a result of disabled categories.
Definition at line 223 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
Returns list of symbols used by the renderer.
context | render context |
Reimplemented from QgsFeatureRenderer.
Definition at line 628 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
used from subclasses to create SLD Rule elements following SLD v1.1 specs
Reimplemented from QgsFeatureRenderer.
Definition at line 516 of file qgscategorizedsymbolrenderer.cpp.
bool QgsCategorizedSymbolRenderer::updateCategoryLabel | ( | int | catIndex, |
const QString & | label | ||
) |
Changes the label for the category with the specified index.
A category's label is used to represent the category within legends and the layer tree.
Definition at line 330 of file qgscategorizedsymbolrenderer.cpp.
bool QgsCategorizedSymbolRenderer::updateCategoryRenderState | ( | int | catIndex, |
bool | render | ||
) |
Changes the render state for the category with the specified index.
The render state indicates whether or not the category will be rendered, and is reflected in whether the category is checked with the project's layer tree.
Definition at line 338 of file qgscategorizedsymbolrenderer.cpp.
bool QgsCategorizedSymbolRenderer::updateCategorySymbol | ( | int | catIndex, |
QgsSymbol * | symbol | ||
) |
Changes the symbol for the category with the specified index.
Ownership of symbol is transferred to the renderer.
Definition at line 322 of file qgscategorizedsymbolrenderer.cpp.
bool QgsCategorizedSymbolRenderer::updateCategoryValue | ( | int | catIndex, |
const QVariant & | value | ||
) |
Changes the value for the category with the specified index.
If value is a list, then the category will match any of the values from this list.
Definition at line 314 of file qgscategorizedsymbolrenderer.cpp.
void QgsCategorizedSymbolRenderer::updateColorRamp | ( | QgsColorRamp * | ramp | ) |
Update the color ramp used and all symbols colors.
ramp | color ramp. Ownership is transferred to the renderer |
Definition at line 1212 of file qgscategorizedsymbolrenderer.cpp.
void QgsCategorizedSymbolRenderer::updateSymbols | ( | QgsSymbol * | sym | ) |
Update all the symbols but leave categories and colors.
This method also sets the source symbol for the renderer.
sym | source symbol to use for categories. Ownership is not transferred. |
Definition at line 1234 of file qgscategorizedsymbolrenderer.cpp.
|
overridevirtual |
Returns a list of attributes required by this renderer.
Attributes not listed in here may not have been requested from the provider at rendering time.
Implements QgsFeatureRenderer.
Definition at line 454 of file qgscategorizedsymbolrenderer.cpp.
|
protected |
Definition at line 470 of file qgscategorizedsymbolrenderer.h.
|
protected |
attribute index (derived from attribute name in startRender)
Definition at line 479 of file qgscategorizedsymbolrenderer.h.
|
protected |
Definition at line 471 of file qgscategorizedsymbolrenderer.h.
|
protected |
Definition at line 483 of file qgscategorizedsymbolrenderer.h.
|
protected |
Definition at line 476 of file qgscategorizedsymbolrenderer.h.
|
protected |
Definition at line 474 of file qgscategorizedsymbolrenderer.h.
|
protected |
Definition at line 473 of file qgscategorizedsymbolrenderer.h.
|
protected |
Definition at line 472 of file qgscategorizedsymbolrenderer.h.
|
protected |
hashtable for faster access to symbols
Definition at line 482 of file qgscategorizedsymbolrenderer.h.