Skip to content

Commit

Permalink
Remove SummaryDataSource
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Sep 26, 2023
1 parent 7132265 commit 722bbba
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -83,7 +82,6 @@ RimSummaryAddressSelector::RimSummaryAddressSelector()
void RimSummaryAddressSelector::setSummaryCase( RimSummaryCase* summaryCase )
{
m_summaryCase = summaryCase;
m_dataSource = SummaryDataSource::SINGLE_CASE;
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -92,7 +90,6 @@ void RimSummaryAddressSelector::setSummaryCase( RimSummaryCase* summaryCase )
void RimSummaryAddressSelector::setEnsemble( RimSummaryCaseCollection* ensemble )
{
m_summaryCaseCollection = ensemble;
m_dataSource = SummaryDataSource::ENSEMBLE;
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -292,18 +289,18 @@ QList<caf::PdmOptionItemInfo> RimSummaryAddressSelector::calculateValueOptions(
if ( fieldNeedingOptions == &m_summaryAddressUiField )
{
std::set<RifEclipseSummaryAddress> 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 )
{
addresses = reader->allResultAddresses();
}
}
else if ( m_dataSource == SummaryDataSource::ENSEMBLE && m_summaryCaseCollection() )
{
addresses = m_summaryCaseCollection()->ensembleSummaryAddresses();
}

return createOptionsForAddresses( addresses );
}
Expand Down Expand Up @@ -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 );
}
}

Expand Down Expand Up @@ -367,3 +364,11 @@ void RimSummaryAddressSelector::defineEditorAttribute( const caf::PdmFieldHandle
}
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryAddressSelector::isEnsemble() const
{
return m_summaryCaseCollection() != nullptr;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ class RimSummaryAddressSelector : public caf::PdmObject
CAF_PDM_HEADER_INIT;

public:
enum class SummaryDataSource
{
SINGLE_CASE,
ENSEMBLE
};

caf::Signal<> addressChanged;

public:
Expand All @@ -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<RimSummaryCase*> m_summaryCase;
caf::PdmPtrField<RimSummaryCaseCollection*> m_summaryCaseCollection;
Expand All @@ -80,8 +76,7 @@ class RimSummaryAddressSelector : public caf::PdmObject
caf::PdmPtrField<RimPlotAxisPropertiesInterface*> m_plotAxisProperties;
caf::PdmField<RiaDefines::DateTimePeriodEnum> m_resamplingPeriod;

SummaryDataSource m_dataSource;
bool m_showDataSource;
bool m_showDataSource;

RimPlotAxisProperties::Orientation m_plotAxisOrientation;
};

0 comments on commit 722bbba

Please sign in to comment.