From 0da7686cdbf933080e5e324eb6fa916e4a3ac2c7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 30 Apr 2018 08:01:12 +0200 Subject: [PATCH] #2760 Ensemble Curves: Show one curve legend --- .../ProjectDataModel/RimPlotCurve.cpp | 13 +++++++++++ .../Summary/RimEnsembleCurveSet.cpp | 11 +++++++++ .../Summary/RimEnsembleCurveSet.h | 1 + .../Summary/RimEnsembleCurveSetCollection.cpp | 23 ++++++++++--------- .../Summary/RimSummaryCurveCollection.cpp | 1 + .../Summary/RimSummaryPlot.cpp | 10 ++++++++ .../Summary/RimSummaryPlotNameHelper.cpp | 21 ++++------------- 7 files changed, 52 insertions(+), 28 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index cef2b397a4..f2bdb24a11 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -19,6 +19,7 @@ #include "RimPlotCurve.h" #include "RimEnsembleCurveSet.h" +#include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" #include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" @@ -590,5 +591,17 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() showLegendInQwt = false; } + RimEnsembleCurveSet* ensembleCurveSet = nullptr; + this->firstAncestorOrThisOfType(ensembleCurveSet); + if (ensembleCurveSet) + { + auto firstCurve = ensembleCurveSet->firstCurve(); + if (firstCurve != this) + { + // Hide legend display for curves other than the first + showLegendInQwt = false; + } + } + m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, showLegendInQwt); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp index 075e1edd83..4da5c0f306 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -184,6 +184,7 @@ void RimEnsembleCurveSet::loadDataAndUpdate(bool updateParentPlot) firstAncestorOrThisOfTypeAsserted(parentPlot); if (parentPlot->qwtPlot()) { + parentPlot->updatePlotTitle(); parentPlot->qwtPlot()->updateLegend(); parentPlot->updateAxes(); parentPlot->updateZoomInQwt(); @@ -277,6 +278,16 @@ std::vector RimEnsembleCurveSet::visibleCurves() const return visible; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCurve* RimEnsembleCurveSet::firstCurve() const +{ + if (!curves().empty()) return curves().front(); + + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h index 7ff6ef433d..802de95035 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -74,6 +74,7 @@ public: RifEclipseSummaryAddress summaryAddress() const; std::vector curves() const; std::vector visibleCurves() const; + RimSummaryCurve* firstCurve() const; void deleteAllCurves(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp index aad83c655b..8b41f6593f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp @@ -111,17 +111,18 @@ void RimEnsembleCurveSetCollection::loadDataAndUpdate(bool updateParentPlot) // curve->updateQwtPlotAxis(); //} - //if ( updateParentPlot ) - //{ - // RimSummaryPlot* parentPlot; - // firstAncestorOrThisOfTypeAsserted(parentPlot); - // if ( parentPlot->qwtPlot() ) - // { - // parentPlot->qwtPlot()->updateLegend(); - // parentPlot->updateAxes(); - // parentPlot->updateZoomInQwt(); - // } - //} + if ( updateParentPlot ) + { + RimSummaryPlot* parentPlot; + firstAncestorOrThisOfTypeAsserted(parentPlot); + if ( parentPlot->qwtPlot() ) + { + parentPlot->updatePlotTitle(); + parentPlot->qwtPlot()->updateLegend(); + parentPlot->updateAxes(); + parentPlot->updateZoomInQwt(); + } + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp index 38a005e209..4a8dd74cd6 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp @@ -107,6 +107,7 @@ void RimSummaryCurveCollection::loadDataAndUpdate(bool updateParentPlot) firstAncestorOrThisOfTypeAsserted(parentPlot); if ( parentPlot->qwtPlot() ) { + parentPlot->updatePlotTitle(); parentPlot->qwtPlot()->updateLegend(); parentPlot->updateAxes(); parentPlot->updateZoomInQwt(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 435b1cd7ac..b21d15a69e 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -1516,6 +1516,16 @@ void RimSummaryPlot::updateCurveNames() } } } + + for (auto curveSet : m_ensembleCurveSetCollection->curveSets()) + { + if (curveSet->isCurvesVisible() && curveSet->firstCurve()) + { + // Only the first curve in the set is used in the legend, + // skip update of other curves + curveSet->firstCurve()->updateCurveNameNoLegendUpdate(); + } + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp index 425cd43c62..e553e3bf8a 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp @@ -213,30 +213,17 @@ void RimSummaryPlotNameHelper::extractPlotTitleSubStrings() } { - QString summaryCaseTitle; - if (m_summaryCases.size() == 1) + if (m_summaryCases.size() == 1 && m_ensembleCases.empty()) { auto summaryCase = *(m_summaryCases.begin()); - summaryCaseTitle = summaryCase->caseName(); + m_titleCaseName = summaryCase->caseName(); } - - QString ensembleCaseTitle; - if (m_titleCaseName.isEmpty() && m_ensembleCases.size() == 1) + else if (m_ensembleCases.size() == 1 && m_summaryCases.empty()) { auto ensembleCase = *(m_ensembleCases.begin()); - ensembleCaseTitle = ensembleCase->name(); - } - - // If one case title is the single available, use the single title - if (summaryCaseTitle.isEmpty() && !ensembleCaseTitle.isEmpty()) - { - m_titleCaseName = ensembleCaseTitle; - } - else if (!summaryCaseTitle.isEmpty() && ensembleCaseTitle.isEmpty()) - { - m_titleCaseName = summaryCaseTitle; + m_titleCaseName = ensembleCase->name(); } } }