#2760 Ensemble Curves: Show one curve legend

This commit is contained in:
Magne Sjaastad 2018-04-30 08:01:12 +02:00
parent 1a0f242c0b
commit 0da7686cdb
7 changed files with 52 additions and 28 deletions

View File

@ -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);
}

View File

@ -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<RimSummaryCurve*> RimEnsembleCurveSet::visibleCurves() const
return visible;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCurve* RimEnsembleCurveSet::firstCurve() const
{
if (!curves().empty()) return curves().front();
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -74,6 +74,7 @@ public:
RifEclipseSummaryAddress summaryAddress() const;
std::vector<RimSummaryCurve*> curves() const;
std::vector<RimSummaryCurve*> visibleCurves() const;
RimSummaryCurve* firstCurve() const;
void deleteAllCurves();

View File

@ -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();
}
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -107,6 +107,7 @@ void RimSummaryCurveCollection::loadDataAndUpdate(bool updateParentPlot)
firstAncestorOrThisOfTypeAsserted(parentPlot);
if ( parentPlot->qwtPlot() )
{
parentPlot->updatePlotTitle();
parentPlot->qwtPlot()->updateLegend();
parentPlot->updateAxes();
parentPlot->updateZoomInQwt();

View File

@ -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();
}
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -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();
}
}
}