38 #include <QDomDocument> 39 #include <QDomElement> 119 if ( !
mSymbol.get() || props.value( QStringLiteral(
"attribute" ), QString() ).isEmpty() )
122 QString attrName = props[ QStringLiteral(
"attribute" )];
124 QDomElement ruleElem = doc.createElement( QStringLiteral(
"se:Rule" ) );
125 element.appendChild( ruleElem );
127 QDomElement nameElem = doc.createElement( QStringLiteral(
"se:Name" ) );
128 nameElem.appendChild( doc.createTextNode(
mLabel ) );
129 ruleElem.appendChild( nameElem );
131 QDomElement descrElem = doc.createElement( QStringLiteral(
"se:Description" ) );
132 QDomElement titleElem = doc.createElement( QStringLiteral(
"se:Title" ) );
133 QString descrStr = QStringLiteral(
"%1 is '%2'" ).arg( attrName,
mValue.toString() );
134 titleElem.appendChild( doc.createTextNode( !
mLabel.isEmpty() ?
mLabel : descrStr ) );
135 descrElem.appendChild( titleElem );
136 ruleElem.appendChild( descrElem );
142 filterFunc = QStringLiteral(
"%1 = '%2' or %1 is null" )
143 .arg( attrName.replace(
'\"', QLatin1String(
"\"\"" ) ),
144 mValue.toString().replace(
'\'', QLatin1String(
"''" ) ) );
148 filterFunc = QStringLiteral(
"%1 = '%2'" )
149 .arg( attrName.replace(
'\"', QLatin1String(
"\"\"" ) ),
150 mValue.toString().replace(
'\'', QLatin1String(
"''" ) ) );
158 mSymbol->toSld( doc, ruleElem, props );
165 , mAttrName( attrName )
174 QgsDebugMsg( QStringLiteral(
"invalid symbol in a category! ignoring..." ) );
186 const QVariant val = cat.value();
188 if ( val.type() == QVariant::List )
190 const QVariantList list = val.toList();
191 for (
const QVariant &v : list )
193 mSymbolHash.insert( v.toString(), ( cat.renderState() ||
mCounting ) ? cat.symbol() : nullptr );
198 mSymbolHash.insert( val.toString(), ( cat.renderState() ||
mCounting ) ? cat.symbol() : nullptr );
216 foundMatchingSymbol =
false;
219 QHash<QString, QgsSymbol *>::const_iterator it =
mSymbolHash.constFind( value.isNull() ? QString() : value.toString() );
224 QgsDebugMsg( QStringLiteral(
"there are no hashed symbols!!!" ) );
233 foundMatchingSymbol =
true;
263 QVariant value = valueForFeature( feature, context );
265 bool foundCategory =
false;
269 if ( !foundCategory )
307 if ( catIndex < 0 || catIndex >=
mCategories.size() )
315 if ( catIndex < 0 || catIndex >=
mCategories.size() )
323 if ( catIndex < 0 || catIndex >=
mCategories.size() )
331 if ( catIndex < 0 || catIndex >=
mCategories.size() )
341 QgsDebugMsg( QStringLiteral(
"invalid symbol in a category! ignoring..." ) );
350 if ( catIndex < 0 || catIndex >=
mCategories.size() )
379 if ( order == Qt::AscendingOrder )
391 return QString::localeAwareCompare( c1.
label(), c2.
label() ) < 0;
401 if ( order == Qt::AscendingOrder )
430 cat.symbol()->startRender( context, fields );
440 cat.symbol()->stopRender( context );
447 QSet<QString> attributes;
459 QgsCategoryList::const_iterator catIt =
mCategories.constBegin();
486 QString s = QStringLiteral(
"CATEGORIZED: idx %1\n" ).arg(
mAttrName );
511 newProps[ QStringLiteral(
"attribute" )] =
mAttrName;
516 it->toSld( doc, element, newProps );
523 bool isExpression = ( attrNum == -1 );
525 bool hasDefault =
false;
526 bool defaultActive =
false;
527 bool allActive =
true;
528 bool noneActive =
true;
532 QString activeValues;
533 QString inactiveValues;
537 if ( cat.value() ==
"" || cat.value().isNull() )
540 defaultActive = cat.renderState();
543 noneActive = noneActive && !cat.renderState();
544 allActive = allActive && cat.renderState();
546 QVariant::Type valType = isExpression ? cat.value().type() : fields.
at( attrNum ).
type();
547 const bool isList = cat.value().type() == QVariant::List;
550 if ( !cat.renderState() )
552 if ( cat.value() !=
"" )
556 const QVariantList list = cat.value().toList();
557 for (
const QVariant &v : list )
559 if ( !inactiveValues.isEmpty() )
560 inactiveValues.append(
',' );
567 if ( !inactiveValues.isEmpty() )
568 inactiveValues.append(
',' );
570 inactiveValues.append( value );
576 if ( cat.value() !=
"" )
580 const QVariantList list = cat.value().toList();
581 for (
const QVariant &v : list )
583 if ( !activeValues.isEmpty() )
584 activeValues.append(
',' );
591 if ( !activeValues.isEmpty() )
592 activeValues.append(
',' );
594 activeValues.append( value );
600 QString attr = isExpression ?
mAttrName : QStringLiteral(
"\"%1\"" ).arg(
mAttrName );
602 if ( allActive && hasDefault )
606 else if ( noneActive )
608 return QStringLiteral(
"FALSE" );
610 else if ( defaultActive )
612 return QStringLiteral(
"(%1) NOT IN (%2) OR (%1) IS NULL" ).arg( attr, inactiveValues );
616 return QStringLiteral(
"(%1) IN (%2)" ).arg( attr, activeValues );
627 lst.append( cat.symbol() );
634 QDomElement symbolsElem = element.firstChildElement( QStringLiteral(
"symbols" ) );
635 if ( symbolsElem.isNull() )
638 QDomElement catsElem = element.firstChildElement( QStringLiteral(
"categories" ) );
639 if ( catsElem.isNull() )
645 QDomElement catElem = catsElem.firstChildElement();
646 while ( !catElem.isNull() )
648 if ( catElem.tagName() == QLatin1String(
"category" ) )
651 if ( catElem.hasAttribute( QStringLiteral(
"value" ) ) )
653 value = QVariant( catElem.attribute( QStringLiteral(
"value" ) ) );
658 QDomElement valElem = catElem.firstChildElement();
659 while ( !valElem.isNull() )
661 if ( valElem.tagName() == QLatin1String(
"val" ) )
663 values << QVariant( valElem.attribute( QStringLiteral(
"value" ) ) );
665 valElem = valElem.nextSiblingElement();
667 if ( !values.isEmpty() )
670 QString symbolName = catElem.attribute( QStringLiteral(
"symbol" ) );
671 QString label = catElem.attribute( QStringLiteral(
"label" ) );
672 bool render = catElem.attribute( QStringLiteral(
"render" ) ) != QLatin1String(
"false" );
673 if ( symbolMap.contains( symbolName ) )
675 QgsSymbol *symbol = symbolMap.take( symbolName );
679 catElem = catElem.nextSiblingElement();
682 QString attrName = element.attribute( QStringLiteral(
"attr" ) );
690 QDomElement sourceSymbolElem = element.firstChildElement( QStringLiteral(
"source-symbol" ) );
691 if ( !sourceSymbolElem.isNull() )
694 if ( sourceSymbolMap.contains( QStringLiteral(
"0" ) ) )
702 QDomElement sourceColorRampElem = element.firstChildElement( QStringLiteral(
"colorramp" ) );
703 if ( !sourceColorRampElem.isNull() && sourceColorRampElem.attribute( QStringLiteral(
"name" ) ) == QLatin1String(
"[source]" ) )
708 QDomElement rotationElem = element.firstChildElement( QStringLiteral(
"rotation" ) );
709 if ( !rotationElem.isNull() && !rotationElem.attribute( QStringLiteral(
"field" ) ).isEmpty() )
721 QDomElement sizeScaleElem = element.firstChildElement( QStringLiteral(
"sizescale" ) );
722 if ( !sizeScaleElem.isNull() && !sizeScaleElem.attribute( QStringLiteral(
"field" ) ).isEmpty() )
728 sizeScaleElem.attribute( QStringLiteral(
"field" ) ) );
734 sizeScaleElem.attribute( QStringLiteral(
"field" ) ) );
738 QDomElement ddsLegendSizeElem = element.firstChildElement( QStringLiteral(
"data-defined-size-legend" ) );
739 if ( !ddsLegendSizeElem.isNull() )
752 rendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"categorizedSymbol" ) );
753 rendererElem.setAttribute( QStringLiteral(
"symbollevels" ), (
mUsingSymbolLevels ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
754 rendererElem.setAttribute( QStringLiteral(
"forceraster" ), (
mForceRaster ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
755 rendererElem.setAttribute( QStringLiteral(
"attr" ),
mAttrName );
762 QDomElement catsElem = doc.createElement( QStringLiteral(
"categories" ) );
763 QgsCategoryList::const_iterator it =
mCategories.constBegin();
767 QString symbolName = QString::number( i );
768 symbols.insert( symbolName, cat.
symbol() );
770 QDomElement catElem = doc.createElement( QStringLiteral(
"category" ) );
771 if ( cat.
value().type() == QVariant::List )
773 const QVariantList list = cat.
value().toList();
774 for (
const QVariant &v : list )
776 QDomElement valueElem = doc.createElement( QStringLiteral(
"val" ) );
777 valueElem.setAttribute(
"value", v.toString() );
778 catElem.appendChild( valueElem );
783 catElem.setAttribute( QStringLiteral(
"value" ), cat.
value().toString() );
785 catElem.setAttribute( QStringLiteral(
"symbol" ), symbolName );
786 catElem.setAttribute( QStringLiteral(
"label" ), cat.
label() );
787 catElem.setAttribute( QStringLiteral(
"render" ), cat.
renderState() ?
"true" :
"false" );
788 catsElem.appendChild( catElem );
791 rendererElem.appendChild( catsElem );
795 rendererElem.appendChild( symbolsElem );
803 sourceSymbols.insert( QStringLiteral(
"0" ),
mSourceSymbol.get() );
805 rendererElem.appendChild( sourceSymbolElem );
812 rendererElem.appendChild( colorRampElem );
815 QDomElement rotationElem = doc.createElement( QStringLiteral(
"rotation" ) );
816 rendererElem.appendChild( rotationElem );
818 QDomElement sizeScaleElem = doc.createElement( QStringLiteral(
"sizescale" ) );
819 rendererElem.appendChild( sizeScaleElem );
826 QDomElement
orderBy = doc.createElement( QStringLiteral(
"orderby" ) );
828 rendererElem.appendChild( orderBy );
830 rendererElem.setAttribute( QStringLiteral(
"enableorderby" ), (
mOrderByEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
834 QDomElement ddsLegendElem = doc.createElement( QStringLiteral(
"data-defined-size-legend" ) );
836 rendererElem.appendChild( ddsLegendElem );
866 if ( sSize != ddSize )
869 return baseLegendSymbolItems();
886 lst += baseLegendSymbolItems();
891 return baseLegendSymbolItems();
896 QString value = valueForFeature( feature, context ).toString();
902 if ( cat.value().type() == QVariant::List )
904 const QVariantList list = cat.value().toList();
905 for (
const QVariant &v : list )
916 match = value == cat.value();
922 return QSet< QString >() << QString::number( i );
924 return QSet< QString >();
929 return QSet< QString >();
967 double value = count / num;
979 symbol->
setColor( cat.symbol()->color() );
994 int index = key.toInt( &ok );
995 if ( ok && index >= 0 && index <
mCategories.size() )
1004 int index = key.toInt( &ok );
1014 int index = key.toInt( &ok );
1022 if ( renderer->
type() == QLatin1String(
"categorizedSymbol" ) )
1026 else if ( renderer->
type() == QLatin1String(
"pointDisplacement" ) || renderer->
type() == QLatin1String(
"pointCluster" ) )
1029 if ( pointDistanceRenderer )
1032 else if ( renderer->
type() == QLatin1String(
"invertedPolygonRenderer" ) )
1035 if ( invertedPolygonRenderer )
1047 if ( !symbols.isEmpty() )
1076 const QSet< QString > allSymbolNames = unmatchedSymbols.toSet();
1078 const QRegularExpression tolerantMatchRe( QStringLiteral(
"[^\\w\\d ]" ), QRegularExpression::UseUnicodePropertiesOption );
1080 for (
int catIdx = 0; catIdx <
mCategories.count(); ++catIdx )
1082 const QVariant value =
mCategories.at( catIdx ).value();
1083 const QString val = value.toString().trimmed();
1084 std::unique_ptr< QgsSymbol > symbol( style->
symbol( val ) );
1086 if ( symbol && symbol->type() ==
type )
1089 unmatchedSymbols.removeAll( val );
1094 if ( !caseSensitive || useTolerantMatch )
1096 QString testVal = val;
1097 if ( useTolerantMatch )
1098 testVal.replace( tolerantMatchRe, QString() );
1100 bool foundMatch =
false;
1101 for (
const QString &name : allSymbolNames )
1103 QString testName = name.trimmed();
1104 if ( useTolerantMatch )
1105 testName.replace( tolerantMatchRe, QString() );
1107 if ( testName == testVal || ( !caseSensitive && testName.trimmed().compare( testVal, Qt::CaseInsensitive ) == 0 ) )
1110 std::unique_ptr< QgsSymbol > symbol( style->
symbol( name ) );
1111 if ( symbol && symbol->type() ==
type )
1114 unmatchedSymbols.removeAll( name );
1125 unmatchedCategories << value;
1134 QVariantList vals = values;
1138 if ( layer && !attributeName.isNull() )
1141 for (
const QVariant &value : vals )
1144 if ( !value.isNull() )
1146 int fieldIdx = fields.
lookupField( attributeName );
1147 QString categoryName = value.toString();
1148 if ( fieldIdx != -1 )
1150 const QgsField field = fields.
at( fieldIdx );
1153 categoryName = formatter->
representValue( layer, fieldIdx, setup.
config(), QVariant(), value );
An abstract base class for distance based point renderers (e.g., clusterer and displacement renderers...
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QString label() const
Returns the label for this category, which is used to represent the category within legends and the l...
Q_DECL_DEPRECATED QgsSymbol * skipRender()
Class for parsing and evaluation of expressions (formerly called "search strings").
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
The class is used as a container of context for various read/write operations on other objects...
double rendererScale() const
Returns the renderer map scale.
QgsSymbolList symbols(QgsRenderContext &context) const override
Returns list of symbols used by the renderer.
static QgsSymbol::ScaleMethod decodeScaleMethod(const QString &str)
static QgsFieldFormatterRegistry * fieldFormatterRegistry()
Gets the registry of available field formatters.
QList< QgsLegendSymbolItem > QgsLegendSymbolList
QgsFeatureRequest::OrderBy mOrderBy
Represents an individual category (class) from a QgsCategorizedSymbolRenderer.
void updateColorRamp(QgsColorRamp *ramp)
Update the color ramp used and all symbols colors.
static bool createFunctionElement(QDomDocument &doc, QDomElement &element, const QString &function)
Abstract base class for all rendered symbols.
bool updateCategoryRenderState(int catIndex, bool render)
Changes the render state for the category with the specified index.
static void applyScaleDependency(QDomDocument &doc, QDomElement &ruleElem, QgsStringMap &props)
Checks if the properties contain scaleMinDenom and scaleMaxDenom, if available, they are added into t...
static QgsFeatureRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
Creates a categorized renderer from an XML element.
QgsSymbol * symbol() const
Returns the symbol which will be used to render this category.
bool filterNeedsGeometry() const override
Returns true if this renderer requires the geometry to apply the filter.
QgsFeatureRequest::OrderBy orderBy() const
Gets the order in which features shall be processed by this renderer.
QgsCategorizedSymbolRenderer(const QString &attrName=QString(), const QgsCategoryList &categories=QgsCategoryList())
Constructor for QgsCategorizedSymbolRenderer.
Abstract base class for color ramps.
void moveCategory(int from, int to)
Moves an existing category at index position from to index position to.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
static QDomElement saveColorRamp(const QString &name, QgsColorRamp *ramp, QDomDocument &doc)
Encodes a color ramp's settings to an XML element.
QString filter(const QgsFields &fields=QgsFields()) override
If a renderer does not require all the features this method may be overridden and return an expressio...
Container of fields for a vector layer.
#define RENDERER_TAG_NAME
void setUsingSymbolLevels(bool usingSymbolLevels)
void checkLegendSymbolItem(const QString &key, bool state=true) override
item in symbology was checked
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
bool updateCategoryLabel(int catIndex, const QString &label)
Changes the label for the category with the specified index.
static void clearSymbolMap(QgsSymbolMap &symbols)
QgsLegendSymbolList legendSymbolItems() const override
Returns a list of symbology items for the legend.
QgsPaintEffect * mPaintEffect
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
std::unique_ptr< QgsSymbol > mSourceSymbol
int categoryIndexForLabel(const QString &val)
Returns the index of the category with the specified label (or -1 if the label was not found...
QgsLegendSymbolList legendSymbolList() const
Generates legend symbol items according to the configuration.
bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is greater than the second.
void swap(QgsRendererCategory &other)
QMap< QString, QString > QgsStringMap
A marker symbol type, for rendering Point and MultiPoint geometries.
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
bool valueGreaterThan(const QgsRendererCategory &c1, const QgsRendererCategory &c2)
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
QList< QgsRendererCategory > QgsCategoryList
SymbolType
Type of the symbol.
QgsCategorizedSymbolRenderer * clone() const override
Create a deep copy of this renderer.
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) override
store renderer info to XML element
static QgsCategoryList createCategories(const QVariantList &values, const QgsSymbol *symbol, QgsVectorLayer *layer=nullptr, const QString &fieldName=QString())
Create categories for a list of values.
QgsDataDefinedSizeLegend * dataDefinedSizeLegend() const
Returns configuration of appearance of legend when using data-defined size for marker symbols...
QList< QgsSymbol * > QgsSymbolList
QgsFields fields() const FINAL
Returns the list of fields of this layer.
void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
Converts the category to a matching SLD rule, within the specified DOM document and element...
QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted...
#define QgsDebugMsgLevel(str, level)
QStringList symbolNames()
Returns a list of names of symbols.
static QDomElement saveSymbols(QgsSymbolMap &symbols, const QString &tagName, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a collection of symbols to XML with specified tagName for the top-level element.
bool labelGreaterThan(const QgsRendererCategory &c1, const QgsRendererCategory &c2)
std::unique_ptr< QgsSymbol > mSymbol
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsCategoryList mCategories
QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns symbol for feature.
void sortByLabel(Qt::SortOrder order=Qt::AscendingOrder)
Sorts the existing categories by their label.
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
void updateFromSymbolAndProperty(const QgsMarkerSymbol *symbol, const QgsProperty &ddSize)
Updates the list of classes, source symbol and title label from given symbol and property.
static QgsColorRamp * loadColorRamp(QDomElement &element)
Creates a color ramp from the settings encoded in an XML element.
static void convertSymbolSizeScale(QgsSymbol *symbol, QgsSymbol::ScaleMethod method, const QString &field)
bool legendSymbolItemChecked(const QString &key) override
items of symbology items in legend is checked
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
void setLegendSymbolItem(const QString &key, QgsSymbol *symbol) override
Sets the symbol to be used for a legend symbol item.
Encapsulate a field in an attribute table or data source.
QgsSymbol * sourceSymbol()
Returns the renderer's source symbol, which is the base symbol used for the each categories' symbol b...
A store for object properties.
void deleteAllCategories()
Deletes all existing categories from the renderer.
virtual void setTotalColorCount(int colorCount)
Sets the desired total number of unique colors for the resultant ramp.
static QgsSymbolMap loadSymbols(QDomElement &element, const QgsReadWriteContext &context)
Reads a collection of symbols from XML and returns them in a map. Caller is responsible for deleting ...
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer...
bool renderState() const
Returns true if the category is currently enabled and should be rendered.
void setSymbol(QgsSymbol *s)
Sets the symbol which will be used to render this category.
bool labelLessThan(const QgsRendererCategory &c1, const QgsRendererCategory &c2)
void setRenderState(bool render)
Sets whether the category is currently enabled and should be rendered.
void setOrderBy(const QgsFeatureRequest::OrderBy &orderBy)
Define the order in which features shall be processed by this renderer.
Totally random color ramp.
QVariant value() const
Returns the value corresponding to this category.
int matchToSymbols(QgsStyle *style, QgsSymbol::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...
Q_DECL_DEPRECATED QgsSymbol * symbolForValue(const QVariant &value) const
Returns the matching symbol corresponding to an attribute value.
QString dump() const override
Returns debug information about this renderer.
QgsExpressionContext & expressionContext()
Gets the expression context.
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
void setDataDefinedSizeLegend(QgsDataDefinedSizeLegend *settings)
Configures appearance of legend when renderer is configured to use data-defined size for marker symbo...
bool legendSymbolItemsCheckable() const override
items of symbology items in legend should be checkable
static void sortVariantList(QList< QVariant > &list, Qt::SortOrder order)
Sorts the passed list in requested order.
static void convertSymbolRotation(QgsSymbol *symbol, const QString &field)
const QgsFeatureRenderer * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns a list of attributes required to render this feature.
void addCategory(const QgsRendererCategory &category)
Adds a new category to the renderer.
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
Contains information about the context of a rendering operation.
void setSourceColorRamp(QgsColorRamp *ramp)
Sets the source color ramp.
bool usingSymbolLevels() const
QgsColorRamp * sourceColorRamp()
Returns the source color ramp, from which each categories' color is derived.
QSet< QString > legendKeysForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns legend keys matching a specified feature.
QgsRendererCategory & operator=(QgsRendererCategory cat)
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
std::unique_ptr< QgsColorRamp > mSourceColorRamp
void CORE_EXPORT save(QDomElement &elem) const
Serialize to XML.
int categoryIndexForValue(const QVariant &val)
Returns the index for the category with the specified value (or -1 if not found). ...
bool updateCategoryValue(int catIndex, const QVariant &value)
Changes the value for the category with the specified index.
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
QMap< QString, QgsSymbol *> QgsSymbolMap
bool updateCategorySymbol(int catIndex, QgsSymbol *symbol)
Changes the symbol for the category with the specified index.
bool valueLessThan(const QgsRendererCategory &c1, const QgsRendererCategory &c2)
QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
To be overridden.
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
static QgsCategorizedSymbolRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
creates a QgsCategorizedSymbolRenderer from an existing renderer.
QHash< QString, QgsSymbol * > mSymbolHash
hashtable for faster access to symbols
void appendScopes(const QList< QgsExpressionContextScope *> &scopes)
Appends a list of scopes to the end of the context.
void sortByValue(Qt::SortOrder order=Qt::AscendingOrder)
Sorts the existing categories by their value.
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
void updateSymbols(QgsSymbol *sym)
Update all the symbols but leave categories and colors.
QString dump() const
Returns a string representing the categories settings, used for debugging purposes only...
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required...
const QgsFeatureRenderer * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
QgsRendererCategory()=default
Constructor for QgsRendererCategory.
Represents a vector layer which manages a vector based data sets.
Object that keeps configuration of appearance of marker symbol's data-defined size in legend...
std::unique_ptr< QgsExpression > mExpression
int mAttrNum
attribute index (derived from attribute name in startRender)
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props=QgsStringMap()) const override
used from subclasses to create SLD Rule elements following SLD v1.1 specs
void setSourceSymbol(QgsSymbol *sym)
Sets the source symbol for the renderer, which is the base symbol used for the each categories' symbo...
void setLabel(const QString &label)
Sets the label for this category, which is used to represent the category within legends and the laye...
static QgsDataDefinedSizeLegend * readXml(const QDomElement &elem, const QgsReadWriteContext &context) SIP_FACTORY
Creates instance from given element and returns it (caller takes ownership). Returns nullptr on error...
bool deleteCategory(int catIndex)
Deletes the category with the specified index from the renderer.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns a list of attributes required by this renderer.
void setOrderByEnabled(bool enabled)
Sets whether custom ordering should be applied before features are processed by this renderer...
void setValue(const QVariant &value)
Sets the value corresponding to this category.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
bool isActive() const
Returns whether the property is currently active.
std::unique_ptr< QgsDataDefinedSizeLegend > mDataDefinedSizeLegend
void setColor(const QColor &color)
Sets the color for the symbol.
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.