Files
ResInsight/ApplicationLibCode/ProjectDataModel/Histogram/RimGridStatisticsHistogramDataSource.h
T
Kristian Bendiksen 488d631d81 #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.
2026-08-19 12:23:07 +02:00

93 lines
3.3 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2025 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RigHistogramData.h"
#include "RimHistogramDataSource.h"
#include "cafPdmField.h"
#include "cafPdmPtrField.h"
class RimSummaryEnsemble;
class RimCase;
class RimGridView;
class RimEclipseResultDefinition;
class RimEclipseView;
class RimHistogramCalculator;
//==================================================================================================
///
///
//==================================================================================================
class RimGridStatisticsHistogramDataSource : public RimHistogramDataSource
{
CAF_PDM_HEADER_INIT;
public:
RimGridStatisticsHistogramDataSource();
~RimGridStatisticsHistogramDataSource() override;
std::string unitNameX() const override;
std::string unitNameY() const override;
HistogramResult compute( RimHistogramPlot::GraphType graphType,
RimHistogramPlot::FrequencyType frequencyType,
bool cumulative = false ) const override;
bool showCumulativeCurve() const override;
void setShowCumulativeCurve( bool showCumulativeCurve ) override;
std::string name() const override;
std::vector<QString> filterDescriptions() const override;
void setDefaults() override;
void cellFilterViewUpdated();
void loadDataAndUpdate();
void setPropertiesFromView( RimEclipseView* view );
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;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void initAfterRead() override;
RigHistogramData createStatisticsData() const;
RigHistogramData statisticsData( RimHistogramCalculator& histogramCalculator ) const;
void updateBinningOnPropertyChange();
caf::PdmPtrField<RimCase*> m_case;
caf::PdmField<int> m_timeStep;
caf::PdmPtrField<RimGridView*> m_cellFilterView;
caf::PdmChildField<RimEclipseResultDefinition*> m_property;
caf::PdmField<int> m_numBins;
caf::PdmField<bool> m_cumulative;
private:
QString m_previousResultVariable;
};