mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-16 00:05:45 -04:00
better naming of methods and API documentation
This commit is contained in:
parent
b580242aef
commit
ac1ce4f4ed
@ -151,20 +151,20 @@ Returns if the symmetric mode is enabled
|
||||
Returns the symmetry point for symmetric mode
|
||||
%End
|
||||
|
||||
bool astride() const;
|
||||
bool symmetryAstride() const;
|
||||
%Docstring
|
||||
Returns if the symmetric mode is astride
|
||||
if ``True``, it will remove the symmetry point break so that the 2 classes form only one
|
||||
%End
|
||||
|
||||
void setSymmetricMode( bool enabled, double symmetryPoint = 0, bool astride = false );
|
||||
void setSymmetricMode( bool enabled, double symmetryPoint = 0, bool symmetryAstride = false );
|
||||
%Docstring
|
||||
Defines if the symmetric mode is enables and configures its parameters.
|
||||
If the symmetric mode is not available in the current implementation, calling this method has no effect.
|
||||
|
||||
:param enabled: if the symmetric mode is enabled
|
||||
:param symmetryPoint: the value of the symmetry point
|
||||
:param astride: if ``True``, it will remove the symmetry point break so that the 2 classes form only one
|
||||
:param symmetryAstride: if ``True``, it will remove the symmetry point break so that the 2 classes form only one
|
||||
%End
|
||||
|
||||
QString labelFormat() const;
|
||||
@ -197,26 +197,26 @@ Defines if the trailing 0 are trimmed in the label
|
||||
Transforms a list of classes to a list of breaks
|
||||
%End
|
||||
|
||||
QList<QgsClassificationRange> classes( const QgsVectorLayer *vl, const QString &expression, int numberOfClasses );
|
||||
QList<QgsClassificationRange> classes( const QgsVectorLayer *vl, const QString &expression, int nclasses );
|
||||
%Docstring
|
||||
This will calculate the breaks for a given layer to define the classes.
|
||||
The breaks do not contain the uppper and lower bounds (minimum and maximum values).
|
||||
|
||||
:param vl: The vector layer
|
||||
:param fieldName: The name of the field on which the classes are calculated
|
||||
:param numberOfClasses: The number of classes to be returned
|
||||
:param nclasses: The number of classes to be returned
|
||||
%End
|
||||
|
||||
QList<QgsClassificationRange> classes( const QList<double> &values, int numberOfClasses );
|
||||
QList<QgsClassificationRange> classes( const QList<double> &values, int nclasses );
|
||||
%Docstring
|
||||
This will calculate the breaks for a list of values.
|
||||
The breaks do not contain the uppper and lower bounds (minimum and maximum values)
|
||||
|
||||
:param values: The list of values
|
||||
:param numberOfClasses: The number of classes to be returned
|
||||
:param nclasses: The number of classes to be returned
|
||||
%End
|
||||
|
||||
QList<QgsClassificationRange> classes( double minimum, double maximum, int numberOfClasses );
|
||||
QList<QgsClassificationRange> classes( double minimum, double maximum, int nclasses );
|
||||
%Docstring
|
||||
This will calculate the classes for defined bounds without any values.
|
||||
The breaks do not contain the uppper and lower bounds (minimum and maximum values)
|
||||
@ -226,20 +226,20 @@ The breaks do not contain the uppper and lower bounds (minimum and maximum value
|
||||
If the method implementation requires values, this will return an empty list.
|
||||
|
||||
:param values: The list of values
|
||||
:param numberOfClasses: The number of classes to be returned
|
||||
:param nclasses: The number of classes to be returned
|
||||
%End
|
||||
|
||||
QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const;
|
||||
static QgsClassificationMethod *create( const QDomElement &element, const QgsReadWriteContext &context ) /Factory/;
|
||||
|
||||
static void makeBreaksSymmetric( QList<double> &breaks /In,Out/, double symmetryPoint, bool astride );
|
||||
static void makeBreaksSymmetric( QList<double> &breaks /In,Out/, double symmetryPoint, bool symmetryAstride );
|
||||
%Docstring
|
||||
Remove the breaks that are above the existing opposite sign classes to keep colors symmetrically balanced around symmetryPoint
|
||||
Does not put a break on the symmetryPoint. This is done before.
|
||||
|
||||
:param breaks: The breaks of an already-done classification
|
||||
:param symmetryPoint: The point around which we want a symmetry
|
||||
:param astride: A bool indicating if the symmetry is made astride the symmetryPoint or not ( [-1,1] vs. [-1,0][0,1] )
|
||||
:param symmetryAstride: A bool indicating if the symmetry is made astride the symmetryPoint or not ( [-1,1] vs. [-1,0][0,1] )
|
||||
%End
|
||||
|
||||
QString labelForRange( const QgsRendererRange &range, ClassPosition position = Inner ) const;
|
||||
|
@ -254,11 +254,12 @@ Recalculate classes for a layer
|
||||
.. deprecated:: since QGIS 3.10
|
||||
%End
|
||||
|
||||
void updateClasses( const QgsVectorLayer *vl, int numberOfClasses );
|
||||
void updateClasses( const QgsVectorLayer *vl, int nclasses );
|
||||
%Docstring
|
||||
Recalculate classes for a layer
|
||||
|
||||
:param vlayer: The layer being rendered (from which data values are calculated)
|
||||
:param vl: The layer being rendered (from which data values are calculated)
|
||||
:param nclasses: the number of classes
|
||||
%End
|
||||
|
||||
const QgsRendererRangeLabelFormat &labelFormat() const;
|
||||
@ -292,7 +293,7 @@ Reset the label decimal places to a numberbased on the minimum class interval
|
||||
%End
|
||||
|
||||
|
||||
static QgsGraduatedSymbolRenderer *createRenderer( QgsVectorLayer *vlayer,
|
||||
static QgsGraduatedSymbolRenderer *createRenderer( QgsVectorLayer *vlayer,
|
||||
const QString &attrName,
|
||||
int classes,
|
||||
Mode mode,
|
||||
|
@ -24,7 +24,15 @@ class QgsRendererRange
|
||||
%Docstring
|
||||
Constructor for QgsRendererRange.
|
||||
%End
|
||||
|
||||
QgsRendererRange( const QgsClassificationRange &range, QgsSymbol *symbol /Transfer/, bool render = true );
|
||||
%Docstring
|
||||
Creates a renderer symbol range
|
||||
|
||||
:param range: The classification range
|
||||
:param symbol: The symbol for this renderer range
|
||||
:param render: If true, it will be renderered
|
||||
%End
|
||||
QgsRendererRange( double lowerValue, double upperValue, QgsSymbol *symbol /Transfer/, const QString &label, bool render = true );
|
||||
QgsRendererRange( const QgsRendererRange &range );
|
||||
|
||||
|
@ -44,11 +44,11 @@ QString QgsClassificationCustom::id() const
|
||||
}
|
||||
|
||||
QList<double> QgsClassificationCustom::calculateBreaks( double minimum, double maximum,
|
||||
const QList<double> &values, int numberOfClasses )
|
||||
const QList<double> &values, int nclasses )
|
||||
{
|
||||
Q_UNUSED( minimum )
|
||||
Q_UNUSED( maximum )
|
||||
Q_UNUSED( values )
|
||||
Q_UNUSED( numberOfClasses )
|
||||
Q_UNUSED( nclasses )
|
||||
return QList<double>();
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class CORE_EXPORT QgsClassificationCustom : public QgsClassificationMethod
|
||||
|
||||
private:
|
||||
QList<double> calculateBreaks( double minimum, double maximum,
|
||||
const QList<double> &values, int numberOfClasses ) override;
|
||||
const QList<double> &values, int nclasses ) override;
|
||||
};
|
||||
|
||||
#endif // QGSCLASSIFICATIONCUSTOM_H
|
||||
|
@ -37,7 +37,7 @@ QString QgsClassificationEqualInterval::id() const
|
||||
}
|
||||
|
||||
QList<double> QgsClassificationEqualInterval::calculateBreaks( double minimum, double maximum,
|
||||
const QList<double> &values, int numberOfClasses )
|
||||
const QList<double> &values, int nclasses )
|
||||
{
|
||||
Q_UNUSED( values )
|
||||
|
||||
@ -46,45 +46,45 @@ QList<double> QgsClassificationEqualInterval::calculateBreaks( double minimum, d
|
||||
QList<double> breaks;
|
||||
if ( !symmetricModeEnabled() ) // normal mode
|
||||
{
|
||||
double step = ( maximum - minimum ) / numberOfClasses;
|
||||
double step = ( maximum - minimum ) / nclasses;
|
||||
|
||||
double value = minimum;
|
||||
breaks.reserve( numberOfClasses );
|
||||
for ( int i = 0; i < numberOfClasses; i++ )
|
||||
breaks.reserve( nclasses );
|
||||
for ( int i = 0; i < nclasses; i++ )
|
||||
{
|
||||
value += step;
|
||||
breaks << value;
|
||||
}
|
||||
// floating point arithmetics is not precise:
|
||||
// set the last break to be exactly maximum so we do not miss it
|
||||
breaks[numberOfClasses - 1] = maximum;
|
||||
breaks[nclasses - 1] = maximum;
|
||||
}
|
||||
else // symmetric mode
|
||||
{
|
||||
double distBelowSymmetricValue = std::abs( minimum - symmetryPoint() );
|
||||
double distAboveSymmetricValue = std::abs( maximum - symmetryPoint() ) ;
|
||||
|
||||
if ( astride() )
|
||||
if ( symmetryAstride() )
|
||||
{
|
||||
if ( numberOfClasses % 2 == 0 ) // we want odd number of classes
|
||||
++numberOfClasses;
|
||||
if ( nclasses % 2 == 0 ) // we want odd number of classes
|
||||
++nclasses;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( numberOfClasses % 2 == 1 ) // we want even number of classes
|
||||
++numberOfClasses;
|
||||
if ( nclasses % 2 == 1 ) // we want even number of classes
|
||||
++nclasses;
|
||||
}
|
||||
double step = 2 * std::min( distBelowSymmetricValue, distAboveSymmetricValue ) / numberOfClasses;
|
||||
double step = 2 * std::min( distBelowSymmetricValue, distAboveSymmetricValue ) / nclasses;
|
||||
|
||||
breaks.reserve( numberOfClasses );
|
||||
double value = ( distBelowSymmetricValue < distAboveSymmetricValue ) ? minimum : maximum - numberOfClasses * step;
|
||||
breaks.reserve( nclasses );
|
||||
double value = ( distBelowSymmetricValue < distAboveSymmetricValue ) ? minimum : maximum - nclasses * step;
|
||||
|
||||
for ( int i = 0; i < numberOfClasses; i++ )
|
||||
for ( int i = 0; i < nclasses; i++ )
|
||||
{
|
||||
value += step;
|
||||
breaks << value;
|
||||
}
|
||||
breaks[numberOfClasses - 1] = maximum;
|
||||
breaks[nclasses - 1] = maximum;
|
||||
}
|
||||
|
||||
return breaks;
|
||||
|
@ -38,7 +38,7 @@ class CORE_EXPORT QgsClassificationEqualInterval : public QgsClassificationMetho
|
||||
|
||||
private:
|
||||
QList<double> calculateBreaks( double minimum, double maximum,
|
||||
const QList<double> &values, int numberOfClasses ) override;
|
||||
const QList<double> &values, int nclasses ) override;
|
||||
|
||||
|
||||
};
|
||||
|
@ -42,7 +42,7 @@ QgsClassificationMethod *QgsClassificationJenks::clone() const
|
||||
|
||||
|
||||
QList<double> QgsClassificationJenks::calculateBreaks( double minimum, double maximum,
|
||||
const QList<double> &values, int numberOfClasses )
|
||||
const QList<double> &values, int nclasses )
|
||||
{
|
||||
// Jenks Optimal (Natural Breaks) algorithm
|
||||
// Based on the Jenks algorithm from the 'classInt' package available for
|
||||
@ -57,12 +57,12 @@ QList<double> QgsClassificationJenks::calculateBreaks( double minimum, double ma
|
||||
if ( values.isEmpty() )
|
||||
return QList<double>();
|
||||
|
||||
if ( numberOfClasses <= 1 )
|
||||
if ( nclasses <= 1 )
|
||||
{
|
||||
return QList<double>() << maximum;
|
||||
}
|
||||
|
||||
if ( numberOfClasses >= values.size() )
|
||||
if ( nclasses >= values.size() )
|
||||
{
|
||||
return values;
|
||||
}
|
||||
@ -106,11 +106,11 @@ QList<double> QgsClassificationJenks::calculateBreaks( double minimum, double ma
|
||||
|
||||
for ( int i = 0; i <= n; i++ )
|
||||
{
|
||||
matrixOne[i].resize( numberOfClasses + 1 );
|
||||
matrixTwo[i].resize( numberOfClasses + 1 );
|
||||
matrixOne[i].resize( nclasses + 1 );
|
||||
matrixTwo[i].resize( nclasses + 1 );
|
||||
}
|
||||
|
||||
for ( int i = 1; i <= numberOfClasses; i++ )
|
||||
for ( int i = 1; i <= nclasses; i++ )
|
||||
{
|
||||
matrixOne[0][i] = 1;
|
||||
matrixOne[1][i] = 1;
|
||||
@ -143,7 +143,7 @@ QList<double> QgsClassificationJenks::calculateBreaks( double minimum, double ma
|
||||
int i4 = i3 - 1;
|
||||
if ( i4 != 0 )
|
||||
{
|
||||
for ( int j = 2; j <= numberOfClasses; j++ )
|
||||
for ( int j = 2; j <= nclasses; j++ )
|
||||
{
|
||||
if ( matrixTwo[l][j] >= v + matrixTwo[i4][j - 1] )
|
||||
{
|
||||
@ -157,10 +157,10 @@ QList<double> QgsClassificationJenks::calculateBreaks( double minimum, double ma
|
||||
matrixTwo[l][1] = v;
|
||||
}
|
||||
|
||||
QVector<double> breaks( numberOfClasses );
|
||||
breaks[numberOfClasses - 1] = sample[n - 1];
|
||||
QVector<double> breaks( nclasses );
|
||||
breaks[nclasses - 1] = sample[n - 1];
|
||||
|
||||
for ( int j = numberOfClasses, k = n; j >= 2; j-- )
|
||||
for ( int j = nclasses, k = n; j >= 2; j-- )
|
||||
{
|
||||
int id = matrixOne[k][j] - 1;
|
||||
breaks[j - 2] = sample[id];
|
||||
|
@ -36,7 +36,7 @@ class CORE_EXPORT QgsClassificationJenks : public QgsClassificationMethod
|
||||
|
||||
private:
|
||||
QList<double> calculateBreaks( double minimum, double maximum,
|
||||
const QList<double> &values, int numberOfClasses ) override;
|
||||
const QList<double> &values, int nclasses ) override;
|
||||
|
||||
int mMaximumSize = 3000;
|
||||
};
|
||||
|
@ -45,7 +45,7 @@ QgsClassificationMethod::QgsClassificationMethod( bool valuesRequired, bool symm
|
||||
|
||||
void QgsClassificationMethod::copyBase( QgsClassificationMethod *c ) const
|
||||
{
|
||||
c->setSymmetricMode( mSymmetricEnabled, mSymmetryPoint, mAstride );
|
||||
c->setSymmetricMode( mSymmetricEnabled, mSymmetryPoint, mSymmetryAstride );
|
||||
c->setLabelFormat( mLabelFormat );
|
||||
c->setLabelPrecision( mLabelPrecision );
|
||||
c->setLabelTrimTrailingZeroes( mLabelTrimTrailingZeroes );
|
||||
@ -96,7 +96,7 @@ QDomElement QgsClassificationMethod::save( QDomDocument &doc, const QgsReadWrite
|
||||
QDomElement symmetricModeElem = doc.createElement( QStringLiteral( "symmetricMode" ) );
|
||||
symmetricModeElem.setAttribute( QStringLiteral( "enabled" ), symmetricModeEnabled() ? 1 : 0 );
|
||||
symmetricModeElem.setAttribute( QStringLiteral( "symmetrypoint" ), symmetryPoint() );
|
||||
symmetricModeElem.setAttribute( QStringLiteral( "astride" ), mAstride ? 1 : 0 );
|
||||
symmetricModeElem.setAttribute( QStringLiteral( "astride" ), mSymmetryAstride ? 1 : 0 );
|
||||
methodElem.appendChild( symmetricModeElem );
|
||||
|
||||
// label format
|
||||
@ -119,7 +119,7 @@ void QgsClassificationMethod::setSymmetricMode( bool enabled, double symmetryPoi
|
||||
{
|
||||
mSymmetricEnabled = enabled;
|
||||
mSymmetryPoint = symmetryPoint;
|
||||
mAstride = astride;
|
||||
mSymmetryAstride = astride;
|
||||
}
|
||||
|
||||
void QgsClassificationMethod::setLabelPrecision( int precision )
|
||||
@ -159,13 +159,13 @@ QString QgsClassificationMethod::formatNumber( double value ) const
|
||||
}
|
||||
}
|
||||
|
||||
QList<QgsClassificationRange> QgsClassificationMethod::classes( const QgsVectorLayer *vl, const QString &expression, int numberOfClasses )
|
||||
QList<QgsClassificationRange> QgsClassificationMethod::classes( const QgsVectorLayer *vl, const QString &expression, int nclasses )
|
||||
{
|
||||
if ( expression.isEmpty() )
|
||||
return QList<QgsClassificationRange>();
|
||||
|
||||
if ( numberOfClasses < 1 )
|
||||
numberOfClasses = 1;
|
||||
if ( nclasses < 1 )
|
||||
nclasses = 1;
|
||||
|
||||
QList<double> values;
|
||||
double minimum;
|
||||
@ -191,24 +191,24 @@ QList<QgsClassificationRange> QgsClassificationMethod::classes( const QgsVectorL
|
||||
}
|
||||
|
||||
// get the breaks
|
||||
const QList<double> breaks = calculateBreaks( minimum, maximum, values, numberOfClasses );
|
||||
const QList<double> breaks = calculateBreaks( minimum, maximum, values, nclasses );
|
||||
// create classes
|
||||
return breaksToClasses( breaks );
|
||||
}
|
||||
|
||||
QList<QgsClassificationRange> QgsClassificationMethod::classes( const QList<double> &values, int numberOfClasses )
|
||||
QList<QgsClassificationRange> QgsClassificationMethod::classes( const QList<double> &values, int nclasses )
|
||||
{
|
||||
auto result = std::minmax_element( values.begin(), values.end() );
|
||||
double minimum = *result.first;
|
||||
double maximum = *result.second;
|
||||
|
||||
// get the breaks
|
||||
const QList<double> breaks = calculateBreaks( minimum, maximum, values, numberOfClasses );
|
||||
const QList<double> breaks = calculateBreaks( minimum, maximum, values, nclasses );
|
||||
// create classes
|
||||
return breaksToClasses( breaks );
|
||||
}
|
||||
|
||||
QList<QgsClassificationRange> QgsClassificationMethod::classes( double minimum, double maximum, int numberOfClasses )
|
||||
QList<QgsClassificationRange> QgsClassificationMethod::classes( double minimum, double maximum, int nclasses )
|
||||
{
|
||||
if ( mValuesRequired )
|
||||
{
|
||||
@ -216,7 +216,7 @@ QList<QgsClassificationRange> QgsClassificationMethod::classes( double minimum,
|
||||
}
|
||||
|
||||
// get the breaks
|
||||
QList<double> breaks = calculateBreaks( minimum, maximum, QList<double>(), numberOfClasses );
|
||||
QList<double> breaks = calculateBreaks( minimum, maximum, QList<double>(), nclasses );
|
||||
breaks.insert( 0, minimum );
|
||||
// create classes
|
||||
return breaksToClasses( breaks );
|
||||
|
@ -162,16 +162,16 @@ class CORE_EXPORT QgsClassificationMethod SIP_ABSTRACT
|
||||
* Returns if the symmetric mode is astride
|
||||
* if TRUE, it will remove the symmetry point break so that the 2 classes form only one
|
||||
*/
|
||||
bool astride() const {return mAstride;}
|
||||
bool symmetryAstride() const {return mSymmetryAstride;}
|
||||
|
||||
/**
|
||||
* Defines if the symmetric mode is enables and configures its parameters.
|
||||
* If the symmetric mode is not available in the current implementation, calling this method has no effect.
|
||||
* \param enabled if the symmetric mode is enabled
|
||||
* \param symmetryPoint the value of the symmetry point
|
||||
* \param astride if TRUE, it will remove the symmetry point break so that the 2 classes form only one
|
||||
* \param symmetryAstride if TRUE, it will remove the symmetry point break so that the 2 classes form only one
|
||||
*/
|
||||
void setSymmetricMode( bool enabled, double symmetryPoint = 0, bool astride = false );
|
||||
void setSymmetricMode( bool enabled, double symmetryPoint = 0, bool symmetryAstride = false );
|
||||
|
||||
// Label properties
|
||||
//! Returns the format of the label for the classes
|
||||
@ -195,26 +195,26 @@ class CORE_EXPORT QgsClassificationMethod SIP_ABSTRACT
|
||||
* The breaks do not contain the uppper and lower bounds (minimum and maximum values).
|
||||
* \param vl The vector layer
|
||||
* \param fieldName The name of the field on which the classes are calculated
|
||||
* \param numberOfClasses The number of classes to be returned
|
||||
* \param nclasses The number of classes to be returned
|
||||
*/
|
||||
QList<QgsClassificationRange> classes( const QgsVectorLayer *vl, const QString &expression, int numberOfClasses );
|
||||
QList<QgsClassificationRange> classes( const QgsVectorLayer *vl, const QString &expression, int nclasses );
|
||||
|
||||
/**
|
||||
* This will calculate the breaks for a list of values.
|
||||
* The breaks do not contain the uppper and lower bounds (minimum and maximum values)
|
||||
* \param values The list of values
|
||||
* \param numberOfClasses The number of classes to be returned
|
||||
* \param nclasses The number of classes to be returned
|
||||
*/
|
||||
QList<QgsClassificationRange> classes( const QList<double> &values, int numberOfClasses );
|
||||
QList<QgsClassificationRange> classes( const QList<double> &values, int nclasses );
|
||||
|
||||
/**
|
||||
* This will calculate the classes for defined bounds without any values.
|
||||
* The breaks do not contain the uppper and lower bounds (minimum and maximum values)
|
||||
* \warning If the method implementation requires values, this will return an empty list.
|
||||
* \param values The list of values
|
||||
* \param numberOfClasses The number of classes to be returned
|
||||
* \param nclasses The number of classes to be returned
|
||||
*/
|
||||
QList<QgsClassificationRange> classes( double minimum, double maximum, int numberOfClasses );
|
||||
QList<QgsClassificationRange> classes( double minimum, double maximum, int nclasses );
|
||||
|
||||
QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const;
|
||||
static QgsClassificationMethod *create( const QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
|
||||
@ -224,9 +224,9 @@ class CORE_EXPORT QgsClassificationMethod SIP_ABSTRACT
|
||||
* Does not put a break on the symmetryPoint. This is done before.
|
||||
* \param breaks The breaks of an already-done classification
|
||||
* \param symmetryPoint The point around which we want a symmetry
|
||||
* \param astride A bool indicating if the symmetry is made astride the symmetryPoint or not ( [-1,1] vs. [-1,0][0,1] )
|
||||
* \param symmetryAstride A bool indicating if the symmetry is made astride the symmetryPoint or not ( [-1,1] vs. [-1,0][0,1] )
|
||||
*/
|
||||
static void makeBreaksSymmetric( QList<double> &breaks SIP_INOUT, double symmetryPoint, bool astride );
|
||||
static void makeBreaksSymmetric( QList<double> &breaks SIP_INOUT, double symmetryPoint, bool symmetryAstride );
|
||||
|
||||
/**
|
||||
* Returns the label for a range
|
||||
@ -250,7 +250,7 @@ class CORE_EXPORT QgsClassificationMethod SIP_ABSTRACT
|
||||
// if some are added here, they should be handled in the clone method
|
||||
bool mSymmetricEnabled = false;
|
||||
double mSymmetryPoint = 0;
|
||||
bool mAstride = false;
|
||||
bool mSymmetryAstride = false;
|
||||
QString mLabelFormat;
|
||||
int mLabelPrecision = 4;
|
||||
bool mLabelTrimTrailingZeroes = true;
|
||||
@ -264,7 +264,7 @@ class CORE_EXPORT QgsClassificationMethod SIP_ABSTRACT
|
||||
* The maximum value is expected to be added at the end of the list, but not the minimum
|
||||
*/
|
||||
virtual QList<double> calculateBreaks( double minimum, double maximum,
|
||||
const QList<double> &values, int numberOfClasses ) = 0;
|
||||
const QList<double> &values, int nclasses ) = 0;
|
||||
|
||||
//! This is called after calculating the breaks or restoring from XML, so it can rely on private variables
|
||||
virtual QString valueToLabel( const double &value ) const {return formatNumber( value );}
|
||||
|
@ -36,13 +36,13 @@ QString QgsClassificationPrettyBreaks::id() const
|
||||
return QStringLiteral( "Pretty" );
|
||||
}
|
||||
|
||||
QList<double> QgsClassificationPrettyBreaks::calculateBreaks( double minimum, double maximum, const QList<double> &values, int numberOfClasses )
|
||||
QList<double> QgsClassificationPrettyBreaks::calculateBreaks( double minimum, double maximum, const QList<double> &values, int nclasses )
|
||||
{
|
||||
Q_UNUSED( values );
|
||||
QList<double> breaks = QgsSymbolLayerUtils::prettyBreaks( minimum, maximum, numberOfClasses );
|
||||
QList<double> breaks = QgsSymbolLayerUtils::prettyBreaks( minimum, maximum, nclasses );
|
||||
|
||||
if ( symmetricModeEnabled() )
|
||||
makeBreaksSymmetric( breaks, symmetryPoint(), astride() );
|
||||
makeBreaksSymmetric( breaks, symmetryPoint(), symmetryAstride() );
|
||||
|
||||
return breaks;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class CORE_EXPORT QgsClassificationPrettyBreaks : public QgsClassificationMethod
|
||||
|
||||
private:
|
||||
QList<double> calculateBreaks( double minimum, double maximum,
|
||||
const QList<double> &values, int numberOfClasses ) override;
|
||||
const QList<double> &values, int nclasses ) override;
|
||||
};
|
||||
|
||||
#endif // QGSCLASSIFICATIONPRETTYBREAKS_H
|
||||
|
@ -41,7 +41,7 @@ QgsClassificationMethod *QgsClassificationQuantile::clone() const
|
||||
|
||||
|
||||
QList<double> QgsClassificationQuantile::calculateBreaks( double minimum, double maximum,
|
||||
const QList<double> &values, int numberOfClasses )
|
||||
const QList<double> &values, int nclasses )
|
||||
{
|
||||
Q_UNUSED( minimum )
|
||||
Q_UNUSED( maximum )
|
||||
@ -67,12 +67,12 @@ QList<double> QgsClassificationQuantile::calculateBreaks( double minimum, double
|
||||
int n = _values.count();
|
||||
double Xq = n > 0 ? _values[0] : 0.0;
|
||||
|
||||
breaks.reserve( numberOfClasses );
|
||||
for ( int i = 1; i < numberOfClasses; i++ )
|
||||
breaks.reserve( nclasses );
|
||||
for ( int i = 1; i < nclasses; i++ )
|
||||
{
|
||||
if ( n > 1 )
|
||||
{
|
||||
double q = i / static_cast< double >( numberOfClasses );
|
||||
double q = i / static_cast< double >( nclasses );
|
||||
double a = q * ( n - 1 );
|
||||
int aa = static_cast< int >( a );
|
||||
|
||||
|
@ -37,7 +37,7 @@ class CORE_EXPORT QgsClassificationQuantile : public QgsClassificationMethod
|
||||
|
||||
private:
|
||||
QList<double> calculateBreaks( double minimum, double maximum,
|
||||
const QList<double> &values, int numberOfClasses ) override;
|
||||
const QList<double> &values, int nclasses ) override;
|
||||
};
|
||||
|
||||
#endif // QGSCLASSIFICATIONQUANTILE_H
|
||||
|
@ -47,7 +47,7 @@ QgsClassificationMethod *QgsClassificationStandardDeviation::clone() const
|
||||
|
||||
|
||||
QList<double> QgsClassificationStandardDeviation::calculateBreaks( double minimum, double maximum,
|
||||
const QList<double> &values, int numberOfClasses )
|
||||
const QList<double> &values, int nclasses )
|
||||
{
|
||||
// C++ implementation of the standard deviation class interval algorithm
|
||||
// as implemented in the 'classInt' package available for the R statistical
|
||||
@ -81,8 +81,8 @@ QList<double> QgsClassificationStandardDeviation::calculateBreaks( double minimu
|
||||
// if not symmetric, the symmetry point is the mean
|
||||
mSymmetryPoint = symmetricModeEnabled() ? symmetryPoint() : mean;
|
||||
|
||||
QList<double> breaks = QgsSymbolLayerUtils::prettyBreaks( ( minimum - mSymmetryPoint ) / mStdDev, ( maximum - mSymmetryPoint ) / mStdDev, numberOfClasses );
|
||||
makeBreaksSymmetric( breaks, 0.0, astride() ); //0.0 because breaks where computed on a centered distribution
|
||||
QList<double> breaks = QgsSymbolLayerUtils::prettyBreaks( ( minimum - mSymmetryPoint ) / mStdDev, ( maximum - mSymmetryPoint ) / mStdDev, nclasses );
|
||||
makeBreaksSymmetric( breaks, 0.0, symmetryAstride() ); //0.0 because breaks where computed on a centered distribution
|
||||
|
||||
for ( int i = 0; i < breaks.count(); i++ )
|
||||
breaks[i] = ( breaks[i] * mStdDev ) + mSymmetryPoint;
|
||||
|
@ -41,7 +41,7 @@ class CORE_EXPORT QgsClassificationStandardDeviation : public QgsClassificationM
|
||||
|
||||
private:
|
||||
QList<double> calculateBreaks( double minimum, double maximum,
|
||||
const QList<double> &values, int numberOfClasses ) override;
|
||||
const QList<double> &values, int nclasses ) override;
|
||||
|
||||
QString valueToLabel( const double &value ) const override;
|
||||
|
||||
|
@ -420,12 +420,12 @@ void QgsGraduatedSymbolRenderer::updateClasses( QgsVectorLayer *vlayer, Mode mod
|
||||
updateClasses( vlayer, nclasses );
|
||||
}
|
||||
|
||||
void QgsGraduatedSymbolRenderer::updateClasses( const QgsVectorLayer *vl, int numberOfClasses )
|
||||
void QgsGraduatedSymbolRenderer::updateClasses( const QgsVectorLayer *vl, int nclasses )
|
||||
{
|
||||
if ( mClassificationMethod->id() == QgsClassificationCustom::METHOD_ID )
|
||||
return;
|
||||
|
||||
QList<QgsClassificationRange> classes = mClassificationMethod->classes( vl, mAttrName, numberOfClasses );
|
||||
QList<QgsClassificationRange> classes = mClassificationMethod->classes( vl, mAttrName, nclasses );
|
||||
|
||||
deleteAllClasses();
|
||||
|
||||
@ -1202,12 +1202,12 @@ void QgsGraduatedSymbolRenderer::setMode( QgsGraduatedSymbolRenderer::Mode mode
|
||||
|
||||
void QgsGraduatedSymbolRenderer::setUseSymmetricMode( bool useSymmetricMode ) SIP_DEPRECATED
|
||||
{
|
||||
mClassificationMethod->setSymmetricMode( useSymmetricMode, mClassificationMethod->symmetryPoint(), mClassificationMethod->astride() );
|
||||
mClassificationMethod->setSymmetricMode( useSymmetricMode, mClassificationMethod->symmetryPoint(), mClassificationMethod->symmetryAstride() );
|
||||
}
|
||||
|
||||
void QgsGraduatedSymbolRenderer::setSymmetryPoint( double symmetryPoint ) SIP_DEPRECATED
|
||||
{
|
||||
mClassificationMethod->setSymmetricMode( mClassificationMethod->symmetricModeEnabled(), symmetryPoint, mClassificationMethod->astride() );
|
||||
mClassificationMethod->setSymmetricMode( mClassificationMethod->symmetricModeEnabled(), symmetryPoint, mClassificationMethod->symmetryAstride() );
|
||||
}
|
||||
|
||||
void QgsGraduatedSymbolRenderer::setAstride( bool astride ) SIP_DEPRECATED
|
||||
|
@ -171,7 +171,7 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
|
||||
* \since QGIS 3.4
|
||||
* \deprecated since QGIS 3.10 use classficationMethod instead
|
||||
*/
|
||||
Q_DECL_DEPRECATED bool astride() const SIP_DEPRECATED { return mClassificationMethod->astride(); }
|
||||
Q_DECL_DEPRECATED bool astride() const SIP_DEPRECATED { return mClassificationMethod->symmetryAstride(); }
|
||||
|
||||
/**
|
||||
* Set if we want a central class astride the pivot value
|
||||
@ -218,9 +218,10 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
|
||||
|
||||
/**
|
||||
* Recalculate classes for a layer
|
||||
* \param vlayer The layer being rendered (from which data values are calculated)
|
||||
* \param vl The layer being rendered (from which data values are calculated)
|
||||
* \param nclasses the number of classes
|
||||
*/
|
||||
void updateClasses( const QgsVectorLayer *vl, int numberOfClasses );
|
||||
void updateClasses( const QgsVectorLayer *vl, int nclasses );
|
||||
|
||||
/**
|
||||
* Returns the label format used to generate default classification labels
|
||||
@ -245,7 +246,7 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
|
||||
*/
|
||||
void calculateLabelPrecision( bool updateRanges = true );
|
||||
|
||||
Q_NOWARN_DEPRECATED_PUSH
|
||||
Q_NOWARN_DEPRECATED_PUSH;
|
||||
|
||||
/**
|
||||
* Creates a new graduated renderer.
|
||||
@ -263,7 +264,7 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
|
||||
* \returns new QgsGraduatedSymbolRenderer object
|
||||
* \deprecated since QGIS 3.10
|
||||
*/
|
||||
Q_DECL_DEPRECATED static QgsGraduatedSymbolRenderer *createRenderer( QgsVectorLayer *vlayer,
|
||||
static Q_DECL_DEPRECATED QgsGraduatedSymbolRenderer *createRenderer( QgsVectorLayer *vlayer,
|
||||
const QString &attrName,
|
||||
int classes,
|
||||
Mode mode,
|
||||
@ -274,7 +275,7 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
|
||||
double symmetryPoint = 0.0,
|
||||
QStringList listForCboPrettyBreaks = QStringList(),
|
||||
bool astride = false ) SIP_DEPRECATED;
|
||||
Q_NOWARN_DEPRECATED_POP
|
||||
Q_NOWARN_DEPRECATED_POP;
|
||||
|
||||
//! create renderer from XML element
|
||||
static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
|
||||
|
@ -41,6 +41,13 @@ class CORE_EXPORT QgsRendererRange
|
||||
* Constructor for QgsRendererRange.
|
||||
*/
|
||||
QgsRendererRange() = default;
|
||||
|
||||
/**
|
||||
* Creates a renderer symbol range
|
||||
* \param range The classification range
|
||||
* \param symbol The symbol for this renderer range
|
||||
* \param render If true, it will be renderered
|
||||
*/
|
||||
QgsRendererRange( const QgsClassificationRange &range, QgsSymbol *symbol SIP_TRANSFER, bool render = true );
|
||||
QgsRendererRange( double lowerValue, double upperValue, QgsSymbol *symbol SIP_TRANSFER, const QString &label, bool render = true );
|
||||
QgsRendererRange( const QgsRendererRange &range );
|
||||
|
@ -654,7 +654,7 @@ void QgsGraduatedSymbolRendererWidget::updateUiFromRenderer( bool updateCount )
|
||||
|
||||
mGroupBoxSymmetric->setVisible( method->symmetricModeAvailable() );
|
||||
mGroupBoxSymmetric->setChecked( method->symmetricModeEnabled() );
|
||||
cbxAstride->setChecked( method->astride() );
|
||||
cbxAstride->setChecked( method->symmetryAstride() );
|
||||
if ( method->symmetricModeEnabled() )
|
||||
cboSymmetryPoint->setItemText( cboSymmetryPoint->currentIndex(), QString::number( method->symmetryPoint(), 'f', method->labelPrecision() + 2 ) );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user