diff --git a/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.cpp b/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.cpp index 554ca64293..a177756486 100644 --- a/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.cpp +++ b/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.cpp @@ -35,26 +35,22 @@ RiaSummaryCurveAnalyzer::RiaSummaryCurveAnalyzer() {} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSummaryCurveAnalyzer::analyzeAdresses(const std::vector& allAddresses) +void RiaSummaryCurveAnalyzer::appendAdresses(const std::vector& allAddresses) { - clearAllSets(); - for (const auto& adr : allAddresses) { - analyzeAddress(adr); + analyzeSingleAddress(adr); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSummaryCurveAnalyzer::analyzeAdresses(const std::set& allAddresses) +void RiaSummaryCurveAnalyzer::appendAdresses(const std::set& allAddresses) { - clearAllSets(); - for (const auto& adr : allAddresses) { - analyzeAddress(adr); + analyzeSingleAddress(adr); } } @@ -153,7 +149,7 @@ std::vector //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSummaryCurveAnalyzer::clearAllSets() +void RiaSummaryCurveAnalyzer::clear() { m_quantities.clear(); m_wellNames.clear(); @@ -165,7 +161,7 @@ void RiaSummaryCurveAnalyzer::clearAllSets() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaSummaryCurveAnalyzer::analyzeAddress(const RifEclipseSummaryAddress& address) +void RiaSummaryCurveAnalyzer::analyzeSingleAddress(const RifEclipseSummaryAddress& address) { if (!address.wellName().empty()) { diff --git a/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.h b/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.h index 0836ea0eff..7037140b73 100644 --- a/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.h +++ b/ApplicationCode/Application/Tools/RiaSummaryCurveAnalyzer.h @@ -36,14 +36,16 @@ class RiaSummaryCurveAnalyzer public: RiaSummaryCurveAnalyzer(); - void analyzeAdresses(const std::vector& allAddresses); - void analyzeAdresses(const std::set& allAddresses); + void appendAdresses(const std::set& allAddresses); + void appendAdresses(const std::vector& allAddresses); + + void clear(); std::set quantities() const; std::set wellNames() const; std::set wellGroupNames() const; + std::set regionNumbers() const; - std::set regionNumbers() const; std::set categories() const; std::set identifierTexts(RifEclipseSummaryAddress::SummaryVarCategory category) const; @@ -52,14 +54,13 @@ public: RifEclipseSummaryAddress::SummaryVarCategory category); private: - void clearAllSets(); - void analyzeAddress(const RifEclipseSummaryAddress& address); + void analyzeSingleAddress(const RifEclipseSummaryAddress& address); private: - std::set m_quantities; - std::set m_wellNames; - std::set m_wellGroupNames; - std::set m_regionNumbers; + std::set m_quantities; + std::set m_wellNames; + std::set m_wellGroupNames; + std::set m_regionNumbers; std::set m_categories; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake index b2502f088a..6e5f40478d 100644 --- a/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake @@ -33,6 +33,7 @@ ${CEE_CURRENT_LIST_DIR}RimSummaryAddress.h ${CEE_CURRENT_LIST_DIR}RimSummaryCrossPlot.h ${CEE_CURRENT_LIST_DIR}RimSummaryPlotSourceStepping.h ${CEE_CURRENT_LIST_DIR}RimCsvUserData.h +${CEE_CURRENT_LIST_DIR}RimSummaryPlotNameHelper.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -64,6 +65,7 @@ ${CEE_CURRENT_LIST_DIR}RimSummaryAddress.cpp ${CEE_CURRENT_LIST_DIR}RimSummaryCrossPlot.cpp ${CEE_CURRENT_LIST_DIR}RimSummaryPlotSourceStepping.cpp ${CEE_CURRENT_LIST_DIR}RimCsvUserData.cpp +${CEE_CURRENT_LIST_DIR}RimSummaryPlotNameHelper.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index eca505b8cb..84cb32d539 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -369,11 +369,13 @@ QList RimSummaryCurve::calculateValueOptions(const caf:: //-------------------------------------------------------------------------------------------------- QString RimSummaryCurve::createCurveAutoName() { - QString name = m_curveNameConfig->curveName(m_yValuesCurveVariable->address()); + RimSummaryPlot* plot = nullptr; + firstAncestorOrThisOfTypeAsserted(plot); + QString name = m_curveNameConfig->curveName(m_yValuesCurveVariable->address(), plot->activePlotTitleHelper()); if (isCrossPlotCurve()) { - QString xCurveName = m_curveNameConfig->curveName(m_xValuesCurveVariable->address()); + QString xCurveName = m_curveNameConfig->curveName(m_xValuesCurveVariable->address(), plot->activePlotTitleHelper()); name += " | " + xCurveName; } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp index 026e87bff9..73bc3b6a3e 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp @@ -20,11 +20,13 @@ #include "RifEclipseSummaryAddress.h" -#include "RimSummaryCurve.h" #include "RimSummaryCase.h" +#include "RimSummaryCurve.h" +#include "RimSummaryPlotNameHelper.h" + +#include "SummaryPlotCommands/RicSummaryCurveCreator.h" #include "cafPdmUiPushButtonEditor.h" -#include "SummaryPlotCommands/RicSummaryCurveCreator.h" @@ -52,7 +54,7 @@ RimSummaryCurveAutoName::RimSummaryCurveAutoName() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimSummaryCurveAutoName::curveName(const RifEclipseSummaryAddress& summaryAddress) const +QString RimSummaryCurveAutoName::curveName(const RifEclipseSummaryAddress& summaryAddress, const RimSummaryPlotNameHelper* nameHelper) const { std::string text; @@ -61,11 +63,15 @@ QString RimSummaryCurveAutoName::curveName(const RifEclipseSummaryAddress& summa if (m_vectorName) { - text += summaryAddress.quantityName(); - - if (m_unit && summaryCurve && !summaryCurve->unitNameY().empty()) + bool skipSubString = nameHelper && nameHelper->isQuantityInTitle(); + if (!skipSubString) { - text += "[" + summaryCurve->unitNameY() + "]"; + text += summaryAddress.quantityName(); + + if (m_unit && summaryCurve && !summaryCurve->unitNameY().empty()) + { + text += "[" + summaryCurve->unitNameY() + "]"; + } } } @@ -75,8 +81,12 @@ QString RimSummaryCurveAutoName::curveName(const RifEclipseSummaryAddress& summa { if (m_regionNumber) { - if (text.size() > 0) text +=":"; - text += std::to_string(summaryAddress.regionNumber()); + bool skipSubString = nameHelper && nameHelper->isRegionInTitle(); + if (!skipSubString) + { + if (text.size() > 0) text +=":"; + text += std::to_string(summaryAddress.regionNumber()); + } } } break; @@ -94,19 +104,23 @@ QString RimSummaryCurveAutoName::curveName(const RifEclipseSummaryAddress& summa { if (m_wellGroupName) { - if (text.size() > 0) text += ":"; - text += summaryAddress.wellGroupName(); + bool skipSubString = nameHelper && nameHelper->isWellGroupNameInTitle(); + if (!skipSubString) + { + if (text.size() > 0) text += ":"; + text += summaryAddress.wellGroupName(); + } } } break; case RifEclipseSummaryAddress::SUMMARY_WELL: { - appendWellName(text, summaryAddress); + appendWellName(text, summaryAddress, nameHelper); } break; case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION: { - appendWellName(text, summaryAddress); + appendWellName(text, summaryAddress, nameHelper); if (m_completion) { @@ -120,13 +134,13 @@ QString RimSummaryCurveAutoName::curveName(const RifEclipseSummaryAddress& summa case RifEclipseSummaryAddress::SUMMARY_WELL_LGR: { appendLgrName(text, summaryAddress); - appendWellName(text, summaryAddress); + appendWellName(text, summaryAddress, nameHelper); } break; case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR: { appendLgrName(text, summaryAddress); - appendWellName(text, summaryAddress); + appendWellName(text, summaryAddress, nameHelper); if (m_completion) { @@ -139,7 +153,7 @@ QString RimSummaryCurveAutoName::curveName(const RifEclipseSummaryAddress& summa break; case RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT: { - appendWellName(text, summaryAddress); + appendWellName(text, summaryAddress, nameHelper); if (m_wellSegmentNumber) { @@ -174,10 +188,11 @@ QString RimSummaryCurveAutoName::curveName(const RifEclipseSummaryAddress& summa break; } - if (summaryCurve) { - if (m_caseName) + bool skipSubString = nameHelper && nameHelper->isCaseInTitle(); + + if (m_caseName && !skipSubString) { if (summaryCurve && summaryCurve->summaryCaseY()) { @@ -209,8 +224,11 @@ void RimSummaryCurveAutoName::applySettings(const RimSummaryCurveAutoName& other //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCurveAutoName::appendWellName(std::string& text, const RifEclipseSummaryAddress& summaryAddress) const +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 += ":"; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.h index a6f143fa71..329e0f2f9e 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.h @@ -24,6 +24,7 @@ class RifEclipseSummaryAddress; +class RimSummaryPlotNameHelper; class RimSummaryCurveAutoName : public caf::PdmObject { @@ -31,7 +32,7 @@ class RimSummaryCurveAutoName : public caf::PdmObject public: RimSummaryCurveAutoName();; - QString curveName(const RifEclipseSummaryAddress& summaryAddress) const; + QString curveName(const RifEclipseSummaryAddress& summaryAddress, const RimSummaryPlotNameHelper* nameHelper) const; void applySettings(const RimSummaryCurveAutoName& other); @@ -43,7 +44,7 @@ protected: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; private: - void appendWellName(std::string& text, const RifEclipseSummaryAddress& summaryAddress) const; + void appendWellName(std::string& text, const RifEclipseSummaryAddress& summaryAddress, const RimSummaryPlotNameHelper* nameHelper) const; void appendLgrName(std::string& text, const RifEclipseSummaryAddress& summaryAddress) const; private: diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp index a3307e6f0c..0a30c4845e 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp @@ -276,7 +276,7 @@ QString RimSummaryCurveCollection::compileAutoPlotTitle() const // Suggestion : Delegate to RimSummaryPlotSourceStepping to find title } - analyzer.analyzeAdresses(addresses); + analyzer.appendAdresses(addresses); auto quantities = analyzer.quantities(); auto wellNames = analyzer.wellNames(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 7e73169dc0..6fc371ae0f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -23,14 +23,15 @@ #include "RimAsciiDataCurve.h" #include "RimGridTimeHistoryCurve.h" +#include "RimSummaryAxisProperties.h" #include "RimSummaryCase.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" #include "RimSummaryCurveFilter.h" #include "RimSummaryCurvesCalculator.h" #include "RimSummaryPlotCollection.h" +#include "RimSummaryPlotNameHelper.h" #include "RimSummaryTimeAxisProperties.h" -#include "RimSummaryAxisProperties.h" #include "RiuMainPlotWindow.h" #include "RiuSummaryQwtPlot.h" @@ -115,6 +116,8 @@ RimSummaryPlot::RimSummaryPlot() setAsPlotMdiWindow(); m_isCrossPlot = false; + + m_nameHelper.reset(new RimSummaryPlotNameHelper); } //-------------------------------------------------------------------------------------------------- @@ -149,6 +152,8 @@ void RimSummaryPlot::updateAxes() { updateTimeAxis(); } + + updatePlotTitle(); } //-------------------------------------------------------------------------------------------------- @@ -493,12 +498,29 @@ void RimSummaryPlot::updatePlotTitle() { if (m_isUsingAutoName) { - m_userDefinedPlotTitle = m_summaryCurveCollection->compileAutoPlotTitle(); + m_userDefinedPlotTitle = generatePlotTitle(); + + updateAutoNameOfCurves(); + + this->updateConnectedEditors(); } updateMdiWindowTitle(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RimSummaryPlotNameHelper* RimSummaryPlot::activePlotTitleHelper() const +{ + if (m_isUsingAutoName()) + { + return m_nameHelper.get(); + } + + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1013,8 +1035,17 @@ void RimSummaryPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c { updatePlotTitle(); } -} + if (changedField == &m_isUsingAutoName && !m_isUsingAutoName) + { + // When auto name of plot is turned off, update the auto name for all curves + + for (auto c : summaryCurves()) + { + c->updateCurveNameNoLegendUpdate(); + } + } +} //-------------------------------------------------------------------------------------------------- /// @@ -1068,10 +1099,7 @@ void RimSummaryPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::onLoadDataAndUpdate() { - if (m_isUsingAutoName) - { - m_userDefinedPlotTitle = m_summaryCurveCollection->compileAutoPlotTitle(); - } + updatePlotTitle(); updateMdiWindowVisibility(); @@ -1216,11 +1244,6 @@ void RimSummaryPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& m_userDefinedPlotTitle.uiCapability()->setUiReadOnly(m_isUsingAutoName); - if (m_isUsingAutoName) - { - m_userDefinedPlotTitle = m_summaryCurveCollection->compileAutoPlotTitle(); - } - uiOrdering.skipRemainingFields(true); } @@ -1328,6 +1351,50 @@ void RimSummaryPlot::updateMdiWindowTitle() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryPlot::generatePlotTitle() +{ + std::vector addresses; + std::vector sumCases; + + if (m_summaryCurveCollection && m_summaryCurveCollection->isCurvesVisible()) + { + for (RimSummaryCurve* curve : m_summaryCurveCollection->curves()) + { + if (curve->isCurveVisible()) + { + addresses.push_back(curve->summaryAddressY()); + sumCases.push_back(curve->summaryCaseY()); + } + } + } + + m_nameHelper->clear(); + m_nameHelper->appendAddresses(addresses); + m_nameHelper->appendSummaryCases(sumCases); + + return m_nameHelper->plotTitle(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::updateAutoNameOfCurves() +{ + if (m_summaryCurveCollection->isCurvesVisible()) + { + for (auto c : summaryCurves()) + { + if (c->isCurveVisible()) + { + c->updateCurveNameNoLegendUpdate(); + } + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index a2cb477f28..c8c876ecce 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -22,10 +22,16 @@ #include "cafPdmChildArrayField.h" #include "RiaDefines.h" + +#include "RifEclipseSummaryAddress.h" + #include "RimViewWindow.h" #include +#include +#include + class PdmUiTreeOrdering; class RimAsciiDataCurve; class RimGridTimeHistoryCurve; @@ -36,6 +42,7 @@ class RimSummaryCurveFilter_OBSOLETE; class RimSummaryTimeAxisProperties; class RimSummaryAxisProperties; class RiuSummaryQwtPlot; +class RimSummaryPlotNameHelper; class QwtInterval; class QwtPlotCurve; @@ -103,6 +110,8 @@ public: void updatePlotTitle(); + const RimSummaryPlotNameHelper* activePlotTitleHelper() const; + // RimViewWindow overrides public: virtual QWidget* createViewWidget(QWidget* mainWindowParent) override; @@ -111,6 +120,8 @@ public: private: void updateMdiWindowTitle() override; + QString generatePlotTitle(); + void updateAutoNameOfCurves(); protected: // Overridden PDM methods @@ -126,8 +137,6 @@ protected: void setAsCrossPlot(); - - private: std::vector visibleSummaryCurvesForAxis(RiaDefines::PlotAxis plotAxis) const; std::vector visibleTimeHistoryCurvesForAxis(RiaDefines::PlotAxis plotAxis) const; @@ -163,8 +172,12 @@ private: QPointer m_qwtPlot; - caf::PdmChildArrayField m_summaryCurves_OBSOLETE; - caf::PdmChildArrayField m_curveFilters_OBSOLETE; bool m_isCrossPlot; + + std::unique_ptr m_nameHelper; + + // Obsolete fields + caf::PdmChildArrayField m_summaryCurves_OBSOLETE; + caf::PdmChildArrayField m_curveFilters_OBSOLETE; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp new file mode 100644 index 0000000000..fdd83cfc58 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp @@ -0,0 +1,204 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimSummaryPlotNameHelper.h" + +#include "RifEclipseSummaryAddress.h" + +#include "RimSummaryCase.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryPlotNameHelper::RimSummaryPlotNameHelper() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotNameHelper::clear() +{ + m_summaryCases.clear(); + + m_analyzer.clear(); + + clearTitleSubStrings(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotNameHelper::appendAddresses(const std::vector& addresses) +{ + m_analyzer.appendAdresses(addresses); + + extractPlotTitleSubStrings(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotNameHelper::appendSummaryCases(const std::vector& summaryCases) +{ + m_summaryCases.clear(); + + for (auto c : summaryCases) + { + m_summaryCases.insert(c); + } + + extractPlotTitleSubStrings(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryPlotNameHelper::plotTitle() const +{ + QString title; + + if (!m_titleCaseName.isEmpty()) + { + if (!title.isEmpty()) title += ", "; + title += m_titleCaseName; + } + + if (!m_titleWellName.empty()) + { + if (!title.isEmpty()) title += ", "; + title += QString::fromStdString(m_titleWellName); + } + + if (!m_titleWellGroupName.empty()) + { + if (!title.isEmpty()) title += ", "; + title += QString::fromStdString(m_titleWellGroupName); + } + + if (!m_titleRegion.empty()) + { + if (!title.isEmpty()) title += ", "; + title += "Region : " + QString::fromStdString(m_titleRegion); + } + + if (!m_titleQuantity.empty()) + { + if (!title.isEmpty()) title += ", "; + title += QString::fromStdString(m_titleQuantity); + } + + if (title.isEmpty()) + { + title = "Composed Plot"; + } + + return title; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryPlotNameHelper::isQuantityInTitle() const +{ + return !m_titleQuantity.empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryPlotNameHelper::isWellNameInTitle() const +{ + return !m_titleWellName.empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryPlotNameHelper::isWellGroupNameInTitle() const +{ + return !m_titleWellGroupName.empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryPlotNameHelper::isRegionInTitle() const +{ + return !m_titleRegion.empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryPlotNameHelper::isCaseInTitle() const +{ + return !m_titleCaseName.isEmpty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotNameHelper::clearTitleSubStrings() +{ + m_titleQuantity.clear(); + m_titleRegion.clear(); + m_titleWellName.clear(); + m_titleRegion.clear(); + + m_titleCaseName.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotNameHelper::extractPlotTitleSubStrings() +{ + clearTitleSubStrings(); + + auto quantities = m_analyzer.quantities(); + auto wellNames = m_analyzer.wellNames(); + auto wellGroupNames = m_analyzer.wellGroupNames(); + auto regions = m_analyzer.regionNumbers(); + + if (quantities.size() == 1) + { + m_titleQuantity = *(quantities.begin()); + } + + if (wellNames.size() == 1) + { + m_titleWellName = *(wellNames.begin()); + } + + if (wellGroupNames.size() == 1) + { + m_titleWellGroupName = *(wellGroupNames.begin()); + } + + if (regions.size() == 1) + { + m_titleRegion = *(regions.begin()); + } + + // Case mane + if (m_summaryCases.size() == 1) + { + auto summaryCase = *(m_summaryCases.begin()); + + m_titleCaseName = summaryCase->caseName(); + } +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h new file mode 100644 index 0000000000..dfbde9919f --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaSummaryCurveAnalyzer.h" + +#include "RifEclipseSummaryAddress.h" + +#include + +#include +#include + +class RimSummaryCurve; +class RimSummaryCase; + +//================================================================================================== +// +//================================================================================================== +class RimSummaryPlotNameHelper +{ +public: + RimSummaryPlotNameHelper(); + + void clear(); + + void appendAddresses(const std::vector& addresses); + void appendSummaryCases(const std::vector& summaryCases); + + QString plotTitle() const; + + bool isQuantityInTitle() const; + bool isWellNameInTitle() const; + bool isWellGroupNameInTitle() const; + bool isRegionInTitle() const; + bool isCaseInTitle() const; + +private: + void clearTitleSubStrings(); + void extractPlotTitleSubStrings(); + +private: + RiaSummaryCurveAnalyzer m_analyzer; + + std::set m_summaryCases; + + std::string m_titleQuantity; + std::string m_titleWellName; + std::string m_titleWellGroupName; + std::string m_titleRegion; + + QString m_titleCaseName; +}; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp index 033a71cf0d..d70b519b85 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp @@ -201,7 +201,7 @@ std::vector RimSummaryPlotSourceStepping::fieldsToShowInTo } RiaSummaryCurveAnalyzer analyzer; - analyzer.analyzeAdresses(allAddressesUsedInCurveCollection()); + analyzer.appendAdresses(allAddressesUsedInCurveCollection()); if (analyzer.wellNames().size() == 1) { @@ -292,8 +292,8 @@ QList RimSummaryPlotSourceStepping::calculateValueOption RiaSummaryCurveAnalyzer quantityAnalyzer; auto subset = RiaSummaryCurveAnalyzer::addressesForCategory(reader->allResultAddresses(), category); - quantityAnalyzer.analyzeAdresses(subset); + quantityAnalyzer.appendAdresses(subset); for (const auto& quantity : quantityAnalyzer.quantities()) { identifierTexts.insert(QString::fromStdString(quantity)); @@ -556,7 +556,7 @@ void RimSummaryPlotSourceStepping::updateUiFromCurves() } RiaSummaryCurveAnalyzer analyzer; - analyzer.analyzeAdresses(allAddressesUsedInCurveCollection()); + analyzer.appendAdresses(allAddressesUsedInCurveCollection()); RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_INVALID; { @@ -616,7 +616,7 @@ void RimSummaryPlotSourceStepping::updateUiFromCurves() caf::PdmValueField* RimSummaryPlotSourceStepping::fieldToModify() { RiaSummaryCurveAnalyzer analyzer; - analyzer.analyzeAdresses(allAddressesUsedInCurveCollection()); + analyzer.appendAdresses(allAddressesUsedInCurveCollection()); if (analyzer.wellNames().size() == 1) { @@ -732,7 +732,7 @@ RiaSummaryCurveAnalyzer* RimSummaryPlotSourceStepping::analyzerForReader(RifSumm m_curveAnalyzerForReader = std::make_pair(reader, analyzer); } - m_curveAnalyzerForReader.second.analyzeAdresses(reader->allResultAddresses()); + m_curveAnalyzerForReader.second.appendAdresses(reader->allResultAddresses()); return &m_curveAnalyzerForReader.second; }