15#ifndef QGSCATEGORIZEDSYMBOLRENDERER_H
16#define QGSCATEGORIZEDSYMBOLRENDERER_H
25using namespace Qt::StringLiterals;
76 QVariant
value()
const;
89 QString
label()
const;
133 QString
dump()
const;
140 Q_DECL_DEPRECATED
void toSld( QDomDocument &doc, QDomElement &element, QVariantMap props )
const SIP_DEPRECATED;
147 bool toSld( QDomDocument &doc, QDomElement &element,
const QString &classAttribute,
QgsSldExportContext &context )
const;
150 SIP_PYOBJECT __repr__();
152 const QString str = !sipCpp->value().isValid()
153 ? u
"<QgsRendererCategory>"_s
154 : sipCpp->label().isEmpty()
155 ? u
"<QgsRendererCategory: %1>"_s.arg( sipCpp->value().toString() )
156 : u
"<QgsRendererCategory: %1 (%2)>"_s.arg( sipCpp->value().toString(), sipCpp->label() );
157 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
200 QString
dump()
const override;
202 Q_DECL_DEPRECATED
void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props = QVariantMap() ) const override
SIP_DEPRECATED;
225 int categoryIndexForValue(
const QVariant &val );
230 int categoryIndexForLabel(
const QString &val );
241 bool updateCategoryValue(
int catIndex,
const QVariant &value );
264 bool updateCategoryLabel(
int catIndex,
const QString &label );
277 bool updateCategoryRenderState(
int catIndex,
bool render );
291 bool deleteCategory(
int catIndex );
298 void deleteAllCategories();
303 void moveCategory(
int from,
int to );
310 void sortByValue( Qt::SortOrder order = Qt::AscendingOrder );
317 void sortByLabel( Qt::SortOrder order = Qt::AscendingOrder );
345 QString legendKeyToExpression(
const QString &key,
QgsVectorLayer *layer,
bool &ok )
const override;
402 bool legendSymbolItemsCheckable() const override;
403 bool legendSymbolItemChecked( const QString &key ) override;
405 void checkLegendSymbolItem( const QString &key,
bool state = true ) override;
451 int matchToSymbols(
QgsStyle *style,
Qgis::SymbolType type,
452 QVariantList &unmatchedCategories
SIP_OUT, QStringList &unmatchedSymbols
SIP_OUT,
bool caseSensitive = true,
bool useTolerantMatch = false );
477 Q_DECL_DEPRECATED static QString displayString( const QVariant &value,
int precision = -1 )
SIP_DEPRECATED;
Provides global constants and enumerations for use throughout the application.
QFlags< FeatureRendererFlag > FeatureRendererFlags
Flags controlling behavior of vector feature renderers.
A feature renderer which represents features using a list of renderer categories.
QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
To be overridden.
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
const QgsCategoryList & categories() const
Returns a list of all categories recognized by the renderer.
std::unique_ptr< QgsColorRamp > mSourceColorRamp
Q_DECL_DEPRECATED QgsSymbol * symbolForValue(const QVariant &value) const
Returns the matching symbol corresponding to an attribute value.
std::unique_ptr< QgsSymbol > mSourceSymbol
QHash< QString, QgsSymbol * > mSymbolHash
hashtable for faster access to symbols
bool filterNeedsGeometry() const override
Returns true if this renderer requires the geometry to apply the filter.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns a list of attributes required by this renderer.
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
QgsCategoryList mCategories
std::unique_ptr< QgsExpression > mExpression
std::unique_ptr< QgsDataDefinedSizeLegend > mDataDefinedSizeLegend
QString classAttribute() const
Returns the class attribute for the renderer, which is the field name or expression string from the l...
QgsCategorizedSymbolRenderer(const QString &attrName=QString(), const QgsCategoryList &categories=QgsCategoryList())
Constructor for QgsCategorizedSymbolRenderer.
QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns symbol for feature.
int mAttrNum
attribute index (derived from attribute name in startRender)
Qgis::FeatureRendererFlags flags() const override
Returns flags associated with the renderer.
Q_DECL_DEPRECATED QgsSymbol * skipRender()
QString dump() const override
Returns debug information about this renderer.
Q_DECL_DEPRECATED 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.
QgsCategorizedSymbolRenderer * clone() const override
Create a deep copy of this renderer.
QgsFeatureRenderer::Capabilities capabilities() override
Returns details about internals of this renderer.
void setClassAttribute(const QString &attr)
Sets the class attribute for the renderer, which is the field name or expression string from the laye...
~QgsCategorizedSymbolRenderer() override
QString legendClassificationAttribute() const override
If supported by the renderer, return classification attribute for the use in legend.
Abstract base class for color ramps.
Object that keeps configuration of appearance of marker symbol's data-defined size in legend.
Handles parsing and evaluation of expressions (formerly called "search strings").
Abstract base class for all 2D vector feature renderers.
QgsFeatureRenderer(const QString &type)
QFlags< Capability > Capabilities
@ SymbolLevels
Rendering with symbol levels (i.e. implements symbols(), symbolForFeature()).
@ Filter
Features may be filtered, i.e. some features may not be rendered (categorized, rule based ....
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Container of fields for a vector layer.
A container for the context for various read/write operations on objects.
Contains information about the context of a rendering operation.
Represents an individual category (class) from a QgsCategorizedSymbolRenderer.
void setRenderState(bool render)
Sets whether the category is currently enabled and should be rendered.
std::unique_ptr< QgsSymbol > mSymbol
QgsSymbol * symbol() const
Returns the symbol which will be used to render this category.
void setSymbol(QgsSymbol *s)
Sets the symbol which will be used to render this category.
QString uuid() const
Returns the unique identifier for this category.
QgsRendererCategory()=default
bool renderState() const
Returns true if the category is currently enabled and should be rendered.
friend class QgsCategorizedSymbolRendererWidget
QString dump() const
Returns a string representing the categories settings, used for debugging purposes only.
void setLabel(const QString &label)
Sets the label for this category, which is used to represent the category within legends and the laye...
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, QVariantMap props) const
Converts the category to a matching SLD rule, within the specified DOM document and element.
void setValue(const QVariant &value)
Sets the value corresponding to this category.
QVariant value() const
Returns the value corresponding to this category.
QString label() const
Returns the label for this category, which is used to represent the category within legends and the l...
QgsRendererCategory & operator=(QgsRendererCategory cat)
Holds SLD export options and other information related to SLD export of a QGIS layer style.
An interface for classes which can visit style entity (e.g.
A database of saved style entities, including symbols, color ramps, text formats and others.
Abstract base class for all rendered symbols.
Represents a vector layer which manages a vector based dataset.
QList< QgsRendererCategory > QgsCategoryList
QList< QgsLegendSymbolItem > QgsLegendSymbolList
QList< QgsSymbol * > QgsSymbolList