#15063: Histogram: Zoom all when data is filtered by 3D view visibility

Zoom all when the cell filter view is changed or when the visibility in the 3D view is updated, as the visible cells can have a very different value range than the full grid.
This commit is contained in:
Magne Sjaastad committed 2026-10-28 14:36:44 +01:00
1 parent e8846e35b2
commit 442854cddd
6 files changed
+32 -1

No files matched your search

@@ -20,7 +20,6 @@
#include "RiaResultNames.h"
#include "Histogram/RimHistogramPlot.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseResultDefinition.h"
@@ -162,6 +161,13 @@ void RimGridStatisticsHistogramDataSource::fieldChangedByUi( const caf::PdmField
// deleted while it is being emitted.
cumulativeChanged.send();
}
else if ( changedField == &m_cellFilterView )
{
m_cellFilterViewDataRange = dataRange();
dataSourceChanged.send();
zoomAllRequested.send();
}
else
{
dataSourceChanged.send();
@@ -362,6 +368,15 @@ void RimGridStatisticsHistogramDataSource::setDefaults()
void RimGridStatisticsHistogramDataSource::cellFilterViewUpdated()
{
dataSourceChanged.send();
// The view is updated for many reasons not affecting the visible cells, e.g. a legend change. Only zoom all when the
// range of the visible data has changed, to keep the user's zoom otherwise.
const auto range = dataRange();
if ( range != m_cellFilterViewDataRange )
{
m_cellFilterViewDataRange = range;
zoomAllRequested.send();
}
}
//--------------------------------------------------------------------------------------------------
@@ -89,4 +89,7 @@ protected:
private:
QString m_previousResultVariable;
// Range of the visible data at the last zoom all, used to detect changes in the cell filter view
std::optional<std::pair<double, double>> m_cellFilterViewDataRange;
};
@@ -118,6 +118,7 @@ void RimHistogramCurve::setDataSource( RimHistogramDataSource* dataSource )
m_dataSource->dataSourceChanged.connect( this, &RimHistogramCurve::onDataSourceChanged );
m_dataSource->cumulativeChanged.connect( this, &RimHistogramCurve::onCumulativeChanged );
m_dataSource->binningModeChanged.connect( this, &RimHistogramCurve::onBinningModeChanged );
m_dataSource->zoomAllRequested.connect( this, &RimHistogramCurve::onZoomAllRequested );
}
}
@@ -140,6 +141,7 @@ void RimHistogramCurve::connectReferencedDataSourceSignals()
{
// Connecting an already connected observer is a no-op
m_dataSourceReference()->dataSourceChanged.connect( this, &RimHistogramCurve::onDataSourceChanged );
m_dataSourceReference()->zoomAllRequested.connect( this, &RimHistogramCurve::onZoomAllRequested );
}
}
@@ -605,6 +607,14 @@ void RimHistogramCurve::onCumulativeChanged( const caf::SignalEmitter* emitter )
updateCumulativeCurve();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimHistogramCurve::onZoomAllRequested( const caf::SignalEmitter* emitter )
{
if ( auto plot = firstAncestorOrThisOfType<RimHistogramPlot>() ) plot->zoomAll();
}
//--------------------------------------------------------------------------------------------------
/// 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.
@@ -88,6 +88,7 @@ protected:
void onDataSourceChanged( const caf::SignalEmitter* emitter );
void onCumulativeChanged( const caf::SignalEmitter* emitter );
void onZoomAllRequested( const caf::SignalEmitter* emitter );
void onBinningModeChanged( const caf::SignalEmitter* emitter, RigHistogramCalculator::BinningMode binningMode );
void updateCumulativeCurve();
@@ -57,6 +57,7 @@ void caf::AppEnum<RigHistogramCalculator::OutOfRangeHandling>::setUp()
RimHistogramDataSource::RimHistogramDataSource()
: dataSourceChanged( this )
, cumulativeChanged( this )
, zoomAllRequested( this )
, binningModeChanged( this )
{
CAF_PDM_InitObject( "Histogram Data Source", );
@@ -70,6 +70,7 @@ public:
caf::Signal<> dataSourceChanged;
caf::Signal<> cumulativeChanged;
caf::Signal<> zoomAllRequested;
caf::Signal<RigHistogramCalculator::BinningMode> binningModeChanged;
virtual std::string unitNameX() const = 0;