mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 05:37:21 -05:00
#14524 Histogram: Auto-select logarithmic binning and show filter info text
Select logarithmic binning and a logarithmic x-axis automatically when creating a grid statistics histogram plot from a 3D view showing a logarithmic result (RiaResultNames::isLogarithmicResult). Show a plot info label at the top right of the plot canvas describing active data filters: "Filter: Visible cells in 3D view" when a cell filter view is set, and "Filter: User defined x-range [min..max]" when the bin range is user-defined. The label collects unique filter descriptions from the data sources of all visible curves and is removed when no filters are active.
This commit is contained in:
+17
@@ -18,6 +18,8 @@
|
||||
|
||||
#include "RimGridStatisticsHistogramDataSource.h"
|
||||
|
||||
#include "RiaResultNames.h"
|
||||
|
||||
#include "Histogram/RimHistogramPlot.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
@@ -277,6 +279,19 @@ std::string RimGridStatisticsHistogramDataSource::name() const
|
||||
return nameTags.join( ", " ).toStdString();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QString> RimGridStatisticsHistogramDataSource::filterDescriptions() const
|
||||
{
|
||||
std::vector<QString> descriptions;
|
||||
if ( m_cellFilterView() ) descriptions.push_back( "Filter: Visible cells in 3D view" );
|
||||
|
||||
auto baseDescriptions = RimHistogramDataSource::filterDescriptions();
|
||||
descriptions.insert( descriptions.end(), baseDescriptions.begin(), baseDescriptions.end() );
|
||||
return descriptions;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -345,5 +360,7 @@ void RimGridStatisticsHistogramDataSource::setPropertiesFromView( RimEclipseView
|
||||
const RimEclipseResultDefinition* resDef = dynamic_cast<const RimEclipseResultDefinition*>( view->cellResult() );
|
||||
if ( resDef ) m_property->simpleCopy( resDef );
|
||||
|
||||
if ( RiaResultNames::isLogarithmicResult( m_property->resultVariable() ) ) enableLogarithmicBinning();
|
||||
|
||||
dataSourceChanged.send();
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ public:
|
||||
|
||||
std::string name() const override;
|
||||
|
||||
std::vector<QString> filterDescriptions() const override;
|
||||
|
||||
void setDefaults() override;
|
||||
|
||||
void cellFilterViewUpdated();
|
||||
|
||||
@@ -90,6 +90,33 @@ void RimHistogramDataSource::setShowCumulativeCurve( bool showCumulativeCurve )
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimHistogramDataSource::enableLogarithmicBinning()
|
||||
{
|
||||
m_binningMode = RigHistogramCalculator::BinningMode::LOGARITHMIC;
|
||||
logarithmicBinningEnabled.send();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QString> RimHistogramDataSource::filterDescriptions() const
|
||||
{
|
||||
if ( useUserDefinedBinRange() ) return { userDefinedRangeFilterText( m_binRangeMin(), m_binRangeMax() ) };
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimHistogramDataSource::userDefinedRangeFilterText( double min, double max )
|
||||
{
|
||||
return QString( "Filter: User defined x-range [%1..%2]" ).arg( min ).arg( max );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -27,8 +27,11 @@
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafSignal.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -77,6 +80,11 @@ public:
|
||||
virtual bool showCumulativeCurve() const;
|
||||
virtual void setShowCumulativeCurve( bool showCumulativeCurve );
|
||||
|
||||
void enableLogarithmicBinning();
|
||||
|
||||
virtual std::vector<QString> filterDescriptions() const;
|
||||
static QString userDefinedRangeFilterText( double min, double max );
|
||||
|
||||
virtual void setDefaults() = 0;
|
||||
|
||||
virtual std::string name() const = 0;
|
||||
|
||||
@@ -38,7 +38,9 @@
|
||||
#include "Summary/RimSummaryAddress.h"
|
||||
#include "Tools/RimPlotAxisTools.h"
|
||||
|
||||
#include "RiuAbstractOverlayContentFrame.h"
|
||||
#include "RiuContextMenuLauncher.h"
|
||||
#include "RiuDraggableOverlayFrame.h"
|
||||
#include "RiuPlotAxis.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
@@ -52,8 +54,6 @@
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include "qwt_text.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
@@ -355,6 +355,57 @@ void RimHistogramPlot::setLegendPosition( RiuPlotWidget::Legend position )
|
||||
m_legendPosition = position;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimHistogramPlot::showPlotInfoLabel( bool show )
|
||||
{
|
||||
if ( !m_plotInfoFrame ) return;
|
||||
|
||||
if ( show )
|
||||
{
|
||||
if ( plotWidget() ) plotWidget()->addOverlayFrame( m_plotInfoFrame );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( plotWidget() ) plotWidget()->removeOverlayFrame( m_plotInfoFrame );
|
||||
delete m_plotInfoFrame;
|
||||
m_plotInfoFrame = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimHistogramPlot::updatePlotInfoLabel()
|
||||
{
|
||||
QStringList descriptions;
|
||||
for ( RimHistogramCurve* curve : histogramCurves() )
|
||||
{
|
||||
if ( !curve->isChecked() || !curve->dataSource() ) continue;
|
||||
|
||||
for ( const QString& description : curve->dataSource()->filterDescriptions() )
|
||||
{
|
||||
if ( !descriptions.contains( description ) ) descriptions += description;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !descriptions.isEmpty() && plotWidget() )
|
||||
{
|
||||
if ( !m_plotInfoFrame )
|
||||
{
|
||||
m_plotInfoFrame = new RiuDraggableOverlayFrame( plotWidget()->getParentForOverlay(), plotWidget()->overlayMargins() );
|
||||
m_plotInfoFrame->setAnchorCorner( RiuDraggableOverlayFrame::AnchorCorner::TopRight );
|
||||
|
||||
m_plotInfoTextFrame = new RiuTextOverlayContentFrame( m_plotInfoFrame );
|
||||
m_plotInfoFrame->setContentFrame( m_plotInfoTextFrame );
|
||||
}
|
||||
m_plotInfoTextFrame->setText( descriptions.join( "\n" ) );
|
||||
}
|
||||
|
||||
showPlotInfoLabel( !descriptions.isEmpty() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -718,6 +769,8 @@ void RimHistogramPlot::onLoadDataAndUpdate()
|
||||
updateAxes();
|
||||
|
||||
updateStackedCurveData();
|
||||
|
||||
updatePlotInfoLabel();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1110,6 +1163,8 @@ void RimHistogramPlot::detachAllPlotItems()
|
||||
{
|
||||
m_histogramCurveCollection->detachPlotCurves();
|
||||
}
|
||||
|
||||
showPlotInfoLabel( false );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1167,6 +1222,7 @@ void RimHistogramPlot::onCurveCollectionChanged( const SignalEmitter* emitter )
|
||||
curvesChanged.send();
|
||||
|
||||
updateStackedCurveData();
|
||||
updatePlotInfoLabel();
|
||||
scheduleReplotIfVisible();
|
||||
|
||||
updateAllRequiredEditors();
|
||||
|
||||
@@ -39,12 +39,13 @@ class RimPlotAxisPropertiesInterface;
|
||||
class RimPlotAxisProperties;
|
||||
class RimPlotTemplateFileItem;
|
||||
class RimStackablePlotCurve;
|
||||
class RiuDraggableOverlayFrame;
|
||||
class RiuTextOverlayContentFrame;
|
||||
|
||||
class PdmUiTreeOrdering;
|
||||
|
||||
class QwtInterval;
|
||||
class QwtPlotCurve;
|
||||
class QwtPlotTextLabel;
|
||||
|
||||
class QKeyEvent;
|
||||
|
||||
@@ -233,6 +234,9 @@ private:
|
||||
|
||||
QPointer<RiuPlotWidget> m_histogramPlot;
|
||||
|
||||
QPointer<RiuDraggableOverlayFrame> m_plotInfoFrame;
|
||||
QPointer<RiuTextOverlayContentFrame> m_plotInfoTextFrame;
|
||||
|
||||
bool m_isValid;
|
||||
RiuPlotWidget::Legend m_legendPosition;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "Histogram/RimGridStatisticsHistogramDataSource.h"
|
||||
#include "Histogram/RimHistogramDataSource.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -224,3 +225,21 @@ TEST( RimHistogramDataSourceTest, ComputeBinRange )
|
||||
EXPECT_DOUBLE_EQ( 6.0, max );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RimHistogramDataSourceTest, UserDefinedRangeFilterText )
|
||||
{
|
||||
EXPECT_EQ( "Filter: User defined x-range [0.1..100]", RimHistogramDataSource::userDefinedRangeFilterText( 0.1, 100.0 ).toStdString() );
|
||||
EXPECT_EQ( "Filter: User defined x-range [-2.5..0]", RimHistogramDataSource::userDefinedRangeFilterText( -2.5, 0.0 ).toStdString() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RimHistogramDataSourceTest, FilterDescriptionsDefaultIsEmpty )
|
||||
{
|
||||
RimGridStatisticsHistogramDataSource dataSource;
|
||||
EXPECT_TRUE( dataSource.filterDescriptions().empty() );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user