#2838 Ensemble Curve Name : Improve logic for display of legend

This commit is contained in:
Magne Sjaastad 2018-05-02 12:00:21 +02:00
parent 26975e3ce3
commit b023bd02a3
2 changed files with 22 additions and 11 deletions

View File

@ -19,6 +19,7 @@
#include "RimPlotCurve.h"
#include "RimEnsembleCurveSet.h"
#include "RimEnsembleCurveSetCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryCurveCollection.h"
#include "RimSummaryCurveFilter.h"
@ -583,14 +584,6 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate()
{
bool showLegendInQwt = m_showLegend();
RimSummaryPlot* summaryPlot = nullptr;
this->firstAncestorOrThisOfType(summaryPlot);
if (summaryPlot && summaryPlot->curveCount() == 1)
{
// Disable display of legend if the summary plot has only one single curve
showLegendInQwt = false;
}
RimEnsembleCurveSet* ensembleCurveSet = nullptr;
this->firstAncestorOrThisOfType(ensembleCurveSet);
if (ensembleCurveSet)
@ -602,6 +595,21 @@ void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate()
showLegendInQwt = false;
}
}
else
{
RimSummaryPlot* summaryPlot = nullptr;
this->firstAncestorOrThisOfType(summaryPlot);
if (summaryPlot)
{
if (summaryPlot->ensembleCurveSets()->visibleCurveSets().empty() && summaryPlot->curveCount() == 1)
{
// Disable display of legend if the summary plot has only one single curve
showLegendInQwt = false;
}
}
}
m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, showLegendInQwt);
}

View File

@ -212,11 +212,14 @@ std::vector<RimEnsembleCurveSet*> RimEnsembleCurveSetCollection::visibleCurveSet
{
std::vector<RimEnsembleCurveSet*> visible;
for (auto c : m_curveSets)
if (m_showCurves())
{
if (c->isCurvesVisible())
for (auto c : m_curveSets)
{
visible.push_back(c);
if (c->isCurvesVisible())
{
visible.push_back(c);
}
}
}