Skip to content

Commit

Permalink
Fix source stepping
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Sep 22, 2023
1 parent df5345a commit 04b784a
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 54 deletions.
58 changes: 26 additions & 32 deletions ApplicationLibCode/ProjectDataModel/RimDataSourceSteppingTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,16 @@ void RimDataSourceSteppingTools::modifyCurrentIndex( caf::PdmValueField*
bool RimDataSourceSteppingTools::updateAddressIfMatching( const QVariant& oldValue,
const QVariant& newValue,
RifEclipseSummaryAddressDefines::SummaryCategory category,
RifEclipseSummaryAddress* adr )
RifEclipseSummaryAddress& adr )
{
if ( !adr ) return false;

if ( category == RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_REGION )
{
int oldInt = oldValue.toInt();
int newInt = newValue.toInt();

if ( adr->regionNumber() == oldInt )
if ( adr.regionNumber() == oldInt )
{
adr->setRegion( newInt );
adr.setRegion( newInt );

return true;
}
Expand All @@ -98,9 +96,9 @@ bool RimDataSourceSteppingTools::updateAddressIfMatching( const QVariant&
int oldInt = oldValue.toInt();
int newInt = newValue.toInt();

if ( adr->aquiferNumber() == oldInt )
if ( adr.aquiferNumber() == oldInt )
{
adr->setAquiferNumber( newInt );
adr.setAquiferNumber( newInt );

return true;
}
Expand All @@ -110,9 +108,9 @@ bool RimDataSourceSteppingTools::updateAddressIfMatching( const QVariant&
std::string oldString = oldValue.toString().toStdString();
std::string newString = newValue.toString().toStdString();

if ( adr->groupName() == oldString )
if ( adr.groupName() == oldString )
{
adr->setGroupName( newString );
adr.setGroupName( newString );

return true;
}
Expand All @@ -122,9 +120,9 @@ bool RimDataSourceSteppingTools::updateAddressIfMatching( const QVariant&
std::string oldString = oldValue.toString().toStdString();
std::string newString = newValue.toString().toStdString();

if ( adr->networkName() == oldString )
if ( adr.networkName() == oldString )
{
adr->setNetworkName( newString );
adr.setNetworkName( newString );

return true;
}
Expand All @@ -134,9 +132,9 @@ bool RimDataSourceSteppingTools::updateAddressIfMatching( const QVariant&
std::string oldString = oldValue.toString().toStdString();
std::string newString = newValue.toString().toStdString();

if ( adr->wellName() == oldString )
if ( adr.wellName() == oldString )
{
adr->setWellName( newString );
adr.setWellName( newString );

return true;
}
Expand All @@ -146,9 +144,9 @@ bool RimDataSourceSteppingTools::updateAddressIfMatching( const QVariant&
{
std::string oldString = oldValue.toString().toStdString();
std::string newString = newValue.toString().toStdString();
if ( adr->blockAsString() == oldString )
if ( adr.blockAsString() == oldString )
{
adr->setCellIjk( newString );
adr.setCellIjk( newString );

return true;
}
Expand All @@ -157,11 +155,11 @@ bool RimDataSourceSteppingTools::updateAddressIfMatching( const QVariant&
{
std::string oldString = oldValue.toString().toStdString();
std::string newString = newValue.toString().toStdString();
if ( adr->formatUiTextRegionToRegion() == oldString )
if ( adr.formatUiTextRegionToRegion() == oldString )
{
auto [region1, region2] = RifEclipseSummaryAddress::regionToRegionPairFromUiText( newString );
adr->setRegion( region1 );
adr->setRegion2( region2 );
adr.setRegion( region1 );
adr.setRegion2( region2 );

return true;
}
Expand All @@ -170,9 +168,9 @@ bool RimDataSourceSteppingTools::updateAddressIfMatching( const QVariant&
{
int oldInt = oldValue.toInt();
int newInt = newValue.toInt();
if ( adr->wellSegmentNumber() == oldInt )
if ( adr.wellSegmentNumber() == oldInt )
{
adr->setWellSegmentNumber( newInt );
adr.setWellSegmentNumber( newInt );

return true;
}
Expand All @@ -186,26 +184,24 @@ bool RimDataSourceSteppingTools::updateAddressIfMatching( const QVariant&
//--------------------------------------------------------------------------------------------------
bool RimDataSourceSteppingTools::updateHistoryAndSummaryQuantityIfMatching( const QVariant& oldValue,
const QVariant& newValue,
RifEclipseSummaryAddress* adr )
RifEclipseSummaryAddress& adr )
{
if ( !adr ) return false;

std::string oldString = oldValue.toString().toStdString();
std::string newString = newValue.toString().toStdString();

if ( adr->vectorName() == oldString )
if ( adr.vectorName() == oldString )
{
adr->setVectorName( newString );
adr.setVectorName( newString );

return true;
}

std::string correspondingOldString = RiaSummaryAddressAnalyzer::correspondingHistorySummaryCurveName( oldString );
std::string correspondingNewString = RiaSummaryAddressAnalyzer::correspondingHistorySummaryCurveName( newString );

if ( adr->vectorName() == correspondingOldString )
if ( adr.vectorName() == correspondingOldString )
{
adr->setVectorName( correspondingNewString );
adr.setVectorName( correspondingNewString );

return true;
}
Expand All @@ -216,16 +212,14 @@ bool RimDataSourceSteppingTools::updateHistoryAndSummaryQuantityIfMatching( cons
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimDataSourceSteppingTools::updateQuantityIfMatching( const QVariant& oldValue, const QVariant& newValue, RifEclipseSummaryAddress* adr )
bool RimDataSourceSteppingTools::updateQuantityIfMatching( const QVariant& oldValue, const QVariant& newValue, RifEclipseSummaryAddress& adr )
{
if ( !adr ) return false;

std::string oldString = oldValue.toString().toStdString();
std::string newString = newValue.toString().toStdString();

if ( adr->vectorName() == oldString )
if ( adr.vectorName() == oldString )
{
adr->setVectorName( newString );
adr.setVectorName( newString );

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class RimDataSourceSteppingTools
static bool updateAddressIfMatching( const QVariant& oldValue,
const QVariant& newValue,
RifEclipseSummaryAddressDefines::SummaryCategory category,
RifEclipseSummaryAddress* adr );
RifEclipseSummaryAddress& adr );

static bool updateHistoryAndSummaryQuantityIfMatching( const QVariant& oldValue, const QVariant& newValue, RifEclipseSummaryAddress* adr );
static bool updateHistoryAndSummaryQuantityIfMatching( const QVariant& oldValue, const QVariant& newValue, RifEclipseSummaryAddress& adr );

static bool updateQuantityIfMatching( const QVariant& oldValue, const QVariant& newValue, RifEclipseSummaryAddress* adr );
static bool updateQuantityIfMatching( const QVariant& oldValue, const QVariant& newValue, RifEclipseSummaryAddress& adr );
};
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void RimSummaryCalculation::substituteVariables( std::vector<SummaryCalculationV
{
if ( v.summaryAddress.category() == address.category() )
{
RimDataSourceSteppingTools::updateAddressIfMatching( oldValue, newValue, address.category(), &v.summaryAddress );
RimDataSourceSteppingTools::updateAddressIfMatching( oldValue, newValue, address.category(), v.summaryAddress );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ RimEnsembleCurveSet::RimEnsembleCurveSet()
m_summaryAddressNameTools = new RimSummaryCurveAutoName;

m_ensembleStatCaseY.reset( new RimEnsembleStatisticsCase() );
m_ensembleStatCaseX.reset( new RimEnsembleStatisticsCase() );

m_disableStatisticCurves = false;
m_isCurveSetFiltered = false;
Expand Down Expand Up @@ -417,6 +418,23 @@ void RimEnsembleCurveSet::setSummaryAddress( RifEclipseSummaryAddress address )
m_objectiveValuesSummaryAddresses.push_back( summaryAddress );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::setCurveAddress( RiaSummaryCurveAddress address )
{
setSummaryAddress( address.summaryAddressY() );
setSummaryAddressX( address.summaryAddressX() );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::setSummaryAddressX( RifEclipseSummaryAddress address )
{
m_xAddressSelector->setAddress( address );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -966,6 +984,8 @@ void RimEnsembleCurveSet::defineObjectEditorAttribute( QString uiConfigName, caf
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
m_yValuesSummaryAddressUiField = m_yValuesSummaryAddress->address();

{
caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Summary Vector" );
curveDataGroup->add( &m_yValuesSummaryCaseCollection );
Expand Down Expand Up @@ -1944,6 +1964,7 @@ void RimEnsembleCurveSet::updateStatisticsCurves( const std::vector<RimSummaryCa
statCases = group->allSummaryCases();
}
m_ensembleStatCaseY->calculate( statCases, summaryAddress(), m_statistics->includeIncompleteCurves() );
m_ensembleStatCaseX->calculate( statCases, m_xAddressSelector->summaryAddress(), m_statistics->includeIncompleteCurves() );
}

std::vector<RiaSummaryCurveAddress> addresses;
Expand Down Expand Up @@ -2016,7 +2037,7 @@ void RimEnsembleCurveSet::updateStatisticsCurves( const std::vector<RimSummaryCa
if ( m_xAxisType() == RiaDefines::HorizontalAxisType::SUMMARY_VECTOR )
{
curve->setAxisTypeX( RiaDefines::HorizontalAxisType::SUMMARY_VECTOR );
curve->setSummaryCaseX( m_ensembleStatCaseY.get() );
curve->setSummaryCaseX( m_ensembleStatCaseX.get() );
curve->setSummaryAddressX( address.summaryAddressX() );
curve->setTopOrBottomAxisX( m_xAddressSelector->plotAxisProperties()->plotAxis() );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt
void deleteCurve( RimSummaryCurve* curve );

void setSummaryAddress( RifEclipseSummaryAddress address );
void setCurveAddress( RiaSummaryCurveAddress address );
void setSummaryAddressAndStatisticsFlag( RifEclipseSummaryAddress address );
RifEclipseSummaryAddress summaryAddress() const;
RiaSummaryCurveAddress curveAddress() const;
Expand Down Expand Up @@ -221,6 +222,8 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt
void setTransparentCurveColor();
void onColorTagClicked( const SignalEmitter* emitter, size_t index );

void setSummaryAddressX( RifEclipseSummaryAddress address );

private:
caf::PdmField<bool> m_showCurves;
caf::PdmChildArrayField<RimSummaryCurve*> m_curves;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ RimSummaryAddressSelector::RimSummaryAddressSelector()

CAF_PDM_InitFieldNoDefault( &m_yValuesResampling, "Resampling", "Resampling" );

m_dataSource = SummaryDataSource::SINGLE_CASE;
m_dataSource = SummaryDataSource::SINGLE_CASE;
m_showDataSource = true;
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -115,6 +116,14 @@ void RimSummaryAddressSelector::setPlotAxisProperties( RimPlotAxisPropertiesInte
m_yPlotAxisProperties = plotAxisProperties;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryAddressSelector::setShowDataSource( bool enable )
{
m_showDataSource = enable;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -353,15 +362,21 @@ QList<caf::PdmOptionItemInfo> RimSummaryAddressSelector::calculateValueOptions(
//--------------------------------------------------------------------------------------------------
void RimSummaryAddressSelector::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
if ( m_dataSource == SummaryDataSource::SINGLE_CASE )
{
uiOrdering.add( &m_yValuesSummaryCase );
}
else
if ( m_showDataSource )
{
uiOrdering.add( &m_yValuesSummaryCaseCollection );
if ( m_dataSource == SummaryDataSource::SINGLE_CASE )
{
uiOrdering.add( &m_yValuesSummaryCase );
}
else
{
uiOrdering.add( &m_yValuesSummaryCaseCollection );
}
}

// Update the UI field, as this is not serialized to file
m_yValuesSummaryAddressUiField = m_yValuesSummaryAddress->address();

uiOrdering.add( &m_yValuesSummaryAddressUiField, { true, 2, 1 } );
uiOrdering.add( &m_yPushButtonSelectSummaryAddress, { false, 1, 0 } );
uiOrdering.add( &m_yValuesResampling, { true, 3, 1 } );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class RimSummaryAddressSelector : public caf::PdmObject
void setAddress( const RifEclipseSummaryAddress& address );
void setResampling( RiaDefines::DateTimePeriodEnum resampling );
void setPlotAxisProperties( RimPlotAxisPropertiesInterface* plotAxisProperties );
void setShowDataSource( bool enable );

RimSummaryCase* summaryCase() const;
RimSummaryCaseCollection* ensemble() const;
Expand Down Expand Up @@ -83,4 +84,5 @@ class RimSummaryAddressSelector : public caf::PdmObject
caf::PdmField<RiaDefines::DateTimePeriodEnum> m_yValuesResampling;

SummaryDataSource m_dataSource;
bool m_showDataSource;
};
Loading

0 comments on commit 04b784a

Please sign in to comment.