mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 14:40:26 -05:00
#14524 Histogram: Start a user-defined bin range at the data range
Initialize the min and max cutoffs to the data range of the selected result when the bin range mode is set to User Defined. The previous fixed default of [0..1] excluded most values for results like PERMX. The data range is computed by the same statistics query as the histogram, respecting the selected time step and an active visible-cells filter, but without custom binning so min and max are the range of the data.
This commit is contained in:
1 parent
05588f4327
commit
488d631d81
4 files changed
+53
-5
No files matched your search
+28
-5
@@ -214,13 +214,21 @@ RimHistogramDataSource::HistogramResult RimGridStatisticsHistogramDataSource::co
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigHistogramData RimGridStatisticsHistogramDataSource::createStatisticsData() const
|
||||
{
|
||||
std::unique_ptr<RimHistogramCalculator> histogramCalculator = std::make_unique<RimHistogramCalculator>();
|
||||
histogramCalculator->setNumBins( static_cast<size_t>( m_numBins() ) );
|
||||
RimHistogramCalculator histogramCalculator;
|
||||
histogramCalculator.setNumBins( static_cast<size_t>( m_numBins() ) );
|
||||
|
||||
std::optional<std::pair<double, double>> customBinRange;
|
||||
if ( useUserDefinedBinRange() ) customBinRange = std::make_pair( m_binRangeMin(), m_binRangeMax() );
|
||||
histogramCalculator->setBinningParameters( binningMode(), outOfRangeHandling(), customBinRange );
|
||||
histogramCalculator.setBinningParameters( binningMode(), outOfRangeHandling(), customBinRange );
|
||||
|
||||
return statisticsData( histogramCalculator );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigHistogramData RimGridStatisticsHistogramDataSource::statisticsData( RimHistogramCalculator& histogramCalculator ) const
|
||||
{
|
||||
RimHistogramCalculator::StatisticsCellRangeType cellRange = RimHistogramCalculator::StatisticsCellRangeType::ALL_CELLS;
|
||||
|
||||
RimHistogramCalculator::StatisticsTimeRangeType timeRange = RimHistogramCalculator::StatisticsTimeRangeType::ALL_TIMESTEPS;
|
||||
@@ -236,15 +244,30 @@ RigHistogramData RimGridStatisticsHistogramDataSource::createStatisticsData() co
|
||||
// Filter by visible cells of the view
|
||||
cellRange = RimHistogramCalculator::StatisticsCellRangeType::VISIBLE_CELLS;
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( m_cellFilterView.value() );
|
||||
return histogramCalculator->histogramData( eclipseView, m_property.value(), cellRange, timeRange, timeStep );
|
||||
return histogramCalculator.histogramData( eclipseView, m_property.value(), cellRange, timeRange, timeStep );
|
||||
}
|
||||
else
|
||||
{
|
||||
RimEclipseView* eclipseView = nullptr;
|
||||
return histogramCalculator->histogramData( eclipseView, m_property.value(), cellRange, timeRange, timeStep );
|
||||
return histogramCalculator.histogramData( eclipseView, m_property.value(), cellRange, timeRange, timeStep );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// The range of the data selected for the histogram: the statistics are computed without custom
|
||||
/// binning, where min and max always are the data range.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::optional<std::pair<double, double>> RimGridStatisticsHistogramDataSource::dataRange() const
|
||||
{
|
||||
RimHistogramCalculator histogramCalculator;
|
||||
RigHistogramData histogramData = statisticsData( histogramCalculator );
|
||||
|
||||
if ( !RigStatisticsTools::isValidNumber( histogramData.min ) || !RigStatisticsTools::isValidNumber( histogramData.max ) )
|
||||
return std::nullopt;
|
||||
|
||||
return std::make_pair( histogramData.min, histogramData.max );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -29,6 +29,7 @@ class RimCase;
|
||||
class RimGridView;
|
||||
class RimEclipseResultDefinition;
|
||||
class RimEclipseView;
|
||||
class RimHistogramCalculator;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -66,6 +67,8 @@ public:
|
||||
|
||||
static RigHistogramCalculator::BinningMode binningModeForResult( const QString& resultVariable );
|
||||
|
||||
std::optional<std::pair<double, double>> dataRange() const override;
|
||||
|
||||
protected:
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
@@ -73,6 +76,7 @@ protected:
|
||||
void initAfterRead() override;
|
||||
|
||||
RigHistogramData createStatisticsData() const;
|
||||
RigHistogramData statisticsData( RimHistogramCalculator& histogramCalculator ) const;
|
||||
|
||||
void updateBinningOnPropertyChange();
|
||||
|
||||
|
||||
@@ -109,6 +109,14 @@ void RimHistogramDataSource::resetBinRange()
|
||||
m_binRangeMax = m_binRangeMax.defaultValue();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::optional<std::pair<double, double>> RimHistogramDataSource::dataRange() const
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -142,6 +150,16 @@ void RimHistogramDataSource::fieldChangedByUi( const caf::PdmFieldHandle* change
|
||||
{
|
||||
resetBinRange();
|
||||
}
|
||||
|
||||
// Start a user-defined range at the data range: the default [0..1] could exclude most values
|
||||
if ( changedField == &m_binRangeMode && m_binRangeMode() == BinRangeMode::USER_DEFINED )
|
||||
{
|
||||
if ( auto range = dataRange() )
|
||||
{
|
||||
m_binRangeMin = range->first;
|
||||
m_binRangeMax = range->second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <QString>
|
||||
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -83,6 +84,8 @@ public:
|
||||
void setBinningMode( RigHistogramCalculator::BinningMode binningMode );
|
||||
void resetBinRange();
|
||||
|
||||
virtual std::optional<std::pair<double, double>> dataRange() const;
|
||||
|
||||
virtual std::vector<QString> filterDescriptions() const;
|
||||
static QString userDefinedRangeFilterText( double min, double max );
|
||||
|
||||
|
||||
Reference in new issue
Block a user