#2689 ensemble curves. Make the curve set legend work. Cache summary addresses for performance reasons

This commit is contained in:
Bjørn Erik Jensen 2018-04-20 10:17:02 +02:00
parent 9550864c9e
commit 6c45725b19
5 changed files with 56 additions and 35 deletions

View File

@ -26,6 +26,7 @@
#include "RimCellEdgeColors.h"
#include "RimEclipseCellColors.h"
#include "RimEnsembleCurveSet.h"
#include "RimEclipseView.h"
#include "RimGeoMechResultDefinition.h"
#include "RimIntersectionCollection.h"
@ -205,6 +206,14 @@ void RimRegularLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changed
{
stimPlanColors->updateStimPlanTemplates();
}
// Update ensemble curve set if relevant
RimEnsembleCurveSet* ensembleCurveSet;
firstAncestorOrThisOfType(ensembleCurveSet);
if (ensembleCurveSet)
{
ensembleCurveSet->onLegendDefinitionChanged();
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -23,6 +23,7 @@
#include "RifReaderEclipseSummary.h"
#include "RimProject.h"
#include "RimRegularLegendConfig.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCurve.h"
@ -38,7 +39,7 @@
#include "cafPdmObject.h"
#include "cafPdmUiPushButtonEditor.h"
#include "cvfScalarMapperContinuousLinear.h"
#include "cvfScalarMapper.h"
namespace caf
@ -181,6 +182,8 @@ void RimEnsembleCurveSet::loadDataAndUpdate(bool updateParentPlot)
}
}
}
updateCurveColors();
}
//--------------------------------------------------------------------------------------------------
@ -275,6 +278,14 @@ RimRegularLegendConfig* RimEnsembleCurveSet::legendConfig()
return m_legendConfig;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::onLegendDefinitionChanged()
{
updateCurveColors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -296,6 +307,8 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
}
else if (changedField == &m_yValuesSummaryGroup)
{
// Empty address cache
m_allAddressesCache.clear();
updateAllCurves();
}
else if (changedField == &m_ensembleParameter ||
@ -313,9 +326,6 @@ void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
updateQwtPlotAxis();
plot->updateAxes();
}
else if (changedField == &m_yPushButtonSelectSummaryAddress)
{
}
}
//--------------------------------------------------------------------------------------------------
@ -358,7 +368,10 @@ void RimEnsembleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder
//--------------------------------------------------------------------------------------------------
void RimEnsembleCurveSet::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
{
uiTreeOrdering.add(m_legendConfig());
if (m_colorMode == BY_ENSEMBLE_PARAM)
{
uiTreeOrdering.add(m_legendConfig());
}
uiTreeOrdering.skipRemainingChildren(true);
}
@ -466,16 +479,17 @@ void RimEnsembleCurveSet::appendOptionItemsForSummaryAddresses(QList<caf::PdmOpt
{
if (!summaryCaseGroup) return;
std::set<RifEclipseSummaryAddress> allAddresses;
for (RimSummaryCase* summaryCase : summaryCaseGroup->allSummaryCases())
if (m_allAddressesCache.empty())
{
RifSummaryReaderInterface* reader = summaryCase->summaryReader();
const std::vector<RifEclipseSummaryAddress> addrs = reader ? reader->allResultAddresses() : std::vector<RifEclipseSummaryAddress>();
allAddresses.insert(addrs.begin(), addrs.end());
for (RimSummaryCase* summaryCase : summaryCaseGroup->allSummaryCases())
{
RifSummaryReaderInterface* reader = summaryCase->summaryReader();
const std::vector<RifEclipseSummaryAddress> addrs = reader ? reader->allResultAddresses() : std::vector<RifEclipseSummaryAddress>();
m_allAddressesCache.insert(addrs.begin(), addrs.end());
}
}
for (auto& address : allAddresses)
for (auto& address : m_allAddressesCache)
{
if (summaryFilter && !summaryFilter->isIncludedByFilter(address)) continue;
@ -514,14 +528,13 @@ void RimEnsembleCurveSet::updateCurveColors()
}
}
cvf::ScalarMapperContinuousLinear colorMapper;
colorMapper.setRange(minValue, maxValue);
m_legendConfig->setAutomaticRanges(minValue, maxValue, minValue, maxValue);
for (auto& curve : m_curves)
{
RimSummaryCase* rimCase = curve->summaryCaseY();
double value = rimCase->caseRealizationParameters()->parameterValue(parameterName);
curve->setColor(cvf::Color3f(colorMapper.mapToColor(value)));
curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(value)));
curve->updateCurveAppearance();
}
}
@ -537,7 +550,18 @@ void RimEnsembleCurveSet::updateCurveColors()
RimSummaryPlot* plot;
firstAncestorOrThisOfType(plot);
if (plot && plot->qwtPlot()) plot->qwtPlot()->replot();
if (plot && plot->qwtPlot())
{
if (m_colorMode == BY_ENSEMBLE_PARAM)
{
plot->qwtPlot()->addOrUpdateEnsembleCurveSetLegend(this);
}
else
{
plot->qwtPlot()->removeEnsembleCurveSetLegend(this);
}
plot->qwtPlot()->replot();
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -34,6 +34,8 @@
#include "cafPdmPtrField.h"
#include "cafAppEnum.h"
#include "RifEclipseSummaryAddressQMetaType.h"
class QwtPlot;
class QwtPlotCurve;
class RimSummaryCase;
@ -72,7 +74,8 @@ public:
void deleteAllCurves();
RimRegularLegendConfig* legendConfig();
RimRegularLegendConfig* legendConfig();
void onLegendDefinitionChanged();
private:
caf::PdmFieldHandle* objectToggleField();
@ -89,7 +92,7 @@ private:
RimSummaryCase* summaryCase,
RimSummaryFilter* summaryFilter);
static void appendOptionItemsForSummaryAddresses(QList<caf::PdmOptionItemInfo>* options,
void appendOptionItemsForSummaryAddresses(QList<caf::PdmOptionItemInfo>* options,
RimSummaryCaseCollection* summaryCaseGroup,
RimSummaryFilter* summaryFilter);
@ -118,5 +121,7 @@ private:
caf::PdmField<caf::AppEnum< RiaDefines::PlotAxis>> m_plotAxis;
caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig;
std::set<RifEclipseSummaryAddress> m_allAddressesCache;
};

View File

@ -957,21 +957,6 @@ void RimSummaryPlot::addCurveNoUpdate(RimSummaryCurve* curve)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
//void RimSummaryPlot::addEnsembleCurve(const RimEnsembleCurveSet* curveSet, RimSummaryCurve* curve)
//{
// if (curveSet && curve)
// {
// curve->setColor(RimSummaryCurveAppearanceCalculator::cycledPaletteColor((int)m_ensembleCurveSetCollection->curveSets().size()));
//
// const_cast<RimEnsembleCurveSet*>(curveSet)->addCurve(curve);
// curve->setParentQwtPlotAndReplot(m_qwtPlot);
// }
//}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -71,8 +71,6 @@ public:
void addCurveAndUpdate(RimSummaryCurve* curve);
void addCurveNoUpdate(RimSummaryCurve* curve);
//void addEnsembleCurve(const RimEnsembleCurveSet* curveSet, RimSummaryCurve* curve);
void deleteCurve(RimSummaryCurve* curve);
void setCurveCollection(RimSummaryCurveCollection* curveCollection);
void deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase);