Skip to content

Commit c921d2e

Browse files
pierreloicqnyalldawson
authored andcommitted
2 improvements regarding kannes comments
1 parent 40ae953 commit c921d2e

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

src/gui/symbology/qgsgraduatedsymbolrendererwidget.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ void QgsGraduatedSymbolRendererWidget::connectUpdateHandlers()
576576
connect( cbxClassifySymmetric, &QAbstractButton::toggled, this, &QgsGraduatedSymbolRendererWidget::classifyGraduated );
577577
connect( cbxAstride, &QAbstractButton::toggled, this, &QgsGraduatedSymbolRendererWidget::classifyGraduated );
578578
connect( cboSymmetryPointForPretty, static_cast<void ( QComboBox::* )( int )>( &QComboBox::activated ), this, &QgsGraduatedSymbolRendererWidget::classifyGraduated );
579-
connect( spinSymmetryPointForOtherMethods, static_cast<void( QgsDoubleSpinBox::* )()>( &QgsDoubleSpinBox::editingFinished ), this, &QgsGraduatedSymbolRendererWidget::classifyGraduated );
579+
connect( spinSymmetryPointForOtherMethods, static_cast<void( QgsDoubleSpinBox::* )( double )>( &QgsDoubleSpinBox::valueChanged ), this, &QgsGraduatedSymbolRendererWidget::classifyGraduated );
580580
}
581581

582582
// Connect/disconnect event handlers which trigger updating renderer
@@ -597,7 +597,7 @@ void QgsGraduatedSymbolRendererWidget::disconnectUpdateHandlers()
597597
disconnect( cbxClassifySymmetric, &QAbstractButton::toggled, this, &QgsGraduatedSymbolRendererWidget::classifyGraduated );
598598
disconnect( cbxAstride, &QAbstractButton::toggled, this, &QgsGraduatedSymbolRendererWidget::classifyGraduated );
599599
disconnect( cboSymmetryPointForPretty, static_cast<void ( QComboBox::* )( int )>( &QComboBox::activated ), this, &QgsGraduatedSymbolRendererWidget::classifyGraduated );
600-
disconnect( spinSymmetryPointForOtherMethods, static_cast<void( QgsDoubleSpinBox::* )()>( &QgsDoubleSpinBox::editingFinished ), this, &QgsGraduatedSymbolRendererWidget::classifyGraduated );
600+
disconnect( spinSymmetryPointForOtherMethods, static_cast<void( QgsDoubleSpinBox::* )( double )>( &QgsDoubleSpinBox::valueChanged ), this, &QgsGraduatedSymbolRendererWidget::classifyGraduated );
601601
}
602602

603603
void QgsGraduatedSymbolRendererWidget::updateUiFromRenderer( bool updateCount )
@@ -871,14 +871,16 @@ void QgsGraduatedSymbolRendererWidget::classifyGraduated()
871871
spinSymmetryPointForOtherMethods->setMinimum( minimum );
872872
spinSymmetryPointForOtherMethods->setMaximum( maximum );
873873
spinSymmetryPointForOtherMethods->setDecimals( spinPrecision->value() );
874+
874875
double symmetryPoint = spinSymmetryPointForOtherMethods->value();
875876

876877
if ( cboGraduatedMode->currentIndex() == 0 ) // EqualInterval
877878
{
878879
mode = QgsGraduatedSymbolRenderer::EqualInterval;
879-
// because spinSymmetryPointForOtherMethods->value() is put at minimum when out of min-max
880-
if ( spinSymmetryPointForOtherMethods->value() <= minimum + ( maximum - minimum ) / 100. ) // to avoid direct comparison of doubles
881-
symmetryPoint = minimum + ( maximum - minimum ) / 2;
880+
// knowing that spinSymmetryPointForOtherMethods->value() is automatically put at minimum when out of min-max
881+
// using "(maximum-minimum)/100)" to avoid direct comparison of doubles
882+
if ( spinSymmetryPointForOtherMethods->value() < ( minimum + ( maximum - minimum ) / 100. ) || spinSymmetryPointForOtherMethods->value() > ( maximum - ( maximum - minimum ) / 100. ) )
883+
spinSymmetryPointForOtherMethods->setValue( minimum + ( maximum - minimum ) / 2. );
882884

883885
if ( cbxClassifySymmetric->isChecked() )
884886
{
@@ -894,8 +896,10 @@ void QgsGraduatedSymbolRendererWidget::classifyGraduated()
894896
else if ( cboGraduatedMode->currentIndex() == 3 ) // StdDev
895897
{
896898
mode = QgsGraduatedSymbolRenderer::StdDev;
897-
if ( spinSymmetryPointForOtherMethods->value() <= minimum + ( maximum - minimum ) / 100. ) // to avoid direct comparison of doubles
898-
symmetryPoint = minimum + ( maximum - minimum ) / 2;
899+
// knowing that spinSymmetryPointForOtherMethods->value() is automatically put at minimum when out of min-max
900+
// using "(maximum-minimum)/100)" to avoid direct comparison of doubles
901+
if ( spinSymmetryPointForOtherMethods->value() < ( minimum + ( maximum - minimum ) / 100. ) || spinSymmetryPointForOtherMethods->value() > ( maximum - ( maximum - minimum ) / 100. ) )
902+
spinSymmetryPointForOtherMethods->setValue( minimum + ( maximum - minimum ) / 2. );
899903

900904
if ( cbxClassifySymmetric->isChecked() )
901905
{

src/ui/qgsgraduatedsymbolrendererv2widget.ui

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,15 @@ Negative rounds to powers of 10</string>
437437
<property name="specialValueText">
438438
<string/>
439439
</property>
440+
<property name="minimum">
441+
<double>-99999999999999995164818811802792197885196090803013355167206819763650035712.000000000000000</double>
442+
</property>
443+
<property name="maximum">
444+
<double>99999999999999995164818811802792197885196090803013355167206819763650035712.000000000000000</double>
445+
</property>
446+
<property name="value">
447+
<double>100.000000000000000</double>
448+
</property>
440449
<property name="showClearButton" stdset="0">
441450
<bool>false</bool>
442451
</property>

0 commit comments

Comments
 (0)