40 #include <QDomDocument>
41 #include <QDomElement>
43 #include <QRegularExpression>
54 : mValue( cat.mValue )
55 , mSymbol( cat.mSymbol ? cat.mSymbol->clone() : nullptr )
56 , mLabel( cat.mLabel )
57 , mRender( cat.mRender )
122 if ( !
mSymbol.get() || props.value( QStringLiteral(
"attribute" ), QString() ).toString().isEmpty() )
125 QString attrName = props[ QStringLiteral(
"attribute" )].toString();
127 QDomElement ruleElem = doc.createElement( QStringLiteral(
"se:Rule" ) );
128 element.appendChild( ruleElem );
130 QDomElement nameElem = doc.createElement( QStringLiteral(
"se:Name" ) );
131 nameElem.appendChild( doc.createTextNode(
mLabel ) );
132 ruleElem.appendChild( nameElem );
134 QDomElement descrElem = doc.createElement( QStringLiteral(
"se:Description" ) );
135 QDomElement titleElem = doc.createElement( QStringLiteral(
"se:Title" ) );
136 QString descrStr = QStringLiteral(
"%1 is '%2'" ).arg( attrName,
mValue.toString() );
137 titleElem.appendChild( doc.createTextNode( !
mLabel.isEmpty() ?
mLabel : descrStr ) );
138 descrElem.appendChild( titleElem );
139 ruleElem.appendChild( descrElem );
145 filterFunc = QStringLiteral(
"%1 = '%2' or %1 is null" )
146 .arg( attrName.replace(
'\"', QLatin1String(
"\"\"" ) ),
147 mValue.toString().replace(
'\'', QLatin1String(
"''" ) ) );
151 filterFunc = QStringLiteral(
"%1 = '%2'" )
152 .arg( attrName.replace(
'\"', QLatin1String(
"\"\"" ) ),
153 mValue.toString().replace(
'\'', QLatin1String(
"''" ) ) );
161 mSymbol->toSld( doc, ruleElem, props );
168 , mAttrName( attrName )
177 QgsDebugMsg( QStringLiteral(
"invalid symbol in a category! ignoring..." ) );
191 const QVariant val = cat.value();
192 if ( val.type() == QVariant::List )
194 const QVariantList list = val.toList();
195 for (
const QVariant &v : list )
197 mSymbolHash.insert( v.toString(), ( cat.renderState() ||
mCounting ) ? cat.symbol() :
nullptr );
202 mSymbolHash.insert( val.toString(), ( cat.renderState() ||
mCounting ) ? cat.symbol() :
nullptr );
220 foundMatchingSymbol =
false;
223 QHash<QString, QgsSymbol *>::const_iterator it =
mSymbolHash.constFind( value.isNull() ? QString() : value.toString() );
228 QgsDebugMsg( QStringLiteral(
"there are no hashed symbols!!!" ) );
237 foundMatchingSymbol =
true;
267 QVariant value = valueForFeature( feature, context );
269 bool foundCategory =
false;
273 if ( !foundCategory )
311 if ( catIndex < 0 || catIndex >=
mCategories.size() )
319 if ( catIndex < 0 || catIndex >=
mCategories.size() )
327 if ( catIndex < 0 || catIndex >=
mCategories.size() )
335 if ( catIndex < 0 || catIndex >=
mCategories.size() )
345 QgsDebugMsg( QStringLiteral(
"invalid symbol in a category! ignoring..." ) );
354 if ( catIndex < 0 || catIndex >=
mCategories.size() )
383 if ( order == Qt::AscendingOrder )
395 return QString::localeAwareCompare( c1.
label(), c2.
label() ) < 0;
405 if ( order == Qt::AscendingOrder )
434 cat.symbol()->startRender( context, fields );
444 cat.symbol()->stopRender( context );
451 QSet<QString> attributes;
463 QgsCategoryList::const_iterator catIt =
mCategories.constBegin();
490 QString s = QStringLiteral(
"CATEGORIZED: idx %1\n" ).arg(
mAttrName );
514 QVariantMap newProps = props;
515 newProps[ QStringLiteral(
"attribute" )] =
mAttrName;
520 it->toSld( doc, element, newProps );
527 bool isExpression = ( attrNum == -1 );
529 bool hasDefault =
false;
530 bool defaultActive =
false;
531 bool allActive =
true;
532 bool noneActive =
true;
536 QString activeValues;
537 QString inactiveValues;
541 if ( cat.value() ==
"" || cat.value().isNull() )
544 defaultActive = cat.renderState();
547 noneActive = noneActive && !cat.renderState();
548 allActive = allActive && cat.renderState();
550 QVariant::Type valType = isExpression ? cat.value().type() : fields.
at( attrNum ).
type();
551 const bool isList = cat.value().type() == QVariant::List;
554 if ( !cat.renderState() )
556 if ( cat.value() !=
"" )
560 const QVariantList list = cat.value().toList();
561 for (
const QVariant &v : list )
563 if ( !inactiveValues.isEmpty() )
564 inactiveValues.append(
',' );
571 if ( !inactiveValues.isEmpty() )
572 inactiveValues.append(
',' );
574 inactiveValues.append( value );
580 if ( cat.value() !=
"" )
584 const QVariantList list = cat.value().toList();
585 for (
const QVariant &v : list )
587 if ( !activeValues.isEmpty() )
588 activeValues.append(
',' );
595 if ( !activeValues.isEmpty() )
596 activeValues.append(
',' );
598 activeValues.append( value );
604 QString attr = isExpression ?
mAttrName : QStringLiteral(
"\"%1\"" ).arg(
mAttrName );
606 if ( allActive && hasDefault )
610 else if ( noneActive )
612 return QStringLiteral(
"FALSE" );
614 else if ( defaultActive )
616 return QStringLiteral(
"(%1) NOT IN (%2) OR (%1) IS NULL" ).arg( attr, inactiveValues );
620 return QStringLiteral(
"(%1) IN (%2)" ).arg( attr, activeValues );
631 lst.append( cat.symbol() );
657 QDomElement symbolsElem = element.firstChildElement( QStringLiteral(
"symbols" ) );
658 if ( symbolsElem.isNull() )
661 QDomElement catsElem = element.firstChildElement( QStringLiteral(
"categories" ) );
662 if ( catsElem.isNull() )
668 QDomElement catElem = catsElem.firstChildElement();
669 while ( !catElem.isNull() )
671 if ( catElem.tagName() == QLatin1String(
"category" ) )
674 if ( catElem.hasAttribute( QStringLiteral(
"value" ) ) )
676 value = QVariant( catElem.attribute( QStringLiteral(
"value" ) ) );
681 QDomElement valElem = catElem.firstChildElement();
682 while ( !valElem.isNull() )
684 if ( valElem.tagName() == QLatin1String(
"val" ) )
686 values << QVariant( valElem.attribute( QStringLiteral(
"value" ) ) );
688 valElem = valElem.nextSiblingElement();
690 if ( !values.isEmpty() )
693 QString symbolName = catElem.attribute( QStringLiteral(
"symbol" ) );
694 QString label = catElem.attribute( QStringLiteral(
"label" ) );
695 bool render = catElem.attribute( QStringLiteral(
"render" ) ) != QLatin1String(
"false" );
696 if ( symbolMap.contains( symbolName ) )
698 QgsSymbol *symbol = symbolMap.take( symbolName );
702 catElem = catElem.nextSiblingElement();
705 QString attrName = element.attribute( QStringLiteral(
"attr" ) );
713 QDomElement sourceSymbolElem = element.firstChildElement( QStringLiteral(
"source-symbol" ) );
714 if ( !sourceSymbolElem.isNull() )
717 if ( sourceSymbolMap.contains( QStringLiteral(
"0" ) ) )
725 QDomElement sourceColorRampElem = element.firstChildElement( QStringLiteral(
"colorramp" ) );
726 if ( !sourceColorRampElem.isNull() && sourceColorRampElem.attribute( QStringLiteral(
"name" ) ) == QLatin1String(
"[source]" ) )
731 QDomElement rotationElem = element.firstChildElement( QStringLiteral(
"rotation" ) );
732 if ( !rotationElem.isNull() && !rotationElem.attribute( QStringLiteral(
"field" ) ).isEmpty() )
744 QDomElement sizeScaleElem = element.firstChildElement( QStringLiteral(
"sizescale" ) );
745 if ( !sizeScaleElem.isNull() && !sizeScaleElem.attribute( QStringLiteral(
"field" ) ).isEmpty() )
751 sizeScaleElem.attribute( QStringLiteral(
"field" ) ) );
757 sizeScaleElem.attribute( QStringLiteral(
"field" ) ) );
761 QDomElement ddsLegendSizeElem = element.firstChildElement( QStringLiteral(
"data-defined-size-legend" ) );
762 if ( !ddsLegendSizeElem.isNull() )
775 rendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"categorizedSymbol" ) );
776 rendererElem.setAttribute( QStringLiteral(
"symbollevels" ), (
mUsingSymbolLevels ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
777 rendererElem.setAttribute( QStringLiteral(
"forceraster" ), (
mForceRaster ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
778 rendererElem.setAttribute( QStringLiteral(
"attr" ),
mAttrName );
785 QDomElement catsElem = doc.createElement( QStringLiteral(
"categories" ) );
786 QgsCategoryList::const_iterator it =
mCategories.constBegin();
790 QString symbolName = QString::number( i );
793 QDomElement catElem = doc.createElement( QStringLiteral(
"category" ) );
794 if ( cat.
value().type() == QVariant::List )
796 const QVariantList list = cat.
value().toList();
797 for (
const QVariant &v : list )
799 QDomElement valueElem = doc.createElement( QStringLiteral(
"val" ) );
800 valueElem.setAttribute(
"value", v.toString() );
801 catElem.appendChild( valueElem );
806 catElem.setAttribute( QStringLiteral(
"value" ), cat.
value().toString() );
808 catElem.setAttribute( QStringLiteral(
"symbol" ), symbolName );
809 catElem.setAttribute( QStringLiteral(
"label" ), cat.
label() );
810 catElem.setAttribute( QStringLiteral(
"render" ), cat.
renderState() ?
"true" :
"false" );
811 catsElem.appendChild( catElem );
814 rendererElem.appendChild( catsElem );
818 rendererElem.appendChild( symbolsElem );
826 sourceSymbols.insert( QStringLiteral(
"0" ),
mSourceSymbol.get() );
828 rendererElem.appendChild( sourceSymbolElem );
835 rendererElem.appendChild( colorRampElem );
838 QDomElement rotationElem = doc.createElement( QStringLiteral(
"rotation" ) );
839 rendererElem.appendChild( rotationElem );
841 QDomElement sizeScaleElem = doc.createElement( QStringLiteral(
"sizescale" ) );
842 rendererElem.appendChild( sizeScaleElem );
849 QDomElement
orderBy = doc.createElement( QStringLiteral(
"orderby" ) );
851 rendererElem.appendChild(
orderBy );
853 rendererElem.setAttribute( QStringLiteral(
"enableorderby" ), (
mOrderByEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
857 QDomElement ddsLegendElem = doc.createElement( QStringLiteral(
"data-defined-size-legend" ) );
859 rendererElem.appendChild( ddsLegendElem );
889 if ( sSize != ddSize )
892 return baseLegendSymbolItems();
909 lst += baseLegendSymbolItems();
914 return baseLegendSymbolItems();
919 QString value = valueForFeature( feature, context ).toString();
925 if ( cat.value().type() == QVariant::List )
927 const QVariantList list = cat.value().toList();
928 for (
const QVariant &v : list )
939 match = value == cat.value();
945 return QSet< QString >() << QString::number( i );
947 return QSet< QString >();
952 return QSet< QString >();
1001 double value = count / num;
1013 symbol->
setColor( cat.symbol()->color() );
1028 int index = key.toInt( &ok );
1029 if ( ok && index >= 0 && index <
mCategories.size() )
1038 int index = key.toInt( &ok );
1048 int index = key.toInt( &ok );
1055 std::unique_ptr< QgsCategorizedSymbolRenderer > r;
1056 if ( renderer->
type() == QLatin1String(
"categorizedSymbol" ) )
1060 else if ( renderer->
type() == QLatin1String(
"graduatedSymbol" ) )
1063 if ( graduatedSymbolRenderer )
1072 r->setClassAttribute( graduatedSymbolRenderer->
classAttribute() );
1075 else if ( renderer->
type() == QLatin1String(
"pointDisplacement" ) || renderer->
type() == QLatin1String(
"pointCluster" ) )
1078 if ( pointDistanceRenderer )
1081 else if ( renderer->
type() == QLatin1String(
"invertedPolygonRenderer" ) )
1084 if ( invertedPolygonRenderer )
1093 r = qgis::make_unique< QgsCategorizedSymbolRenderer >( QString(),
QgsCategoryList() );
1098 r->setSourceSymbol(
symbols.at( 0 )->clone() );
1102 r->setOrderBy( renderer->
orderBy() );
1125 const QSet< QString > allSymbolNames = qgis::listToSet( unmatchedSymbols );
1127 const QRegularExpression tolerantMatchRe( QStringLiteral(
"[^\\w\\d ]" ), QRegularExpression::UseUnicodePropertiesOption );
1129 for (
int catIdx = 0; catIdx <
mCategories.count(); ++catIdx )
1131 const QVariant value =
mCategories.at( catIdx ).value();
1132 const QString val = value.toString().trimmed();
1133 std::unique_ptr< QgsSymbol > symbol( style->
symbol( val ) );
1135 if ( symbol && symbol->type() ==
type )
1138 unmatchedSymbols.removeAll( val );
1143 if ( !caseSensitive || useTolerantMatch )
1145 QString testVal = val;
1146 if ( useTolerantMatch )
1147 testVal.replace( tolerantMatchRe, QString() );
1149 bool foundMatch =
false;
1150 for (
const QString &name : allSymbolNames )
1152 QString testName = name.trimmed();
1153 if ( useTolerantMatch )
1154 testName.replace( tolerantMatchRe, QString() );
1156 if ( testName == testVal || ( !caseSensitive && testName.trimmed().compare( testVal, Qt::CaseInsensitive ) == 0 ) )
1159 std::unique_ptr< QgsSymbol > symbol( style->
symbol( name ) );
1160 if ( symbol && symbol->type() ==
type )
1163 unmatchedSymbols.removeAll( name );
1174 unmatchedCategories << value;
1183 QVariantList vals = values;
1187 if ( layer && !attributeName.isNull() )
1190 for (
const QVariant &value : vals )
1193 if ( !value.isNull() )
1195 int fieldIdx = fields.
lookupField( attributeName );
1196 QString categoryName = value.toString();
1197 if ( fieldIdx != -1 )
1202 categoryName =
formatter->representValue( layer, fieldIdx, setup.
config(), QVariant(), value );
static QgsFieldFormatterRegistry * fieldFormatterRegistry()
Gets the registry of available field formatters.
void sortByValue(Qt::SortOrder order=Qt::AscendingOrder)
Sorts the existing categories by their value.
const QgsCategoryList & categories() const
Returns a list of all categories recognized by the renderer.
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...
QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
To be overridden.
static QgsCategorizedSymbolRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
creates a QgsCategorizedSymbolRenderer from an existing renderer.
void updateSymbols(QgsSymbol *sym)
Update all the symbols but leave categories and colors.
bool updateCategoryRenderState(int catIndex, bool render)
Changes the render state for the category with the specified index.
void setSourceColorRamp(QgsColorRamp *ramp)
Sets the source color ramp.
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
QgsSymbol * sourceSymbol()
Returns the renderer's source symbol, which is the base symbol used for the each categories' symbol b...
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
void updateColorRamp(QgsColorRamp *ramp)
Update the color ramp used and all symbols colors.
QgsDataDefinedSizeLegend * dataDefinedSizeLegend() const
Returns configuration of appearance of legend when using data-defined size for marker symbols.
static QgsCategoryList createCategories(const QVariantList &values, const QgsSymbol *symbol, QgsVectorLayer *layer=nullptr, const QString &fieldName=QString())
Create categories for a list of values.
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 setSourceSymbol(QgsSymbol *sym)
Sets the source symbol for the renderer, which is the base symbol used for the each categories' symbo...
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
QgsSymbolList symbols(QgsRenderContext &context) const override
Returns list of symbols used by the renderer.
int categoryIndexForValue(const QVariant &val)
Returns the index for the category with the specified value (or -1 if not found).
static QgsFeatureRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
Creates a categorized renderer from an XML element.
bool updateCategorySymbol(int catIndex, QgsSymbol *symbol)
Changes the symbol for the category with the specified index.
QgsCategoryList mCategories
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
void setLegendSymbolItem(const QString &key, QgsSymbol *symbol) override
Sets the symbol to be used for a legend symbol item.
std::unique_ptr< QgsExpression > mExpression
std::unique_ptr< QgsDataDefinedSizeLegend > mDataDefinedSizeLegend
bool legendSymbolItemChecked(const QString &key) override
items of symbology items in legend is checked
bool legendSymbolItemsCheckable() const override
items of symbology items in legend should be checkable
void addCategory(const QgsRendererCategory &category)
Adds a new category to the renderer.
QgsCategorizedSymbolRenderer(const QString &attrName=QString(), const QgsCategoryList &categories=QgsCategoryList())
Constructor for QgsCategorizedSymbolRenderer.
void sortByLabel(Qt::SortOrder order=Qt::AscendingOrder)
Sorts the existing categories by their label.
QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns symbol for feature.
int mAttrNum
attribute index (derived from attribute name in startRender)
QgsLegendSymbolList legendSymbolItems() const override
Returns a list of symbology items for the legend.
void moveCategory(int from, int to)
Moves an existing category at index position from to index position to.
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) override
store renderer info to XML element
bool deleteCategory(int catIndex)
Deletes the category with the specified index from the renderer.
Q_DECL_DEPRECATED QgsSymbol * skipRender()
void checkLegendSymbolItem(const QString &key, bool state=true) override
item in symbology was checked
QString dump() const override
Returns debug information about this renderer.
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.
bool updateCategoryValue(int catIndex, const QVariant &value)
Changes the value for the category with the specified index.
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.
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.
void deleteAllCategories()
Deletes all existing categories from the renderer.
void setDataDefinedSizeLegend(QgsDataDefinedSizeLegend *settings)
Configures appearance of legend when renderer is configured to use data-defined size for marker symbo...
bool updateCategoryLabel(int catIndex, const QString &label)
Changes the label for the category with the specified index.
~QgsCategorizedSymbolRenderer() override
int categoryIndexForLabel(const QString &val)
Returns the index of the category with the specified label (or -1 if the label was not found,...
Abstract base class for color ramps.
virtual QgsColorRamp * clone() const =0
Creates a clone of the color ramp.
Object that keeps configuration of appearance of marker symbol's data-defined size in legend.
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...
void updateFromSymbolAndProperty(const QgsMarkerSymbol *symbol, const QgsProperty &ddSize)
Updates the list of classes, source symbol and title label from given symbol and property.
QgsLegendSymbolList legendSymbolList() const
Generates legend symbol items according to the configuration.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScopes(const QList< QgsExpressionContextScope * > &scopes)
Appends a list of scopes to the end of the context.
Class for parsing and evaluation of expressions (formerly called "search strings").
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required.
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
static void convertSymbolSizeScale(QgsSymbol *symbol, QgsSymbol::ScaleMethod method, const QString &field)
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
QgsPaintEffect * mPaintEffect
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
bool usingSymbolLevels() const
void setUsingSymbolLevels(bool usingSymbolLevels)
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer.
static void convertSymbolRotation(QgsSymbol *symbol, const QString &field)
QgsFeatureRequest::OrderBy mOrderBy
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
QgsFeatureRequest::OrderBy orderBy() const
Gets the order in which features shall be processed by this renderer.
void CORE_EXPORT save(QDomElement &elem) const
Serialize to XML.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Encapsulate a field in an attribute table or data source.
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
Container of fields for a vector layer.
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QgsSymbol * sourceSymbol()
Returns the renderer's source symbol, which is the base symbol used for the each classes' symbol befo...
QgsColorRamp * sourceColorRamp()
Returns the source color ramp, from which each classes' color is derived.
QString classAttribute() const
void setSourceSymbol(QgsSymbol *sym)
Sets the source symbol for the renderer, which is the base symbol used for the each classes' symbol b...
QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted,...
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
A marker symbol type, for rendering Point and MultiPoint geometries.
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
const QgsFeatureRenderer * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.
An abstract base class for distance based point renderers (e.g., clusterer and displacement renderers...
const QgsFeatureRenderer * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
A store for object properties.
bool isActive() const
Returns whether the property is currently active.
Totally random color ramp.
virtual void setTotalColorCount(int colorCount)
Sets the desired total number of unique colors for the resultant ramp.
The class is used as a container of context for various read/write operations on other objects.
Contains information about the context of a rendering operation.
double rendererScale() const
Returns the renderer map scale.
QgsExpressionContext & expressionContext()
Gets the expression context.
Represents an individual category (class) from a QgsCategorizedSymbolRenderer.
void setRenderState(bool render)
Sets whether the category is currently enabled and should be rendered.
void swap(QgsRendererCategory &other)
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.
QgsRendererCategory()=default
Constructor for QgsRendererCategory.
bool renderState() const
Returns true if the category is currently enabled and should be rendered.
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...
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)
A color ramp entity for QgsStyle databases.
An interface for classes which can visit style entity (e.g.
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
A symbol entity for QgsStyle databases.
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
QStringList symbolNames() const
Returns a list of names of symbols.
static void sortVariantList(QList< QVariant > &list, Qt::SortOrder order)
Sorts the passed list in requested order.
static void applyScaleDependency(QDomDocument &doc, QDomElement &ruleElem, QVariantMap &props)
Checks if the properties contain scaleMinDenom and scaleMaxDenom, if available, they are added into t...
static bool createFunctionElement(QDomDocument &doc, QDomElement &element, const QString &function)
static QgsColorRamp * loadColorRamp(QDomElement &element)
Creates a color ramp from the settings encoded in an XML element.
static QDomElement saveColorRamp(const QString &name, QgsColorRamp *ramp, QDomDocument &doc)
Encodes a color ramp's settings to an XML element.
static void clearSymbolMap(QgsSymbolMap &symbols)
static QgsSymbol::ScaleMethod decodeScaleMethod(const QString &str)
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 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.
Abstract base class for all rendered symbols.
QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns a list of attributes required to render this feature.
void setColor(const QColor &color)
Sets the color for the symbol.
SymbolType
Type of the symbol.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
Represents a vector layer which manages a vector based data sets.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is greater than the second.
bool labelGreaterThan(const QgsRendererCategory &c1, const QgsRendererCategory &c2)
bool valueLessThan(const QgsRendererCategory &c1, const QgsRendererCategory &c2)
bool valueGreaterThan(const QgsRendererCategory &c1, const QgsRendererCategory &c2)
bool labelLessThan(const QgsRendererCategory &c1, const QgsRendererCategory &c2)
QList< QgsRendererCategory > QgsCategoryList
QList< QgsLegendSymbolItem > QgsLegendSymbolList
#define QgsDebugMsgLevel(str, level)
#define RENDERER_TAG_NAME
QMap< QString, QgsSymbol * > QgsSymbolMap
QList< QgsSymbol * > QgsSymbolList
Contains information relating to the style entity currently being visited.