16 #ifndef QGSCLASSIFICATIONMETHOD_H 17 #define QGSCLASSIFICATIONMETHOD_H 22 #include "qgis_core.h" 54 , mLowerBound( lowerBound )
55 , mUpperBound( upperBound )
63 QString
label()
const {
return mLabel;}
66 SIP_PYOBJECT __repr__();
68 QString str = QStringLiteral(
"<QgsClassificationRange: '%1'>" ).arg( sipCpp->label() );
69 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
92 if ( dynamic_cast<QgsClassificationEqualInterval *>( sipCpp ) )
93 sipType = sipType_QgsClassificationEqualInterval;
94 else if ( dynamic_cast<QgsClassificationJenks *>( sipCpp ) )
95 sipType = sipType_QgsClassificationJenks;
96 else if ( dynamic_cast<QgsClassificationPrettyBreaks *>( sipCpp ) )
97 sipType = sipType_QgsClassificationPrettyBreaks;
98 else if ( dynamic_cast<QgsClassificationQuantile *>( sipCpp ) )
99 sipType = sipType_QgsClassificationQuantile;
100 else if ( dynamic_cast<QgsClassificationStandardDeviation *>( sipCpp ) )
101 sipType = sipType_QgsClassificationStandardDeviation;
113 ValuesNotRequired = 1 << 1,
114 SymmetricModeAvailable = 1 << 2,
143 virtual QString name()
const = 0;
146 virtual QString id()
const = 0;
149 virtual QIcon
icon()
const {
return QIcon();}
154 virtual QString labelForRange(
double lowerValue,
double upperValue,
ClassPosition position = Inner )
const;
202 void setSymmetricMode(
bool enabled,
double symmetryPoint = 0,
bool symmetryAstride =
false );
212 void setLabelPrecision(
int labelPrecision );
219 static QList<double> rangesToBreaks(
const QList<QgsClassificationRange> &classes );
227 QList<QgsClassificationRange> classes(
const QgsVectorLayer *layer,
const QString &expression,
int nclasses );
234 QList<QgsClassificationRange> classes(
const QList<double> &values,
int nclasses );
243 QList<QgsClassificationRange> classes(
double minimum,
double maximum,
int nclasses );
266 static void makeBreaksSymmetric( QList<double> &breaks
SIP_INOUT,
double symmetryPoint,
bool astride );
284 QString formatNumber(
double value )
const;
293 virtual QList<double> calculateBreaks(
double minimum,
double maximum,
294 const QList<double> &values,
int nclasses ) = 0;
297 virtual QString valueToLabel(
double value )
const {
return formatNumber( value );}
301 QList<QgsClassificationRange> breaksToClasses(
const QList<double> &breaks )
const;
304 MethodProperties mFlags =
nullptr;
305 int mCodeComplexity = 1;
309 bool mSymmetricEnabled =
false;
310 double mSymmetryPoint = 0;
311 bool mSymmetryAstride =
false;
312 int mLabelPrecision = 4;
313 bool mLabelTrimTrailingZeroes =
true;
314 QString mLabelFormat;
318 double mLabelNumberScale = 1.0;
319 QString mLabelNumberSuffix;
322 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsClassificationMethod::MethodProperties )
324 #endif // QGSCLASSIFICATIONMETHOD_H The class is used as a container of context for various read/write operations on other objects...
double lowerBound() const
Returns the lower bound.
virtual QIcon icon() const
The icon of the method.
bool symmetricModeAvailable() const
Returns if the method supports symmetric calculation.
QString label() const
Returns the lower bound.
int codeComplexity() const
Code complexity as the exponent in Big O notation.
bool symmetryAstride() const
Returns if the symmetric mode is astride if true, it will remove the symmetry point break so that the...
QgsClassificationRange contains the information about a classification range.
virtual void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes extra information about the method.
The class is not at a bound.
double upperBound() const
Returns the upper bound.
bool valuesRequired() const
Returns if the method requires values to calculate the classes If not, bounds are sufficient...
static const int MAX_PRECISION
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
The class is at the lower bound.
double symmetryPoint() const
Returns the symmetry point for symmetric mode.
int labelPrecision() const
Returns the precision for the formatting of the labels.
MethodProperty
Flags for the classification method.
void setLabelFormat(const QString &format)
Defines the format of the labels for the classes, using %1 and %2 for the bounds. ...
bool labelTrimTrailingZeroes() const
Returns if the trailing 0 are trimmed in the label.
static const int MIN_PRECISION
bool symmetricModeEnabled() const
Returns if the symmetric mode is enabled.
virtual void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads extra information to apply it to the method.
QString labelFormat() const
Returns the format of the label for the classes.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
QgsClassificationRange(const QString &label, double lowerBound, double upperBound)
Constructor.
ClassPosition
Defines the class position.
void setLabelTrimTrailingZeroes(bool trimTrailingZeroes)
Defines if the trailing 0 are trimmed in the label.
Represents a vector layer which manages a vector based data sets.
QgsClassificationMethod is an abstract class for implementations of classification methods...