From e73f74063e139945fb2a26bb06428ebe0659dc67 Mon Sep 17 00:00:00 2001 From: pierreloicq Date: Fri, 7 Sep 2018 09:35:18 +0200 Subject: [PATCH] sip, doc, bad keywords --- .../qgsgraduatedsymbolrenderer.sip.in | 24 +++++++++++++++++++ .../symbology/qgsgraduatedsymbolrenderer.cpp | 11 +++++---- .../symbology/qgsgraduatedsymbolrenderer.h | 14 ++++++++++- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/python/core/auto_generated/symbology/qgsgraduatedsymbolrenderer.sip.in b/python/core/auto_generated/symbology/qgsgraduatedsymbolrenderer.sip.in index 50e6351fd04..f6514a8f4d5 100644 --- a/python/core/auto_generated/symbology/qgsgraduatedsymbolrenderer.sip.in +++ b/python/core/auto_generated/symbology/qgsgraduatedsymbolrenderer.sip.in @@ -279,6 +279,30 @@ Returns if we want to have a central class astride the pivot value Set if we want a central class astride the pivot value .. versionadded:: 3.4 +%End + + static void makeBreaksSymmetric( QList &breaks, double symmetryPoint, bool astride ); +%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] ) + +.. versionadded:: 3.4 +%End + + static QList calcEqualIntervalBreaks( double minimum, double maximum, int classes, bool useSymmetricMode, double symmetryPoint, bool astride ); +%Docstring +Compute the equal interval classification + +:param minimum: The minimum value of the distribution +:param maximum: The maximum value of the distribution +:param classes: The number of classes desired +:param useSymmetricMode: A bool indicating if we want to have classes and hence colors ramp symmetric around a value +: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] ) %End void updateClasses( QgsVectorLayer *vlayer, Mode mode, int nclasses, bool useSymmetricMode = false, double symmetryPoint = 0.0, bool astride = false ); diff --git a/src/core/symbology/qgsgraduatedsymbolrenderer.cpp b/src/core/symbology/qgsgraduatedsymbolrenderer.cpp index 61b9623a43a..4c396c108c4 100644 --- a/src/core/symbology/qgsgraduatedsymbolrenderer.cpp +++ b/src/core/symbology/qgsgraduatedsymbolrenderer.cpp @@ -538,16 +538,17 @@ void QgsGraduatedSymbolRenderer::makeBreaksSymmetric( QList &breaks, dou if ( breaks.size() > 1 ) //to avoid crash when only 1 class { - qSort( breaks.begin(), breaks.end() ); + std::sort( breaks.begin(), breaks.end() ); // breaks contain the maximum of the distrib but not the minimum - double distBelowSymmetricValue = qAbs( breaks[0] - symmetryPoint ); - double distAboveSymmetricValue = qAbs( breaks[ breaks.size() - 2 ] - symmetryPoint ) ; - double absMin = qMin( qAbs( distAboveSymmetricValue ), qAbs( distBelowSymmetricValue ) ); + double distBelowSymmetricValue = std::fabs( breaks[0] - symmetryPoint ); + double distAboveSymmetricValue = std::fabs( breaks[ breaks.size() - 2 ] - symmetryPoint ) ; + double absMin = std::min( distAboveSymmetricValue, distBelowSymmetricValue ); // make symmetric for ( int i = 0; i <= breaks.size() - 2; ++i ) { - if ( qAbs( breaks.at( i ) - symmetryPoint ) >= ( absMin - qAbs( breaks[0] - breaks[1] ) / 100. ) ) + // part after "absMin" is for doubles rounding issues + if ( std::fabs( breaks.at( i ) - symmetryPoint ) >= ( absMin - std::fabs( breaks[0] - breaks[1] ) / 100. ) ) { breaks.removeAt( i ); --i; diff --git a/src/core/symbology/qgsgraduatedsymbolrenderer.h b/src/core/symbology/qgsgraduatedsymbolrenderer.h index e1d6115efa3..91a446d5b85 100644 --- a/src/core/symbology/qgsgraduatedsymbolrenderer.h +++ b/src/core/symbology/qgsgraduatedsymbolrenderer.h @@ -272,11 +272,23 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer /** * 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 + * 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] ) * \since QGIS 3.4 */ static void makeBreaksSymmetric( QList &breaks, double symmetryPoint, bool astride ); + /** + * Compute the equal interval classification + * \param minimum The minimum value of the distribution + * \param maximum The maximum value of the distribution + * \param classes The number of classes desired + * \param useSymmetricMode A bool indicating if we want to have classes and hence colors ramp symmetric around a value + * \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] ) + */ static QList calcEqualIntervalBreaks( double minimum, double maximum, int classes, bool useSymmetricMode, double symmetryPoint, bool astride ); /**