QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
40 #include <QDomDocument>
41 #include <QDomElement>
53 : mValue( cat.mValue )
54 , mSymbol( cat.mSymbol ? cat.mSymbol->clone() : nullptr )
55 , mLabel( cat.mLabel )
56 , mRender( cat.mRender )
121 if ( !
mSymbol.get() || props.value( QStringLiteral(
"attribute" ), QString() ).isEmpty() )
124 QString attrName = props[ QStringLiteral(
"attribute" )];
126 QDomElement ruleElem = doc.createElement( QStringLiteral(
"se:Rule" ) );
127 element.appendChild( ruleElem );
129 QDomElement nameElem = doc.createElement( QStringLiteral(
"se:Name" ) );
130 nameElem.appendChild( doc.createTextNode(
mLabel ) );
131 ruleElem.appendChild( nameElem );
133 QDomElement descrElem = doc.createElement( QStringLiteral(
"se:Description" ) );
134 QDomElement titleElem = doc.createElement( QStringLiteral(
"se:Title" ) );
135 QString descrStr = QStringLiteral(
"%1 is '%2'" ).arg( attrName,
mValue.toString() );
136 titleElem.appendChild( doc.createTextNode( !
mLabel.isEmpty() ?
mLabel : descrStr ) );
137 descrElem.appendChild( titleElem );
138 ruleElem.appendChild( descrElem );
144 filterFunc = QStringLiteral(
"%1 = '%2' or %1 is null" )
145 .arg( attrName.replace(
'\"', QLatin1String(
"\"\"" ) ),
146 mValue.toString().replace(
'\'', QLatin1String(
"''" ) ) );
150 filterFunc = QStringLiteral(
"%1 = '%2'" )
151 .arg( attrName.replace(
'\"', QLatin1String(
"\"\"" ) ),
152 mValue.toString().replace(
'\'', QLatin1String(
"''" ) ) );
160 mSymbol->toSld( doc, ruleElem, props );
167 , mAttrName( attrName )
176 QgsDebugMsg( QStringLiteral(
"invalid symbol in a category! ignoring..." ) );
190 const QVariant val = cat.value();
191 if ( val.type() == QVariant::List )
193 const QVariantList list = val.toList();
194 for (
const QVariant &v : list )
196 mSymbolHash.insert( v.toString(), ( cat.renderState() ||
mCounting ) ? cat.symbol() :
nullptr );
201 mSymbolHash.insert( val.toString(), ( cat.renderState() ||
mCounting ) ? cat.symbol() :
nullptr );
219 foundMatchingSymbol =
false;
222 QHash<QString, QgsSymbol *>::const_iterator it =
mSymbolHash.constFind( value.isNull() ? QString() : value.toString() );
227 QgsDebugMsg( QStringLiteral(
"there are no hashed symbols!!!" ) );
236 foundMatchingSymbol =
true;
266 QVariant value = valueForFeature( feature, context );
268 bool foundCategory =
false;
272 if ( !foundCategory )
310 if ( catIndex < 0 || catIndex >=
mCategories.size() )
318 if ( catIndex < 0 || catIndex >=
mCategories.size() )
326 if ( catIndex < 0 || catIndex >=
mCategories.size() )
334 if ( catIndex < 0 || catIndex >=
mCategories.size() )
344 QgsDebugMsg( QStringLiteral(
"invalid symbol in a category! ignoring..." ) );
353 if ( catIndex < 0 || catIndex >=
mCategories.size() )
382 if ( order == Qt::AscendingOrder )
394 return QString::localeAwareCompare( c1.
label(), c2.
label() ) < 0;
404 if ( order == Qt::AscendingOrder )
433 cat.symbol()->startRender( context, fields );
443 cat.symbol()->stopRender( context );
450 QSet<QString> attributes;
462 QgsCategoryList::const_iterator catIt =
mCategories.constBegin();
489 QString s = QStringLiteral(
"CATEGORIZED: idx %1\n" ).arg(
mAttrName );
514 newProps[ QStringLiteral(
"attribute" )] =
mAttrName;
519 it->toSld( doc, element, newProps );
526 bool isExpression = ( attrNum == -1 );
528 bool hasDefault =
false;
529 bool defaultActive =
false;
530 bool allActive =
true;
531 bool noneActive =
true;
535 QString activeValues;
536 QString inactiveValues;
540 if ( cat.value() ==
"" || cat.value().isNull() )
543 defaultActive = cat.renderState();
546 noneActive = noneActive && !cat.renderState();
547 allActive = allActive && cat.renderState();
549 QVariant::Type valType = isExpression ? cat.value().type() : fields.
at( attrNum ).
type();
550 const bool isList = cat.value().type() == QVariant::List;
553 if ( !cat.renderState() )
555 if ( cat.value() !=
"" )
559 const QVariantList list = cat.value().toList();
560 for (
const QVariant &v : list )
562 if ( !inactiveValues.isEmpty() )
563 inactiveValues.append(
',' );
570 if ( !inactiveValues.isEmpty() )
571 inactiveValues.append(
',' );
573 inactiveValues.append( value );
579 if ( cat.value() !=
"" )
583 const QVariantList list = cat.value().toList();
584 for (
const QVariant &v : list )
586 if ( !activeValues.isEmpty() )
587 activeValues.append(
',' );
594 if ( !activeValues.isEmpty() )
595 activeValues.append(
',' );
597 activeValues.append( value );
603 QString attr = isExpression ?
mAttrName : QStringLiteral(
"\"%1\"" ).arg(
mAttrName );
605 if ( allActive && hasDefault )
609 else if ( noneActive )
611 return QStringLiteral(
"FALSE" );
613 else if ( defaultActive )
615 return QStringLiteral(
"(%1) NOT IN (%2) OR (%1) IS NULL" ).arg( attr, inactiveValues );
619 return QStringLiteral(
"(%1) IN (%2)" ).arg( attr, activeValues );
630 lst.append( cat.symbol() );
656 QDomElement symbolsElem = element.firstChildElement( QStringLiteral(
"symbols" ) );
657 if ( symbolsElem.isNull() )
660 QDomElement catsElem = element.firstChildElement( QStringLiteral(
"categories" ) );
661 if ( catsElem.isNull() )
667 QDomElement catElem = catsElem.firstChildElement();
668 while ( !catElem.isNull() )
670 if ( catElem.tagName() == QLatin1String(
"category" ) )
673 if ( catElem.hasAttribute( QStringLiteral(
"value" ) ) )
675 value = QVariant( catElem.attribute( QStringLiteral(
"value" ) ) );
680 QDomElement valElem = catElem.firstChildElement();
681 while ( !valElem.isNull() )
683 if ( valElem.tagName() == QLatin1String(
"val" ) )
685 values << QVariant( valElem.attribute( QStringLiteral(
"value" ) ) );
687 valElem = valElem.nextSiblingElement();
689 if ( !values.isEmpty() )
692 QString symbolName = catElem.attribute( QStringLiteral(
"symbol" ) );
693 QString label = catElem.attribute( QStringLiteral(
"label" ) );
694 bool render = catElem.attribute( QStringLiteral(
"render" ) ) != QLatin1String(
"false" );
695 if ( symbolMap.contains( symbolName ) )
697 QgsSymbol *symbol = symbolMap.take( symbolName );
701 catElem = catElem.nextSiblingElement();
704 QString attrName = element.attribute( QStringLiteral(
"attr" ) );
712 QDomElement sourceSymbolElem = element.firstChildElement( QStringLiteral(
"source-symbol" ) );
713 if ( !sourceSymbolElem.isNull() )
716 if ( sourceSymbolMap.contains( QStringLiteral(
"0" ) ) )
724 QDomElement sourceColorRampElem = element.firstChildElement( QStringLiteral(
"colorramp" ) );
725 if ( !sourceColorRampElem.isNull() && sourceColorRampElem.attribute( QStringLiteral(
"name" ) ) == QLatin1String(
"[source]" ) )
730 QDomElement rotationElem = element.firstChildElement( QStringLiteral(
"rotation" ) );
731 if ( !rotationElem.isNull() && !rotationElem.attribute( QStringLiteral(
"field" ) ).isEmpty() )
743 QDomElement sizeScaleElem = element.firstChildElement( QStringLiteral(
"sizescale" ) );
744 if ( !sizeScaleElem.isNull() && !sizeScaleElem.attribute( QStringLiteral(
"field" ) ).isEmpty() )
750 sizeScaleElem.attribute( QStringLiteral(
"field" ) ) );
756 sizeScaleElem.attribute( QStringLiteral(
"field" ) ) );
760 QDomElement ddsLegendSizeElem = element.firstChildElement( QStringLiteral(
"data-defined-size-legend" ) );
761 if ( !ddsLegendSizeElem.isNull() )
774 rendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"categorizedSymbol" ) );
775 rendererElem.setAttribute( QStringLiteral(
"symbollevels" ), (
mUsingSymbolLevels ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
776 rendererElem.setAttribute( QStringLiteral(
"forceraster" ), (
mForceRaster ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
777 rendererElem.setAttribute( QStringLiteral(
"attr" ),
mAttrName );
784 QDomElement catsElem = doc.createElement( QStringLiteral(
"categories" ) );
785 QgsCategoryList::const_iterator it =
mCategories.constBegin();
789 QString symbolName = QString::number( i );
792 QDomElement catElem = doc.createElement( QStringLiteral(
"category" ) );
793 if ( cat.
value().type() == QVariant::List )
795 const QVariantList list = cat.
value().toList();
796 for (
const QVariant &v : list )
798 QDomElement valueElem = doc.createElement( QStringLiteral(
"val" ) );
799 valueElem.setAttribute(
"value", v.toString() );
800 catElem.appendChild( valueElem );
805 catElem.setAttribute( QStringLiteral(
"value" ), cat.
value().toString() );
807 catElem.setAttribute( QStringLiteral(
"symbol" ), symbolName );
808 catElem.setAttribute( QStringLiteral(
"label" ), cat.
label() );
809 catElem.setAttribute( QStringLiteral(
"render" ), cat.
renderState() ?
"true" :
"false" );
810 catsElem.appendChild( catElem );
813 rendererElem.appendChild( catsElem );
817 rendererElem.appendChild( symbolsElem );
825 sourceSymbols.insert( QStringLiteral(
"0" ),
mSourceSymbol.get() );
827 rendererElem.appendChild( sourceSymbolElem );
834 rendererElem.appendChild( colorRampElem );
837 QDomElement rotationElem = doc.createElement( QStringLiteral(
"rotation" ) );
838 rendererElem.appendChild( rotationElem );
840 QDomElement sizeScaleElem = doc.createElement( QStringLiteral(
"sizescale" ) );
841 rendererElem.appendChild( sizeScaleElem );
848 QDomElement
orderBy = doc.createElement( QStringLiteral(
"orderby" ) );
850 rendererElem.appendChild(
orderBy );
852 rendererElem.setAttribute( QStringLiteral(
"enableorderby" ), (
mOrderByEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
856 QDomElement ddsLegendElem = doc.createElement( QStringLiteral(
"data-defined-size-legend" ) );
858 rendererElem.appendChild( ddsLegendElem );
888 if ( sSize != ddSize )
891 return baseLegendSymbolItems();
908 lst += baseLegendSymbolItems();
913 return baseLegendSymbolItems();
918 QString value = valueForFeature( feature, context ).toString();
924 if ( cat.value().type() == QVariant::List )
926 const QVariantList list = cat.value().toList();
927 for (
const QVariant &v : list )
938 match = value == cat.value();
944 return QSet< QString >() << QString::number( i );
946 return QSet< QString >();
951 return QSet< QString >();
1000 double value = count / num;
1012 symbol->
setColor( cat.symbol()->color() );
1027 int index = key.toInt( &ok );
1028 if ( ok && index >= 0 && index <
mCategories.size() )
1037 int index = key.toInt( &ok );
1047 int index = key.toInt( &ok );
1054 std::unique_ptr< QgsCategorizedSymbolRenderer > r;
1055 if ( renderer->
type() == QLatin1String(
"categorizedSymbol" ) )
1059 else if ( renderer->
type() == QLatin1String(
"graduatedSymbol" ) )
1062 if ( graduatedSymbolRenderer )
1071 r->setClassAttribute( graduatedSymbolRenderer->
classAttribute() );
1074 else if ( renderer->
type() == QLatin1String(
"pointDisplacement" ) || renderer->
type() == QLatin1String(
"pointCluster" ) )
1077 if ( pointDistanceRenderer )
1080 else if ( renderer->
type() == QLatin1String(
"invertedPolygonRenderer" ) )
1083 if ( invertedPolygonRenderer )
1092 r = qgis::make_unique< QgsCategorizedSymbolRenderer >( QString(),
QgsCategoryList() );
1097 r->setSourceSymbol(
symbols.at( 0 )->clone() );
1101 r->setOrderBy( renderer->
orderBy() );
1124 const QSet< QString > allSymbolNames = qgis::listToSet( unmatchedSymbols );
1126 const QRegularExpression tolerantMatchRe( QStringLiteral(
"[^\\w\\d ]" ), QRegularExpression::UseUnicodePropertiesOption );
1128 for (
int catIdx = 0; catIdx <
mCategories.count(); ++catIdx )
1130 const QVariant value =
mCategories.at( catIdx ).value();
1131 const QString val = value.toString().trimmed();
1132 std::unique_ptr< QgsSymbol > symbol( style->
symbol( val ) );
1134 if ( symbol && symbol->type() ==
type )
1137 unmatchedSymbols.removeAll( val );
1142 if ( !caseSensitive || useTolerantMatch )
1144 QString testVal = val;
1145 if ( useTolerantMatch )
1146 testVal.replace( tolerantMatchRe, QString() );
1148 bool foundMatch =
false;
1149 for (
const QString &name : allSymbolNames )
1151 QString testName = name.trimmed();
1152 if ( useTolerantMatch )
1153 testName.replace( tolerantMatchRe, QString() );
1155 if ( testName == testVal || ( !caseSensitive && testName.trimmed().compare( testVal, Qt::CaseInsensitive ) == 0 ) )
1158 std::unique_ptr< QgsSymbol > symbol( style->
symbol( name ) );
1159 if ( symbol && symbol->type() ==
type )
1162 unmatchedSymbols.removeAll( name );
1173 unmatchedCategories << value;
1182 QVariantList vals = values;
1186 if ( layer && !attributeName.isNull() )
1189 for (
const QVariant &value : vals )
1192 if ( !value.isNull() )
1194 int fieldIdx = fields.
lookupField( attributeName );
1195 QString categoryName = value.toString();
1196 if ( fieldIdx != -1 )
1201 categoryName =
formatter->representValue( layer, fieldIdx, setup.
config(), QVariant(), value );
QString dump() const override
Returns debug information about this renderer.
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) override
store renderer info to XML element
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
bool isActive() const
Returns whether the property is currently active.
Abstract base class for color ramps.
void appendScopes(const QList< QgsExpressionContextScope * > &scopes)
Appends a list of scopes to the end of the context.
QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
To be overridden.
QgsPaintEffect * mPaintEffect
void setLabel(const QString &label)
Sets the label for this category, which is used to represent the category within legends and the laye...
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 ...
static QgsCategorizedSymbolRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
creates a QgsCategorizedSymbolRenderer from an existing renderer.
A store for object properties.
QgsExpressionContext & expressionContext()
Gets the expression context.
The class is used as a container of context for various read/write operations on other objects.
QString classAttribute() const
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
QgsDataDefinedSizeLegend * dataDefinedSizeLegend() const
Returns configuration of appearance of legend when using data-defined size for marker symbols.
QgsCategorizedSymbolRenderer * clone() const override
Create a deep copy of this renderer.
#define QgsDebugMsgLevel(str, level)
void CORE_EXPORT save(QDomElement &elem) const
Serialize to XML.
A symbol entity for QgsStyle databases.
QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns symbol for feature.
void updateSymbols(QgsSymbol *sym)
Update all the symbols but leave categories and colors.
bool labelLessThan(const QgsRendererCategory &c1, const QgsRendererCategory &c2)
std::unique_ptr< QgsColorRamp > mSourceColorRamp
void sortByLabel(Qt::SortOrder order=Qt::AscendingOrder)
Sorts the existing categories by their label.
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
QMap< QString, QgsSymbol * > QgsSymbolMap
bool updateCategorySymbol(int catIndex, QgsSymbol *symbol)
Changes the symbol for the category with the specified index.
A color ramp entity for QgsStyle databases.
static QgsSymbol::ScaleMethod decodeScaleMethod(const QString &str)
const QgsCategoryList & categories() const
Returns a list of all categories recognized by the renderer.
Container of fields for a vector layer.
void setLegendSymbolItem(const QString &key, QgsSymbol *symbol) override
Sets the symbol to be used for a legend symbol item.
static void convertSymbolRotation(QgsSymbol *symbol, const QString &field)
Object that keeps configuration of appearance of marker symbol's data-defined size in legend.
Represents an individual category (class) from a QgsCategorizedSymbolRenderer.
Contains information about the context of a rendering operation.
An interface for classes which can visit style entity (e.g.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
std::unique_ptr< QgsDataDefinedSizeLegend > mDataDefinedSizeLegend
const QgsFeatureRenderer * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
Abstract base class for all rendered symbols.
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
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.
bool legendSymbolItemChecked(const QString &key) override
items of symbology items in legend is checked
int mAttrNum
attribute index (derived from attribute name in startRender)
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.
void setDataDefinedSizeLegend(QgsDataDefinedSizeLegend *settings)
Configures appearance of legend when renderer is configured to use data-defined size for marker symbo...
Contains information relating to the style entity currently being visited.
QgsSymbol * sourceSymbol()
Returns the renderer's source symbol, which is the base symbol used for the each classes' symbol befo...
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
bool legendSymbolItemsCheckable() const override
items of symbology items in legend should be checkable
QgsFeatureRequest::OrderBy orderBy() const
Gets the order in which features shall be processed by this renderer.
Totally random color ramp.
bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is greater than the second.
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required.
static void sortVariantList(QList< QVariant > &list, Qt::SortOrder order)
Sorts the passed list in requested order.
Q_DECL_DEPRECATED QgsSymbol * skipRender()
QgsFields fields() const FINAL
Returns the list of fields of this layer.
Q_DECL_DEPRECATED QgsSymbol * symbolForValue(const QVariant &value) const
Returns the matching symbol corresponding to an attribute value.
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
QgsLegendSymbolList legendSymbolList() const
Generates legend symbol items according to the configuration.
~QgsCategorizedSymbolRenderer() override
QgsSymbolList symbols(QgsRenderContext &context) const override
Returns list of symbols used by the renderer.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
const QgsFeatureRenderer * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
QgsRendererCategory & operator=(QgsRendererCategory cat)
bool updateCategoryValue(int catIndex, const QVariant &value)
Changes the value for the category with the specified index.
bool valueGreaterThan(const QgsRendererCategory &c1, const QgsRendererCategory &c2)
int categoryIndexForValue(const QVariant &val)
Returns the index for the category with the specified value (or -1 if not found).
QgsCategorizedSymbolRenderer(const QString &attrName=QString(), const QgsCategoryList &categories=QgsCategoryList())
Constructor for QgsCategorizedSymbolRenderer.
void moveCategory(int from, int to)
Moves an existing category at index position from to index position to.
void setUsingSymbolLevels(bool usingSymbolLevels)
bool filterNeedsGeometry() const override
Returns true if this renderer requires the geometry to apply the filter.
QList< QgsRendererCategory > QgsCategoryList
void setSymbol(QgsSymbol *s)
Sets the symbol which will be used to render this category.
QList< QgsSymbol * > QgsSymbolList
A marker symbol type, for rendering Point and MultiPoint geometries.
bool updateCategoryRenderState(int catIndex, bool render)
Changes the render state for the category with the specified index.
virtual void setTotalColorCount(int colorCount)
Sets the desired total number of unique colors for the resultant ramp.
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...
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
void setRenderState(bool render)
Sets whether the category is currently enabled and should be rendered.
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
QgsSymbol * symbol() const
Returns the symbol which will be used to render this category.
static QDomElement saveColorRamp(const QString &name, QgsColorRamp *ramp, QDomDocument &doc)
Encodes a color ramp's settings to an XML element.
static QgsFeatureRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
Creates a categorized renderer from an XML element.
#define RENDERER_TAG_NAME
An abstract base class for distance based point renderers (e.g., clusterer and displacement renderers...
QgsLegendSymbolList legendSymbolItems() const override
Returns a list of symbology items for the legend.
std::unique_ptr< QgsSymbol > mSourceSymbol
bool usingSymbolLevels() const
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
std::unique_ptr< QgsExpression > mExpression
QHash< QString, QgsSymbol * > mSymbolHash
hashtable for faster access to symbols
QgsRendererCategory()=default
Constructor for QgsRendererCategory.
bool deleteCategory(int catIndex)
Deletes the category with the specified index from the renderer.
bool updateCategoryLabel(int catIndex, const QString &label)
Changes the label for the category with the specified index.
void swap(QgsRendererCategory &other)
void sortByValue(Qt::SortOrder order=Qt::AscendingOrder)
Sorts the existing categories by their value.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns a list of attributes required by this renderer.
void setSourceSymbol(QgsSymbol *sym)
Sets the source symbol for the renderer, which is the base symbol used for the each classes' symbol b...
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
virtual QgsColorRamp * clone() const =0
Creates a clone of the color ramp.
static QgsFieldFormatterRegistry * fieldFormatterRegistry()
Gets the registry of available field formatters.
static QgsColorRamp * loadColorRamp(QDomElement &element)
Creates a color ramp from the settings encoded in an XML element.
int categoryIndexForLabel(const QString &val)
Returns the index of the category with the specified label (or -1 if the label was not found,...
bool valueLessThan(const QgsRendererCategory &c1, const QgsRendererCategory &c2)
QStringList symbolNames() const
Returns a list of names of symbols.
static void applyScaleDependency(QDomDocument &doc, QDomElement &ruleElem, QgsStringMap &props)
Checks if the properties contain scaleMinDenom and scaleMaxDenom, if available, they are added into t...
QgsFeatureRequest::OrderBy mOrderBy
void updateFromSymbolAndProperty(const QgsMarkerSymbol *symbol, const QgsProperty &ddSize)
Updates the list of classes, source symbol and title label from given symbol and property.
void setSourceSymbol(QgsSymbol *sym)
Sets the source symbol for the renderer, which is the base symbol used for the each categories' symbo...
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
QString label() const
Returns the label for this category, which is used to represent the category within legends and the l...
QMap< QString, QString > QgsStringMap
bool renderState() const
Returns true if the category is currently enabled and should be rendered.
static QgsCategoryList createCategories(const QVariantList &values, const QgsSymbol *symbol, QgsVectorLayer *layer=nullptr, const QString &fieldName=QString())
Create categories for a list of values.
void setColor(const QColor &color)
Sets the color for the symbol.
Represents a vector layer which manages a vector based data sets.
void updateColorRamp(QgsColorRamp *ramp)
Update the color ramp used and all symbols colors.
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 orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer.
void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
Converts the category to a matching SLD rule, within the specified DOM document and element.
static void convertSymbolSizeScale(QgsSymbol *symbol, QgsSymbol::ScaleMethod method, const QString &field)
QString dump() const
Returns a string representing the categories settings, used for debugging purposes only.
QgsColorRamp * sourceColorRamp()
Returns the source color ramp, from which each classes' color is derived.
static void clearSymbolMap(QgsSymbolMap &symbols)
QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns a list of attributes required to render this feature.
bool labelGreaterThan(const QgsRendererCategory &c1, const QgsRendererCategory &c2)
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
QgsSymbol * sourceSymbol()
Returns the renderer's source symbol, which is the base symbol used for the each categories' symbol b...
QgsCategoryList mCategories
void setValue(const QVariant &value)
Sets the value corresponding to this category.
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...
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void deleteAllCategories()
Deletes all existing categories from the renderer.
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
SymbolType
Type of the symbol.
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
double rendererScale() const
Returns the renderer map scale.
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
Class for parsing and evaluation of expressions (formerly called "search strings").
QList< QgsLegendSymbolItem > QgsLegendSymbolList
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
QVariant value() const
Returns the value corresponding to this category.
void setSourceColorRamp(QgsColorRamp *ramp)
Sets the source color ramp.
void addCategory(const QgsRendererCategory &category)
Adds a new category to the renderer.
std::unique_ptr< QgsSymbol > mSymbol
void checkLegendSymbolItem(const QString &key, bool state=true) override
item in symbology was checked
QSet< QString > legendKeysForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns legend keys matching a specified feature.
QgsColorRamp * sourceColorRamp()
Returns the source color ramp, from which each categories' color is derived.
static bool createFunctionElement(QDomDocument &doc, QDomElement &element, const QString &function)
QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted,...
Encapsulate a field in an attribute table or data source.