16#include <QDomDocument>
53 , mAttrName( attrName )
60 const auto constRanges =
ranges;
77 auto catIt =
mRanges.constBegin();
78 for ( ; catIt !=
mRanges.constEnd(); ++catIt )
80 if (
QgsSymbol *catSymbol = catIt->symbol() )
94 if ( range.lowerValue() <= value && range.upperValue() >= value )
123 return range->symbol();
133 if ( matchingRange == &range )
163 QVariant value = valueForFeature( feature, context );
190 if ( !range.symbol() )
193 range.symbol()->startRender( context, fields );
203 if ( !range.symbol() )
206 range.symbol()->stopRender( context );
212 QSet<QString> attributes;
224 QgsRangeList::const_iterator range_it =
mRanges.constBegin();
225 for ( ; range_it !=
mRanges.constEnd(); ++range_it )
251 if ( rangeIndex < 0 || rangeIndex >=
mRanges.size() )
253 mRanges[rangeIndex].setSymbol( symbol );
259 if ( rangeIndex < 0 || rangeIndex >=
mRanges.size() )
261 mRanges[rangeIndex].setLabel( label );
267 if ( rangeIndex < 0 || rangeIndex >=
mRanges.size() )
271 if ( rangeIndex == 0 )
273 else if ( rangeIndex ==
mRanges.count() )
278 if ( isDefaultLabel )
286 if ( rangeIndex < 0 || rangeIndex >=
mRanges.size() )
291 if ( rangeIndex == 0 )
293 else if ( rangeIndex ==
mRanges.count() )
298 if ( isDefaultLabel )
306 if ( rangeIndex < 0 || rangeIndex >=
mRanges.size() )
308 mRanges[rangeIndex].setRenderState( value );
314 QString s = QStringLiteral(
"GRADUATED: attr %1\n" ).arg(
mAttrName );
315 for (
int i = 0; i <
mRanges.count(); i++ )
340 QVariantMap newProps = props;
341 newProps[ QStringLiteral(
"attribute" )] =
mAttrName;
346 for ( QgsRangeList::const_iterator it =
mRanges.constBegin(); it !=
mRanges.constEnd(); ++it )
348 it->toSld( doc, element, newProps, first );
357 lst.reserve(
mRanges.count() );
360 lst.append( range.symbol() );
393 QList<QgsClassificationRange> _classes = method.
classes( minimum, maximum, classes );
400 const QString &attrName,
406 bool useSymmetricMode,
407 double symmetryPoint,
408 const QStringList &listForCboPrettyBreaks,
412 Q_UNUSED( listForCboPrettyBreaks )
415 std::unique_ptr< QgsGraduatedSymbolRenderer > r = std::make_unique< QgsGraduatedSymbolRenderer >( attrName,
ranges );
416 r->setSourceSymbol( symbol->
clone() );
417 r->setSourceColorRamp( ramp->
clone() );
419 QString methodId = methodIdFromMode(
mode );
429 r->setClassificationMethod( method.release() );
432 r->updateClasses( vlayer, classes, error );
440 bool useSymmetricMode,
double symmetryPoint,
bool astride )
445 QString methodId = methodIdFromMode(
mode );
465 for ( QList<QgsClassificationRange>::iterator it = classes.begin(); it != classes.end(); ++it )
482 QDomElement symbolsElem = element.firstChildElement( QStringLiteral(
"symbols" ) );
483 if ( symbolsElem.isNull() )
486 QDomElement rangesElem = element.firstChildElement( QStringLiteral(
"ranges" ) );
487 if ( rangesElem.isNull() )
493 QDomElement rangeElem = rangesElem.firstChildElement();
495 while ( !rangeElem.isNull() )
497 if ( rangeElem.tagName() == QLatin1String(
"range" ) )
499 double lowerValue = rangeElem.attribute( QStringLiteral(
"lower" ) ).toDouble();
500 double upperValue = rangeElem.attribute( QStringLiteral(
"upper" ) ).toDouble();
501 QString symbolName = rangeElem.attribute( QStringLiteral(
"symbol" ) );
502 QString label = rangeElem.attribute( QStringLiteral(
"label" ) );
503 bool render = rangeElem.attribute( QStringLiteral(
"render" ), QStringLiteral(
"true" ) ) != QLatin1String(
"false" );
504 QString uuid = rangeElem.attribute( QStringLiteral(
"uuid" ), QString::number( i++ ) );
505 if ( symbolMap.contains( symbolName ) )
507 QgsSymbol *symbol = symbolMap.take( symbolName );
511 rangeElem = rangeElem.nextSiblingElement();
514 QString attrName = element.attribute( QStringLiteral(
"attr" ) );
516 std::unique_ptr< QgsGraduatedSymbolRenderer > r = std::make_unique< QgsGraduatedSymbolRenderer >( attrName,
ranges );
518 QString attrMethod = element.attribute( QStringLiteral(
"graduatedMethod" ) );
519 if ( !attrMethod.isEmpty() )
532 QDomElement sourceSymbolElem = element.firstChildElement( QStringLiteral(
"source-symbol" ) );
533 if ( !sourceSymbolElem.isNull() )
536 if ( sourceSymbolMap.contains( QStringLiteral(
"0" ) ) )
538 r->setSourceSymbol( sourceSymbolMap.take( QStringLiteral(
"0" ) ) );
544 QDomElement sourceColorRampElem = element.firstChildElement( QStringLiteral(
"colorramp" ) );
545 if ( !sourceColorRampElem.isNull() && sourceColorRampElem.attribute( QStringLiteral(
"name" ) ) == QLatin1String(
"[source]" ) )
552 QDomElement modeElem = element.firstChildElement( QStringLiteral(
"mode" ) );
553 QDomElement methodElem = element.firstChildElement( QStringLiteral(
"classificationMethod" ) );
554 std::unique_ptr< QgsClassificationMethod > method;
558 if ( !modeElem.isNull() )
560 QString modeString = modeElem.attribute( QStringLiteral(
"name" ) );
563 if ( modeString == QLatin1String(
"equal" ) )
564 methodId = QStringLiteral(
"EqualInterval" );
565 else if ( modeString == QLatin1String(
"quantile" ) )
566 methodId = QStringLiteral(
"Quantile" );
567 else if ( modeString == QLatin1String(
"jenks" ) )
568 methodId = QStringLiteral(
"Jenks" );
569 else if ( modeString == QLatin1String(
"stddev" ) )
570 methodId = QStringLiteral(
"StdDev" );
571 else if ( modeString == QLatin1String(
"pretty" ) )
572 methodId = QStringLiteral(
"Pretty" );
577 QDomElement symmetricModeElem = element.firstChildElement( QStringLiteral(
"symmetricMode" ) );
578 if ( !symmetricModeElem.isNull() )
581 QString symmetricEnabled = symmetricModeElem.attribute( QStringLiteral(
"enabled" ) );
582 QString symmetricPointString = symmetricModeElem.attribute( QStringLiteral(
"symmetryPoint" ) );
583 QString astrideEnabled = symmetricModeElem.attribute( QStringLiteral(
"astride" ) );
584 method->setSymmetricMode( symmetricEnabled == QLatin1String(
"true" ), symmetricPointString.toDouble(), astrideEnabled == QLatin1String(
"true" ) );
586 QDomElement labelFormatElem = element.firstChildElement( QStringLiteral(
"labelformat" ) );
587 if ( !labelFormatElem.isNull() )
590 QString format = labelFormatElem.attribute( QStringLiteral(
"format" ),
"%1" + QStringLiteral(
" - " ) +
"%2" );
591 int precision = labelFormatElem.attribute( QStringLiteral(
"decimalplaces" ), QStringLiteral(
"4" ) ).toInt();
592 bool trimTrailingZeroes = labelFormatElem.attribute( QStringLiteral(
"trimtrailingzeroes" ), QStringLiteral(
"false" ) ) == QLatin1String(
"true" );
593 method->setLabelFormat( format );
595 method->setLabelTrimTrailingZeroes( trimTrailingZeroes );
606 r->setClassificationMethod( method.release() );
608 QDomElement rotationElem = element.firstChildElement( QStringLiteral(
"rotation" ) );
609 if ( !rotationElem.isNull() && !rotationElem.attribute( QStringLiteral(
"field" ) ).isEmpty() )
615 if ( r->mSourceSymbol )
617 convertSymbolRotation( r->mSourceSymbol.get(), rotationElem.attribute( QStringLiteral(
"field" ) ) );
620 QDomElement sizeScaleElem = element.firstChildElement( QStringLiteral(
"sizescale" ) );
621 if ( !sizeScaleElem.isNull() && !sizeScaleElem.attribute( QStringLiteral(
"field" ) ).isEmpty() )
627 sizeScaleElem.attribute( QStringLiteral(
"field" ) ) );
633 sizeScaleElem.attribute( QStringLiteral(
"field" ) ) );
637 QDomElement ddsLegendSizeElem = element.firstChildElement( QStringLiteral(
"data-defined-size-legend" ) );
638 if ( !ddsLegendSizeElem.isNull() )
649 rendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"graduatedSymbol" ) );
650 rendererElem.setAttribute( QStringLiteral(
"attr" ),
mAttrName );
656 QDomElement rangesElem = doc.createElement( QStringLiteral(
"ranges" ) );
657 QgsRangeList::const_iterator it =
mRanges.constBegin();
658 for ( ; it !=
mRanges.constEnd(); ++it )
661 QString symbolName = QString::number( i );
664 QDomElement rangeElem = doc.createElement( QStringLiteral(
"range" ) );
665 rangeElem.setAttribute( QStringLiteral(
"lower" ), QString::number( range.
lowerValue(),
'f', 15 ) );
666 rangeElem.setAttribute( QStringLiteral(
"upper" ), QString::number( range.
upperValue(),
'f', 15 ) );
667 rangeElem.setAttribute( QStringLiteral(
"symbol" ), symbolName );
668 rangeElem.setAttribute( QStringLiteral(
"label" ), range.
label() );
669 rangeElem.setAttribute( QStringLiteral(
"render" ), range.
renderState() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" ) );
670 rangeElem.setAttribute( QStringLiteral(
"uuid" ), range.
uuid() );
671 rangesElem.appendChild( rangeElem );
675 rendererElem.appendChild( rangesElem );
679 rendererElem.appendChild( symbolsElem );
685 sourceSymbols.insert( QStringLiteral(
"0" ),
mSourceSymbol.get() );
687 rendererElem.appendChild( sourceSymbolElem );
694 rendererElem.appendChild( colorRampElem );
699 rendererElem.appendChild( classificationMethodElem );
701 QDomElement rotationElem = doc.createElement( QStringLiteral(
"rotation" ) );
702 rendererElem.appendChild( rotationElem );
704 QDomElement sizeScaleElem = doc.createElement( QStringLiteral(
"sizescale" ) );
705 rendererElem.appendChild( sizeScaleElem );
709 QDomElement ddsLegendElem = doc.createElement( QStringLiteral(
"data-defined-size-legend" ) );
711 rendererElem.appendChild( ddsLegendElem );
736 return QStringLiteral(
"EqualInterval" );
738 return QStringLiteral(
"Quantile" );
740 return QStringLiteral(
"Jenks" );
742 return QStringLiteral(
"StdDev" );
744 return QStringLiteral(
"Pretty" );
753 if ( methodId == QLatin1String(
"EqualInterval" ) )
755 if ( methodId == QLatin1String(
"Quantile" ) )
757 if ( methodId == QLatin1String(
"Jenks" ) )
759 if ( methodId == QLatin1String(
"StdDev" ) )
761 if ( methodId == QLatin1String(
"Pretty" ) )
780 if ( sSize && sSize != ddSize )
783 return baseLegendSymbolItems();
800 lst += baseLegendSymbolItems();
805 return baseLegendSymbolItems();
810 QVariant value = valueForFeature( feature, context );
814 return QSet< QString >();
819 return QSet< QString >() << key;
821 return QSet< QString >();
828 for ( i = 0; i <
mRanges.size(); i++ )
830 if (
mRanges[i].uuid() == key )
885 double min = std::numeric_limits<double>::max();
886 for (
int i = 0; i <
mRanges.count(); i++ )
893 min = std::min( sz, min );
900 double max = std::numeric_limits<double>::min();
901 for (
int i = 0; i <
mRanges.count(); i++ )
908 max = std::max( sz, max );
915 for (
int i = 0; i <
mRanges.count(); i++ )
917 std::unique_ptr<QgsSymbol> symbol(
mRanges.at( i ).symbol() ?
mRanges.at( i ).symbol()->clone() : nullptr );
918 const double size =
mRanges.count() > 1
919 ? minSize + i * ( maxSize - minSize ) / (
mRanges.count() - 1 )
920 : .5 * ( maxSize + minSize );
924 static_cast< QgsLineSymbol *
>( symbol.get() )->setWidth( size );
941 QgsSymbol *symbol = range.symbol() ? range.symbol()->
clone() :
nullptr;
945 colorValue = (
mRanges.count() > 1 ?
static_cast< double >( i ) / (
mRanges.count() - 1 ) : 0 );
963 std::unique_ptr<QgsSymbol> symbol( sym->
clone() );
968 symbol->setColor( range.symbol()->color() );
997 if ( range.uuid() == key )
999 return range.renderState();
1007 for (
int i = 0; i <
mRanges.size(); i++ )
1009 if (
mRanges[i].uuid() == key )
1021 for ( i = 0; i <
mRanges.size(); i++ )
1023 if (
mRanges[i].uuid() == key )
1039 QString label = QStringLiteral(
"0.0 - 0.0" );
1052 QMutableListIterator< QgsRendererRange > it(
mRanges );
1053 while ( it.hasNext() )
1067 if ( isDefaultLabel )
1069 it.setValue( range );
1071 it.insert( newRange );
1121 for (
int i = 0; i <
mRanges.count(); i++ )
1126 else if ( i ==
mRanges.count() - 1 )
1135 double minClassRange = 0.0;
1138 double range = rendererRange.upperValue() - rendererRange.lowerValue();
1141 if ( minClassRange == 0.0 || range < minClassRange )
1142 minClassRange = range;
1144 if ( minClassRange <= 0.0 )
1151 double nextDpMinRange = 0.0000000099;
1152 while ( ndp > 0 && nextDpMinRange < minClassRange )
1155 nextDpMinRange *= 10.0;
1164 if ( from < 0 || from >=
mRanges.size() || to < 0 || to >=
mRanges.size() )
1181 if ( order == Qt::AscendingOrder )
1194 std::sort( sortedRanges.begin(), sortedRanges.end(),
valueLessThan );
1196 QgsRangeList::const_iterator it = sortedRanges.constBegin();
1197 if ( it == sortedRanges.constEnd() )
1200 if ( ( *it ).upperValue() < ( *it ).lowerValue() )
1203 double prevMax = ( *it ).upperValue();
1206 for ( ; it != sortedRanges.constEnd(); ++it )
1208 if ( ( *it ).upperValue() < ( *it ).lowerValue() )
1211 if ( ( *it ).lowerValue() < prevMax )
1214 prevMax = ( *it ).upperValue();
1222 std::sort( sortedRanges.begin(), sortedRanges.end(),
valueLessThan );
1224 QgsRangeList::const_iterator it = sortedRanges.constBegin();
1225 if ( it == sortedRanges.constEnd() )
1228 double prevMax = ( *it ).upperValue();
1231 for ( ; it != sortedRanges.constEnd(); ++it )
1236 prevMax = ( *it ).upperValue();
1243 return QString::localeAwareCompare( r1.
label(), r2.
label() ) < 0;
1253 if ( order == Qt::AscendingOrder )
1275 QString methodId = methodIdFromMode(
mode );
1282 mClassificationMethod->setSymmetricMode( useSymmetricMode, mClassificationMethod->symmetryPoint(), mClassificationMethod->symmetryAstride() );
1287 mClassificationMethod->setSymmetricMode( mClassificationMethod->symmetricModeEnabled(), symmetryPoint, mClassificationMethod->symmetryAstride() );
1292 mClassificationMethod->setSymmetricMode( mClassificationMethod->symmetricModeEnabled(), mClassificationMethod->symmetryPoint(), astride );
1297 std::unique_ptr< QgsGraduatedSymbolRenderer > r;
1298 if ( renderer->
type() == QLatin1String(
"graduatedSymbol" ) )
1302 else if ( renderer->
type() == QLatin1String(
"categorizedSymbol" ) )
1305 if ( categorizedSymbolRenderer )
1307 r = std::make_unique< QgsGraduatedSymbolRenderer >( QString(),
QgsRangeList() );
1317 r->setClassAttribute( categorizedSymbolRenderer->
classAttribute() );
1320 else if ( renderer->
type() == QLatin1String(
"pointDisplacement" ) || renderer->
type() == QLatin1String(
"pointCluster" ) )
1323 if ( pointDistanceRenderer )
1326 else if ( renderer->
type() == QLatin1String(
"invertedPolygonRenderer" ) )
1329 if ( invertedPolygonRenderer )
1338 r = std::make_unique< QgsGraduatedSymbolRenderer >( QString(),
QgsRangeList() );
1343 r->setSourceSymbol(
symbols.at( 0 )->clone() );
1367 return QStringLiteral(
"GraduatedColor" );
1369 return QStringLiteral(
"GraduatedSize" );
QFlags< FeatureRendererFlag > FeatureRendererFlags
Flags controlling behavior of vector feature renderers.
GraduatedMethod
Methods for modifying symbols by range in a graduated symbol renderer.
@ Size
Alter size of symbols.
@ Color
Alter color of symbols.
@ AffectsLabeling
If present, indicates that the renderer will participate in the map labeling problem.
@ AffectsLabeling
If present, indicates that the symbol will participate in the map labeling problem.
static QgsClassificationMethodRegistry * classificationMethodRegistry()
Returns the application's classification methods registry, used in graduated renderer.
QgsSymbol * sourceSymbol()
Returns the renderer's source symbol, which is the base symbol used for the each categories' symbol b...
QString classAttribute() const
Returns the class attribute for the renderer, which is the field name or expression string from the l...
QgsColorRamp * sourceColorRamp()
Returns the source color ramp, from which each categories' color is derived.
QgsClassificationCustom is a dummy implementation of QgsClassification which does not compute any bre...
static const QString METHOD_ID
QgsClassificationEqualInterval is an implementation of QgsClassificationMethod for equal intervals.
std::unique_ptr< QgsClassificationMethod > method(const QString &id)
Returns a new instance of the method for the given id.
QgsClassificationMethod is an abstract class for implementations of classification methods.
static void makeBreaksSymmetric(QList< double > &breaks, double symmetryPoint, bool astride)
Remove the breaks that are above the existing opposite sign classes to keep colors symmetrically bala...
static std::unique_ptr< QgsClassificationMethod > create(const QDomElement &element, const QgsReadWriteContext &context)
Reads the DOM element and return a new classification method from it.
Q_DECL_DEPRECATED QList< QgsClassificationRange > classes(const QgsVectorLayer *layer, const QString &expression, int nclasses)
This will calculate the classes for a given layer to define the classes.
void setSymmetricMode(bool enabled, double symmetryPoint=0, bool symmetryAstride=false)
Defines if the symmetric mode is enables and configures its parameters.
ClassPosition
Defines the class position.
@ LowerBound
The class is at the lower bound.
@ UpperBound
The class is at the upper bound.
@ Inner
The class is not at a bound.
static QList< double > rangesToBreaks(const QList< QgsClassificationRange > &classes)
Transforms a list of classes to a list of breaks.
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.
static QString quoteFieldExpression(const QString &expression, const QgsVectorLayer *layer)
Validate if the expression is a field in the layer and ensure it is quoted.
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.
Abstract base class for all 2D vector feature renderers.
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
static void convertSymbolRotation(QgsSymbol *symbol, const QString &field)
void saveRendererData(QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context)
Saves generic renderer data into the specified element.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
static void convertSymbolSizeScale(QgsSymbol *symbol, Qgis::ScaleMethod method, const QString &field)
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Container of fields for a vector layer.
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
A vector feature renderer which uses numeric attributes to classify features into different ranges.
QgsLegendSymbolList legendSymbolItems() const override
Returns a list of symbology items for the legend.
QgsSymbol * sourceSymbol()
Returns the renderer's source symbol, which is the base symbol used for the each classes' symbol befo...
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) override
Stores renderer properties to an XML element.
~QgsGraduatedSymbolRenderer() override
void updateSymbols(QgsSymbol *sym)
Update all the symbols but leave breaks and colors.
const QgsRendererRange * rangeForValue(double value) const
Returns the renderer range matching the provided value, or nullptr if no range matches the value.
QgsColorRamp * sourceColorRamp()
Returns the source color ramp, from which each classes' color is derived.
bool updateRangeSymbol(int rangeIndex, QgsSymbol *symbol)
void addBreak(double breakValue, bool updateSymbols=true)
Add a breakpoint by splitting existing classes so that the specified value becomes a break between tw...
Q_DECL_DEPRECATED void setAstride(bool astride)
Set if we want a central class astride the pivot value.
void setClassificationMethod(QgsClassificationMethod *method)
Defines the classification method This will take ownership of the method.
static Q_DECL_DEPRECATED QList< double > calcEqualIntervalBreaks(double minimum, double maximum, int classes, bool useSymmetricMode, double symmetryPoint, bool astride)
Compute the equal interval classification.
QgsGraduatedSymbolRenderer * clone() const override
Create a deep copy of this renderer.
std::unique_ptr< QgsDataDefinedSizeLegend > mDataDefinedSizeLegend
static Q_DECL_DEPRECATED void makeBreaksSymmetric(QList< double > &breaks, double symmetryPoint, bool astride)
Remove the breaks that are above the existing opposite sign classes to keep colors symmetrically bala...
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
double maxSymbolSize() const
Returns the max symbol size when graduated by size.
Q_DECL_DEPRECATED bool useSymmetricMode() const
Returns if we want to classify symmetric around a given value.
bool updateRangeLabel(int rangeIndex, const QString &label)
void addClass(QgsSymbol *symbol)
QgsClassificationMethod * classificationMethod() const
Returns the classification method.
QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns symbol for feature.
void sortByValue(Qt::SortOrder order=Qt::AscendingOrder)
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
void checkLegendSymbolItem(const QString &key, bool state=true) override
Sets whether the legend symbology item with the specified ley should be checked.
std::unique_ptr< QgsSymbol > mSourceSymbol
void setLegendSymbolItem(const QString &key, QgsSymbol *symbol) override
Sets the symbol to be used for a legend symbol item.
Qgis::FeatureRendererFlags flags() const override
Returns flags associated with the renderer.
void setGraduatedMethod(Qgis::GraduatedMethod method)
Set the method used for graduation (either size or color).
static QgsFeatureRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
create renderer from XML element
Q_DECL_DEPRECATED void setMode(Mode mode)
QSet< QString > legendKeysForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns legend keys matching a specified feature.
bool rangesOverlap() const
Tests whether classes assigned to the renderer have ranges which overlap.
std::shared_ptr< QgsClassificationMethod > mClassificationMethod
Q_DECL_DEPRECATED bool astride() const
Returns if we want to have a central class astride the pivot value.
Q_DECL_DEPRECATED void setLabelFormat(const QgsRendererRangeLabelFormat &labelFormat, bool updateRanges=false)
Set the label format used to generate default classification labels.
Q_DECL_DEPRECATED void updateClasses(QgsVectorLayer *vlayer, Mode mode, int nclasses, bool useSymmetricMode=false, double symmetryPoint=0.0, bool astride=false)
Recalculate classes for a layer.
QString dump() const override
Returns debug information about this renderer.
bool updateRangeUpperValue(int rangeIndex, double value)
QString legendKeyToExpression(const QString &key, QgsVectorLayer *layer, bool &ok) const override
Attempts to convert the specified legend rule key to a QGIS expression matching the features displaye...
QString legendKeyForValue(double value) const
Returns the matching legend key for a value.
void setSourceColorRamp(QgsColorRamp *ramp)
Sets the source color ramp.
void setSourceSymbol(QgsSymbol *sym)
Sets the source symbol for the renderer, which is the base symbol used for the each classes' symbol b...
bool legendSymbolItemChecked(const QString &key) override
Returns true if the legend symbology item with the specified key is checked.
bool updateRangeLowerValue(int rangeIndex, double value)
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
static QgsGraduatedSymbolRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
creates a QgsGraduatedSymbolRenderer from an existing renderer.
bool legendSymbolItemsCheckable() const override
Returns true if symbology items in legend are checkable.
void moveClass(int from, int to)
Moves the category at index position from to index position to.
void sortByLabel(Qt::SortOrder order=Qt::AscendingOrder)
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns a list of attributes required by this renderer.
void updateRangeLabels()
Updates the labels of the ranges.
bool updateRangeRenderState(int rangeIndex, bool render)
QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
To be overridden.
std::unique_ptr< QgsColorRamp > mSourceColorRamp
QgsSymbolList symbols(QgsRenderContext &context) const override
Returns list of symbols used by the renderer.
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
QgsDataDefinedSizeLegend * dataDefinedSizeLegend() const
Returns configuration of appearance of legend when using data-defined size for marker symbols.
void updateColorRamp(QgsColorRamp *ramp=nullptr)
Update the color ramp used.
Q_DECL_DEPRECATED Mode mode() const
void deleteClass(int idx)
QgsGraduatedSymbolRenderer(const QString &attrName=QString(), const QgsRangeList &ranges=QgsRangeList())
Qgis::GraduatedMethod mGraduatedMethod
double minSymbolSize() const
Returns the min symbol size when graduated by size.
Qgis::GraduatedMethod graduatedMethod() const
Returns the method used for graduation (either size or color).
bool filterNeedsGeometry() const override
Returns true if this renderer requires the geometry to apply the filter.
int mAttrNum
attribute index (derived from attribute name in startRender)
Q_DECL_DEPRECATED void setSymmetryPoint(double symmetryPoint)
Set the pivot point.
std::unique_ptr< QgsExpression > mExpression
static QString graduatedMethodStr(Qgis::GraduatedMethod method)
void setSymbolSizes(double minSize, double maxSize)
set varying symbol size for classes
void calculateLabelPrecision(bool updateRanges=true)
Reset the label decimal places to a numberbased on the minimum class interval.
void setDataDefinedSizeLegend(QgsDataDefinedSizeLegend *settings)
Configures appearance of legend when renderer is configured to use data-defined size for marker symbo...
const QgsRangeList & ranges() const
Returns a list of all ranges used in the classification.
Q_DECL_DEPRECATED QgsRendererRangeLabelFormat labelFormat() const
Returns the label format used to generate default classification labels.
static Q_DECL_DEPRECATED QgsGraduatedSymbolRenderer * createRenderer(QgsVectorLayer *vlayer, const QString &attrName, int classes, Mode mode, QgsSymbol *symbol, QgsColorRamp *ramp, const QgsRendererRangeLabelFormat &legendFormat=QgsRendererRangeLabelFormat(), bool useSymmetricMode=false, double symmetryPoint=0.0, const QStringList &listForCboPrettyBreaks=QStringList(), bool astride=false)
Creates a new graduated renderer.
Q_DECL_DEPRECATED double symmetryPoint() const
Returns the pivot value for symmetric classification.
Q_DECL_DEPRECATED void setUseSymmetricMode(bool useSymmetricMode)
Set if we want to classify symmetric around a given value.
QgsSymbol * symbolForValue(double value) const
Gets the symbol which is used to represent value.
bool rangesHaveGaps() const
Tests whether classes assigned to the renderer have gaps between the ranges.
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...
Constrained random color ramp, which returns random colors based on preset parameters.
A line symbol type, for rendering LineString and MultiLineString geometries.
double width() const
Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol lay...
A marker symbol type, for rendering Point and MultiPoint geometries.
double size() const
Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layer...
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.
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.
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.
void setUpperValue(double upperValue)
Sets the upper bound of the range.
QString label() const
Returns the label used for the range.
void setSymbol(QgsSymbol *s)
Sets the symbol used for the range.
QgsSymbol * symbol() const
Returns the symbol used for the range.
void setLabel(const QString &label)
Sets the label used for the range.
bool renderState() const
Returns true if the range should be rendered.
double upperValue() const
Returns the upper bound of the range.
void setLowerValue(double lowerValue)
Sets the lower bound of the range.
QString uuid() const
Returns the unique identifier for this range.
double lowerValue() const
Returns the lower bound of the range.
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.
static QgsColorRamp * loadColorRamp(QDomElement &element)
Creates a color ramp from the settings encoded in an XML element.
static Qgis::ScaleMethod decodeScaleMethod(const QString &str)
Decodes a symbol scale method from a string.
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 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.
void setColor(const QColor &color) const
Sets the color for the symbol.
QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns a list of attributes required to render this feature.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
static QgsSymbol * defaultSymbol(Qgis::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
#define Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_PUSH
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
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)
bool valueLessThan(const QgsRendererRange &r1, const QgsRendererRange &r2)
bool labelGreaterThan(const QgsRendererRange &r1, const QgsRendererRange &r2)
bool labelLessThan(const QgsRendererRange &r1, const QgsRendererRange &r2)
bool valueGreaterThan(const QgsRendererRange &r1, const QgsRendererRange &r2)
QList< QgsLegendSymbolItem > QgsLegendSymbolList
#define RENDERER_TAG_NAME
QMap< QString, QgsSymbol * > QgsSymbolMap
QList< QgsSymbol * > QgsSymbolList
QList< QgsRendererRange > QgsRangeList
Contains information relating to the style entity currently being visited.