From 722bbba84924bb10d9592e7ae5f99c607f5f7115 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 26 Sep 2023 14:09:43 +0200 Subject: [PATCH] Remove SummaryDataSource --- .../Summary/RimSummaryAddressSelector.cpp | 39 +++++++++++-------- .../Summary/RimSummaryAddressSelector.h | 11 ++---- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp index e4a683877be..c6af1b2ede8 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.cpp @@ -72,7 +72,6 @@ RimSummaryAddressSelector::RimSummaryAddressSelector() CAF_PDM_InitFieldNoDefault( &m_resamplingPeriod, "Resampling", "Resampling" ); - m_dataSource = SummaryDataSource::SINGLE_CASE; m_showDataSource = true; m_plotAxisOrientation = RimPlotAxisProperties::Orientation::ANY; } @@ -83,7 +82,6 @@ RimSummaryAddressSelector::RimSummaryAddressSelector() void RimSummaryAddressSelector::setSummaryCase( RimSummaryCase* summaryCase ) { m_summaryCase = summaryCase; - m_dataSource = SummaryDataSource::SINGLE_CASE; } //-------------------------------------------------------------------------------------------------- @@ -92,7 +90,6 @@ void RimSummaryAddressSelector::setSummaryCase( RimSummaryCase* summaryCase ) void RimSummaryAddressSelector::setEnsemble( RimSummaryCaseCollection* ensemble ) { m_summaryCaseCollection = ensemble; - m_dataSource = SummaryDataSource::ENSEMBLE; } //-------------------------------------------------------------------------------------------------- @@ -184,16 +181,16 @@ void RimSummaryAddressSelector::fieldChangedByUi( const caf::PdmFieldHandle* cha { RiuSummaryVectorSelectionDialog dlg( nullptr ); - if ( m_dataSource == SummaryDataSource::SINGLE_CASE ) - { - dlg.hideEnsembles(); - dlg.setCaseAndAddress( m_summaryCase(), m_summaryAddress->address() ); - } - else if ( m_dataSource == SummaryDataSource::ENSEMBLE ) + if ( isEnsemble() ) { dlg.hideSummaryCases(); dlg.setEnsembleAndAddress( m_summaryCaseCollection(), m_summaryAddress->address() ); } + else + { + dlg.hideEnsembles(); + dlg.setCaseAndAddress( m_summaryCase(), m_summaryAddress->address() ); + } if ( dlg.exec() == QDialog::Accepted ) { @@ -292,7 +289,11 @@ QList RimSummaryAddressSelector::calculateValueOptions( if ( fieldNeedingOptions == &m_summaryAddressUiField ) { std::set addresses; - if ( m_dataSource == SummaryDataSource::SINGLE_CASE && m_summaryCase() ) + if ( isEnsemble() && m_summaryCaseCollection() ) + { + addresses = m_summaryCaseCollection()->ensembleSummaryAddresses(); + } + else if ( m_summaryCase() ) { RifSummaryReaderInterface* reader = m_summaryCase()->summaryReader(); if ( reader ) @@ -300,10 +301,6 @@ QList RimSummaryAddressSelector::calculateValueOptions( addresses = reader->allResultAddresses(); } } - else if ( m_dataSource == SummaryDataSource::ENSEMBLE && m_summaryCaseCollection() ) - { - addresses = m_summaryCaseCollection()->ensembleSummaryAddresses(); - } return createOptionsForAddresses( addresses ); } @@ -332,13 +329,13 @@ void RimSummaryAddressSelector::defineUiOrdering( QString uiConfigName, caf::Pdm { if ( m_showDataSource ) { - if ( m_dataSource == SummaryDataSource::SINGLE_CASE ) + if ( isEnsemble() ) { - uiOrdering.add( &m_summaryCase ); + uiOrdering.add( &m_summaryCaseCollection ); } else { - uiOrdering.add( &m_summaryCaseCollection ); + uiOrdering.add( &m_summaryCase ); } } @@ -367,3 +364,11 @@ void RimSummaryAddressSelector::defineEditorAttribute( const caf::PdmFieldHandle } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAddressSelector::isEnsemble() const +{ + return m_summaryCaseCollection() != nullptr; +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h index f7fb4622c9e..ca5cb253927 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressSelector.h @@ -40,12 +40,6 @@ class RimSummaryAddressSelector : public caf::PdmObject CAF_PDM_HEADER_INIT; public: - enum class SummaryDataSource - { - SINGLE_CASE, - ENSEMBLE - }; - caf::Signal<> addressChanged; public: @@ -71,6 +65,8 @@ class RimSummaryAddressSelector : public caf::PdmObject void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override; + bool isEnsemble() const; + private: caf::PdmPtrField m_summaryCase; caf::PdmPtrField m_summaryCaseCollection; @@ -80,8 +76,7 @@ class RimSummaryAddressSelector : public caf::PdmObject caf::PdmPtrField m_plotAxisProperties; caf::PdmField m_resamplingPeriod; - SummaryDataSource m_dataSource; - bool m_showDataSource; + bool m_showDataSource; RimPlotAxisProperties::Orientation m_plotAxisOrientation; };