#2170 Summary Cross Plot : Improve computation of summary case set

This commit is contained in:
Magne Sjaastad 2017-12-01 13:22:41 +01:00
parent b8f8b2bc16
commit 7f31c245ae
5 changed files with 85 additions and 59 deletions

View File

@ -32,25 +32,6 @@
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveAnalyzer::RiaSummaryCurveAnalyzer() {}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveAnalyzer::analyzeCurves(const RimSummaryCurveCollection* sumCurveCollection)
{
clearAllSets();
if (!sumCurveCollection)
return;
for (auto curve : sumCurveCollection->curves())
{
m_summaryCases.insert(curve->summaryCaseY());
auto adr = curve->summaryAddressY();
analyzeAddress(adr);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -65,7 +46,7 @@ void RiaSummaryCurveAnalyzer::analyzeAdresses(const std::vector<RifEclipseSummar
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveAnalyzer::analyzeAdresses(const std::set<RifEclipseSummaryAddress>& allAddresses)
{
@ -112,14 +93,6 @@ std::set<int> RiaSummaryCurveAnalyzer::regionNumbers() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RimSummaryCase*> RiaSummaryCurveAnalyzer::summaryCases() const
{
return m_summaryCases;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RifEclipseSummaryAddress::SummaryVarCategory> RiaSummaryCurveAnalyzer::categories() const
{
return m_categories;
@ -158,9 +131,11 @@ std::set<QString> RiaSummaryCurveAnalyzer::identifierTexts(RifEclipseSummaryAddr
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<RifEclipseSummaryAddress> RiaSummaryCurveAnalyzer::addressesForCategory(const std::vector<RifEclipseSummaryAddress>& addresses, RifEclipseSummaryAddress::SummaryVarCategory category)
std::vector<RifEclipseSummaryAddress>
RiaSummaryCurveAnalyzer::addressesForCategory(const std::vector<RifEclipseSummaryAddress>& addresses,
RifEclipseSummaryAddress::SummaryVarCategory category)
{
std::vector<RifEclipseSummaryAddress> filteredAddresses;
@ -184,7 +159,6 @@ void RiaSummaryCurveAnalyzer::clearAllSets()
m_wellNames.clear();
m_wellGroupNames.clear();
m_regionNumbers.clear();
m_summaryCases.clear();
m_categories.clear();
}

View File

@ -25,7 +25,6 @@
#include <vector>
class RimSummaryCurveCollection;
class RimSummaryCase;
class QString;
@ -37,7 +36,6 @@ class RiaSummaryCurveAnalyzer
public:
RiaSummaryCurveAnalyzer();
void analyzeCurves(const RimSummaryCurveCollection* sumCurveCollection);
void analyzeAdresses(const std::vector<RifEclipseSummaryAddress>& allAddresses);
void analyzeAdresses(const std::set<RifEclipseSummaryAddress>& allAddresses);
@ -46,7 +44,6 @@ public:
std::set<std::string> wellGroupNames() const;
std::set<int> regionNumbers() const;
std::set<RimSummaryCase*> summaryCases() const;
std::set<RifEclipseSummaryAddress::SummaryVarCategory> categories() const;
std::set<QString> identifierTexts(RifEclipseSummaryAddress::SummaryVarCategory category) const;
@ -63,7 +60,6 @@ private:
std::set<std::string> m_wellNames;
std::set<std::string> m_wellGroupNames;
std::set<int> m_regionNumbers;
std::set<RimSummaryCase*> m_summaryCases;
std::set<RifEclipseSummaryAddress::SummaryVarCategory> m_categories;
};

View File

@ -281,7 +281,16 @@ QString RimSummaryCurveCollection::compileAutoPlotTitle() const
{
RiaSummaryCurveAnalyzer analyzer;
analyzer.analyzeCurves(this);
std::set<RifEclipseSummaryAddress> addresses;
for (auto c : m_curves)
{
addresses.insert(c->summaryAddressY());
// TODO : Improve how cross plot curves contribute to title
// Suggestion : Delegate to RimSummaryPlotSourceStepping to find title
}
analyzer.analyzeAdresses(addresses);
auto quantities = analyzer.quantities();
auto wellNames = analyzer.wellNames();

View File

@ -169,10 +169,8 @@ std::vector<caf::PdmFieldHandle*> RimSummaryPlotSourceStepping::fieldsToShowInTo
{
std::vector<caf::PdmFieldHandle*> fields;
RiaSummaryCurveAnalyzer analyzer;
analyzer.analyzeAdresses(allAddressesUsedInCurveCollection());
if (analyzer.summaryCases().size() == 1)
auto sumCases = allSummaryCasesUsedInCurveCollection();
if (sumCases.size() == 1)
{
RimProject* proj = RiaApplication::instance()->project();
if (proj->allSummaryCases().size() > 1)
@ -181,6 +179,9 @@ std::vector<caf::PdmFieldHandle*> RimSummaryPlotSourceStepping::fieldsToShowInTo
}
}
RiaSummaryCurveAnalyzer analyzer;
analyzer.analyzeAdresses(allAddressesUsedInCurveCollection());
if (analyzer.wellNames().size() == 1)
{
fields.push_back(&m_wellName);
@ -237,22 +238,19 @@ QList<caf::PdmOptionItemInfo> RimSummaryPlotSourceStepping::calculateValueOption
RifSummaryReaderInterface* reader = summaryReader();
if (reader)
{
const std::vector<RifEclipseSummaryAddress> allAddresses = reader->allResultAddresses();
RiaSummaryCurveAnalyzer analyzer;
analyzer.analyzeAdresses(allAddresses);
RiaSummaryCurveAnalyzer* analyzer = analyzerForReader(reader);
if (fieldNeedingOptions == &m_wellName)
{
identifierTexts = analyzer.identifierTexts(RifEclipseSummaryAddress::SUMMARY_WELL);
identifierTexts = analyzer->identifierTexts(RifEclipseSummaryAddress::SUMMARY_WELL);
}
else if (fieldNeedingOptions == &m_region)
{
identifierTexts = analyzer.identifierTexts(RifEclipseSummaryAddress::SUMMARY_REGION);
identifierTexts = analyzer->identifierTexts(RifEclipseSummaryAddress::SUMMARY_REGION);
}
else if (fieldNeedingOptions == &m_wellGroupName)
{
identifierTexts = analyzer.identifierTexts(RifEclipseSummaryAddress::SUMMARY_WELL_GROUP);
identifierTexts = analyzer->identifierTexts(RifEclipseSummaryAddress::SUMMARY_WELL_GROUP);
}
else if (fieldNeedingOptions == &m_quantity)
{
@ -268,7 +266,7 @@ QList<caf::PdmOptionItemInfo> RimSummaryPlotSourceStepping::calculateValueOption
RiaSummaryCurveAnalyzer quantityAnalyzer;
auto subset = RiaSummaryCurveAnalyzer::addressesForCategory(allAddresses, category);
auto subset = RiaSummaryCurveAnalyzer::addressesForCategory(reader->allResultAddresses(), category);
quantityAnalyzer.analyzeAdresses(subset);
for (const auto& quantity : quantityAnalyzer.quantities())
@ -502,16 +500,9 @@ void RimSummaryPlotSourceStepping::updateUiFromCurves()
m_region.uiCapability()->setUiHidden(true);
m_quantity.uiCapability()->setUiHidden(true);
RimSummaryCurveCollection* curveCollection = nullptr;
this->firstAncestorOrThisOfTypeAsserted(curveCollection);
RiaSummaryCurveAnalyzer analyzer;
analyzer.analyzeAdresses(allAddressesUsedInCurveCollection());
if (analyzer.summaryCases().size() == 1)
auto sumCases = allSummaryCasesUsedInCurveCollection();
if (sumCases.size() == 1)
{
std::set<RimSummaryCase*> sumCases = analyzer.summaryCases();
if (sumCases.find(m_summaryCase) == sumCases.end())
{
m_summaryCase = *(sumCases.begin());
@ -524,6 +515,9 @@ void RimSummaryPlotSourceStepping::updateUiFromCurves()
}
}
RiaSummaryCurveAnalyzer analyzer;
analyzer.analyzeAdresses(allAddressesUsedInCurveCollection());
RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_INVALID;
{
if (analyzer.categories().size() == 1)
@ -593,7 +587,8 @@ caf::PdmFieldHandle* RimSummaryPlotSourceStepping::fieldToModify()
// A pointer field is no a value field, so this must be improved
// to be able to step between summary cases
if (analyzer.summaryCases().size() == 1)
auto sumCases = allSummaryCasesUsedInCurveCollection();
if (sumCases.size() == 1)
{
RimProject* proj = RiaApplication::instance()->project();
if (proj->allSummaryCases().size() > 1)
@ -616,7 +611,7 @@ caf::PdmValueField* RimSummaryPlotSourceStepping::valueFieldToModify()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::set<RifEclipseSummaryAddress> RimSummaryPlotSourceStepping::allAddressesUsedInCurveCollection() const
{
@ -642,6 +637,33 @@ std::set<RifEclipseSummaryAddress> RimSummaryPlotSourceStepping::allAddressesUse
return addresses;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RimSummaryCase*> RimSummaryPlotSourceStepping::allSummaryCasesUsedInCurveCollection() const
{
std::set<RimSummaryCase*> sumCases;
RimSummaryCurveCollection* curveCollection = nullptr;
this->firstAncestorOrThisOfTypeAsserted(curveCollection);
auto curves = curveCollection->curves();
for (auto c : curves)
{
if (isYAxisStepping())
{
sumCases.insert(c->summaryCaseY());
}
if (isXAxisStepping())
{
sumCases.insert(c->summaryCaseX());
}
}
return sumCases;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -670,6 +692,25 @@ bool RimSummaryPlotSourceStepping::isYAxisStepping() const
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveAnalyzer* RimSummaryPlotSourceStepping::analyzerForReader(RifSummaryReaderInterface* reader)
{
if (!reader)
return nullptr;
if (m_curveAnalyzerForReader.first != reader)
{
RiaSummaryCurveAnalyzer analyzer;
m_curveAnalyzerForReader = std::make_pair(reader, analyzer);
}
m_curveAnalyzerForReader.second.analyzeAdresses(reader->allResultAddresses());
return &m_curveAnalyzerForReader.second;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -18,6 +18,7 @@
#pragma once
#include "RiaSummaryCurveAnalyzer.h"
#include "RifEclipseSummaryAddress.h"
#include "cafPdmField.h"
@ -77,10 +78,13 @@ private:
caf::PdmValueField* valueFieldToModify();
std::set<RifEclipseSummaryAddress> allAddressesUsedInCurveCollection() const;
std::set<RimSummaryCase*> allSummaryCasesUsedInCurveCollection() const;
bool isXAxisStepping() const;
bool isYAxisStepping() const;
RiaSummaryCurveAnalyzer* analyzerForReader(RifSummaryReaderInterface* reader);
private:
caf::PdmPtrField<RimSummaryCase*> m_summaryCase;
caf::PdmField<QString> m_wellName;
@ -88,4 +92,6 @@ private:
caf::PdmField<int> m_region;
caf::PdmField<QString> m_quantity;
SourceSteppingType m_sourceSteppingType;
std::pair<RifSummaryReaderInterface*, RiaSummaryCurveAnalyzer> m_curveAnalyzerForReader;
};