QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
16 #include <QDomDocument>
17 #include <QDomElement>
55 , mAttrName( attrName )
62 const auto constRanges =
ranges;
81 if ( range.lowerValue() <= value && range.upperValue() >= value )
110 return range->symbol();
121 if ( matchingRange == &range )
122 return QString::number( i );
152 QVariant value = valueForFeature( feature, context );
155 if ( value.isNull() )
179 if ( !range.symbol() )
182 range.symbol()->startRender( context, fields );
192 if ( !range.symbol() )
195 range.symbol()->stopRender( context );
201 QSet<QString> attributes;
213 QgsRangeList::const_iterator range_it =
mRanges.constBegin();
214 for ( ; range_it !=
mRanges.constEnd(); ++range_it )
240 if ( rangeIndex < 0 || rangeIndex >=
mRanges.size() )
242 mRanges[rangeIndex].setSymbol( symbol );
248 if ( rangeIndex < 0 || rangeIndex >=
mRanges.size() )
250 mRanges[rangeIndex].setLabel( label );
256 if ( rangeIndex < 0 || rangeIndex >=
mRanges.size() )
260 if ( rangeIndex == 0 )
262 else if ( rangeIndex ==
mRanges.count() )
267 if ( isDefaultLabel )
275 if ( rangeIndex < 0 || rangeIndex >=
mRanges.size() )
280 if ( rangeIndex == 0 )
282 else if ( rangeIndex ==
mRanges.count() )
287 if ( isDefaultLabel )
295 if ( rangeIndex < 0 || rangeIndex >=
mRanges.size() )
297 mRanges[rangeIndex].setRenderState( value );
303 QString s = QStringLiteral(
"GRADUATED: attr %1\n" ).arg(
mAttrName );
304 for (
int i = 0; i <
mRanges.count(); i++ )
329 QVariantMap newProps = props;
330 newProps[ QStringLiteral(
"attribute" )] =
mAttrName;
335 for ( QgsRangeList::const_iterator it =
mRanges.constBegin(); it !=
mRanges.constEnd(); ++it )
337 it->toSld( doc, element, newProps, first );
346 lst.reserve(
mRanges.count() );
349 lst.append( range.symbol() );
382 QList<QgsClassificationRange> _classes = method.
classes( minimum, maximum, classes );
389 const QString &attrName,
395 bool useSymmetricMode,
396 double symmetryPoint,
397 const QStringList &listForCboPrettyBreaks,
401 Q_UNUSED( listForCboPrettyBreaks )
408 QString methodId = methodIdFromMode(
mode );
426 bool useSymmetricMode,
double symmetryPoint,
bool astride )
431 QString methodId = methodIdFromMode(
mode );
448 for ( QList<QgsClassificationRange>::iterator it = classes.begin(); it != classes.end(); ++it )
465 QDomElement symbolsElem = element.firstChildElement( QStringLiteral(
"symbols" ) );
466 if ( symbolsElem.isNull() )
469 QDomElement rangesElem = element.firstChildElement( QStringLiteral(
"ranges" ) );
470 if ( rangesElem.isNull() )
476 QDomElement rangeElem = rangesElem.firstChildElement();
477 while ( !rangeElem.isNull() )
479 if ( rangeElem.tagName() == QLatin1String(
"range" ) )
481 double lowerValue = rangeElem.attribute( QStringLiteral(
"lower" ) ).toDouble();
482 double upperValue = rangeElem.attribute( QStringLiteral(
"upper" ) ).toDouble();
483 QString symbolName = rangeElem.attribute( QStringLiteral(
"symbol" ) );
484 QString label = rangeElem.attribute( QStringLiteral(
"label" ) );
485 bool render = rangeElem.attribute( QStringLiteral(
"render" ), QStringLiteral(
"true" ) ) != QLatin1String(
"false" );
486 if ( symbolMap.contains( symbolName ) )
488 QgsSymbol *symbol = symbolMap.take( symbolName );
492 rangeElem = rangeElem.nextSiblingElement();
495 QString attrName = element.attribute( QStringLiteral(
"attr" ) );
499 QString attrMethod = element.attribute( QStringLiteral(
"graduatedMethod" ) );
500 if ( !attrMethod.isEmpty() )
513 QDomElement sourceSymbolElem = element.firstChildElement( QStringLiteral(
"source-symbol" ) );
514 if ( !sourceSymbolElem.isNull() )
517 if ( sourceSymbolMap.contains( QStringLiteral(
"0" ) ) )
525 QDomElement sourceColorRampElem = element.firstChildElement( QStringLiteral(
"colorramp" ) );
526 if ( !sourceColorRampElem.isNull() && sourceColorRampElem.attribute( QStringLiteral(
"name" ) ) == QLatin1String(
"[source]" ) )
533 QDomElement modeElem = element.firstChildElement( QStringLiteral(
"mode" ) );
534 QDomElement methodElem = element.firstChildElement( QStringLiteral(
"classificationMethod" ) );
539 if ( !modeElem.isNull() )
541 QString modeString = modeElem.attribute( QStringLiteral(
"name" ) );
544 if ( modeString == QLatin1String(
"equal" ) )
545 methodId = QStringLiteral(
"EqualInterval" );
546 else if ( modeString == QLatin1String(
"quantile" ) )
547 methodId = QStringLiteral(
"Quantile" );
548 else if ( modeString == QLatin1String(
"jenks" ) )
549 methodId = QStringLiteral(
"Jenks" );
550 else if ( modeString == QLatin1String(
"stddev" ) )
551 methodId = QStringLiteral(
"StdDev" );
552 else if ( modeString == QLatin1String(
"pretty" ) )
553 methodId = QStringLiteral(
"Pretty" );
558 QDomElement symmetricModeElem = element.firstChildElement( QStringLiteral(
"symmetricMode" ) );
559 if ( !symmetricModeElem.isNull() )
562 QString symmetricEnabled = symmetricModeElem.attribute( QStringLiteral(
"enabled" ) );
563 QString symmetricPointString = symmetricModeElem.attribute( QStringLiteral(
"symmetryPoint" ) );
564 QString astrideEnabled = symmetricModeElem.attribute( QStringLiteral(
"astride" ) );
565 method->
setSymmetricMode( symmetricEnabled == QLatin1String(
"true" ), symmetricPointString.toDouble(), astrideEnabled == QLatin1String(
"true" ) );
567 QDomElement labelFormatElem = element.firstChildElement( QStringLiteral(
"labelformat" ) );
568 if ( !labelFormatElem.isNull() )
571 QString format = labelFormatElem.attribute( QStringLiteral(
"format" ),
"%1" + QStringLiteral(
" - " ) +
"%2" );
572 int precision = labelFormatElem.attribute( QStringLiteral(
"decimalplaces" ), QStringLiteral(
"4" ) ).toInt();
573 bool trimTrailingZeroes = labelFormatElem.attribute( QStringLiteral(
"trimtrailingzeroes" ), QStringLiteral(
"false" ) ) == QLatin1String(
"true" );
589 QDomElement rotationElem = element.firstChildElement( QStringLiteral(
"rotation" ) );
590 if ( !rotationElem.isNull() && !rotationElem.attribute( QStringLiteral(
"field" ) ).isEmpty() )
601 QDomElement sizeScaleElem = element.firstChildElement( QStringLiteral(
"sizescale" ) );
602 if ( !sizeScaleElem.isNull() && !sizeScaleElem.attribute( QStringLiteral(
"field" ) ).isEmpty() )
608 sizeScaleElem.attribute( QStringLiteral(
"field" ) ) );
614 sizeScaleElem.attribute( QStringLiteral(
"field" ) ) );
618 QDomElement ddsLegendSizeElem = element.firstChildElement( QStringLiteral(
"data-defined-size-legend" ) );
619 if ( !ddsLegendSizeElem.isNull() )
630 rendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"graduatedSymbol" ) );
631 rendererElem.setAttribute( QStringLiteral(
"attr" ),
mAttrName );
637 QDomElement rangesElem = doc.createElement( QStringLiteral(
"ranges" ) );
638 QgsRangeList::const_iterator it =
mRanges.constBegin();
639 for ( ; it !=
mRanges.constEnd(); ++it )
642 QString symbolName = QString::number( i );
645 QDomElement rangeElem = doc.createElement( QStringLiteral(
"range" ) );
646 rangeElem.setAttribute( QStringLiteral(
"lower" ), QString::number( range.
lowerValue(),
'f', 15 ) );
647 rangeElem.setAttribute( QStringLiteral(
"upper" ), QString::number( range.
upperValue(),
'f', 15 ) );
648 rangeElem.setAttribute( QStringLiteral(
"symbol" ), symbolName );
649 rangeElem.setAttribute( QStringLiteral(
"label" ), range.
label() );
650 rangeElem.setAttribute( QStringLiteral(
"render" ), range.
renderState() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" ) );
651 rangesElem.appendChild( rangeElem );
655 rendererElem.appendChild( rangesElem );
659 rendererElem.appendChild( symbolsElem );
665 sourceSymbols.insert( QStringLiteral(
"0" ),
mSourceSymbol.get() );
667 rendererElem.appendChild( sourceSymbolElem );
674 rendererElem.appendChild( colorRampElem );
679 rendererElem.appendChild( classificationMethodElem );
681 QDomElement rotationElem = doc.createElement( QStringLiteral(
"rotation" ) );
682 rendererElem.appendChild( rotationElem );
684 QDomElement sizeScaleElem = doc.createElement( QStringLiteral(
"sizescale" ) );
685 rendererElem.appendChild( sizeScaleElem );
689 QDomElement ddsLegendElem = doc.createElement( QStringLiteral(
"data-defined-size-legend" ) );
691 rendererElem.appendChild( ddsLegendElem );
717 return QStringLiteral(
"EqualInterval" );
719 return QStringLiteral(
"Quantile" );
721 return QStringLiteral(
"Jenks" );
723 return QStringLiteral(
"StdDev" );
725 return QStringLiteral(
"Pretty" );
734 if ( methodId == QLatin1String(
"EqualInterval" ) )
736 if ( methodId == QLatin1String(
"Quantile" ) )
738 if ( methodId == QLatin1String(
"Jenks" ) )
740 if ( methodId == QLatin1String(
"StdDev" ) )
742 if ( methodId == QLatin1String(
"Pretty" ) )
761 if ( sSize && sSize != ddSize )
764 return baseLegendSymbolItems();
781 lst += baseLegendSymbolItems();
786 return baseLegendSymbolItems();
791 QVariant value = valueForFeature( feature, context );
794 if ( value.isNull() )
795 return QSet< QString >();
800 return QSet< QString >() << key;
802 return QSet< QString >();
808 int ruleIndex = key.toInt( &ok );
809 if ( !ok || ruleIndex < 0 || ruleIndex >=
mRanges.size() )
859 double min = std::numeric_limits<double>::max();
860 for (
int i = 0; i <
mRanges.count(); i++ )
867 min = std::min( sz, min );
874 double max = std::numeric_limits<double>::min();
875 for (
int i = 0; i <
mRanges.count(); i++ )
882 max = std::max( sz, max );
889 for (
int i = 0; i <
mRanges.count(); i++ )
891 std::unique_ptr<QgsSymbol> symbol(
mRanges.at( i ).symbol() ?
mRanges.at( i ).symbol()->clone() :
nullptr );
892 const double size =
mRanges.count() > 1
893 ? minSize + i * ( maxSize - minSize ) / (
mRanges.count() - 1 )
894 : .5 * ( maxSize + minSize );
898 static_cast< QgsLineSymbol *
>( symbol.get() )->setWidth( size );
915 QgsSymbol *symbol = range.symbol() ? range.symbol()->
clone() :
nullptr;
919 colorValue = (
mRanges.count() > 1 ?
static_cast< double >( i ) / (
mRanges.count() - 1 ) : 0 );
937 std::unique_ptr<QgsSymbol> symbol( sym->
clone() );
940 case Qgis::GraduatedMethod::Color:
942 symbol->setColor( range.symbol()->color() );
945 case Qgis::GraduatedMethod::Size:
970 int index = key.toInt( &ok );
971 if ( ok && index >= 0 && index <
mRanges.size() )
972 return mRanges.at( index ).renderState();
980 int index = key.toInt( &ok );
988 int index = key.toInt( &ok );
998 QString label = QStringLiteral(
"0.0 - 0.0" );
1011 QMutableListIterator< QgsRendererRange > it(
mRanges );
1012 while ( it.hasNext() )
1026 if ( isDefaultLabel )
1028 it.setValue( range );
1030 it.insert( newRange );
1039 case Qgis::GraduatedMethod::Color:
1042 case Qgis::GraduatedMethod::Size:
1080 for (
int i = 0; i <
mRanges.count(); i++ )
1085 else if ( i ==
mRanges.count() - 1 )
1094 double minClassRange = 0.0;
1097 double range = rendererRange.upperValue() - rendererRange.lowerValue();
1100 if ( minClassRange == 0.0 || range < minClassRange )
1101 minClassRange = range;
1103 if ( minClassRange <= 0.0 )
1110 double nextDpMinRange = 0.0000000099;
1111 while ( ndp > 0 && nextDpMinRange < minClassRange )
1114 nextDpMinRange *= 10.0;
1123 if ( from < 0 || from >=
mRanges.size() || to < 0 || to >=
mRanges.size() )
1140 if ( order == Qt::AscendingOrder )
1153 std::sort( sortedRanges.begin(), sortedRanges.end(),
valueLessThan );
1155 QgsRangeList::const_iterator it = sortedRanges.constBegin();
1156 if ( it == sortedRanges.constEnd() )
1159 if ( ( *it ).upperValue() < ( *it ).lowerValue() )
1162 double prevMax = ( *it ).upperValue();
1165 for ( ; it != sortedRanges.constEnd(); ++it )
1167 if ( ( *it ).upperValue() < ( *it ).lowerValue() )
1170 if ( ( *it ).lowerValue() < prevMax )
1173 prevMax = ( *it ).upperValue();
1181 std::sort( sortedRanges.begin(), sortedRanges.end(),
valueLessThan );
1183 QgsRangeList::const_iterator it = sortedRanges.constBegin();
1184 if ( it == sortedRanges.constEnd() )
1187 double prevMax = ( *it ).upperValue();
1190 for ( ; it != sortedRanges.constEnd(); ++it )
1195 prevMax = ( *it ).upperValue();
1202 return QString::localeAwareCompare( r1.
label(), r2.
label() ) < 0;
1212 if ( order == Qt::AscendingOrder )
1234 QString methodId = methodIdFromMode(
mode );
1241 mClassificationMethod->setSymmetricMode( useSymmetricMode, mClassificationMethod->symmetryPoint(), mClassificationMethod->symmetryAstride() );
1246 mClassificationMethod->setSymmetricMode( mClassificationMethod->symmetricModeEnabled(), symmetryPoint, mClassificationMethod->symmetryAstride() );
1251 mClassificationMethod->setSymmetricMode( mClassificationMethod->symmetricModeEnabled(), mClassificationMethod->symmetryPoint(), astride );
1256 std::unique_ptr< QgsGraduatedSymbolRenderer > r;
1257 if ( renderer->
type() == QLatin1String(
"graduatedSymbol" ) )
1261 else if ( renderer->
type() == QLatin1String(
"categorizedSymbol" ) )
1264 if ( categorizedSymbolRenderer )
1266 r = std::make_unique< QgsGraduatedSymbolRenderer >( QString(),
QgsRangeList() );
1276 r->setClassAttribute( categorizedSymbolRenderer->
classAttribute() );
1279 else if ( renderer->
type() == QLatin1String(
"pointDisplacement" ) || renderer->
type() == QLatin1String(
"pointCluster" ) )
1282 if ( pointDistanceRenderer )
1285 else if ( renderer->
type() == QLatin1String(
"invertedPolygonRenderer" ) )
1288 if ( invertedPolygonRenderer )
1297 r = std::make_unique< QgsGraduatedSymbolRenderer >( QString(),
QgsRangeList() );
1302 r->setSourceSymbol(
symbols.at( 0 )->clone() );
1325 case Qgis::GraduatedMethod::Color:
1326 return QStringLiteral(
"GraduatedColor" );
1327 case Qgis::GraduatedMethod::Size:
1328 return QStringLiteral(
"GraduatedSize" );
QgsColorRamp * sourceColorRamp()
Returns the source color ramp, from which each classes' color is derived.
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.
void setSourceColorRamp(QgsColorRamp *ramp)
Sets the source color ramp.
static const QString METHOD_ID
Abstract base class for color ramps.
QgsSymbol * symbolForValue(double value) const
Gets the symbol which is used to represent value.
void appendScopes(const QList< QgsExpressionContextScope * > &scopes)
Appends a list of scopes to the end of the context.
std::unique_ptr< QgsDataDefinedSizeLegend > mDataDefinedSizeLegend
Q_DECL_DEPRECATED void setSymmetryPoint(double symmetryPoint)
Set the pivot point.
QgsClassificationMethod is an abstract class for implementations of classification methods.
void setSymbolSizes(double minSize, double maxSize)
set varying symbol size for classes
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 ...
A store for object properties.
void addBreak(double breakValue, bool updateSymbols=true)
Add a breakpoint by splitting existing classes so that the specified value becomes a break between tw...
QgsSymbol * sourceSymbol()
Returns the renderer's source symbol, which is the base symbol used for the each classes' symbol befo...
QgsExpressionContext & expressionContext()
Gets the expression context.
QString label() const
Returns the label used for the range.
QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
To be overridden.
Q_DECL_DEPRECATED QgsRendererRangeLabelFormat labelFormat() const
Returns the label format used to generate default classification labels.
The class is used as a container of context for various read/write operations on other objects.
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
bool updateRangeLabel(int rangeIndex, const QString &label)
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
double size() const
Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layer...
bool valueLessThan(const QgsRendererRange &r1, const QgsRendererRange &r2)
@ UpperBound
The class is at the upper bound.
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
A symbol entity for QgsStyle databases.
std::unique_ptr< QgsSymbol > mSourceSymbol
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
static void convertSymbolSizeScale(QgsSymbol *symbol, Qgis::ScaleMethod method, const QString &field)
QMap< QString, QgsSymbol * > QgsSymbolMap
static QgsClassificationMethod * create(const QDomElement &element, const QgsReadWriteContext &context)
Reads the DOM element and return a new classification method from it.
double width() const
Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol lay...
A color ramp entity for QgsStyle databases.
bool labelLessThan(const QgsRendererRange &r1, const QgsRendererRange &r2)
bool labelGreaterThan(const QgsRendererRange &r1, const QgsRendererRange &r2)
Container of fields for a vector layer.
QgsClassificationMethod * method(const QString &id)
Returns a new instance of the method for the given id.
bool updateRangeLowerValue(int rangeIndex, double value)
QgsSymbol * symbol() const
Returns the symbol used for the range.
static void convertSymbolRotation(QgsSymbol *symbol, const QString &field)
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
const QgsRendererRange * rangeForValue(double value) const
Returns the renderer range matching the provided value, or nullptr if no range matches the value.
Object that keeps configuration of appearance of marker symbol's data-defined size in legend.
void setLegendSymbolItem(const QString &key, QgsSymbol *symbol) override
Sets the symbol to be used for a legend symbol item.
Contains information about the context of a rendering operation.
QList< QgsClassificationRange > classes(const QgsVectorLayer *layer, const QString &expression, int nclasses)
This will calculate the classes for a given layer to define the classes.
An interface for classes which can visit style entity (e.g. symbol) nodes (using the visitor pattern)...
~QgsGraduatedSymbolRenderer() override
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
bool filterNeedsGeometry() const override
Returns true if this renderer requires the geometry to apply the filter.
void setGraduatedMethod(Qgis::GraduatedMethod method)
Set the method used for graduation (either size or color).
double lowerValue() const
Returns the lower bound of the range.
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.
const QgsFeatureRenderer * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
Abstract base class for all rendered symbols.
void moveClass(int from, int to)
Moves the category at index position from to index position to.
int ANALYSIS_EXPORT lower(int n, int i)
Lower function.
Q_DECL_DEPRECATED double symmetryPoint() const
Returns the pivot value for symmetric classification.
Constrained random color ramp, which returns random colors based on preset parameters.
Qgis::GraduatedMethod graduatedMethod() const
Returns the method used for graduation (either size or color).
Contains information relating to the style entity currently being visited.
static QString quoteFieldExpression(const QString &expression, const QgsVectorLayer *layer)
Validate if the expression is a field in the layer and ensure it is quoted.
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
QgsClassificationMethod * classificationMethod() const
Returns the classification method.
void updateRangeLabels()
Updates the labels of the ranges.
void updateColorRamp(QgsColorRamp *ramp=nullptr)
Update the color ramp used.
bool updateRangeSymbol(int rangeIndex, QgsSymbol *symbol)
Q_DECL_DEPRECATED void setAstride(bool astride)
Set if we want a central class astride the pivot value.
QgsClassificationEqualInterval is an implementation of QgsClassificationMethod for equal intervals.
QgsDataDefinedSizeLegend * dataDefinedSizeLegend() const
Returns configuration of appearance of legend when using data-defined size for marker symbols.
Totally random color ramp. Returns colors generated at random, but constrained to some hardcoded satu...
std::unique_ptr< QgsExpression > mExpression
Q_DECL_DEPRECATED void setUseSymmetricMode(bool useSymmetricMode)
Set if we want to classify symmetric around a given value.
std::shared_ptr< QgsClassificationMethod > mClassificationMethod
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required.
bool updateRangeUpperValue(int rangeIndex, double value)
#define Q_NOWARN_DEPRECATED_POP
@ LowerBound
The class is at the lower bound.
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...
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.
QgsClassificationCustom is a dummy implementation of QgsClassification which does not compute any bre...
QSet< QString > legendKeysForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns legend keys matching a specified feature.
void addClass(QgsSymbol *symbol)
QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns symbol for feature.
void setLowerValue(double lowerValue)
Sets the lower bound of the range.
bool legendSymbolItemsCheckable() const override
items of symbology items in legend should be checkable
void setLabelFormat(const QString &format)
Defines the format of the labels for the classes, using %1 and %2 for the bounds.
Qgis::GraduatedMethod mGraduatedMethod
QList< QgsRendererRange > QgsRangeList
void setSymmetricMode(bool enabled, double symmetryPoint=0, bool symmetryAstride=false)
Defines if the symmetric mode is enables and configures its parameters.
bool rangesHaveGaps() const
Tests whether classes assigned to the renderer have gaps between the ranges.
static Qgis::ScaleMethod decodeScaleMethod(const QString &str)
Decodes a symbol scale method from a string.
Q_DECL_DEPRECATED Mode mode() const
QList< QgsSymbol * > QgsSymbolList
A marker symbol type, for rendering Point and MultiPoint geometries.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
static Q_DECL_DEPRECATED QList< double > calcEqualIntervalBreaks(double minimum, double maximum, int classes, bool useSymmetricMode, double symmetryPoint, bool astride)
Compute the equal interval classification.
void saveRendererData(QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context)
Saves generic renderer data into the specified element.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
void setClassificationMethod(QgsClassificationMethod *method)
Defines the classification method This will take ownership of the method.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns a list of attributes required by this renderer.
static QString graduatedMethodStr(Qgis::GraduatedMethod method)
static QDomElement saveColorRamp(const QString &name, QgsColorRamp *ramp, QDomDocument &doc)
Encodes a color ramp's settings to an XML element.
void setSymbol(QgsSymbol *s)
Sets the symbol used for the range.
#define RENDERER_TAG_NAME
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.
static QgsFeatureRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
create renderer from XML element
std::unique_ptr< QgsColorRamp > mSourceColorRamp
void setLabelPrecision(int labelPrecision)
Defines the precision for the formatting of the labels.
A line symbol type, for rendering LineString and MultiLineString geometries.
QgsColorRamp * sourceColorRamp()
Returns the source color ramp, from which each categories' color is derived.
@ Inner
The class is not at a bound.
double upperValue() const
Returns the upper bound of the range.
void sortByLabel(Qt::SortOrder order=Qt::AscendingOrder)
void sortByValue(Qt::SortOrder order=Qt::AscendingOrder)
static QgsClassificationMethodRegistry * classificationMethodRegistry()
Returns the application's classification methods registry, used in graduated renderer.
void checkLegendSymbolItem(const QString &key, bool state=true) override
item in symbology was checked
bool legendSymbolItemChecked(const QString &key) override
items of symbology items in legend is checked
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.
bool renderState() const
Returns true if the range should be rendered.
int mAttrNum
attribute index (derived from attribute name in startRender)
QString dump() const override
Returns debug information about this renderer.
virtual QgsColorRamp * clone() const =0
Creates a clone of the color ramp.
Q_DECL_DEPRECATED bool astride() const
Returns if we want to have a central class astride the pivot value.
QString legendKeyForValue(double value) const
Returns the matching legend key for a value.
static QgsColorRamp * loadColorRamp(QDomElement &element)
Creates a color ramp from the settings encoded in an XML element.
void setDataDefinedSizeLegend(QgsDataDefinedSizeLegend *settings)
Configures appearance of legend when renderer is configured to use data-defined size for marker symbo...
void updateFromSymbolAndProperty(const QgsMarkerSymbol *symbol, const QgsProperty &ddSize)
Updates the list of classes, source symbol and title label from given symbol and property.
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.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
const QgsRangeList & ranges() const
Returns a list of all ranges used in the classification.
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...
GraduatedMethod
Methods for modifying symbols by range in a graduated symbol renderer.
void deleteClass(int idx)
QgsGraduatedSymbolRenderer * clone() const override
Create a deep copy of this renderer.
bool updateRangeRenderState(int rangeIndex, bool render)
double maxSymbolSize() const
Returns the max symbol size when graduated by size.
Represents a vector layer which manages a vector based data sets.
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.
Q_DECL_DEPRECATED void setLabelFormat(const QgsRendererRangeLabelFormat &labelFormat, bool updateRanges=false)
Set the label format used to generate default classification labels.
static void clearSymbolMap(QgsSymbolMap &symbols)
ClassPosition
Defines the class position.
QgsSymbolList symbols(QgsRenderContext &context) const override
Returns list of symbols used by the renderer.
QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns a list of attributes required to render this feature.
Q_DECL_DEPRECATED bool useSymmetricMode() const
Returns if we want to classify symmetric around a given value.
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 setLabelTrimTrailingZeroes(bool trimTrailingZeroes)
Defines if the trailing 0 are trimmed in the label.
static QgsGraduatedSymbolRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
creates a QgsGraduatedSymbolRenderer from an existing renderer.
double minSymbolSize() const
Returns the min symbol size when graduated by size.
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.
QgsGraduatedSymbolRenderer(const QString &attrName=QString(), const QgsRangeList &ranges=QgsRangeList())
Q_DECL_DEPRECATED void setMode(Mode mode)
A vector of attributes. Mostly equal to QVector<QVariant>.
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
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 unique ID, geometry and a list of field...
void setUpperValue(double upperValue)
Sets the upper bound of the range.
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
void calculateLabelPrecision(bool updateRanges=true)
Reset the label decimal places to a numberbased on the minimum class interval.
void updateSymbols(QgsSymbol *sym)
Update all the symbols but leave breaks and colors.
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
double rendererScale() const
Returns the renderer map scale.
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.
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
#define Q_NOWARN_DEPRECATED_PUSH
static QList< double > rangesToBreaks(const QList< QgsClassificationRange > &classes)
Transforms a list of classes to a list of breaks.
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) override
Stores renderer properties to an XML element.
void setLabel(const QString &label)
Sets the label used for the range.
QgsLegendSymbolList legendSymbolItems() const override
Returns a list of symbology items for the legend.
void setColor(const QColor &color) const
Sets the color for the symbol.
QString classAttribute() const
Returns the class attribute for the renderer, which is the field name or expression string from the l...
bool rangesOverlap() const
Tests whether classes assigned to the renderer have ranges which overlap.
QgsSymbol * sourceSymbol()
Returns the renderer's source symbol, which is the base symbol used for the each categories' symbol b...
QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted,...
bool valueGreaterThan(const QgsRendererRange &r1, const QgsRendererRange &r2)