mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 14:40:26 -05:00
#14524 Histogram: Set linear binning when selecting a non-logarithmic property
Make the property-driven binning mode symmetric: selecting a non-logarithmic result (e.g. FLUXNUM) after a logarithmic one (e.g. PERMX) sets the binning mode and x-axis back to linear. Replace the one-way logarithmicBinningEnabled signal with a binningModeChanged signal carrying the new mode, so the x-axis scale follows the binning mode in both directions, also when the binning mode itself is changed in the UI.
This commit is contained in:
1 parent
aaaf5689aa
commit
5f465bf19a
7 files changed
+41
-37
No files matched your search
+12
-8
@@ -352,23 +352,27 @@ void RimGridStatisticsHistogramDataSource::loadDataAndUpdate()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Logarithmic results are best viewed with logarithmic binning: enable it once when a logarithmic
|
||||
/// property is selected. The user stays in control of the binning mode afterwards.
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGridStatisticsHistogramDataSource::shouldEnableLogarithmicBinning( const QString& previousResultVariable,
|
||||
const QString& newResultVariable )
|
||||
RigHistogramCalculator::BinningMode RimGridStatisticsHistogramDataSource::binningModeForResult( const QString& resultVariable )
|
||||
{
|
||||
return newResultVariable != previousResultVariable && RiaResultNames::isLogarithmicResult( newResultVariable );
|
||||
return RiaResultNames::isLogarithmicResult( resultVariable ) ? RigHistogramCalculator::BinningMode::LOGARITHMIC
|
||||
: RigHistogramCalculator::BinningMode::LINEAR;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
/// The binning mode follows the selected property: logarithmic results are best viewed with
|
||||
/// logarithmic binning, others with linear binning. Only an actual property change updates the
|
||||
/// binning mode: the user stays in control of the setting afterwards.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridStatisticsHistogramDataSource::updateBinningModeOnPropertyChange()
|
||||
{
|
||||
const QString resultVariable = m_property()->resultVariable();
|
||||
if ( shouldEnableLogarithmicBinning( m_previousResultVariable, resultVariable ) ) enableLogarithmicBinning();
|
||||
m_previousResultVariable = resultVariable;
|
||||
if ( resultVariable != m_previousResultVariable )
|
||||
{
|
||||
setBinningMode( binningModeForResult( resultVariable ) );
|
||||
m_previousResultVariable = resultVariable;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public:
|
||||
|
||||
void setPropertiesFromView( RimEclipseView* view );
|
||||
|
||||
static bool shouldEnableLogarithmicBinning( const QString& previousResultVariable, const QString& newResultVariable );
|
||||
static RigHistogramCalculator::BinningMode binningModeForResult( const QString& resultVariable );
|
||||
|
||||
protected:
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
|
||||
@@ -117,7 +117,7 @@ void RimHistogramCurve::setDataSource( RimHistogramDataSource* dataSource )
|
||||
m_dataSource->uiCapability()->setUiTreeHidden( true );
|
||||
m_dataSource->dataSourceChanged.connect( this, &RimHistogramCurve::onDataSourceChanged );
|
||||
m_dataSource->cumulativeChanged.connect( this, &RimHistogramCurve::onCumulativeChanged );
|
||||
m_dataSource->logarithmicBinningEnabled.connect( this, &RimHistogramCurve::onLogarithmicBinningEnabled );
|
||||
m_dataSource->binningModeChanged.connect( this, &RimHistogramCurve::onBinningModeChanged );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -606,16 +606,16 @@ void RimHistogramCurve::onCumulativeChanged( const caf::SignalEmitter* emitter )
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Logarithmic bins are best viewed on a logarithmic axis: enable it once when logarithmic binning
|
||||
/// is selected. The user stays in control of the axis setting afterwards.
|
||||
/// Bins are best viewed on a matching axis: select a logarithmic axis for logarithmic binning and a
|
||||
/// linear axis for linear binning. The user stays in control of the axis setting afterwards.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimHistogramCurve::onLogarithmicBinningEnabled( const caf::SignalEmitter* emitter )
|
||||
void RimHistogramCurve::onBinningModeChanged( const caf::SignalEmitter* emitter, RigHistogramCalculator::BinningMode binningMode )
|
||||
{
|
||||
auto plot = firstAncestorOrThisOfType<RimHistogramPlot>();
|
||||
if ( !plot ) return;
|
||||
|
||||
auto axisProperties = dynamic_cast<RimPlotAxisProperties*>( plot->axisPropertiesForPlotAxis( axisX() ) );
|
||||
if ( axisProperties ) axisProperties->setLogarithmicScaleEnabled( true );
|
||||
if ( axisProperties ) axisProperties->setLogarithmicScaleEnabled( binningMode == RigHistogramCalculator::BinningMode::LOGARITHMIC );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RigStatisticsMath.h"
|
||||
|
||||
#include "RiuPlotAnnotationTool.h"
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmField.h"
|
||||
@@ -86,7 +88,7 @@ protected:
|
||||
|
||||
void onDataSourceChanged( const caf::SignalEmitter* emitter );
|
||||
void onCumulativeChanged( const caf::SignalEmitter* emitter );
|
||||
void onLogarithmicBinningEnabled( const caf::SignalEmitter* emitter );
|
||||
void onBinningModeChanged( const caf::SignalEmitter* emitter, RigHistogramCalculator::BinningMode binningMode );
|
||||
|
||||
void updateCumulativeCurve();
|
||||
void connectReferencedDataSourceSignals();
|
||||
|
||||
@@ -57,7 +57,7 @@ void caf::AppEnum<RigHistogramCalculator::OutOfRangeHandling>::setUp()
|
||||
RimHistogramDataSource::RimHistogramDataSource()
|
||||
: dataSourceChanged( this )
|
||||
, cumulativeChanged( this )
|
||||
, logarithmicBinningEnabled( this )
|
||||
, binningModeChanged( this )
|
||||
{
|
||||
CAF_PDM_InitObject( "Histogram Data Source", );
|
||||
|
||||
@@ -93,10 +93,10 @@ void RimHistogramDataSource::setShowCumulativeCurve( bool showCumulativeCurve )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimHistogramDataSource::enableLogarithmicBinning()
|
||||
void RimHistogramDataSource::setBinningMode( RigHistogramCalculator::BinningMode binningMode )
|
||||
{
|
||||
m_binningMode = RigHistogramCalculator::BinningMode::LOGARITHMIC;
|
||||
logarithmicBinningEnabled.send();
|
||||
m_binningMode = binningMode;
|
||||
binningModeChanged.send( binningMode );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -122,9 +122,9 @@ QString RimHistogramDataSource::userDefinedRangeFilterText( double min, double m
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimHistogramDataSource::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_binningMode && m_binningMode() == RigHistogramCalculator::BinningMode::LOGARITHMIC )
|
||||
if ( changedField == &m_binningMode )
|
||||
{
|
||||
logarithmicBinningEnabled.send();
|
||||
binningModeChanged.send( m_binningMode() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,9 +67,9 @@ public:
|
||||
RimHistogramDataSource();
|
||||
~RimHistogramDataSource() override;
|
||||
|
||||
caf::Signal<> dataSourceChanged;
|
||||
caf::Signal<> cumulativeChanged;
|
||||
caf::Signal<> logarithmicBinningEnabled;
|
||||
caf::Signal<> dataSourceChanged;
|
||||
caf::Signal<> cumulativeChanged;
|
||||
caf::Signal<RigHistogramCalculator::BinningMode> binningModeChanged;
|
||||
|
||||
virtual std::string unitNameX() const = 0;
|
||||
virtual std::string unitNameY() const = 0;
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
virtual bool showCumulativeCurve() const;
|
||||
virtual void setShowCumulativeCurve( bool showCumulativeCurve );
|
||||
|
||||
void enableLogarithmicBinning();
|
||||
void setBinningMode( RigHistogramCalculator::BinningMode binningMode );
|
||||
|
||||
virtual std::vector<QString> filterDescriptions() const;
|
||||
static QString userDefinedRangeFilterText( double min, double max );
|
||||
|
||||
Reference in new issue
Block a user