Skip to content

Commit e73f740

Browse files
pierreloicqnyalldawson
authored andcommittedSep 14, 2018
sip, doc, bad keywords
1 parent 7cec3ef commit e73f740

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed
 

‎python/core/auto_generated/symbology/qgsgraduatedsymbolrenderer.sip.in

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,30 @@ Returns if we want to have a central class astride the pivot value
279279
Set if we want a central class astride the pivot value
280280

281281
.. versionadded:: 3.4
282+
%End
283+
284+
static void makeBreaksSymmetric( QList<double> &breaks, double symmetryPoint, bool astride );
285+
%Docstring
286+
Remove the breaks that are above the existing opposite sign classes to keep colors symmetrically balanced around symmetryPoint
287+
Does not put a break on the symmetryPoint. This is done before.
288+
289+
:param breaks: The breaks of an already-done classification
290+
:param symmetryPoint: The point around which we want a symmetry
291+
:param astride: A bool indicating if the symmetry is made astride the symmetryPoint or not ( [-1,1] vs. [-1,0][0,1] )
292+
293+
.. versionadded:: 3.4
294+
%End
295+
296+
static QList<double> calcEqualIntervalBreaks( double minimum, double maximum, int classes, bool useSymmetricMode, double symmetryPoint, bool astride );
297+
%Docstring
298+
Compute the equal interval classification
299+
300+
:param minimum: The minimum value of the distribution
301+
:param maximum: The maximum value of the distribution
302+
:param classes: The number of classes desired
303+
:param useSymmetricMode: A bool indicating if we want to have classes and hence colors ramp symmetric around a value
304+
:param symmetryPoint: The point around which we want a symmetry
305+
:param astride: A bool indicating if the symmetry is made astride the symmetryPoint or not ( [-1,1] vs. [-1,0][0,1] )
282306
%End
283307

284308
void updateClasses( QgsVectorLayer *vlayer, Mode mode, int nclasses, bool useSymmetricMode = false, double symmetryPoint = 0.0, bool astride = false );

‎src/core/symbology/qgsgraduatedsymbolrenderer.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,16 +538,17 @@ void QgsGraduatedSymbolRenderer::makeBreaksSymmetric( QList<double> &breaks, dou
538538

539539
if ( breaks.size() > 1 ) //to avoid crash when only 1 class
540540
{
541-
qSort( breaks.begin(), breaks.end() );
541+
std::sort( breaks.begin(), breaks.end() );
542542
// breaks contain the maximum of the distrib but not the minimum
543-
double distBelowSymmetricValue = qAbs( breaks[0] - symmetryPoint );
544-
double distAboveSymmetricValue = qAbs( breaks[ breaks.size() - 2 ] - symmetryPoint ) ;
545-
double absMin = qMin( qAbs( distAboveSymmetricValue ), qAbs( distBelowSymmetricValue ) );
543+
double distBelowSymmetricValue = std::fabs( breaks[0] - symmetryPoint );
544+
double distAboveSymmetricValue = std::fabs( breaks[ breaks.size() - 2 ] - symmetryPoint ) ;
545+
double absMin = std::min( distAboveSymmetricValue, distBelowSymmetricValue );
546546

547547
// make symmetric
548548
for ( int i = 0; i <= breaks.size() - 2; ++i )
549549
{
550-
if ( qAbs( breaks.at( i ) - symmetryPoint ) >= ( absMin - qAbs( breaks[0] - breaks[1] ) / 100. ) )
550+
// part after "absMin" is for doubles rounding issues
551+
if ( std::fabs( breaks.at( i ) - symmetryPoint ) >= ( absMin - std::fabs( breaks[0] - breaks[1] ) / 100. ) )
551552
{
552553
breaks.removeAt( i );
553554
--i;

‎src/core/symbology/qgsgraduatedsymbolrenderer.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,23 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
272272

273273
/**
274274
* Remove the breaks that are above the existing opposite sign classes to keep colors symmetrically balanced around symmetryPoint
275-
* Does not put a break on the symmetryPoint
275+
* Does not put a break on the symmetryPoint. This is done before.
276+
* \param breaks The breaks of an already-done classification
277+
* \param symmetryPoint The point around which we want a symmetry
278+
* \param astride A bool indicating if the symmetry is made astride the symmetryPoint or not ( [-1,1] vs. [-1,0][0,1] )
276279
* \since QGIS 3.4
277280
*/
278281
static void makeBreaksSymmetric( QList<double> &breaks, double symmetryPoint, bool astride );
279282

283+
/**
284+
* Compute the equal interval classification
285+
* \param minimum The minimum value of the distribution
286+
* \param maximum The maximum value of the distribution
287+
* \param classes The number of classes desired
288+
* \param useSymmetricMode A bool indicating if we want to have classes and hence colors ramp symmetric around a value
289+
* \param symmetryPoint The point around which we want a symmetry
290+
* \param astride A bool indicating if the symmetry is made astride the symmetryPoint or not ( [-1,1] vs. [-1,0][0,1] )
291+
*/
280292
static QList<double> calcEqualIntervalBreaks( double minimum, double maximum, int classes, bool useSymmetricMode, double symmetryPoint, bool astride );
281293

282294
/**

0 commit comments

Comments
 (0)
Please sign in to comment.