Histogram: add data source for ensemble fracture statistics histograms.

This commit is contained in:
Kristian Bendiksen committed 2025-07-04 16:57:41 +02:00
1 parent 11d85583dd
commit 0da6e3ccb5
13 files changed
+272 -174

No files matched your search

@@ -20,7 +20,6 @@
#include "RiaApplication.h"
#include "RiaDefines.h"
#include "RiaInterpolationTools.h"
#include "RiaLogging.h"
#include "RiaNumberFormat.h"
#include "RiaPreferences.h"
@@ -34,11 +33,8 @@
#include "RigStatisticsMath.h"
#include "RigStimPlanFractureDefinition.h"
#ifdef USE_QTCHARTS
#include "RimEnsembleFractureStatisticsPlot.h"
#endif
#include "Histogram/RimEnsembleFractureHistogramDataSource.h"
#include "RimFractureTemplateCollection.h"
#include "RimHistogramCalculator.h"
#include "RimProject.h"
#include "RimStimPlanFractureTemplate.h"
@@ -288,15 +284,13 @@ void RimEnsembleFractureStatistics::fieldChangedByUi( const caf::PdmFieldHandle*
{
loadAndUpdateData();
#ifdef USE_QTCHARTS
// Update referring plots
std::vector<caf::PdmObjectHandle*> referringObjects = objectsWithReferringPtrFields();
for ( caf::PdmObjectHandle* obj : referringObjects )
{
auto plot = dynamic_cast<RimEnsembleFractureStatisticsPlot*>( obj );
auto plot = dynamic_cast<RimEnsembleFractureHistogramDataSource*>( obj );
if ( plot ) plot->loadDataAndUpdate();
}
#endif
}
}
@@ -8,6 +8,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimHistogramMultiPlot.h
${CMAKE_CURRENT_LIST_DIR}/RimHistogramMultiPlotCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimHistogramPlot.h
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleFractureHistogramDataSource.h
)
set(SOURCE_GROUP_SOURCE_FILES
@@ -20,6 +21,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimHistogramMultiPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimHistogramMultiPlotCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimHistogramPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleFractureHistogramDataSource.cpp
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
@@ -0,0 +1,185 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimEnsembleFractureHistogramDataSource.h"
#include "Histogram/RimHistogramPlot.h"
#include "RimEnsembleFractureStatistics.h"
#include "RimProject.h"
CAF_PDM_XML_SOURCE_INIT( RimEnsembleFractureHistogramDataSource, "EnsembleFractureHistogramDataSource" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEnsembleFractureHistogramDataSource::RimEnsembleFractureHistogramDataSource()
{
CAF_PDM_InitObject( "Ensemble Fracture Histogram Data Source" );
CAF_PDM_InitFieldNoDefault( &m_ensembleFractureStatistics, "EnsembleFractureStatistics", "Ensemble Fracture Statistics" );
m_ensembleFractureStatistics.uiCapability()->setUiTreeChildrenHidden( true );
CAF_PDM_InitFieldNoDefault( &m_property, "Property", "Property" );
CAF_PDM_InitField( &m_numBins, "NumBins", 15, "Number of Bins" );
setDefaults();
setDeletable( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEnsembleFractureHistogramDataSource::~RimEnsembleFractureHistogramDataSource()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimEnsembleFractureHistogramDataSource::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_ensembleFractureStatistics )
{
std::vector<RimEnsembleFractureStatistics*> esfItems =
RimProject::current()->descendantsIncludingThisOfType<RimEnsembleFractureStatistics>();
for ( auto item : esfItems )
{
options.push_back( caf::PdmOptionItemInfo( item->name(), item ) );
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleFractureHistogramDataSource ::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_ensembleFractureStatistics );
uiOrdering.add( &m_property );
uiOrdering.add( &m_numBins );
uiOrdering.skipRemainingFields( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleFractureHistogramDataSource::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
dataSourceChanged.send();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RimEnsembleFractureHistogramDataSource::unitNameY() const
{
return "";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RimEnsembleFractureHistogramDataSource::unitNameX() const
{
return "";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimHistogramDataSource::HistogramResult RimEnsembleFractureHistogramDataSource::compute( RimHistogramPlot::GraphType graphType,
RimHistogramPlot::FrequencyType frequencyType ) const
{
RimHistogramDataSource::HistogramResult result;
RigHistogramData histogramData =
RigEnsembleFractureStatisticsCalculator::createStatisticsData( m_ensembleFractureStatistics(), m_property(), m_numBins() );
if ( !histogramData.isHistogramVectorValid() ) return result;
double min = histogramData.min;
double max = histogramData.max;
result.valuesX = computeHistogramBins( min, max, m_numBins, graphType );
result.valuesY = computeHistogramFrequencies( histogramData.histogram, graphType, frequencyType );
result.p10 = histogramData.p10;
result.mean = histogramData.mean;
result.p90 = histogramData.p90;
return result;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RimEnsembleFractureHistogramDataSource::name() const
{
if ( m_ensembleFractureStatistics() == nullptr )
{
return "Undefined";
}
QStringList nameTags;
nameTags += m_ensembleFractureStatistics()->name();
nameTags += caf::AppEnum<RigEnsembleFractureStatisticsCalculator::PropertyType>::uiText( m_property() );
return nameTags.join( ", " ).toStdString();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleFractureHistogramDataSource::setEnsembleFractureStatistics( RimEnsembleFractureStatistics* statistics )
{
m_ensembleFractureStatistics = statistics;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleFractureHistogramDataSource::setProperty( RigEnsembleFractureStatisticsCalculator::PropertyType property )
{
m_property = property;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleFractureHistogramDataSource::setDefaults()
{
auto esfItems = RimProject::current()->descendantsIncludingThisOfType<RimEnsembleFractureStatistics>();
if ( !esfItems.empty() ) m_ensembleFractureStatistics = esfItems.front();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleFractureHistogramDataSource::loadDataAndUpdate()
{
dataSourceChanged.send();
}
@@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimHistogramDataSource.h"
#include "cafPdmField.h"
#include "cafPdmPtrField.h"
#include "RigEnsembleFractureStatisticsCalculator.h"
class RimEnsembleFractureStatistics;
//==================================================================================================
///
///
//==================================================================================================
class RimEnsembleFractureHistogramDataSource : public RimHistogramDataSource
{
CAF_PDM_HEADER_INIT;
public:
RimEnsembleFractureHistogramDataSource();
~RimEnsembleFractureHistogramDataSource() override;
void setEnsembleFractureStatistics( RimEnsembleFractureStatistics* statistics );
void setProperty( RigEnsembleFractureStatisticsCalculator::PropertyType property );
std::string unitNameX() const override;
std::string unitNameY() const override;
HistogramResult compute( RimHistogramPlot::GraphType graphType, RimHistogramPlot::FrequencyType frequencyType ) const override;
void setDefaults() override;
std::string name() const override;
void loadDataAndUpdate();
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;
caf::PdmPtrField<RimEnsembleFractureStatistics*> m_ensembleFractureStatistics;
caf::PdmField<caf::AppEnum<RigEnsembleFractureStatisticsCalculator::PropertyType>> m_property;
caf::PdmField<int> m_numBins;
};
@@ -160,10 +160,6 @@
#include "RimWellPltPlot.h"
#include "RimWellRftPlot.h"
#ifdef USE_QTCHARTS
#include "RimEnsembleFractureStatisticsPlotCollection.h"
#endif
#include "RiuMainWindow.h"
#include "OctaveScriptCommands/RicExecuteScriptForCasesFeature.h"
@@ -656,12 +652,6 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
{
menuBuilder << "RicCreateSaturationPressurePlotsFeature";
}
#ifdef USE_QTCHARTS
else if ( dynamic_cast<RimEnsembleFractureStatisticsPlotCollection*>( firstUiItem ) )
{
menuBuilder << "RicCreateEnsembleFractureStatisticsPlotFeature";
}
#endif
else if ( dynamic_cast<RimGridCrossPlot*>( firstUiItem ) )
{
menuBuilder << "RicPasteGridCrossPlotDataSetFeature";
@@ -996,7 +986,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder.subMenuStart( "New Histogram Curve" );
// TODO: make an enum of these?
std::vector<QString> curveTypes = { "Ensemble Parameter", "Grid Statistics", "Summary Vector" };
std::vector<QString> curveTypes = { "Ensemble Parameter", "Grid Statistics", "Summary Vector", "Ensemble Fracture Statistics" };
for ( const QString& curveType : curveTypes )
{
@@ -95,10 +95,6 @@
#include "RimWellMeasurementInViewCollection.h"
#include "RimWellPathCollection.h"
#ifdef USE_QTCHARTS
#include "RimGridStatisticsPlot.h"
#endif
#include "Riu3dSelectionManager.h"
#include "RiuMainWindow.h"
#include "RiuTools.h"
@@ -851,17 +847,6 @@ void RimEclipseView::onCreateDisplayModel()
}
}
#ifdef USE_QTCHARTS
std::vector<RimGridStatisticsPlot*> gridStatisticsPlots = objectsWithReferringPtrFieldsOfType<RimGridStatisticsPlot>();
for ( auto gridStatisticsPlot : gridStatisticsPlots )
{
if ( gridStatisticsPlot != nullptr )
{
gridStatisticsPlot->cellFilterViewUpdated();
}
}
#endif
std::vector<RimGridStatisticsHistogramDataSource*> gridStatisticsHistogramDataSources =
objectsWithReferringPtrFieldsOfType<RimGridStatisticsHistogramDataSource>();
for ( auto gridStatisticsPlot : gridStatisticsHistogramDataSources )
@@ -113,12 +113,6 @@ RimMainPlotCollection::RimMainPlotCollection()
CAF_PDM_InitFieldNoDefault( &m_histogramMultiPlotCollection, "HistogramMultiPlotCollection", "" );
#ifdef USE_QTCHARTS
CAF_PDM_InitFieldNoDefault( &m_gridStatisticsPlotCollection, "GridStatisticsPlotCollection", "" );
CAF_PDM_InitFieldNoDefault( &m_ensembleFractureStatisticsPlotCollection, "EnsembleFractureStatisticsPlotCollection", "" );
#endif
m_wellLogPlotCollection = new RimWellLogPlotCollection();
m_rftPlotCollection = new RimRftPlotCollection();
m_pltPlotCollection = new RimPltPlotCollection();
@@ -134,10 +128,12 @@ RimMainPlotCollection::RimMainPlotCollection()
m_stimPlanModelPlotCollection = new RimStimPlanModelPlotCollection;
m_vfpPlotCollection = new RimVfpPlotCollection();
m_histogramMultiPlotCollection = new RimHistogramMultiPlotCollection();
#ifdef USE_QTCHARTS
m_gridStatisticsPlotCollection = new RimGridStatisticsPlotCollection;
m_ensembleFractureStatisticsPlotCollection = new RimEnsembleFractureStatisticsPlotCollection;
#endif
CAF_PDM_InitFieldNoDefault( &m_gridStatisticsPlotCollection_OBSOLETE, "GridStatisticsPlotCollection", "" );
m_gridStatisticsPlotCollection_OBSOLETE = new RimGridStatisticsPlotCollection;
CAF_PDM_InitFieldNoDefault( &m_ensembleFractureStatisticsPlotCollection_OBSOLETE, "EnsembleFractureStatisticsPlotCollection", "" );
m_ensembleFractureStatisticsPlotCollection_OBSOLETE = new RimEnsembleFractureStatisticsPlotCollection;
CAF_PDM_InitFieldNoDefault( &m_summaryPlotCollection_OBSOLETE, "SummaryPlotCollection", "Summary Plots" );
m_summaryPlotCollection_OBSOLETE.xmlCapability()->setIOWritable( false );
@@ -344,7 +340,7 @@ RimHistogramMultiPlotCollection* RimMainPlotCollection::histogramMultiPlotCollec
//--------------------------------------------------------------------------------------------------
RimGridStatisticsPlotCollection* RimMainPlotCollection::gridStatisticsPlotCollection() const
{
return m_gridStatisticsPlotCollection();
return m_gridStatisticsPlotCollection_OBSOLETE();
}
//--------------------------------------------------------------------------------------------------
@@ -352,7 +348,7 @@ RimGridStatisticsPlotCollection* RimMainPlotCollection::gridStatisticsPlotCollec
//--------------------------------------------------------------------------------------------------
RimEnsembleFractureStatisticsPlotCollection* RimMainPlotCollection::ensembleFractureStatisticsPlotCollection() const
{
return m_ensembleFractureStatisticsPlotCollection();
return m_ensembleFractureStatisticsPlotCollection_OBSOLETE();
}
#endif
@@ -125,10 +125,9 @@ private:
caf::PdmChildField<RimStimPlanModelPlotCollection*> m_stimPlanModelPlotCollection;
caf::PdmChildField<RimVfpPlotCollection*> m_vfpPlotCollection;
caf::PdmChildField<RimHistogramMultiPlotCollection*> m_histogramMultiPlotCollection;
#ifdef USE_QTCHARTS
caf::PdmChildField<RimGridStatisticsPlotCollection*> m_gridStatisticsPlotCollection;
caf::PdmChildField<RimEnsembleFractureStatisticsPlotCollection*> m_ensembleFractureStatisticsPlotCollection;
#endif
caf::PdmChildField<RimGridStatisticsPlotCollection*> m_gridStatisticsPlotCollection_OBSOLETE;
caf::PdmChildField<RimEnsembleFractureStatisticsPlotCollection*> m_ensembleFractureStatisticsPlotCollection_OBSOLETE;
caf::PdmField<bool> m_show;
@@ -102,12 +102,6 @@
#include "VerticalFlowPerformance/RimVfpDataCollection.h"
#include "VerticalFlowPerformance/RimVfpPlotCollection.h"
#ifdef USE_QTCHARTS
#include "RimEnsembleFractureStatisticsPlotCollection.h"
#include "RimGridStatisticsPlot.h"
#include "RimGridStatisticsPlotCollection.h"
#endif
#include "RiuPlotMainWindow.h"
#include "cafCmdFeatureMenuBuilder.h"
@@ -1469,17 +1463,6 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q
uiTreeOrdering.add( m_mainPlotCollection->histogramMultiPlotCollection() );
}
#ifdef USE_QTCHARTS
if ( m_mainPlotCollection->gridStatisticsPlotCollection() || m_mainPlotCollection->ensembleFractureStatisticsPlotCollection() )
{
auto statisticsItemCollection = uiTreeOrdering.add( "Statistics Plots", ":/Folder.png" );
if ( m_mainPlotCollection->gridStatisticsPlotCollection() )
statisticsItemCollection->add( m_mainPlotCollection->gridStatisticsPlotCollection() );
if ( m_mainPlotCollection->ensembleFractureStatisticsPlotCollection() )
statisticsItemCollection->add( m_mainPlotCollection->ensembleFractureStatisticsPlotCollection() );
}
#endif
uiTreeOrdering.add( automationSettings() );
}
}