From 388d4196f1228bf99f3af34cae7bb6959c90554d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 Dec 2017 21:03:23 +0100 Subject: [PATCH] #2283 Cross Plot : Improve curve title and plot title based on x-axis data --- .../Summary/RimSummaryCurve.cpp | 10 +- .../Summary/RimSummaryCurveAutoName.cpp | 177 ++++++++++++------ .../Summary/RimSummaryCurveAutoName.h | 8 +- .../Summary/RimSummaryPlot.cpp | 10 + 4 files changed, 136 insertions(+), 69 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index b63fa172b4..0d0cfdefa0 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -371,18 +371,18 @@ QString RimSummaryCurve::createCurveAutoName() RimSummaryPlot* plot = nullptr; firstAncestorOrThisOfTypeAsserted(plot); - QString name = m_curveNameConfig->curveName(m_yValuesCurveVariable->address(), plot->activePlotTitleHelper()); + QString curveName = m_curveNameConfig->curveNameY(m_yValuesCurveVariable->address(), plot->activePlotTitleHelper()); if (isCrossPlotCurve()) { - QString xCurveName = m_curveNameConfig->curveName(m_xValuesCurveVariable->address(), plot->activePlotTitleHelper()); + QString curveNameX = m_curveNameConfig->curveNameX(m_xValuesCurveVariable->address(), plot->activePlotTitleHelper()); - if (!name.isEmpty() || !xCurveName.isEmpty()) + if (!curveName.isEmpty() || !curveNameX.isEmpty()) { - name += " | " + xCurveName; + curveName += " | " + curveNameX; } } - return name; + return curveName; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp index 43d965cf2d..0bd7b9f400 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp @@ -56,7 +56,7 @@ RimSummaryCurveAutoName::RimSummaryCurveAutoName() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimSummaryCurveAutoName::curveName(const RifEclipseSummaryAddress& summaryAddress, +QString RimSummaryCurveAutoName::curveNameY(const RifEclipseSummaryAddress& summaryAddress, const RimSummaryPlotNameHelper* nameHelper) const { std::string text; @@ -78,6 +78,120 @@ QString RimSummaryCurveAutoName::curveName(const RifEclipseSummaryAddress& summa } } + appendAddressDetails(text, summaryAddress, nameHelper); + + if (summaryCurve) + { + bool skipSubString = nameHelper && nameHelper->isCaseInTitle(); + + if (m_caseName && !skipSubString) + { + if (summaryCurve && summaryCurve->summaryCaseY()) + { + if (text.size() > 0) text += ", "; + text += summaryCurve->summaryCaseY()->caseName().toStdString(); + } + } + } + + return QString::fromStdString(text); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryCurveAutoName::curveNameX(const RifEclipseSummaryAddress& summaryAddress, + const RimSummaryPlotNameHelper* nameHelper) const +{ + std::string text; + + RimSummaryCurve* summaryCurve = nullptr; + this->firstAncestorOrThisOfType(summaryCurve); + + if (m_vectorName) + { + bool skipSubString = nameHelper && nameHelper->isQuantityInTitle(); + if (!skipSubString) + { + text += summaryAddress.quantityName(); + + if (m_unit && summaryCurve && !summaryCurve->unitNameX().empty()) + { + text += "[" + summaryCurve->unitNameX() + "]"; + } + } + } + + appendAddressDetails(text, summaryAddress, nameHelper); + + if (summaryCurve) + { + bool skipSubString = nameHelper && nameHelper->isCaseInTitle(); + + if (m_caseName && !skipSubString) + { + if (summaryCurve && summaryCurve->summaryCaseX()) + { + if (text.size() > 0) text += ", "; + text += summaryCurve->summaryCaseX()->caseName().toStdString(); + } + } + } + + return QString::fromStdString(text); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurveAutoName::applySettings(const RimSummaryCurveAutoName& other) +{ + m_caseName = other.m_caseName; + m_vectorName = other.m_vectorName; + m_unit = other.m_unit; + m_regionNumber = other.m_regionNumber; + m_wellGroupName = other.m_wellGroupName; + m_wellName = other.m_wellName; + m_wellSegmentNumber = other.m_wellSegmentNumber; + m_lgrName = other.m_lgrName; + m_completion = other.m_completion; + m_aquiferNumber = other.m_aquiferNumber; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurveAutoName::appendWellName(std::string& text, const RifEclipseSummaryAddress& summaryAddress, + const RimSummaryPlotNameHelper* nameHelper) const +{ + bool skipSubString = nameHelper && nameHelper->isWellNameInTitle(); + if (skipSubString) return; + + if (m_wellName) + { + if (text.size() > 0) text += ":"; + text += summaryAddress.wellName(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurveAutoName::appendLgrName(std::string& text, const RifEclipseSummaryAddress& summaryAddress) const +{ + if (m_lgrName) + { + if (text.size() > 0) text += ":"; + text += ":" + summaryAddress.lgrName(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifEclipseSummaryAddress& summaryAddress, + const RimSummaryPlotNameHelper* nameHelper) const +{ switch (summaryAddress.category()) { case RifEclipseSummaryAddress::SUMMARY_AQUIFER: @@ -193,67 +307,6 @@ QString RimSummaryCurveAutoName::curveName(const RifEclipseSummaryAddress& summa } break; } - - if (summaryCurve) - { - bool skipSubString = nameHelper && nameHelper->isCaseInTitle(); - - if (m_caseName && !skipSubString) - { - if (summaryCurve && summaryCurve->summaryCaseY()) - { - if (text.size() > 0) text += ", "; - text += summaryCurve->summaryCaseY()->caseName().toStdString(); - } - } - } - - return QString::fromStdString(text); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCurveAutoName::applySettings(const RimSummaryCurveAutoName& other) -{ - m_caseName = other.m_caseName; - m_vectorName = other.m_vectorName; - m_unit = other.m_unit; - m_regionNumber = other.m_regionNumber; - m_wellGroupName = other.m_wellGroupName; - m_wellName = other.m_wellName; - m_wellSegmentNumber = other.m_wellSegmentNumber; - m_lgrName = other.m_lgrName; - m_completion = other.m_completion; - m_aquiferNumber = other.m_aquiferNumber; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCurveAutoName::appendWellName(std::string& text, const RifEclipseSummaryAddress& summaryAddress, - const RimSummaryPlotNameHelper* nameHelper) const -{ - bool skipSubString = nameHelper && nameHelper->isWellNameInTitle(); - if (skipSubString) return; - - if (m_wellName) - { - if (text.size() > 0) text += ":"; - text += summaryAddress.wellName(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryCurveAutoName::appendLgrName(std::string& text, const RifEclipseSummaryAddress& summaryAddress) const -{ - if (m_lgrName) - { - if (text.size() > 0) text += ":"; - text += ":" + summaryAddress.lgrName(); - } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.h index b45084ac29..8397aa9569 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.h @@ -31,8 +31,10 @@ class RimSummaryCurveAutoName : public caf::PdmObject public: RimSummaryCurveAutoName(); - QString curveName(const RifEclipseSummaryAddress& summaryAddress, const RimSummaryPlotNameHelper* nameHelper) const; - void applySettings(const RimSummaryCurveAutoName& other); + QString curveNameY(const RifEclipseSummaryAddress& summaryAddress, const RimSummaryPlotNameHelper* nameHelper) const; + QString curveNameX(const RifEclipseSummaryAddress& summaryAddress, const RimSummaryPlotNameHelper* nameHelper) const; + + void applySettings(const RimSummaryCurveAutoName& other); private: friend class RimSummaryCurve; @@ -41,6 +43,8 @@ private: const QVariant& newValue) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + void appendAddressDetails(std::string& text, const RifEclipseSummaryAddress& summaryAddress, + const RimSummaryPlotNameHelper* nameHelper) const; void appendWellName(std::string& text, const RifEclipseSummaryAddress& summaryAddress, const RimSummaryPlotNameHelper* nameHelper) const; void appendLgrName(std::string& text, const RifEclipseSummaryAddress& summaryAddress) const; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 5d3dc93ca3..e4b50f9035 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -1384,6 +1384,16 @@ QString RimSummaryPlot::generatePlotTitle(RimSummaryPlotNameHelper* nameHelper) { addresses.push_back(curve->summaryAddressY()); sumCases.push_back(curve->summaryCaseY()); + + if (curve->summaryCaseX()) + { + sumCases.push_back(curve->summaryCaseX()); + + if (curve->summaryAddressX().category() != RifEclipseSummaryAddress::SUMMARY_INVALID) + { + addresses.push_back(curve->summaryAddressX()); + } + } } } }