mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add derived summary case (#5496)
* #5488 Derived Summary Case : Refactor ensemble summary case - Refactor ensemble summary case to be able to us as standalone derived summary case - rename to RimDerivedSummaryCase - allow negative values in well disk visualization * #5488 Derived Summary Case : Add feature to create derived case * #5487 Well Disks : Add scaling factor
This commit is contained in:
@@ -34,7 +34,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveFilter.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveFilterCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleStatistics.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleStatisticsCase.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimDerivedEnsembleCase.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimDerivedSummaryCase.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimDerivedEnsembleCaseCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotFilterTextCurveSetEditor.h
|
||||
)
|
||||
@@ -74,7 +74,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveFilter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveFilterCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleStatistics.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEnsembleStatisticsCase.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimDerivedEnsembleCase.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimDerivedSummaryCase.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimDerivedEnsembleCaseCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotFilterTextCurveSetEditor.cpp
|
||||
)
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
#include "SummaryPlotCommands/RicNewDerivedEnsembleFeature.h"
|
||||
|
||||
#include "RimDerivedEnsembleCase.h"
|
||||
#include "RimDerivedEnsembleCaseCollection.h"
|
||||
#include "RimDerivedSummaryCase.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "RimSummaryCaseMainCollection.h"
|
||||
@@ -32,17 +32,6 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
template <>
|
||||
void caf::AppEnum<DerivedEnsembleOperator>::setUp()
|
||||
{
|
||||
addItem( DERIVED_ENSEMBLE_SUB, "Sub", "-" );
|
||||
addItem( DERIVED_ENSEMBLE_ADD, "Add", "+" );
|
||||
setDefault( DERIVED_ENSEMBLE_SUB );
|
||||
}
|
||||
} // namespace caf
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimDerivedEnsembleCaseCollection, "RimDerivedEnsembleCaseCollection" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -150,6 +139,7 @@ void RimDerivedEnsembleCaseCollection::updateDerivedEnsembleCases()
|
||||
|
||||
auto derivedCase = firstCaseNotInUse();
|
||||
derivedCase->setSummaryCases( sumCase1, sumCase2 );
|
||||
derivedCase->setOperator( m_operator() );
|
||||
derivedCase->createSummaryReaderInterface();
|
||||
derivedCase->setCaseRealizationParameters( crp );
|
||||
derivedCase->setInUse( true );
|
||||
@@ -326,12 +316,12 @@ void RimDerivedEnsembleCaseCollection::setAllCasesNotInUse()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDerivedEnsembleCaseCollection::deleteCasesNoInUse()
|
||||
{
|
||||
std::vector<RimDerivedEnsembleCase*> inactiveCases;
|
||||
auto allCases = allDerivedCases( false );
|
||||
std::vector<RimDerivedSummaryCase*> inactiveCases;
|
||||
auto allCases = allDerivedCases( false );
|
||||
std::copy_if( allCases.begin(),
|
||||
allCases.end(),
|
||||
std::back_inserter( inactiveCases ),
|
||||
[]( RimDerivedEnsembleCase* derCase ) { return !derCase->isInUse(); } );
|
||||
[]( RimDerivedSummaryCase* derCase ) { return !derCase->isInUse(); } );
|
||||
|
||||
for ( auto derCase : inactiveCases )
|
||||
{
|
||||
@@ -343,10 +333,10 @@ void RimDerivedEnsembleCaseCollection::deleteCasesNoInUse()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimDerivedEnsembleCase* RimDerivedEnsembleCaseCollection::firstCaseNotInUse()
|
||||
RimDerivedSummaryCase* RimDerivedEnsembleCaseCollection::firstCaseNotInUse()
|
||||
{
|
||||
auto allCases = allDerivedCases( false );
|
||||
auto itr = std::find_if( allCases.begin(), allCases.end(), []( RimDerivedEnsembleCase* derCase ) {
|
||||
auto itr = std::find_if( allCases.begin(), allCases.end(), []( RimDerivedSummaryCase* derCase ) {
|
||||
return !derCase->isInUse();
|
||||
} );
|
||||
if ( itr != allCases.end() )
|
||||
@@ -355,7 +345,7 @@ RimDerivedEnsembleCase* RimDerivedEnsembleCaseCollection::firstCaseNotInUse()
|
||||
}
|
||||
|
||||
// If no active case was found, add a new case to the collection
|
||||
auto newCase = new RimDerivedEnsembleCase();
|
||||
auto newCase = new RimDerivedSummaryCase();
|
||||
m_cases.push_back( newCase );
|
||||
return newCase;
|
||||
}
|
||||
@@ -363,12 +353,12 @@ RimDerivedEnsembleCase* RimDerivedEnsembleCaseCollection::firstCaseNotInUse()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimDerivedEnsembleCase*> RimDerivedEnsembleCaseCollection::allDerivedCases( bool activeOnly ) const
|
||||
std::vector<RimDerivedSummaryCase*> RimDerivedEnsembleCaseCollection::allDerivedCases( bool activeOnly ) const
|
||||
{
|
||||
std::vector<RimDerivedEnsembleCase*> activeCases;
|
||||
std::vector<RimDerivedSummaryCase*> activeCases;
|
||||
for ( auto sumCase : RimSummaryCaseCollection::allSummaryCases() )
|
||||
{
|
||||
auto derivedCase = dynamic_cast<RimDerivedEnsembleCase*>( sumCase );
|
||||
auto derivedCase = dynamic_cast<RimDerivedSummaryCase*>( sumCase );
|
||||
if ( derivedCase && ( !activeOnly || derivedCase->isInUse() ) )
|
||||
{
|
||||
activeCases.push_back( derivedCase );
|
||||
@@ -382,7 +372,7 @@ std::vector<RimDerivedEnsembleCase*> RimDerivedEnsembleCaseCollection::allDerive
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDerivedEnsembleCaseCollection::updateAutoName()
|
||||
{
|
||||
QString op = caf::AppEnum<DerivedEnsembleOperator>::uiText( m_operator() );
|
||||
QString op = caf::AppEnum<DerivedSummaryOperator>::uiText( m_operator() );
|
||||
|
||||
auto derivedEnsemble1 = dynamic_cast<RimDerivedEnsembleCaseCollection*>( m_ensemble1() );
|
||||
auto derivedEnsemble2 = dynamic_cast<RimDerivedEnsembleCaseCollection*>( m_ensemble2() );
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
|
||||
#include "RimDerivedEnsembleCase.h"
|
||||
#include "RimDerivedSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
{
|
||||
return m_ensemble2;
|
||||
}
|
||||
DerivedEnsembleOperator op() const
|
||||
DerivedSummaryOperator op() const
|
||||
{
|
||||
return m_operator();
|
||||
}
|
||||
@@ -82,11 +82,11 @@ private:
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
void setAllCasesNotInUse();
|
||||
void deleteCasesNoInUse();
|
||||
RimDerivedEnsembleCase* firstCaseNotInUse();
|
||||
std::vector<RimDerivedEnsembleCase*> allDerivedCases( bool activeOnly ) const;
|
||||
void updateAutoName();
|
||||
void setAllCasesNotInUse();
|
||||
void deleteCasesNoInUse();
|
||||
RimDerivedSummaryCase* firstCaseNotInUse();
|
||||
std::vector<RimDerivedSummaryCase*> allDerivedCases( bool activeOnly ) const;
|
||||
void updateAutoName();
|
||||
RimSummaryCase* findCaseByParametersHash( const std::vector<RimSummaryCase*>& cases, size_t hash ) const;
|
||||
std::vector<RimDerivedEnsembleCaseCollection*> findReferringEnsembles() const;
|
||||
|
||||
@@ -94,9 +94,9 @@ private:
|
||||
std::vector<RimSummaryCaseCollection*> allEnsembles() const;
|
||||
|
||||
private:
|
||||
caf::PdmPtrField<RimSummaryCaseCollection*> m_ensemble1;
|
||||
caf::PdmPtrField<RimSummaryCaseCollection*> m_ensemble2;
|
||||
caf::PdmField<caf::AppEnum<DerivedEnsembleOperator>> m_operator;
|
||||
caf::PdmField<bool> m_swapEnsemblesButton;
|
||||
caf::PdmField<QString> m_caseCount;
|
||||
caf::PdmPtrField<RimSummaryCaseCollection*> m_ensemble1;
|
||||
caf::PdmPtrField<RimSummaryCaseCollection*> m_ensemble2;
|
||||
caf::PdmField<caf::AppEnum<DerivedSummaryOperator>> m_operator;
|
||||
caf::PdmField<bool> m_swapEnsemblesButton;
|
||||
caf::PdmField<QString> m_caseCount;
|
||||
};
|
||||
|
||||
@@ -16,44 +16,41 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimDerivedEnsembleCase.h"
|
||||
#include "RimDerivedSummaryCase.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaCurveMerger.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaSummaryTools.h"
|
||||
|
||||
#include "RifDerivedEnsembleReader.h"
|
||||
|
||||
#include "RimDerivedEnsembleCaseCollection.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "RimSummaryCaseMainCollection.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
namespace caf
|
||||
{
|
||||
template <>
|
||||
void caf::AppEnum<DerivedSummaryOperator>::setUp()
|
||||
{
|
||||
addItem( DerivedSummaryOperator::DERIVED_OPERATOR_SUB, "Sub", "-" );
|
||||
addItem( DerivedSummaryOperator::DERIVED_OPERATOR_ADD, "Add", "+" );
|
||||
setDefault( DerivedSummaryOperator::DERIVED_OPERATOR_SUB );
|
||||
}
|
||||
} // namespace caf
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
CAF_PDM_ABSTRACT_SOURCE_INIT( RimDerivedEnsembleCase, "RimDerivedEnsembleCase" );
|
||||
CAF_PDM_SOURCE_INIT( RimDerivedSummaryCase, "RimDerivedEnsembleCase" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<time_t> RimDerivedEnsembleCase::EMPTY_TIME_STEPS_VECTOR;
|
||||
const std::vector<double> RimDerivedEnsembleCase::EMPTY_VALUES_VECTOR;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimDerivedEnsembleCase::RimDerivedEnsembleCase()
|
||||
RimDerivedSummaryCase::RimDerivedSummaryCase()
|
||||
: m_summaryCase1( nullptr )
|
||||
, m_summaryCase2( nullptr )
|
||||
{
|
||||
CAF_PDM_InitObject( "Summary Case", ":/SummaryCase16x16.png", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_summaryCase1, "SummaryCase1", "SummaryCase1", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_summaryCase2, "SummaryCase2", "SummaryCase2", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_operator, "Operator", "Operator", "", "", "" );
|
||||
|
||||
m_inUse = false;
|
||||
}
|
||||
@@ -61,12 +58,12 @@ RimDerivedEnsembleCase::RimDerivedEnsembleCase()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimDerivedEnsembleCase::~RimDerivedEnsembleCase() {}
|
||||
RimDerivedSummaryCase::~RimDerivedSummaryCase() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDerivedEnsembleCase::setInUse( bool inUse )
|
||||
void RimDerivedSummaryCase::setInUse( bool inUse )
|
||||
{
|
||||
m_inUse = inUse;
|
||||
|
||||
@@ -74,14 +71,14 @@ void RimDerivedEnsembleCase::setInUse( bool inUse )
|
||||
{
|
||||
m_summaryCase1 = nullptr;
|
||||
m_summaryCase2 = nullptr;
|
||||
m_data.clear();
|
||||
m_dataCache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimDerivedEnsembleCase::isInUse() const
|
||||
bool RimDerivedSummaryCase::isInUse() const
|
||||
{
|
||||
return m_inUse;
|
||||
}
|
||||
@@ -89,7 +86,7 @@ bool RimDerivedEnsembleCase::isInUse() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDerivedEnsembleCase::setSummaryCases( RimSummaryCase* sumCase1, RimSummaryCase* sumCase2 )
|
||||
void RimDerivedSummaryCase::setSummaryCases( RimSummaryCase* sumCase1, RimSummaryCase* sumCase2 )
|
||||
{
|
||||
if ( !sumCase1 || !sumCase2 ) return;
|
||||
m_summaryCase1 = sumCase1;
|
||||
@@ -99,39 +96,49 @@ void RimDerivedEnsembleCase::setSummaryCases( RimSummaryCase* sumCase1, RimSumma
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimDerivedEnsembleCase::needsCalculation( const RifEclipseSummaryAddress& address ) const
|
||||
bool RimDerivedSummaryCase::needsCalculation( const RifEclipseSummaryAddress& address ) const
|
||||
{
|
||||
return m_data.count( address ) == 0;
|
||||
return m_dataCache.count( address ) == 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<time_t>& RimDerivedEnsembleCase::timeSteps( const RifEclipseSummaryAddress& address ) const
|
||||
const std::vector<time_t>& RimDerivedSummaryCase::timeSteps( const RifEclipseSummaryAddress& address ) const
|
||||
{
|
||||
if ( m_data.count( address ) == 0 ) return EMPTY_TIME_STEPS_VECTOR;
|
||||
return m_data.at( address ).first;
|
||||
if ( m_dataCache.count( address ) == 0 )
|
||||
{
|
||||
static std::vector<time_t> empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
return m_dataCache.at( address ).first;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<double>& RimDerivedEnsembleCase::values( const RifEclipseSummaryAddress& address ) const
|
||||
const std::vector<double>& RimDerivedSummaryCase::values( const RifEclipseSummaryAddress& address ) const
|
||||
{
|
||||
if ( m_data.count( address ) == 0 ) return EMPTY_VALUES_VECTOR;
|
||||
return m_data.at( address ).second;
|
||||
if ( m_dataCache.count( address ) == 0 )
|
||||
{
|
||||
static std::vector<double> empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
return m_dataCache.at( address ).second;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDerivedEnsembleCase::calculate( const RifEclipseSummaryAddress& address )
|
||||
void RimDerivedSummaryCase::calculate( const RifEclipseSummaryAddress& address )
|
||||
{
|
||||
clearData( address );
|
||||
|
||||
RifSummaryReaderInterface* reader1 = m_summaryCase1 ? m_summaryCase1->summaryReader() : nullptr;
|
||||
RifSummaryReaderInterface* reader2 = m_summaryCase2 ? m_summaryCase2->summaryReader() : nullptr;
|
||||
if ( !reader1 || !reader2 || !parentEnsemble() ) return;
|
||||
if ( !reader1 || !reader2 ) return;
|
||||
|
||||
if ( !reader1->hasAddress( address ) || !reader2->hasAddress( address ) )
|
||||
{
|
||||
@@ -147,7 +154,6 @@ void RimDerivedEnsembleCase::calculate( const RifEclipseSummaryAddress& address
|
||||
RiaTimeHistoryCurveMerger merger;
|
||||
std::vector<double> values1;
|
||||
std::vector<double> values2;
|
||||
DerivedEnsembleOperator op = parentEnsemble()->op();
|
||||
|
||||
reader1->values( address, &values1 );
|
||||
reader2->values( address, &values2 );
|
||||
@@ -164,17 +170,17 @@ void RimDerivedEnsembleCase::calculate( const RifEclipseSummaryAddress& address
|
||||
calculatedValues.reserve( sampleCount );
|
||||
for ( size_t i = 0; i < sampleCount; i++ )
|
||||
{
|
||||
if ( op == DERIVED_ENSEMBLE_SUB )
|
||||
if ( m_operator() == DerivedSummaryOperator::DERIVED_OPERATOR_SUB )
|
||||
{
|
||||
calculatedValues.push_back( allValues1[i] - allValues2[i] );
|
||||
}
|
||||
else if ( op == DERIVED_ENSEMBLE_ADD )
|
||||
else if ( m_operator() == DerivedSummaryOperator::DERIVED_OPERATOR_ADD )
|
||||
{
|
||||
calculatedValues.push_back( allValues1[i] + allValues2[i] );
|
||||
}
|
||||
}
|
||||
|
||||
auto& dataItem = m_data[address];
|
||||
auto& dataItem = m_dataCache[address];
|
||||
dataItem.first = merger.allXValues();
|
||||
dataItem.second = calculatedValues;
|
||||
}
|
||||
@@ -182,21 +188,26 @@ void RimDerivedEnsembleCase::calculate( const RifEclipseSummaryAddress& address
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimDerivedEnsembleCase::caseName() const
|
||||
QString RimDerivedSummaryCase::caseName() const
|
||||
{
|
||||
auto case1Name = m_summaryCase1->displayCaseName();
|
||||
auto case2Name = m_summaryCase2->displayCaseName();
|
||||
if ( m_summaryCase1 && m_summaryCase2 )
|
||||
{
|
||||
auto case1Name = m_summaryCase1->displayCaseName();
|
||||
auto case2Name = m_summaryCase2->displayCaseName();
|
||||
|
||||
if ( case1Name == case2Name )
|
||||
return case1Name;
|
||||
else
|
||||
return QString( "%1/%2" ).arg( case1Name ).arg( case2Name );
|
||||
if ( case1Name == case2Name )
|
||||
return case1Name;
|
||||
else
|
||||
return QString( "%1/%2" ).arg( case1Name ).arg( case2Name );
|
||||
}
|
||||
|
||||
return m_shortName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDerivedEnsembleCase::createSummaryReaderInterface()
|
||||
void RimDerivedSummaryCase::createSummaryReaderInterface()
|
||||
{
|
||||
RifSummaryReaderInterface* summaryCase1Reader = nullptr;
|
||||
if ( m_summaryCase1 )
|
||||
@@ -215,7 +226,7 @@ void RimDerivedEnsembleCase::createSummaryReaderInterface()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifSummaryReaderInterface* RimDerivedEnsembleCase::summaryReader()
|
||||
RifSummaryReaderInterface* RimDerivedSummaryCase::summaryReader()
|
||||
{
|
||||
return m_reader.get();
|
||||
}
|
||||
@@ -223,7 +234,7 @@ RifSummaryReaderInterface* RimDerivedEnsembleCase::summaryReader()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDerivedEnsembleCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
|
||||
void RimDerivedSummaryCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
|
||||
{
|
||||
// NOP
|
||||
}
|
||||
@@ -231,17 +242,110 @@ void RimDerivedEnsembleCase::updateFilePathsFromProjectPath( const QString& newP
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimDerivedEnsembleCaseCollection* RimDerivedEnsembleCase::parentEnsemble() const
|
||||
void RimDerivedSummaryCase::setOperator( DerivedSummaryOperator oper )
|
||||
{
|
||||
RimDerivedEnsembleCaseCollection* ensemble;
|
||||
firstAncestorOrThisOfType( ensemble );
|
||||
return ensemble;
|
||||
m_operator = oper;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDerivedEnsembleCase::clearData( const RifEclipseSummaryAddress& address )
|
||||
void RimDerivedSummaryCase::clearData( const RifEclipseSummaryAddress& address )
|
||||
{
|
||||
m_data.erase( address );
|
||||
m_dataCache.erase( address );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDerivedSummaryCase::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
// Base class
|
||||
uiOrdering.add( &m_shortName );
|
||||
|
||||
// This class
|
||||
uiOrdering.add( &m_summaryCase1 );
|
||||
uiOrdering.add( &m_operator );
|
||||
uiOrdering.add( &m_summaryCase2 );
|
||||
|
||||
uiOrdering.skipRemainingFields();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo>
|
||||
RimDerivedSummaryCase::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
auto summaryCases = proj->allSummaryCases();
|
||||
|
||||
if ( fieldNeedingOptions == &m_summaryCase1 || fieldNeedingOptions == &m_summaryCase2 )
|
||||
{
|
||||
for ( auto c : summaryCases )
|
||||
{
|
||||
if ( c != this ) options.push_back( caf::PdmOptionItemInfo( c->displayCaseName(), c ) );
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDerivedSummaryCase::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
bool reloadData = false;
|
||||
if ( changedField == &m_summaryCase2 || changedField == &m_summaryCase1 )
|
||||
{
|
||||
if ( !m_reader )
|
||||
{
|
||||
createSummaryReaderInterface();
|
||||
}
|
||||
|
||||
if ( m_reader )
|
||||
{
|
||||
m_reader->updateData( m_summaryCase1(), m_summaryCase2() );
|
||||
}
|
||||
|
||||
reloadData = true;
|
||||
}
|
||||
else if ( changedField == &m_operator )
|
||||
{
|
||||
reloadData = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
RimSummaryCase::fieldChangedByUi( changedField, oldValue, newValue );
|
||||
}
|
||||
|
||||
if ( reloadData )
|
||||
{
|
||||
m_dataCache.clear();
|
||||
|
||||
std::vector<caf::PdmObjectHandle*> referringObjects;
|
||||
this->objectsWithReferringPtrFields( referringObjects );
|
||||
|
||||
std::set<RimSummaryPlot*> plotsToUpdate;
|
||||
for ( auto o : referringObjects )
|
||||
{
|
||||
RimSummaryPlot* sumPlot = nullptr;
|
||||
o->firstAncestorOrThisOfType( sumPlot );
|
||||
|
||||
if ( sumPlot )
|
||||
{
|
||||
plotsToUpdate.insert( sumPlot );
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto p : plotsToUpdate )
|
||||
{
|
||||
p->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,55 +28,63 @@
|
||||
class RifEclipseSummaryAddress;
|
||||
class RifSummaryReaderInterface;
|
||||
class RifDerivedEnsembleReader;
|
||||
class RimDerivedEnsembleCaseCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
enum DerivedEnsembleOperator
|
||||
enum class DerivedSummaryOperator
|
||||
{
|
||||
DERIVED_ENSEMBLE_SUB,
|
||||
DERIVED_ENSEMBLE_ADD
|
||||
DERIVED_OPERATOR_SUB,
|
||||
DERIVED_OPERATOR_ADD
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//==================================================================================================
|
||||
|
||||
class RimDerivedEnsembleCase : public RimSummaryCase
|
||||
class RimDerivedSummaryCase : public RimSummaryCase
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
static const std::vector<time_t> EMPTY_TIME_STEPS_VECTOR;
|
||||
static const std::vector<double> EMPTY_VALUES_VECTOR;
|
||||
|
||||
public:
|
||||
RimDerivedEnsembleCase();
|
||||
~RimDerivedEnsembleCase() override;
|
||||
RimDerivedSummaryCase();
|
||||
~RimDerivedSummaryCase() override;
|
||||
|
||||
void setInUse( bool inUse );
|
||||
bool isInUse() const;
|
||||
void setSummaryCases( RimSummaryCase* sumCase1, RimSummaryCase* sumCase2 );
|
||||
void setOperator( DerivedSummaryOperator oper );
|
||||
|
||||
void setInUse( bool inUse );
|
||||
bool isInUse() const;
|
||||
void setSummaryCases( RimSummaryCase* sumCase1, RimSummaryCase* sumCase2 );
|
||||
bool needsCalculation( const RifEclipseSummaryAddress& address ) const;
|
||||
const std::vector<time_t>& timeSteps( const RifEclipseSummaryAddress& address ) const;
|
||||
const std::vector<double>& values( const RifEclipseSummaryAddress& address ) const;
|
||||
|
||||
void calculate( const RifEclipseSummaryAddress& address );
|
||||
|
||||
QString caseName() const override;
|
||||
void createSummaryReaderInterface() override;
|
||||
RifSummaryReaderInterface* summaryReader() override;
|
||||
void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override;
|
||||
|
||||
RimDerivedEnsembleCaseCollection* parentEnsemble() const;
|
||||
protected:
|
||||
QString caseName() const override;
|
||||
|
||||
private:
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue ) override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
|
||||
bool* useOptionsOnly ) override;
|
||||
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
|
||||
void clearData( const RifEclipseSummaryAddress& address );
|
||||
|
||||
private:
|
||||
caf::PdmPtrField<RimSummaryCase*> m_summaryCase1;
|
||||
caf::PdmPtrField<RimSummaryCase*> m_summaryCase2;
|
||||
caf::PdmField<caf::AppEnum<DerivedSummaryOperator>> m_operator;
|
||||
|
||||
bool m_inUse;
|
||||
std::unique_ptr<RifDerivedEnsembleReader> m_reader;
|
||||
|
||||
bool m_inUse;
|
||||
caf::PdmPtrField<RimSummaryCase*> m_summaryCase1;
|
||||
caf::PdmPtrField<RimSummaryCase*> m_summaryCase2;
|
||||
std::map<RifEclipseSummaryAddress, std::pair<std::vector<time_t>, std::vector<double>>> m_data;
|
||||
std::map<RifEclipseSummaryAddress, std::pair<std::vector<time_t>, std::vector<double>>> m_dataCache;
|
||||
};
|
||||
@@ -195,7 +195,7 @@ void RimSummaryCaseCollection::removeCase( RimSummaryCase* summaryCase )
|
||||
|
||||
if ( m_isEnsemble && m_cases.size() != caseCountBeforeRemove )
|
||||
{
|
||||
if ( dynamic_cast<RimDerivedEnsembleCase*>( summaryCase ) == nullptr )
|
||||
if ( dynamic_cast<RimDerivedSummaryCase*>( summaryCase ) == nullptr )
|
||||
calculateEnsembleParametersIntersectionHash();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user