Skip to content

Commit

Permalink
Summary titles WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Sep 18, 2023
1 parent 4c431d4 commit f0063b7
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 15 deletions.
8 changes: 8 additions & 0 deletions ApplicationLibCode/Application/RiaSummaryCurveAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ RiaSummaryCurveAddress::RiaSummaryCurveAddress( const RifEclipseSummaryAddress&
{
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveAddress::RiaSummaryCurveAddress( const RifEclipseSummaryAddress& summaryAddressY )
: m_summaryAddressX( RifEclipseSummaryAddress::timeAddress() )
{
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions ApplicationLibCode/Application/RiaSummaryCurveAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
class RiaSummaryCurveAddress
{
public:
explicit RiaSummaryCurveAddress( const RifEclipseSummaryAddress& summaryAddressY );
explicit RiaSummaryCurveAddress( const RifEclipseSummaryAddress& summaryAddressX, const RifEclipseSummaryAddress& summaryAddressY );

RifEclipseSummaryAddress summaryAddressX() const;
Expand Down
57 changes: 57 additions & 0 deletions ApplicationLibCode/Application/Tools/RiaSummaryAddressAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ using namespace RifEclipseSummaryAddressDefines;
///
//--------------------------------------------------------------------------------------------------
RiaSummaryAddressAnalyzer::RiaSummaryAddressAnalyzer()
: m_onlyCrossPlotCurves( false )
{
}

Expand All @@ -57,6 +58,34 @@ void RiaSummaryAddressAnalyzer::appendAddresses( const std::set<RifEclipseSummar
}
}

/*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryAddressAnalyzer::appendAddresses_concept( input_range_of<RiaSummaryCurveAddress> auto&& addresses )
{
for ( const auto& adr : addresses )
{
analyzeSingleAddress( adr.summaryAddressX() );
analyzeSingleAddress( adr.summaryAddressY() );
}
}
*/

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryAddressAnalyzer::appendAddresses_concept( const std::vector<RiaSummaryCurveAddress>& addresses )
{
m_onlyCrossPlotCurves = true;

for ( const auto& adr : addresses )
{
analyzeSingleAddress( adr.summaryAddressX() );
analyzeSingleAddress( adr.summaryAddressY() );
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -100,6 +129,14 @@ bool RiaSummaryAddressAnalyzer::isSingleQuantityIgnoreHistory() const
return false;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaSummaryAddressAnalyzer::onlyCrossPlotCurves() const
{
return m_onlyCrossPlotCurves;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand All @@ -110,6 +147,20 @@ std::string RiaSummaryAddressAnalyzer::quantityNameForTitle() const
return *quantities().begin();
}

if ( quantities().size() == 2 && m_onlyCrossPlotCurves )
{
// We have a cross plot with only one curve

std::string title;
for ( const auto& q : quantities() )
{
if ( !title.empty() ) title += " | ";
title += q;
}

return title;
}

if ( quantities().size() == 2 && quantityNamesWithHistory().size() == 1 )
{
return *quantityNamesWithHistory().begin();
Expand Down Expand Up @@ -429,6 +480,12 @@ void RiaSummaryAddressAnalyzer::computeQuantityNamesWithHistory() const
//--------------------------------------------------------------------------------------------------
void RiaSummaryAddressAnalyzer::analyzeSingleAddress( const RifEclipseSummaryAddress& address )
{
if ( address.category() == SummaryCategory::SUMMARY_TIME )
{
m_onlyCrossPlotCurves = false;
return;
}

const std::string& wellName = address.wellName();

if ( !wellName.empty() )
Expand Down
16 changes: 16 additions & 0 deletions ApplicationLibCode/Application/Tools/RiaSummaryAddressAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

#pragma once

#include "RiaSummaryCurveAddress.h"
#include "RifEclipseSummaryAddress.h"

#include <concepts>
#include <set>
#include <string>
#include <tuple>
Expand All @@ -29,6 +31,13 @@ class RimSummaryCurveCollection;

class QString;

// Define a concept for an input range of a specific type. This allows any container type to be used as input argument, like std::vector<T>,
// std::set<T>, ...
// Inspired by https://www.reedbeta.com/blog/ranges-compatible-containers/
//
template <typename R, typename T>
concept input_range_of = std::ranges::input_range<R> && std::convertible_to<std::ranges::range_value_t<R>, T>;

//==================================================================================================
//
//==================================================================================================
Expand All @@ -40,6 +49,9 @@ class RiaSummaryAddressAnalyzer
void appendAddresses( const std::set<RifEclipseSummaryAddress>& allAddresses );
void appendAddresses( const std::vector<RifEclipseSummaryAddress>& allAddresses );

// void appendAddresses_concept( input_range_of<RiaSummaryCurveAddress> auto&& addresses );
void appendAddresses_concept( const std::vector<RiaSummaryCurveAddress>& addresses );

void clear();

std::set<std::string> quantities() const;
Expand All @@ -48,6 +60,8 @@ class RiaSummaryAddressAnalyzer

bool isSingleQuantityIgnoreHistory() const;

bool onlyCrossPlotCurves() const;

std::string quantityNameForTitle() const;

std::set<std::string> wellNames() const;
Expand Down Expand Up @@ -104,4 +118,6 @@ class RiaSummaryAddressAnalyzer
std::multimap<int, RifEclipseSummaryAddress> m_aquifers;

std::map<RifEclipseSummaryAddressDefines::SummaryCategory, std::set<std::string>> m_categories;

bool m_onlyCrossPlotCurves;
};
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,14 @@ RifEclipseSummaryAddress RimEnsembleCurveSet::summaryAddress() const
return m_yValuesSummaryAddress->address();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveAddress RimEnsembleCurveSet::curveAddress() const
{
return RiaSummaryCurveAddress( summaryAddress(), RifEclipseSummaryAddress::timeAddress() );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "RiaDateTimeDefines.h"
#include "RiaPlotDefines.h"
#include "RiaSummaryCurveAddress.h"

#include "RimEnsembleCurveSetColorManager.h"
#include "RimEnsembleCurveSetInterface.h"
Expand Down Expand Up @@ -112,6 +113,7 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt
void setSummaryAddress( RifEclipseSummaryAddress address );
void setSummaryAddressAndStatisticsFlag( RifEclipseSummaryAddress address );
RifEclipseSummaryAddress summaryAddress() const;
RiaSummaryCurveAddress curveAddress() const;
std::vector<RimSummaryCurve*> curves() const;

int ensembleId() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ RiaSummaryCurveDefinition RimSummaryCurve::curveDefinition() const
return curveDefinition;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveAddress RimSummaryCurve::curveAddress() const
{
return RiaSummaryCurveAddress( summaryAddressX(), summaryAddressY() );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "RiaDateTimeDefines.h"
#include "RiaDefines.h"
#include "RiaSummaryCurveAddress.h"
#include "RiaSummaryDefines.h"

#include "RifEclipseSummaryAddressQMetaType.h"
Expand Down Expand Up @@ -54,6 +55,7 @@ class RimSummaryCurve : public RimStackablePlotCurve
~RimSummaryCurve() override;

RiaSummaryCurveDefinition curveDefinition() const;
RiaSummaryCurveAddress curveAddress() const;

// Y Axis functions
RimSummaryCase* summaryCaseY() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,19 +374,19 @@ void RimSummaryMultiPlot::populateNameHelper( RimSummaryPlotNameHelper* nameHelp
{
nameHelper->clear();

std::vector<RifEclipseSummaryAddress> addresses;
std::vector<RiaSummaryCurveAddress> addresses;
std::vector<RimSummaryCase*> sumCases;
std::vector<RimSummaryCaseCollection*> ensembleCases;

for ( RimSummaryCurve* curve : allCurves( RimSummaryDataSourceStepping::Axis::Y_AXIS ) )
{
addresses.push_back( curve->summaryAddressY() );
addresses.push_back( curve->curveAddress() );
sumCases.push_back( curve->summaryCaseY() );
}

for ( auto curveSet : curveSets() )
{
addresses.push_back( curveSet->summaryAddress() );
addresses.push_back( curveSet->curveAddress() );
ensembleCases.push_back( curveSet->summaryCaseCollection() );
}

Expand Down
18 changes: 9 additions & 9 deletions ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2841,7 +2841,7 @@ void RimSummaryPlot::updateNameHelperWithCurveData( RimSummaryPlotNameHelper* na
if ( !nameHelper ) return;

nameHelper->clear();
std::vector<RifEclipseSummaryAddress> addresses;
std::vector<RiaSummaryCurveAddress> addresses;
std::vector<RimSummaryCase*> sumCases;
std::vector<RimSummaryCaseCollection*> ensembleCases;

Expand All @@ -2851,29 +2851,29 @@ void RimSummaryPlot::updateNameHelperWithCurveData( RimSummaryPlotNameHelper* na
{
if ( curve->summaryAddressY().isCalculated() )
{
RiaSummaryTools::getSummaryCasesAndAddressesForCalculation( curve->summaryAddressY().id(), sumCases, addresses );
std::vector<RifEclipseSummaryAddress> calcAddresses;
RiaSummaryTools::getSummaryCasesAndAddressesForCalculation( curve->summaryAddressY().id(), sumCases, calcAddresses );
for ( const auto& adr : calcAddresses )
{
addresses.push_back( RiaSummaryCurveAddress( adr ) );
}
}
else
{
addresses.push_back( curve->summaryAddressY() );
addresses.push_back( curve->curveAddress() );
sumCases.push_back( curve->summaryCaseY() );

if ( curve->summaryCaseX() )
{
sumCases.push_back( curve->summaryCaseX() );

if ( curve->summaryAddressX().category() != RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_INVALID )
{
addresses.push_back( curve->summaryAddressX() );
}
}
}
}
}

for ( auto curveSet : m_ensembleCurveSetCollection->curveSets() )
{
addresses.push_back( curveSet->summaryAddress() );
addresses.push_back( curveSet->curveAddress() );
ensembleCases.push_back( curveSet->summaryCaseCollection() );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ void RimSummaryPlotNameHelper::clear()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlotNameHelper::appendAddresses( const std::vector<RifEclipseSummaryAddress>& addresses )
void RimSummaryPlotNameHelper::appendAddresses( const std::vector<RiaSummaryCurveAddress>& addresses )
{
m_analyzer->appendAddresses( addresses );
m_analyzer->appendAddresses_concept( addresses );

extractPlotTitleSubStrings();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class RimSummaryPlotNameHelper : public RimSummaryNameHelper

void clear();

void appendAddresses( const std::vector<RifEclipseSummaryAddress>& addresses );
void appendAddresses( const std::vector<RiaSummaryCurveAddress>& addresses );
void setSummaryCases( const std::vector<RimSummaryCase*>& summaryCases );
void setEnsembleCases( const std::vector<RimSummaryCaseCollection*>& ensembleCases );

Expand Down

0 comments on commit f0063b7

Please sign in to comment.