16 #include <QDomDocument> 17 #include <QDomElement> 52 , mAttrName( attrName )
59 const auto constRanges =
ranges;
77 if ( range.lowerValue() <= value && range.upperValue() >= value )
80 return range.symbol();
94 if ( range.lowerValue() <= value && range.upperValue() >= value )
97 return QString::number( i );
116 if ( mAttrNum < 0 || mAttrNum >= attrs.count() )
130 QVariant value = valueForFeature( feature, context );
133 if ( value.isNull() )
157 if ( !range.symbol() )
160 range.symbol()->startRender( context, fields );
170 if ( !range.symbol() )
173 range.symbol()->stopRender( context );
179 QSet<QString> attributes;
191 QgsRangeList::const_iterator range_it =
mRanges.constBegin();
192 for ( ; range_it !=
mRanges.constEnd(); ++range_it )
218 if ( rangeIndex < 0 || rangeIndex >=
mRanges.size() )
220 mRanges[rangeIndex].setSymbol( symbol );
226 if ( rangeIndex < 0 || rangeIndex >=
mRanges.size() )
228 mRanges[rangeIndex].setLabel( label );
234 if ( rangeIndex < 0 || rangeIndex >=
mRanges.size() )
238 if ( rangeIndex == 0 )
240 else if ( rangeIndex ==
mRanges.count() )
245 if ( isDefaultLabel )
253 if ( rangeIndex < 0 || rangeIndex >=
mRanges.size() )
258 if ( rangeIndex == 0 )
260 else if ( rangeIndex ==
mRanges.count() )
265 if ( isDefaultLabel )
273 if ( rangeIndex < 0 || rangeIndex >=
mRanges.size() )
275 mRanges[rangeIndex].setRenderState( value );
281 QString s = QStringLiteral(
"GRADUATED: attr %1\n" ).arg(
mAttrName );
282 for (
int i = 0; i <
mRanges.count(); i++ )
309 newProps[ QStringLiteral(
"attribute" )] =
mAttrName;
314 for ( QgsRangeList::const_iterator it =
mRanges.constBegin(); it !=
mRanges.constEnd(); ++it )
316 it->toSld( doc, element, newProps, first );
325 lst.reserve(
mRanges.count() );
328 lst.append( range.symbol() );
361 QList<QgsClassificationRange> _classes = method.
classes( minimum, maximum, classes );
368 const QString &attrName,
376 const QStringList &listForCboPrettyBreaks,
380 Q_UNUSED( listForCboPrettyBreaks )
387 QString methodId = methodIdFromMode( mode );
410 QString methodId = methodIdFromMode( mode );
427 for ( QList<QgsClassificationRange>::iterator it = classes.begin(); it != classes.end(); ++it )
444 QDomElement symbolsElem = element.firstChildElement( QStringLiteral(
"symbols" ) );
445 if ( symbolsElem.isNull() )
448 QDomElement rangesElem = element.firstChildElement( QStringLiteral(
"ranges" ) );
449 if ( rangesElem.isNull() )
455 QDomElement rangeElem = rangesElem.firstChildElement();
456 while ( !rangeElem.isNull() )
458 if ( rangeElem.tagName() == QLatin1String(
"range" ) )
460 double lowerValue = rangeElem.attribute( QStringLiteral(
"lower" ) ).toDouble();
461 double upperValue = rangeElem.attribute( QStringLiteral(
"upper" ) ).toDouble();
462 QString symbolName = rangeElem.attribute( QStringLiteral(
"symbol" ) );
463 QString label = rangeElem.attribute( QStringLiteral(
"label" ) );
464 bool render = rangeElem.attribute( QStringLiteral(
"render" ), QStringLiteral(
"true" ) ) != QLatin1String(
"false" );
465 if ( symbolMap.contains( symbolName ) )
467 QgsSymbol *symbol = symbolMap.take( symbolName );
468 ranges.append(
QgsRendererRange( lowerValue, upperValue, symbol, label, render ) );
471 rangeElem = rangeElem.nextSiblingElement();
474 QString attrName = element.attribute( QStringLiteral(
"attr" ) );
478 QString attrMethod = element.attribute( QStringLiteral(
"graduatedMethod" ) );
479 if ( !attrMethod.isEmpty() )
492 QDomElement sourceSymbolElem = element.firstChildElement( QStringLiteral(
"source-symbol" ) );
493 if ( !sourceSymbolElem.isNull() )
496 if ( sourceSymbolMap.contains( QStringLiteral(
"0" ) ) )
504 QDomElement sourceColorRampElem = element.firstChildElement( QStringLiteral(
"colorramp" ) );
505 if ( !sourceColorRampElem.isNull() && sourceColorRampElem.attribute( QStringLiteral(
"name" ) ) == QLatin1String(
"[source]" ) )
512 QDomElement modeElem = element.firstChildElement( QStringLiteral(
"mode" ) );
513 QDomElement methodElem = element.firstChildElement( QStringLiteral(
"classificationMethod" ) );
518 if ( !modeElem.isNull() )
520 QString modeString = modeElem.attribute( QStringLiteral(
"name" ) );
523 if ( modeString == QLatin1String(
"equal" ) )
524 methodId = QStringLiteral(
"EqualInterval" );
525 else if ( modeString == QLatin1String(
"quantile" ) )
526 methodId = QStringLiteral(
"Quantile" );
527 else if ( modeString == QLatin1String(
"jenks" ) )
528 methodId = QStringLiteral(
"Jenks" );
529 else if ( modeString == QLatin1String(
"stddev" ) )
530 methodId = QStringLiteral(
"StdDev" );
531 else if ( modeString == QLatin1String(
"pretty" ) )
532 methodId = QStringLiteral(
"Pretty" );
537 QDomElement symmetricModeElem = element.firstChildElement( QStringLiteral(
"symmetricMode" ) );
538 if ( !symmetricModeElem.isNull() )
541 QString symmetricEnabled = symmetricModeElem.attribute( QStringLiteral(
"enabled" ) );
542 QString symmetricPointString = symmetricModeElem.attribute( QStringLiteral(
"symmetryPoint" ) );
543 QString astrideEnabled = symmetricModeElem.attribute( QStringLiteral(
"astride" ) );
544 method->
setSymmetricMode( symmetricEnabled == QLatin1String(
"true" ), symmetricPointString.toDouble(), astrideEnabled == QLatin1String(
"true" ) );
546 QDomElement labelFormatElem = element.firstChildElement( QStringLiteral(
"labelformat" ) );
547 if ( !labelFormatElem.isNull() )
550 QString format = labelFormatElem.attribute( QStringLiteral(
"format" ),
"%1" + QStringLiteral(
" - " ) +
"%2" );
551 int precision = labelFormatElem.attribute( QStringLiteral(
"decimalplaces" ), QStringLiteral(
"4" ) ).toInt();
552 bool trimTrailingZeroes = labelFormatElem.attribute( QStringLiteral(
"trimtrailingzeroes" ), QStringLiteral(
"false" ) ) == QLatin1String(
"true" );
568 QDomElement rotationElem = element.firstChildElement( QStringLiteral(
"rotation" ) );
569 if ( !rotationElem.isNull() && !rotationElem.attribute( QStringLiteral(
"field" ) ).isEmpty() )
580 QDomElement sizeScaleElem = element.firstChildElement( QStringLiteral(
"sizescale" ) );
581 if ( !sizeScaleElem.isNull() && !sizeScaleElem.attribute( QStringLiteral(
"field" ) ).isEmpty() )
587 sizeScaleElem.attribute( QStringLiteral(
"field" ) ) );
593 sizeScaleElem.attribute( QStringLiteral(
"field" ) ) );
597 QDomElement ddsLegendSizeElem = element.firstChildElement( QStringLiteral(
"data-defined-size-legend" ) );
598 if ( !ddsLegendSizeElem.isNull() )
609 rendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"graduatedSymbol" ) );
610 rendererElem.setAttribute( QStringLiteral(
"symbollevels" ), (
mUsingSymbolLevels ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
611 rendererElem.setAttribute( QStringLiteral(
"forceraster" ), (
mForceRaster ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
612 rendererElem.setAttribute( QStringLiteral(
"attr" ),
mAttrName );
618 QDomElement rangesElem = doc.createElement( QStringLiteral(
"ranges" ) );
619 QgsRangeList::const_iterator it =
mRanges.constBegin();
620 for ( ; it !=
mRanges.constEnd(); ++it )
623 QString symbolName = QString::number( i );
624 symbols.insert( symbolName, range.
symbol() );
626 QDomElement rangeElem = doc.createElement( QStringLiteral(
"range" ) );
627 rangeElem.setAttribute( QStringLiteral(
"lower" ), QString::number( range.
lowerValue(),
'f', 15 ) );
628 rangeElem.setAttribute( QStringLiteral(
"upper" ), QString::number( range.
upperValue(),
'f', 15 ) );
629 rangeElem.setAttribute( QStringLiteral(
"symbol" ), symbolName );
630 rangeElem.setAttribute( QStringLiteral(
"label" ), range.
label() );
631 rangeElem.setAttribute( QStringLiteral(
"render" ), range.
renderState() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" ) );
632 rangesElem.appendChild( rangeElem );
636 rendererElem.appendChild( rangesElem );
640 rendererElem.appendChild( symbolsElem );
646 sourceSymbols.insert( QStringLiteral(
"0" ),
mSourceSymbol.get() );
648 rendererElem.appendChild( sourceSymbolElem );
655 rendererElem.appendChild( colorRampElem );
660 rendererElem.appendChild( classificationMethodElem );
662 QDomElement rotationElem = doc.createElement( QStringLiteral(
"rotation" ) );
663 rendererElem.appendChild( rotationElem );
665 QDomElement sizeScaleElem = doc.createElement( QStringLiteral(
"sizescale" ) );
666 rendererElem.appendChild( sizeScaleElem );
673 QDomElement
orderBy = doc.createElement( QStringLiteral(
"orderby" ) );
675 rendererElem.appendChild( orderBy );
677 rendererElem.setAttribute( QStringLiteral(
"enableorderby" ), (
mOrderByEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
681 QDomElement ddsLegendElem = doc.createElement( QStringLiteral(
"data-defined-size-legend" ) );
683 rendererElem.appendChild( ddsLegendElem );
707 return QStringLiteral(
"EqualInterval" );
709 return QStringLiteral(
"Quantile" );
711 return QStringLiteral(
"Jenks" );
713 return QStringLiteral(
"StdDev" );
715 return QStringLiteral(
"Pretty" );
724 if ( methodId == QLatin1String(
"EqualInterval" ) )
726 if ( methodId == QLatin1String(
"Quantile" ) )
728 if ( methodId == QLatin1String(
"Jenks" ) )
730 if ( methodId == QLatin1String(
"StdDev" ) )
732 if ( methodId == QLatin1String(
"Pretty" ) )
751 if ( sSize && sSize != ddSize )
754 return baseLegendSymbolItems();
771 lst += baseLegendSymbolItems();
776 return baseLegendSymbolItems();
781 QVariant value = valueForFeature( feature, context );
784 if ( value.isNull() )
785 return QSet< QString >();
790 return QSet< QString >() << key;
792 return QSet< QString >();
830 double min = std::numeric_limits<double>::max();
831 for (
int i = 0; i <
mRanges.count(); i++ )
835 sz = static_cast< QgsMarkerSymbol * >(
mRanges[i].symbol() )->size();
837 sz = static_cast< QgsLineSymbol * >(
mRanges[i].symbol() )->width();
838 min = std::min( sz, min );
845 double max = std::numeric_limits<double>::min();
846 for (
int i = 0; i <
mRanges.count(); i++ )
850 sz = static_cast< QgsMarkerSymbol * >(
mRanges[i].symbol() )->size();
852 sz = static_cast< QgsLineSymbol * >(
mRanges[i].symbol() )->width();
853 max = std::max( sz, max );
860 for (
int i = 0; i <
mRanges.count(); i++ )
862 std::unique_ptr<QgsSymbol> symbol(
mRanges.at( i ).symbol() ?
mRanges.at( i ).symbol()->clone() : nullptr );
863 const double size =
mRanges.count() > 1
864 ? minSize + i * ( maxSize - minSize ) / (
mRanges.count() - 1 )
865 : .5 * ( maxSize + minSize );
867 static_cast< QgsMarkerSymbol * >( symbol.get() )->setSize( size );
869 static_cast< QgsLineSymbol * >( symbol.get() )->setWidth( size );
886 QgsSymbol *symbol = range.symbol() ? range.symbol()->
clone() :
nullptr;
890 colorValue = (
mRanges.count() > 1 ?
static_cast< double >( i ) / (
mRanges.count() - 1 ) : 0 );
908 std::unique_ptr<QgsSymbol> symbol( sym->
clone() );
911 symbol->setColor( range.symbol()->color() );
916 static_cast<QgsMarkerSymbol *>( symbol.get() )->setSize(
917 static_cast<QgsMarkerSymbol *>( range.symbol() )->size() );
919 static_cast<QgsLineSymbol *>( symbol.get() )->setWidth(
920 static_cast<QgsLineSymbol *>( range.symbol() )->width() );
936 int index = key.toInt( &ok );
937 if ( ok && index >= 0 && index <
mRanges.size() )
938 return mRanges.at( index ).renderState();
946 int index = key.toInt( &ok );
954 int index = key.toInt( &ok );
964 QString label = QStringLiteral(
"0.0 - 0.0" );
977 QMutableListIterator< QgsRendererRange > it(
mRanges );
978 while ( it.hasNext() )
992 if ( isDefaultLabel )
994 it.setValue( range );
996 it.insert( newRange );
1001 if ( updateSymbols )
1046 for (
int i = 0; i <
mRanges.count(); i++ )
1051 else if ( i ==
mRanges.count() - 1 )
1061 double minClassRange = 0.0;
1064 double range = rendererRange.upperValue() - rendererRange.lowerValue();
1067 if ( minClassRange == 0.0 || range < minClassRange )
1068 minClassRange = range;
1070 if ( minClassRange <= 0.0 )
1077 double nextDpMinRange = 0.0000000099;
1078 while ( ndp > 0 && nextDpMinRange < minClassRange )
1081 nextDpMinRange *= 10.0;
1090 if ( from < 0 || from >=
mRanges.size() || to < 0 || to >=
mRanges.size() )
1107 if ( order == Qt::AscendingOrder )
1120 std::sort( sortedRanges.begin(), sortedRanges.end(),
valueLessThan );
1122 QgsRangeList::const_iterator it = sortedRanges.constBegin();
1123 if ( it == sortedRanges.constEnd() )
1126 if ( ( *it ).upperValue() < ( *it ).lowerValue() )
1129 double prevMax = ( *it ).upperValue();
1132 for ( ; it != sortedRanges.constEnd(); ++it )
1134 if ( ( *it ).upperValue() < ( *it ).lowerValue() )
1137 if ( ( *it ).lowerValue() < prevMax )
1140 prevMax = ( *it ).upperValue();
1148 std::sort( sortedRanges.begin(), sortedRanges.end(),
valueLessThan );
1150 QgsRangeList::const_iterator it = sortedRanges.constBegin();
1151 if ( it == sortedRanges.constEnd() )
1154 double prevMax = ( *it ).upperValue();
1157 for ( ; it != sortedRanges.constEnd(); ++it )
1162 prevMax = ( *it ).upperValue();
1169 return QString::localeAwareCompare( r1.
label(), r2.
label() ) < 0;
1179 if ( order == Qt::AscendingOrder )
1201 QString methodId = methodIdFromMode( mode );
1223 std::unique_ptr< QgsGraduatedSymbolRenderer > r;
1224 if ( renderer->
type() == QLatin1String(
"graduatedSymbol" ) )
1226 r.reset( static_cast<QgsGraduatedSymbolRenderer *>( renderer->
clone() ) );
1228 else if ( renderer->
type() == QLatin1String(
"categorizedSymbol" ) )
1231 if ( categorizedSymbolRenderer )
1233 r = qgis::make_unique< QgsGraduatedSymbolRenderer >( QString(),
QgsRangeList() );
1238 dynamic_cast<const QgsLimitedRandomColorRamp *>( categorizedSymbolRenderer->
sourceColorRamp() );
1242 r->setClassAttribute( categorizedSymbolRenderer->
classAttribute() );
1245 else if ( renderer->
type() == QLatin1String(
"pointDisplacement" ) || renderer->
type() == QLatin1String(
"pointCluster" ) )
1248 if ( pointDistanceRenderer )
1251 else if ( renderer->
type() == QLatin1String(
"invertedPolygonRenderer" ) )
1254 if ( invertedPolygonRenderer )
1263 r = qgis::make_unique< QgsGraduatedSymbolRenderer >( QString(),
QgsRangeList() );
1266 if ( !symbols.isEmpty() )
1268 r->setSourceSymbol( symbols.at( 0 )->clone() );
1272 r->setOrderBy( renderer->
orderBy() );
1293 return QStringLiteral(
"GraduatedColor" );
1295 return QStringLiteral(
"GraduatedSize" );
An abstract base class for distance based point renderers (e.g., clusterer and displacement renderers...
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
Class for parsing and evaluation of expressions (formerly called "search strings").
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
QgsClassificationMethod * method(const QString &id)
Returns a new instance of the method for the given id.
static QgsGraduatedSymbolRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
creates a QgsGraduatedSymbolRenderer from an existing renderer.
The class is used as a container of context for various read/write operations on other objects...
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
double rendererScale() const
Returns the renderer map scale.
A symbol entity for QgsStyle databases.
static QgsSymbol::ScaleMethod decodeScaleMethod(const QString &str)
std::unique_ptr< QgsSymbol > mSourceSymbol
QList< QgsRendererRange > QgsRangeList
QList< QgsClassificationRange > classes(const QgsVectorLayer *layer, const QString &expression, int nclasses)
This will calculate the classes for a given layer to define the classes.
static const QString METHOD_ID
QList< QgsLegendSymbolItem > QgsLegendSymbolList
bool filterNeedsGeometry() const override
Returns true if this renderer requires the geometry to apply the filter.
QgsFeatureRequest::OrderBy mOrderBy
QgsClassificationEqualInterval is an implementation of QgsClassificationMethod for equal intervals...
bool labelLessThan(const QgsRendererRange &r1, const QgsRendererRange &r2)
Abstract base class for all rendered symbols.
bool updateRangeUpperValue(int rangeIndex, double value)
bool rangesOverlap() const
Tests whether classes assigned to the renderer have ranges which overlap.
void setLabel(const QString &label)
virtual QgsColorRamp * clone() const =0
Creates a clone of the color ramp.
QgsClassificationMethod * classificationMethod() const
Returns the classification method.
Q_DECL_DEPRECATED void setSymmetryPoint(double symmetryPoint)
Set the pivot point.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
QgsFeatureRequest::OrderBy orderBy() const
Gets the order in which features shall be processed by this renderer.
Abstract base class for color ramps.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
void addBreak(double breakValue, bool updateSymbols=true)
Add a breakpoint by splitting existing classes so that the specified value becomes a break between tw...
static QDomElement saveColorRamp(const QString &name, QgsColorRamp *ramp, QDomDocument &doc)
Encodes a color ramp's settings to an XML element.
QString classAttribute() const
Returns the class attribute for the renderer, which is the field name or expression string from the l...
void setGraduatedMethod(GraduatedMethod method)
set the method used for graduation (either size or color)
void updateRangeLabels()
Updates the labels of the ranges.
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
Container of fields for a vector layer.
#define RENDERER_TAG_NAME
void setUsingSymbolLevels(bool usingSymbolLevels)
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
static void clearSymbolMap(QgsSymbolMap &symbols)
Q_DECL_DEPRECATED void setAstride(bool astride)
Set if we want a central class astride the pivot value.
static QgsFeatureRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
create renderer from XML element
QgsPaintEffect * mPaintEffect
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.
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void setSymbolSizes(double minSize, double maxSize)
set varying symbol size for classes
QgsClassificationCustom is a dummy implementation of QgsClassification which does not compute any bre...
An interface for classes which can visit style entity (e.g.
QgsLegendSymbolList legendSymbolList() const
Generates legend symbol items according to the configuration.
std::unique_ptr< QgsExpression > mExpression
The class is not at a bound.
void setUpperValue(double upperValue)
void addClass(QgsSymbol *symbol)
QMap< QString, QString > QgsStringMap
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.
A marker symbol type, for rendering Point and MultiPoint geometries.
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
void setLegendSymbolItem(const QString &key, QgsSymbol *symbol) override
Sets the symbol to be used for a legend symbol item.
bool rangesHaveGaps() const
Tests whether classes assigned to the renderer have gaps between the ranges.
void checkLegendSymbolItem(const QString &key, bool state=true) override
item in symbology was checked
void sortByValue(Qt::SortOrder order=Qt::AscendingOrder)
Q_DECL_DEPRECATED void setUseSymmetricMode(bool useSymmetricMode)
Set if we want to classify symmetric around a given value.
Q_DECL_DEPRECATED double symmetryPoint() const
Returns the pivot value for symmetric classification.
double lowerValue() const
The class is at the upper bound.
QSet< QString > legendKeysForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns legend keys matching a specified feature.
bool updateRangeSymbol(int rangeIndex, QgsSymbol *symbol)
void setSymmetricMode(bool enabled, double symmetryPoint=0, bool symmetryAstride=false)
Defines if the symmetric mode is enables and configures its parameters.
GraduatedMethod mGraduatedMethod
The class is at the lower bound.
QList< QgsSymbol * > QgsSymbolList
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
void updateColorRamp(QgsColorRamp *ramp=nullptr)
Update the color ramp used.
Q_DECL_DEPRECATED Mode mode() const
QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted...
bool updateRangeLowerValue(int rangeIndex, double value)
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.
void setLowerValue(double lowerValue)
bool labelGreaterThan(const QgsRendererRange &r1, const QgsRendererRange &r2)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setLabelFormat(const QString &format)
Defines the format of the labels for the classes, using %1 and %2 for the bounds. ...
QgsColorRamp * sourceColorRamp()
Returns the source color ramp, from which each classes' color is derived.
void updateFromSymbolAndProperty(const QgsMarkerSymbol *symbol, const QgsProperty &ddSize)
Updates the list of classes, source symbol and title label from given symbol and property.
static QgsColorRamp * loadColorRamp(QDomElement &element)
Creates a color ramp from the settings encoded in an XML element.
static void convertSymbolSizeScale(QgsSymbol *symbol, QgsSymbol::ScaleMethod method, const QString &field)
void setClassificationMethod(QgsClassificationMethod *method)
Defines the classification method This will take ownership of the method.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
QgsSymbol * symbol() const
QgsSymbol * sourceSymbol()
Returns the renderer's source symbol, which is the base symbol used for the each categories' symbol b...
A store for object properties.
bool valueLessThan(const QgsRendererRange &r1, const QgsRendererRange &r2)
std::shared_ptr< QgsClassificationMethod > mClassificationMethod
~QgsGraduatedSymbolRenderer() override
static QgsSymbolMap loadSymbols(QDomElement &element, const QgsReadWriteContext &context)
Reads a collection of symbols from XML and returns them in a map. Caller is responsible for deleting ...
void setLabelPrecision(int labelPrecision)
Defines the precision for the formatting of the labels.
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer...
QgsDataDefinedSizeLegend * dataDefinedSizeLegend() const
Returns configuration of appearance of legend when using data-defined size for marker symbols...
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns a list of attributes required by this renderer.
void moveClass(int from, int to)
Moves the category at index position from to index position to.
Totally random color ramp.
QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns symbol for feature.
QgsExpressionContext & expressionContext()
Gets the expression context.
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
void calculateLabelPrecision(bool updateRanges=true)
Reset the label decimal places to a numberbased on the minimum class interval.
Q_DECL_DEPRECATED void setMode(Mode mode)
static void convertSymbolRotation(QgsSymbol *symbol, const QString &field)
bool legendSymbolItemsCheckable() const override
items of symbology items in legend should be checkable
const QgsFeatureRenderer * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
double minSymbolSize() const
Returns the min symbol size when graduated by size.
QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns a list of attributes required to render this feature.
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
Contains information about the context of a rendering operation.
bool usingSymbolLevels() const
QgsSymbolList symbols(QgsRenderContext &context) const override
Returns list of symbols used by the renderer.
QgsLegendSymbolList legendSymbolItems() const override
Returns a list of symbology items for the legend.
Q_DECL_DEPRECATED bool useSymmetricMode() const
Returns if we want to classify symmetric around a given value.
void sortByLabel(Qt::SortOrder order=Qt::AscendingOrder)
QgsColorRamp * sourceColorRamp()
Returns the source color ramp, from which each categories' color is derived.
void setSymbol(QgsSymbol *s)
GraduatedMethod graduatedMethod() const
Returns the method used for graduation (either size or color)
QgsGraduatedSymbolRenderer(const QString &attrName=QString(), const QgsRangeList &ranges=QgsRangeList())
Q_DECL_DEPRECATED bool astride() const
Returns if we want to have a central class astride the pivot value.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
double maxSymbolSize() const
Returns the max symbol size when graduated by size.
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
static QgsClassificationMethodRegistry * classificationMethodRegistry()
Returns the application's classification methods registry, used in graduated renderer.
static QList< double > rangesToBreaks(const QList< QgsClassificationRange > &classes)
Transforms a list of classes to a list of breaks.
void setDataDefinedSizeLegend(QgsDataDefinedSizeLegend *settings)
Configures appearance of legend when renderer is configured to use data-defined size for marker symbo...
void CORE_EXPORT save(QDomElement &elem) const
Serialize to XML.
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.
QString dump() const override
Returns debug information about this renderer.
double upperValue() const
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props=QgsStringMap()) const override
used from subclasses to create SLD Rule elements following SLD v1.1 specs
QgsGraduatedSymbolRenderer * clone() const override
Create a deep copy of this renderer.
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
QMap< QString, QgsSymbol *> QgsSymbolMap
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
ClassPosition
Defines the class position.
static Q_DECL_DEPRECATED QList< double > calcEqualIntervalBreaks(double minimum, double maximum, int classes, bool useSymmetricMode, double symmetryPoint, bool astride)
Compute the equal interval classification.
Q_DECL_DEPRECATED void setLabelFormat(const QgsRendererRangeLabelFormat &labelFormat, bool updateRanges=false)
Set the label format used to generate default classification labels.
bool updateRangeRenderState(int rangeIndex, bool render)
bool valueGreaterThan(const QgsRendererRange &r1, const QgsRendererRange &r2)
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...
bool updateRangeLabel(int rangeIndex, const QString &label)
void setLabelTrimTrailingZeroes(bool trimTrailingZeroes)
Defines if the trailing 0 are trimmed in the label.
bool legendSymbolItemChecked(const QString &key) override
items of symbology items in legend is checked
void appendScopes(const QList< QgsExpressionContextScope *> &scopes)
Appends a list of scopes to the end of the context.
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) override
store renderer info to XML element
A color ramp entity for QgsStyle databases.
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...
int mAttrNum
attribute index (derived from attribute name in startRender)
int ANALYSIS_EXPORT lower(int n, int i)
Lower function.
std::unique_ptr< QgsColorRamp > mSourceColorRamp
const QgsFeatureRenderer * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
QString legendKeyForValue(double value) const
Returns the matching legend key for a value.
static QString graduatedMethodStr(GraduatedMethod method)
Represents a vector layer which manages a vector based data sets.
Object that keeps configuration of appearance of marker symbol's data-defined size in legend...
QgsSymbol * symbolForValue(double value) const
Gets the symbol which is used to represent value.
std::unique_ptr< QgsDataDefinedSizeLegend > mDataDefinedSizeLegend
void setSourceSymbol(QgsSymbol *sym)
Sets the source symbol for the renderer, which is the base symbol used for the each categories' symbo...
const QgsRangeList & ranges() const
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...
QgsClassificationMethod is an abstract class for implementations of classification methods...
void setSourceColorRamp(QgsColorRamp *ramp)
Sets the source color ramp.
void updateSymbols(QgsSymbol *sym)
Update all the symbols but leave breaks and colors.
Contains information relating to the style entity currently being visited.
QgsSymbol * sourceSymbol()
Returns the renderer's source symbol, which is the base symbol used for the each classes' symbol befo...
void setSourceSymbol(QgsSymbol *sym)
Sets the source symbol for the renderer, which is the base symbol used for the each classes' symbol b...
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
void deleteClass(int idx)
bool isActive() const
Returns whether the property is currently active.
void setColor(const QColor &color)
Sets the color for the symbol.
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.
static QgsClassificationMethod * create(const QDomElement &element, const QgsReadWriteContext &context)
Reads the DOM element and return a new classification method from it.