mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-24 07:16:53 -06:00
#2845 Ensemble Curve Set Legend : Update ensemble legend item text
Use special symbol for curve color by parameter
This commit is contained in:
parent
c5cd8b2a4b
commit
4b6bd3d9fc
@ -582,28 +582,26 @@ void RimPlotCurve::updateLegendEntryVisibilityAndPlotLegend()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate()
|
||||
{
|
||||
bool showLegendInQwt = m_showLegend();
|
||||
|
||||
RimEnsembleCurveSet* ensembleCurveSet = nullptr;
|
||||
this->firstAncestorOrThisOfType(ensembleCurveSet);
|
||||
if (ensembleCurveSet)
|
||||
{
|
||||
m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, false);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
this->firstAncestorOrThisOfType(summaryPlot);
|
||||
|
||||
if (summaryPlot)
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
this->firstAncestorOrThisOfType(summaryPlot);
|
||||
|
||||
if (summaryPlot)
|
||||
{
|
||||
bool showLegendInQwt = m_showLegend();
|
||||
|
||||
if (summaryPlot->ensembleCurveSets()->visibleCurveSets().empty() && summaryPlot->curveCount() == 1)
|
||||
{
|
||||
if (summaryPlot->ensembleCurveSets()->visibleCurveSets().empty() && summaryPlot->curveCount() == 1)
|
||||
{
|
||||
// Disable display of legend if the summary plot has only one single curve
|
||||
showLegendInQwt = false;
|
||||
}
|
||||
// Disable display of legend if the summary plot has only one single curve
|
||||
showLegendInQwt = false;
|
||||
}
|
||||
|
||||
|
||||
m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, showLegendInQwt);
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,9 @@
|
||||
|
||||
#include "cvfScalarMapper.h"
|
||||
|
||||
#include "qwt_plot_curve.h"
|
||||
#include "qwt_symbol.h"
|
||||
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@ -133,6 +136,9 @@ RimEnsembleCurveSet::RimEnsembleCurveSet()
|
||||
m_summaryAddressNameTools.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
m_summaryAddressNameTools = new RimSummaryCurveAutoName;
|
||||
|
||||
m_qwtPlotCurveForLegendText = new QwtPlotCurve;
|
||||
m_qwtPlotCurveForLegendText->setLegendAttribute(QwtPlotCurve::LegendShowSymbol, true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -180,6 +186,12 @@ void RimEnsembleCurveSet::loadDataAndUpdate(bool updateParentPlot)
|
||||
for (RimSummaryCurve* curve : m_curves)
|
||||
{
|
||||
curve->loadDataAndUpdate(false);
|
||||
|
||||
if (curve->qwtPlotCurve())
|
||||
{
|
||||
curve->qwtPlotCurve()->setItemAttribute(QwtPlotItem::Legend, false);
|
||||
}
|
||||
|
||||
curve->updateQwtPlotAxis();
|
||||
}
|
||||
|
||||
@ -208,6 +220,8 @@ void RimEnsembleCurveSet::setParentQwtPlotNoReplot(QwtPlot* plot)
|
||||
{
|
||||
curve->setParentQwtPlotNoReplot(plot);
|
||||
}
|
||||
|
||||
m_qwtPlotCurveForLegendText->attach(plot);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -219,6 +233,8 @@ void RimEnsembleCurveSet::detachQwtCurves()
|
||||
{
|
||||
curve->detachQwtCurve();
|
||||
}
|
||||
|
||||
m_qwtPlotCurveForLegendText->detach();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -283,16 +299,6 @@ std::vector<RimSummaryCurve*> RimEnsembleCurveSet::visibleCurves() const
|
||||
return visible;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCurve* RimEnsembleCurveSet::firstCurve() const
|
||||
{
|
||||
if (!curves().empty()) return curves().front();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -424,10 +430,25 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
|
||||
{
|
||||
m_userDefinedName = createAutoName();
|
||||
}
|
||||
|
||||
if (changedField == &m_isUsingAutoName ||
|
||||
changedField == &m_userDefinedName ||
|
||||
changedField == &m_colorMode ||
|
||||
changedField == &m_color)
|
||||
{
|
||||
updateEnsembleLegendItem();
|
||||
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted(summaryPlot);
|
||||
if (summaryPlot->qwtPlot())
|
||||
{
|
||||
summaryPlot->qwtPlot()->updateLegend();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
@ -759,11 +780,6 @@ void RimEnsembleCurveSet::updateCurveColors()
|
||||
}
|
||||
plot->qwtPlot()->replot();
|
||||
}
|
||||
|
||||
if (firstCurve())
|
||||
{
|
||||
firstCurve()->updateLegendEntryVisibilityAndPlotLegend();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -804,6 +820,11 @@ void RimEnsembleCurveSet::updateAllCurves()
|
||||
|
||||
curve->updateCurveVisibility(true);
|
||||
curve->loadDataAndUpdate(true);
|
||||
|
||||
if (curve->qwtPlotCurve())
|
||||
{
|
||||
curve->qwtPlotCurve()->setItemAttribute(QwtPlotItem::Legend, false);
|
||||
}
|
||||
}
|
||||
|
||||
RimSummaryPlot* plot;
|
||||
@ -817,6 +838,39 @@ void RimEnsembleCurveSet::updateAllCurves()
|
||||
updateCurveColors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsembleCurveSet::updateEnsembleLegendItem()
|
||||
{
|
||||
m_qwtPlotCurveForLegendText->setTitle(name());
|
||||
|
||||
{
|
||||
QwtSymbol* symbol = nullptr;
|
||||
|
||||
if (m_colorMode == SINGLE_COLOR)
|
||||
{
|
||||
symbol = new QwtSymbol(QwtSymbol::HLine);
|
||||
|
||||
QColor curveColor(m_color.value().rByte(), m_color.value().gByte(), m_color.value().bByte());
|
||||
QPen curvePen(curveColor);
|
||||
curvePen.setWidth(2);
|
||||
|
||||
symbol->setPen(curvePen);
|
||||
}
|
||||
else if (m_colorMode == BY_ENSEMBLE_PARAM)
|
||||
{
|
||||
symbol = new QwtSymbol(QwtSymbol::Star1);
|
||||
}
|
||||
|
||||
symbol->setSize(6, 6);
|
||||
m_qwtPlotCurveForLegendText->setSymbol(symbol);
|
||||
}
|
||||
|
||||
bool showLegendItem = isCurvesVisible();
|
||||
m_qwtPlotCurveForLegendText->setItemAttribute(QwtPlotItem::Legend, showLegendItem);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -75,7 +75,6 @@ public:
|
||||
RifEclipseSummaryAddress summaryAddress() const;
|
||||
std::vector<RimSummaryCurve*> curves() const;
|
||||
std::vector<RimSummaryCurve*> visibleCurves() const;
|
||||
RimSummaryCurve* firstCurve() const;
|
||||
|
||||
void deleteAllCurves();
|
||||
|
||||
@ -86,6 +85,7 @@ public:
|
||||
RimSummaryCaseCollection* summaryCaseCollection() const;
|
||||
|
||||
ColorMode colorMode() const;
|
||||
void updateEnsembleLegendItem();
|
||||
EnsembleParameterType currentEnsembleParameterType() const;
|
||||
|
||||
void updateAllCurves();
|
||||
@ -146,5 +146,7 @@ private:
|
||||
caf::PdmChildField<RimSummaryCurveAutoName*> m_summaryAddressNameTools;
|
||||
|
||||
std::set<RifEclipseSummaryAddress> m_allAddressesCache;
|
||||
|
||||
QwtPlotCurve* m_qwtPlotCurveForLegendText;
|
||||
};
|
||||
|
||||
|
@ -506,10 +506,10 @@ void RimSummaryPlot::updatePlotTitle()
|
||||
if (m_useAutoPlotTitle)
|
||||
{
|
||||
m_userDefinedPlotTitle = generatePlotTitle(m_nameHelper.get());
|
||||
|
||||
updateCurveNames();
|
||||
}
|
||||
|
||||
updateCurveNames();
|
||||
|
||||
updateMdiWindowTitle();
|
||||
}
|
||||
|
||||
@ -1519,12 +1519,7 @@ 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();
|
||||
}
|
||||
curveSet->updateEnsembleLegendItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user