16#ifndef QGSCLASSIFICATIONMETHOD_H
17#define QGSCLASSIFICATIONMETHOD_H
55 , mLowerBound( lowerBound )
56 , mUpperBound( upperBound )
64 QString
label()
const {
return mLabel;}
67 SIP_PYOBJECT __repr__();
69 QString str = QStringLiteral(
"<QgsClassificationRange: '%1'>" ).arg( sipCpp->label() );
70 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
94 sipType = sipType_QgsClassificationEqualInterval;
96 sipType = sipType_QgsClassificationJenks;
98 sipType = sipType_QgsClassificationPrettyBreaks;
100 sipType = sipType_QgsClassificationQuantile;
102 sipType = sipType_QgsClassificationStandardDeviation;
104 sipType = sipType_QgsClassificationFixedInterval;
116 ValuesNotRequired = 1 << 1,
117 SymmetricModeAvailable = 1 << 2,
118 IgnoresClassCount = 1 << 3,
144 virtual std::unique_ptr< QgsClassificationMethod >
clone()
const = 0;
147 virtual QString
name()
const = 0;
150 virtual QString
id()
const = 0;
153 virtual QIcon
icon()
const {
return QIcon();}
165 virtual QString labelForRange(
double lowerValue,
double upperValue, ClassPosition position = Inner )
const;
214 void setSymmetricMode(
bool enabled,
double symmetryPoint = 0,
bool symmetryAstride =
false );
224 void setLabelPrecision(
int labelPrecision );
231 static QList<double> rangesToBreaks(
const QList<QgsClassificationRange> &classes );
241 Q_DECL_DEPRECATED QList<QgsClassificationRange> classes(
const QgsVectorLayer *layer,
const QString &expression,
int nclasses )
SIP_DEPRECATED;
255 QList<QgsClassificationRange> classesV2(
const QgsVectorLayer *layer,
const QString &expression,
int nclasses, QString &error
SIP_OUT );
262 QList<QgsClassificationRange> classes(
const QList<double> &values,
int nclasses );
271 QList<QgsClassificationRange> classes(
double minimum,
double maximum,
int nclasses );
285 static std::unique_ptr< QgsClassificationMethod > create(
const QDomElement &element,
const QgsReadWriteContext &context );
294 static void makeBreaksSymmetric( QList<double> &breaks
SIP_INOUT,
double symmetryPoint,
bool astride );
299 QString labelForRange(
const QgsRendererRange &range, ClassPosition position = Inner )
const;
317 void setParameterValues(
const QVariantMap &values );
335 QString formatNumber(
double value )
const;
353 virtual QList<double> calculateBreaks(
double &minimum,
double &maximum,
354 const QList<double> &values,
int nclasses, QString &error ) = 0;
357 virtual QString valueToLabel(
double value )
const {
return formatNumber( value );}
360 QList<QgsClassificationRange> breaksToClasses(
const QList<double> &breaks )
const;
363 MethodProperties mFlags = MethodProperties();
364 int mCodeComplexity = 1;
368 bool mSymmetricEnabled =
false;
369 double mSymmetryPoint = 0;
370 bool mSymmetryAstride =
false;
371 int mLabelPrecision = 4;
372 bool mLabelTrimTrailingZeroes =
true;
373 QString mLabelFormat;
376 double mLabelNumberScale = 1.0;
377 QString mLabelNumberSuffix;
381 QVariantMap mParameterValues;
QgsClassificationEqualInterval is an implementation of QgsClassificationMethod for equal intervals.
Implementation of a fixed interval classification.
QgsClassificationJenks is an implementation of QgsClassificationMethod for natural breaks based on Je...
QgsClassificationMethod is 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.
@ 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
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.
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.
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.
bool symmetricModeAvailable() const
Returns if the method supports symmetric calculation.
QgsClassificationMethod::MethodProperties flags() const
Returns the classification flags.
QgsClassificationPrettyBreaks is an implementation of QgsClassificationMethod for pretty breaks.
QgsClassificationQuantile is an implementation of QgsClassificationMethod based on quantiles.
QgsClassificationRange contains the information about a classification range.
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.
QgsClassificationCustom is an implementation of QgsClassificationMethod based on standard deviation.
Base class for the definition of processing parameters.
The class is used as a container of context for various read/write operations on other objects.
Represents a vector layer which manages a vector based data sets.
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.
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsTextRendererUtils::CurvedTextFlags)