16#ifndef QGSCLASSIFICATIONMETHOD_H
17#define QGSCLASSIFICATIONMETHOD_H
26using namespace Qt::StringLiterals;
67 QString
label()
const {
return mLabel;}
70 SIP_PYOBJECT __repr__();
72 QString str = u
"<QgsClassificationRange: '%1'>"_s.arg( sipCpp->label() );
73 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
97 sipType = sipType_QgsClassificationEqualInterval;
99 sipType = sipType_QgsClassificationJenks;
101 sipType = sipType_QgsClassificationPrettyBreaks;
103 sipType = sipType_QgsClassificationQuantile;
105 sipType = sipType_QgsClassificationStandardDeviation;
107 sipType = sipType_QgsClassificationFixedInterval;
147 virtual std::unique_ptr< QgsClassificationMethod >
clone()
const = 0;
150 virtual QString
name()
const = 0;
153 virtual QString
id()
const = 0;
156 virtual QIcon
icon()
const {
return QIcon();}
168 virtual QString labelForRange(
double lowerValue,
double upperValue, ClassPosition position = Inner )
const;
217 void setSymmetricMode(
bool enabled,
double symmetryPoint = 0,
bool symmetryAstride =
false );
227 void setLabelPrecision(
int labelPrecision );
234 static QList<double> rangesToBreaks(
const QList<QgsClassificationRange> &classes );
244 Q_DECL_DEPRECATED QList<QgsClassificationRange> classes(
const QgsVectorLayer *layer,
const QString &expression,
int nclasses )
SIP_DEPRECATED;
258 QList<QgsClassificationRange> classesV2(
const QgsVectorLayer *layer,
const QString &expression,
int nclasses, QString &error
SIP_OUT );
265 QList<QgsClassificationRange> classes(
const QList<double> &values,
int nclasses );
274 QList<QgsClassificationRange> classes(
double minimum,
double maximum,
int nclasses );
288 static std::unique_ptr< QgsClassificationMethod > create(
const QDomElement &element,
const QgsReadWriteContext &context );
297 static void makeBreaksSymmetric( QList<double> &breaks
SIP_INOUT,
double symmetryPoint,
bool astride );
302 QString labelForRange(
const QgsRendererRange &range, ClassPosition position = Inner )
const;
320 void setParameterValues(
const QVariantMap &values );
356 virtual QList<double> calculateBreaks(
double &minimum,
double &maximum,
357 const QList<double> &values,
int nclasses, QString &error ) = 0;
360 virtual QString valueToLabel(
double value )
const {
return formatNumber( value );}
363 QList<QgsClassificationRange> breaksToClasses(
const QList<double> &breaks )
const;
366 MethodProperties mFlags = MethodProperties();
367 int mCodeComplexity = 1;
371 bool mSymmetricEnabled =
false;
372 double mSymmetryPoint = 0;
373 bool mSymmetryAstride =
false;
374 int mLabelPrecision = 4;
375 bool mLabelTrimTrailingZeroes =
true;
376 QString mLabelFormat;
379 double mLabelNumberScale = 1.0;
380 QString mLabelNumberSuffix;
384 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.