Skip to content

Commit

Permalink
2 improvements regarding kannes comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreloicq authored and nyalldawson committed Sep 14, 2018
1 parent 40ae953 commit c921d2e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/gui/symbology/qgsgraduatedsymbolrendererwidget.cpp
Expand Up @@ -576,7 +576,7 @@ void QgsGraduatedSymbolRendererWidget::connectUpdateHandlers()
connect( cbxClassifySymmetric, &QAbstractButton::toggled, this, &QgsGraduatedSymbolRendererWidget::classifyGraduated );
connect( cbxAstride, &QAbstractButton::toggled, this, &QgsGraduatedSymbolRendererWidget::classifyGraduated );
connect( cboSymmetryPointForPretty, static_cast<void ( QComboBox::* )( int )>( &QComboBox::activated ), this, &QgsGraduatedSymbolRendererWidget::classifyGraduated );
connect( spinSymmetryPointForOtherMethods, static_cast<void( QgsDoubleSpinBox::* )()>( &QgsDoubleSpinBox::editingFinished ), this, &QgsGraduatedSymbolRendererWidget::classifyGraduated );
connect( spinSymmetryPointForOtherMethods, static_cast<void( QgsDoubleSpinBox::* )( double )>( &QgsDoubleSpinBox::valueChanged ), this, &QgsGraduatedSymbolRendererWidget::classifyGraduated );
}

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

void QgsGraduatedSymbolRendererWidget::updateUiFromRenderer( bool updateCount )
Expand Down Expand Up @@ -871,14 +871,16 @@ void QgsGraduatedSymbolRendererWidget::classifyGraduated()
spinSymmetryPointForOtherMethods->setMinimum( minimum );
spinSymmetryPointForOtherMethods->setMaximum( maximum );
spinSymmetryPointForOtherMethods->setDecimals( spinPrecision->value() );

double symmetryPoint = spinSymmetryPointForOtherMethods->value();

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

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

if ( cbxClassifySymmetric->isChecked() )
{
Expand Down
9 changes: 9 additions & 0 deletions src/ui/qgsgraduatedsymbolrendererv2widget.ui
Expand Up @@ -437,6 +437,15 @@ Negative rounds to powers of 10</string>
<property name="specialValueText">
<string/>
</property>
<property name="minimum">
<double>-99999999999999995164818811802792197885196090803013355167206819763650035712.000000000000000</double>
</property>
<property name="maximum">
<double>99999999999999995164818811802792197885196090803013355167206819763650035712.000000000000000</double>
</property>
<property name="value">
<double>100.000000000000000</double>
</property>
<property name="showClearButton" stdset="0">
<bool>false</bool>
</property>
Expand Down

0 comments on commit c921d2e

Please sign in to comment.