16#ifndef QGSCLASSIFICATIONMETHOD_H
17#define QGSCLASSIFICATIONMETHOD_H
26using namespace Qt::StringLiterals;
68 QString
label()
const {
return mLabel; }
72 SIP_PYOBJECT __repr__();
74 QString str = u
"<QgsClassificationRange: '%1'>"_s.arg( sipCpp->label() );
75 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
99 sipType = sipType_QgsClassificationEqualInterval;
101 sipType = sipType_QgsClassificationJenks;
103 sipType = sipType_QgsClassificationPrettyBreaks;
105 sipType = sipType_QgsClassificationQuantile;
107 sipType = sipType_QgsClassificationStandardDeviation;
109 sipType = sipType_QgsClassificationFixedInterval;
148 virtual std::unique_ptr< QgsClassificationMethod >
clone()
const = 0;
151 virtual QString
name()
const = 0;
154 virtual QString
id()
const = 0;
157 virtual QIcon
icon()
const {
return QIcon(); }
169 virtual QString labelForRange(
double lowerValue,
double upperValue, ClassPosition position = Inner )
const;
226 void setSymmetricMode(
bool enabled,
double symmetryPoint = 0,
bool symmetryAstride =
false );
236 void setLabelPrecision(
int labelPrecision );
243 static QList<double> rangesToBreaks(
const QList<QgsClassificationRange> &classes );
253 Q_DECL_DEPRECATED QList<QgsClassificationRange> classes(
const QgsVectorLayer *layer,
const QString &expression,
int nclasses )
SIP_DEPRECATED;
267 QList<QgsClassificationRange> classesV2(
const QgsVectorLayer *layer,
const QString &expression,
int nclasses, QString &error
SIP_OUT );
274 QList<QgsClassificationRange> classes(
const QList<double> &values,
int nclasses );
283 QList<QgsClassificationRange> classes(
double minimum,
double maximum,
int nclasses );
297 static std::unique_ptr< QgsClassificationMethod > create(
const QDomElement &element,
const QgsReadWriteContext &context );
306 static void makeBreaksSymmetric( QList<double> &breaks
SIP_INOUT,
double symmetryPoint,
bool astride );
311 QString labelForRange(
const QgsRendererRange &range, ClassPosition position = Inner )
const;
329 void setParameterValues(
const QVariantMap &values );
363 virtual QList<double> calculateBreaks(
double &minimum,
double &maximum,
const QList<double> &values,
int nclasses, QString &error ) = 0;
366 virtual QString valueToLabel(
double value )
const {
return formatNumber( value ); }
369 QList<QgsClassificationRange> breaksToClasses(
const QList<double> &breaks )
const;
372 MethodProperties mFlags = MethodProperties();
373 int mCodeComplexity = 1;
377 bool mSymmetricEnabled =
false;
378 double mSymmetryPoint = 0;
379 bool mSymmetryAstride =
false;
380 int mLabelPrecision = 4;
381 bool mLabelTrimTrailingZeroes =
true;
382 QString mLabelFormat;
385 double mLabelNumberScale = 1.0;
386 QString mLabelNumberSuffix;
390 QVariantMap mParameterValues;
A classification method which uses equal width intervals.
Implementation of a fixed interval classification.
A classification method for natural breaks, based on Jenks method.
An abstract class for implementations of classification methods.
double symmetryPoint() const
Returns the symmetry point for symmetric mode.
int codeComplexity() const
Code complexity as the exponent in Big O notation.
bool symmetricModeEnabled() const
Returns if the symmetric mode is enabled.
QFlags< MethodProperty > MethodProperties
int labelPrecision() const
Returns the precision for the formatting of the labels.
virtual QString id() const =0
The id of the method as saved in the project, must be unique in registry.
virtual std::unique_ptr< QgsClassificationMethod > clone() const =0
Returns a clone of the method.
void setLabelTrimTrailingZeroes(bool trimTrailingZeroes)
Defines if the trailing 0 are trimmed in the label.
QVariantMap parameterValues() const
Returns the values of the processing 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.
bool symmetryAstride() const
Returns if the symmetric mode is astride if true, it will remove the symmetry point break so that the...
static const int MIN_PRECISION
void addParameter(QgsProcessingParameterDefinition *definition)
Add a parameter to the method.
virtual void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads extra information to apply it to the method.
virtual void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes extra information about the method.
QString labelFormat() const
Returns the format of the label for the classes.
virtual bool valuesRequired() const
Returns if the method requires values to calculate the classes If not, bounds are sufficient.
virtual QString name() const =0
The readable and translate name of the method.
QgsClassificationMethod(MethodProperties properties=NoFlag, int codeComplexity=1)
Creates a classification method.
void setLabelFormat(const QString &format)
Defines the format of the labels for the classes, using %1 and %2 for the bounds.
virtual QIcon icon() const
The icon of the method.
QString formatNumber(double value) const
Format the number according to label properties.
static const int MAX_PRECISION
bool labelTrimTrailingZeroes() const
Returns if the trailing 0 are trimmed in the label.
QgsProcessingParameterDefinitions parameterDefinitions() const
Returns the list of parameters.
MethodProperty
Flags for the classification method.
@ ValuesNotRequired
Deprecated since QGIS 3.12.
@ SymmetricModeAvailable
This allows using symmetric classification.
@ IgnoresClassCount
The classification method does not compute classes based on a class count.
bool symmetricModeAvailable() const
Returns if the method supports symmetric calculation.
void copyBase(QgsClassificationMethod *c) const
Copy the parameters (shall be used in clone implementation).
QgsClassificationMethod::MethodProperties flags() const
Returns the classification flags.
A classification method which applies pretty breaks to data.
A classification method which creates classes based on quantiles.
QgsClassificationRange(const QString &label, double lowerBound, double upperBound)
Constructor.
QString label() const
Returns the lower bound.
double upperBound() const
Returns the upper bound.
double lowerBound() const
Returns the lower bound.
A classification method which classifies based on standard deviation of values.
Base class for the definition of processing parameters.
A container for the context for various read/write operations on objects.
Represents a value range for a QgsGraduatedSymbolRenderer.
Represents a vector layer which manages a vector based dataset.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
#define SIP_ENUM_BASETYPE(type)
QList< const QgsProcessingParameterDefinition * > QgsProcessingParameterDefinitions
List of processing parameters.