Skip to content

Commit

Permalink
Fix several issues with ensemble cross plots
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Sep 26, 2023
1 parent 722bbba commit 6a14444
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,15 @@ void RimEnsembleCurveSet::setCurveAddress( RiaSummaryCurveAddress address )
{
setSummaryAddress( address.summaryAddressY() );
setSummaryAddressX( address.summaryAddressX() );

if ( address.summaryAddressX().category() == SummaryCategory::SUMMARY_TIME )
{
m_xAxisType = RiaDefines::HorizontalAxisType::TIME;
}
else
{
m_xAxisType = RiaDefines::HorizontalAxisType::SUMMARY_VECTOR;
}
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -565,6 +574,7 @@ void RimEnsembleCurveSet::onLegendDefinitionChanged()
void RimEnsembleCurveSet::setSummaryCaseCollection( RimSummaryCaseCollection* sumCaseCollection )
{
m_yValuesSummaryCaseCollection = sumCaseCollection;
m_xAddressSelector->setEnsemble( sumCaseCollection );
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2396,6 +2406,17 @@ RiuPlotAxis RimEnsembleCurveSet::axisY() const
return RiuPlotAxis::defaultLeft();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPlotAxis RimEnsembleCurveSet::axisX() const
{
if ( m_xAddressSelector->plotAxisProperties() )
return m_xAddressSelector->plotAxisProperties()->plotAxis();
else
return RiuPlotAxis::defaultBottomForSummaryVectors();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand All @@ -2410,6 +2431,20 @@ void RimEnsembleCurveSet::setLeftOrRightAxisY( RiuPlotAxis plotAxis )
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::setBottomOrTopAxis( RiuPlotAxis plotAxis )
{
auto plot = firstAncestorOrThisOfTypeAsserted<RimSummaryPlot>();
m_xAddressSelector->setPlotAxisProperties( plot->axisPropertiesForPlotAxis( plotAxis ) );

for ( RimSummaryCurve* curve : curves() )
{
curve->setTopOrBottomAxisX( axisX() );
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt
std::vector<cvf::Color3f> generateColorsForCases( const std::vector<RimSummaryCase*>& summaryCases ) const;

RiuPlotAxis axisY() const;
RiuPlotAxis axisX() const;
void setLeftOrRightAxisY( RiuPlotAxis plotAxis );
void setBottomOrTopAxis( RiuPlotAxis plotAxis );

protected:
void initAfterRead() override;
Expand Down
48 changes: 35 additions & 13 deletions ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,18 +924,35 @@ void RimSummaryPlot::updateNumericalAxis( RiaDefines::PlotAxis plotAxis )
std::vector<RiaSummaryCurveDefinition> curveDefs;
for ( auto summaryCurve : summaryCurves() )
{
if ( summaryCurve->axisY() == riuPlotAxis || summaryCurve->axisX() == riuPlotAxis )
if ( summaryCurve->axisY() == riuPlotAxis )
{
curveDefs.push_back( summaryCurve->curveDefinition() );
curveDefs.push_back( RiaSummaryCurveDefinition( summaryCurve->summaryCaseY(),
summaryCurve->summaryAddressY(),
summaryCurve->isEnsembleCurve() ) );
}
if ( summaryCurve->axisX() == riuPlotAxis )
{
curveDefs.push_back( RiaSummaryCurveDefinition( summaryCurve->summaryCaseX(),
summaryCurve->summaryAddressX(),
summaryCurve->isEnsembleCurve() ) );
}
}

for ( auto curveSet : ensembleCurveSetCollection()->curveSets() )
{
if ( curveSet->axisY() != riuPlotAxis ) continue;
if ( curveSet->axisY() == riuPlotAxis )
{
RiaSummaryCurveDefinition def( curveSet->summaryCaseCollection(), curveSet->summaryAddress() );
curveDefs.push_back( def );
}
if ( curveSet->axisX() == riuPlotAxis )
{
RiaSummaryCurveDefinition def;
def.setEnsemble( curveSet->summaryCaseCollection() );
def.setSummaryAddressX( curveSet->curveAddress().summaryAddressX() );

RiaSummaryCurveDefinition def( curveSet->summaryCaseCollection(), curveSet->summaryAddress() );
curveDefs.push_back( def );
curveDefs.push_back( def );
}
}

RimSummaryPlotAxisFormatter calc( axisProps, {}, curveDefs, visibleAsciiDataCurvesForAxis( riuPlotAxis ), timeHistoryQuantities );
Expand Down Expand Up @@ -2320,19 +2337,19 @@ RimSummaryPlot::CurveInfo RimSummaryPlot::handleEnsembleDrop( RimSummaryCaseColl
int newCurves = 0;
std::vector<RimEnsembleCurveSet*> curveSetsToUpdate;

std::map<RifEclipseSummaryAddress, std::set<RimSummaryCaseCollection*>> dataVectorMap;
std::map<RiaSummaryCurveAddress, std::set<RimSummaryCaseCollection*>> dataVectorMap;

for ( auto& curve : curveSets() )
{
const auto addr = curve->summaryAddress();
const auto addr = curve->curveAddress();
dataVectorMap[addr].insert( curve->summaryCaseCollection() );
}

for ( const auto& [addr, ensembles] : dataVectorMap )
{
if ( ensembles.count( ensemble ) > 0 ) continue;

auto curveSet = addNewEnsembleCurveY( addr, ensemble );
auto curveSet = addNewEnsembleCurve( addr, ensemble );
curveSetsToUpdate.push_back( curveSet );
newCurves++;
}
Expand Down Expand Up @@ -2370,7 +2387,7 @@ RimSummaryPlot::CurveInfo RimSummaryPlot::handleAddressCollectionDrop( RimSummar
auto curveSets = m_ensembleCurveSetCollection->curveSets();
for ( auto curveSet : curveSets )
{
sourceCurveDefs.push_back( RiaSummaryCurveDefinition( ensembleCase, curveSet->summaryAddress() ) );
sourceCurveDefs.push_back( RiaSummaryCurveDefinition( ensembleCase, curveSet->curveAddress() ) );
}
}

Expand Down Expand Up @@ -2434,7 +2451,7 @@ RimSummaryPlot::CurveInfo RimSummaryPlot::handleAddressCollectionDrop( RimSummar
auto addresses = curveDef.ensemble()->ensembleSummaryAddresses();
if ( addresses.find( curveDef.summaryAddressY() ) != addresses.end() )
{
curveSetsToUpdate.push_back( addNewEnsembleCurveY( curveDef.summaryAddressY(), curveDef.ensemble() ) );
curveSetsToUpdate.push_back( addNewEnsembleCurve( curveDef.summaryCurveAddress(), curveDef.ensemble() ) );
newCurves++;
}
}
Expand Down Expand Up @@ -2504,7 +2521,8 @@ RimSummaryPlot::CurveInfo RimSummaryPlot::handleSummaryAddressDrop( RimSummaryAd

if ( !skipAddress )
{
curveSetsToUpdate.push_back( addNewEnsembleCurveY( droppedAddress, ensemble ) );
curveSetsToUpdate.push_back(
addNewEnsembleCurve( RiaSummaryCurveAddress( RifEclipseSummaryAddress::timeAddress(), droppedAddress ), ensemble ) );
newCurves++;
}
}
Expand Down Expand Up @@ -2626,12 +2644,13 @@ RimSummaryCurve* RimSummaryPlot::addNewCurve( const RifEclipseSummaryAddress& ad
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEnsembleCurveSet* RimSummaryPlot::addNewEnsembleCurveY( const RifEclipseSummaryAddress& address, RimSummaryCaseCollection* ensemble )
RimEnsembleCurveSet* RimSummaryPlot::addNewEnsembleCurve( const RiaSummaryCurveAddress& address, RimSummaryCaseCollection* ensemble )
{
auto* curveSet = new RimEnsembleCurveSet();

curveSet->setSummaryCaseCollection( ensemble );
curveSet->setSummaryAddressAndStatisticsFlag( address );
curveSet->setSummaryAddressAndStatisticsFlag( address.summaryAddressY() );
curveSet->setCurveAddress( address );

cvf::Color3f curveColor =
RimSummaryCurveAppearanceCalculator::computeTintedCurveColorForAddress( curveSet->summaryAddress(),
Expand All @@ -2645,6 +2664,9 @@ RimEnsembleCurveSet* RimSummaryPlot::addNewEnsembleCurveY( const RifEclipseSumma

ensembleCurveSetCollection()->addCurveSet( curveSet );

curveSet->setLeftOrRightAxisY( RiuPlotAxis::defaultLeft() );
curveSet->setBottomOrTopAxis( RiuPlotAxis::defaultBottomForSummaryVectors() );

return curveSet;
}

Expand Down
3 changes: 2 additions & 1 deletion ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class RimSummaryPlotSourceStepping;
class RimTimeAxisAnnotation;
class RiaSummaryCurveDefinition;
class RifEclipseSummaryAddress;
class RiaSummaryCurveAddress;

class QwtInterval;
class QwtPlotCurve;
Expand Down Expand Up @@ -307,7 +308,7 @@ private slots:
RimSummaryCase* summaryCase,
const RifEclipseSummaryAddress& addressX,
RimSummaryCase* summaryCaseX );
RimEnsembleCurveSet* addNewEnsembleCurveY( const RifEclipseSummaryAddress& address, RimSummaryCaseCollection* ensemble );
RimEnsembleCurveSet* addNewEnsembleCurve( const RiaSummaryCurveAddress& curveAddress, RimSummaryCaseCollection* ensemble );

void updateStackedCurveData();
bool updateStackedCurveDataForAxis( RiuPlotAxis plotAxis );
Expand Down

0 comments on commit 6a14444

Please sign in to comment.