Skip to content

Commit

Permalink
sip, doc, bad keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreloicq authored and nyalldawson committed Sep 14, 2018
1 parent 7cec3ef commit e73f740
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
Expand Up @@ -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 Set if we want a central class astride the pivot value


.. versionadded:: 3.4 .. versionadded:: 3.4
%End

static void makeBreaksSymmetric( QList<double> &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<double> 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 %End


void updateClasses( QgsVectorLayer *vlayer, Mode mode, int nclasses, bool useSymmetricMode = false, double symmetryPoint = 0.0, bool astride = false ); void updateClasses( QgsVectorLayer *vlayer, Mode mode, int nclasses, bool useSymmetricMode = false, double symmetryPoint = 0.0, bool astride = false );
Expand Down
11 changes: 6 additions & 5 deletions src/core/symbology/qgsgraduatedsymbolrenderer.cpp
Expand Up @@ -538,16 +538,17 @@ void QgsGraduatedSymbolRenderer::makeBreaksSymmetric( QList<double> &breaks, dou


if ( breaks.size() > 1 ) //to avoid crash when only 1 class 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 // breaks contain the maximum of the distrib but not the minimum
double distBelowSymmetricValue = qAbs( breaks[0] - symmetryPoint ); double distBelowSymmetricValue = std::fabs( breaks[0] - symmetryPoint );
double distAboveSymmetricValue = qAbs( breaks[ breaks.size() - 2 ] - symmetryPoint ) ; double distAboveSymmetricValue = std::fabs( breaks[ breaks.size() - 2 ] - symmetryPoint ) ;
double absMin = qMin( qAbs( distAboveSymmetricValue ), qAbs( distBelowSymmetricValue ) ); double absMin = std::min( distAboveSymmetricValue, distBelowSymmetricValue );


// make symmetric // make symmetric
for ( int i = 0; i <= breaks.size() - 2; ++i ) 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 ); breaks.removeAt( i );
--i; --i;
Expand Down
14 changes: 13 additions & 1 deletion src/core/symbology/qgsgraduatedsymbolrenderer.h
Expand Up @@ -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 * 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 * \since QGIS 3.4
*/ */
static void makeBreaksSymmetric( QList<double> &breaks, double symmetryPoint, bool astride ); static void makeBreaksSymmetric( QList<double> &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<double> calcEqualIntervalBreaks( double minimum, double maximum, int classes, bool useSymmetricMode, double symmetryPoint, bool astride ); static QList<double> calcEqualIntervalBreaks( double minimum, double maximum, int classes, bool useSymmetricMode, double symmetryPoint, bool astride );


/** /**
Expand Down

0 comments on commit e73f740

Please sign in to comment.