diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTable.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTable.cpp index 0a9deda34d..a12fd375f0 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTable.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTable.cpp @@ -152,7 +152,7 @@ void RimSummaryTable::setDefaultCaseAndCategoryAndVectorName() m_case = summaryCases.front(); - const auto summaryReader = m_case->summaryReader(); + const auto summaryReader = summaryReaderWithAddresses(); if ( !summaryReader ) return; const auto categoryVectors = getCategoryVectorFromSummaryReader( summaryReader, m_category() ); @@ -215,7 +215,7 @@ void RimSummaryTable::fieldChangedByUi( const caf::PdmFieldHandle* changedField, { if ( m_case ) { - auto* summaryReader = m_case->summaryReader(); + const auto summaryReader = summaryReaderWithAddresses(); const auto categoryVectors = getCategoryVectorFromSummaryReader( summaryReader, m_category() ); if ( summaryReader && !categoryVectors.empty() ) { @@ -236,7 +236,7 @@ void RimSummaryTable::fieldChangedByUi( const caf::PdmFieldHandle* changedField, { if ( m_case ) { - auto* summaryReader = m_case->summaryReader(); + const auto summaryReader = summaryReaderWithAddresses(); const auto categoryVectors = getCategoryVectorFromSummaryReader( summaryReader, m_category() ); if ( summaryReader && !categoryVectors.empty() ) { @@ -406,7 +406,7 @@ QList RimSummaryTable::calculateValueOptions( const caf: } else if ( fieldNeedingOptions == &m_vector && m_case ) { - auto* summaryReader = m_case->summaryReader(); + const auto summaryReader = summaryReaderWithAddresses(); if ( summaryReader ) { const auto categoryVectorsUnion = getCategoryVectorFromSummaryReader( summaryReader, m_category() ); @@ -447,7 +447,7 @@ void RimSummaryTable::onLoadDataAndUpdate() return; } - const auto summaryReader = m_case->summaryReader(); + const auto summaryReader = summaryReaderWithAddresses(); if ( !summaryReader ) { return; @@ -709,8 +709,7 @@ std::vector RimSummaryTable::getToplevelSummaryCases() const //-------------------------------------------------------------------------------------------------- void RimSummaryTable::initializeDateRange() { - if ( !m_case ) return; - const auto summaryReader = m_case->summaryReader(); + auto summaryReader = summaryReaderWithAddresses(); if ( !summaryReader ) return; const std::set allResultAddresses = summaryReader->allResultAddresses(); @@ -723,6 +722,25 @@ void RimSummaryTable::initializeDateRange() m_endDate = RiaQDateTimeTools::fromTime_t( timeSteps.back() ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifSummaryReaderInterface* RimSummaryTable::summaryReaderWithAddresses() +{ + if ( !m_case ) return nullptr; + + if ( auto summaryReader = m_case->summaryReader() ) + { + // This is required for ensemble cases, addresses are created on demand + // Consider moving this to the summary reader interface, and make the call as part of the pure virtual method + // virtual RifSummaryReaderInterface* summaryReader() = 0; in RimSummaryCase + summaryReader->createAddressesIfRequired(); + return summaryReader; + } + + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -731,9 +749,7 @@ void RimSummaryTable::createTableData() m_tableData = TableData(); m_tableData.thresholdValue = m_thresholdValue(); - if ( !m_case ) return; - - const auto summaryReader = m_case->summaryReader(); + const auto summaryReader = summaryReaderWithAddresses(); if ( !summaryReader ) return; // Create time step value for vectors with no values above threshold diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTable.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTable.h index 6766efd2a9..601d2c57e7 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTable.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTable.h @@ -108,6 +108,8 @@ private: std::vector getToplevelSummaryCases() const; void initializeDateRange(); + RifSummaryReaderInterface* summaryReaderWithAddresses(); + private: // Matrix plot for visualizing table data QPointer m_matrixPlotWidget;