mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2688 Set different curves color for each curve set
This commit is contained in:
@@ -157,6 +157,14 @@ bool RimEnsambleCurveSet::isCurvesVisible()
|
||||
return m_showCurves() && (coll ? coll->isCurveSetsVisible() : true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsambleCurveSet::setColor(cvf::Color3f color)
|
||||
{
|
||||
m_color = color;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -184,14 +192,12 @@ void RimEnsambleCurveSet::loadDataAndUpdate(bool updateParentPlot)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsambleCurveSet::setParentQwtPlotAndReplot(QwtPlot* plot)
|
||||
void RimEnsambleCurveSet::setParentQwtPlotNoReplot(QwtPlot* plot)
|
||||
{
|
||||
for (RimSummaryCurve* curve : m_curves)
|
||||
{
|
||||
curve->setParentQwtPlotNoReplot(plot);
|
||||
}
|
||||
|
||||
if (plot) plot->replot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -228,6 +234,11 @@ void RimEnsambleCurveSet::addCurve(RimSummaryCurve* curve)
|
||||
{
|
||||
if (curve)
|
||||
{
|
||||
RimSummaryPlot* plot;
|
||||
firstAncestorOrThisOfType(plot);
|
||||
if (plot) curve->setParentQwtPlotNoReplot(plot->qwtPlot());
|
||||
|
||||
curve->setColor(m_color);
|
||||
m_curves.push_back(curve);
|
||||
}
|
||||
}
|
||||
@@ -422,6 +433,9 @@ void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
|
||||
}
|
||||
else if (changedField == &m_yValuesSummaryGroup || changedField == &m_yValuesSelectedVariableDisplayField)
|
||||
{
|
||||
// Update backing field
|
||||
m_yValuesCurveVariable->setAddress(m_yValuesSelectedVariableDisplayField);
|
||||
|
||||
deleteAllCurves();
|
||||
|
||||
RimSummaryPlot* plot;
|
||||
@@ -439,7 +453,6 @@ void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
|
||||
curve->setSummaryAddressY(addr);
|
||||
|
||||
addCurve(curve);
|
||||
curve->setParentQwtPlotNoReplot(plot->qwtPlot());
|
||||
|
||||
curve->updateCurveVisibility(true);
|
||||
curve->loadDataAndUpdate(true);
|
||||
@@ -454,56 +467,20 @@ void RimEnsambleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedFie
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (changedField == &m_ensambleParameter)
|
||||
else if (changedField == &m_ensambleParameter ||
|
||||
changedField == &m_color ||
|
||||
changedField == &m_colorMode)
|
||||
{
|
||||
RimSummaryCaseCollection* group = m_yValuesSummaryGroup();
|
||||
QString parameterName = m_ensambleParameter();
|
||||
if (group && !parameterName.isEmpty())
|
||||
{
|
||||
double minValue = HUGE_VAL;
|
||||
double maxValue = -HUGE_VAL;
|
||||
|
||||
for (RimSummaryCase* rimCase : group->allSummaryCases())
|
||||
{
|
||||
if (!rimCase->caseRealizationParameters().isNull())
|
||||
{
|
||||
double value = rimCase->caseRealizationParameters()->parameterValue(parameterName);
|
||||
if (value != HUGE_VAL)
|
||||
{
|
||||
if (value < minValue) minValue = value;
|
||||
if (value > maxValue) maxValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cvf::ScalarMapperContinuousLinear colorMapper;
|
||||
colorMapper.setRange(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->updateCurveAppearance();
|
||||
}
|
||||
|
||||
RimSummaryPlot* plot;
|
||||
firstAncestorOrThisOfType(plot);
|
||||
if (plot && plot->qwtPlot()) plot->qwtPlot()->replot();
|
||||
}
|
||||
updateCurveColors();
|
||||
}
|
||||
else if (changedField == &m_color)
|
||||
{
|
||||
for (auto& curve : m_curves)
|
||||
{
|
||||
curve->setColor(m_color);
|
||||
curve->updateCurveAppearance();
|
||||
}
|
||||
}
|
||||
|
||||
RimSummaryPlot* plot;
|
||||
firstAncestorOrThisOfType(plot);
|
||||
if (plot && plot->qwtPlot()) plot->qwtPlot()->replot();
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsambleCurveSet::initAfterRead()
|
||||
{
|
||||
m_yValuesSelectedVariableDisplayField = m_yValuesCurveVariable->address();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -696,3 +673,56 @@ void RimEnsambleCurveSet::getOptionsForSummaryAddresses(std::map<QString, RifEcl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsambleCurveSet::updateCurveColors()
|
||||
{
|
||||
if(m_colorMode == BY_ENSAMBLE_PARAM)
|
||||
{
|
||||
RimSummaryCaseCollection* group = m_yValuesSummaryGroup();
|
||||
QString parameterName = m_ensambleParameter();
|
||||
if (group && !parameterName.isEmpty())
|
||||
{
|
||||
double minValue = HUGE_VAL;
|
||||
double maxValue = -HUGE_VAL;
|
||||
|
||||
for (RimSummaryCase* rimCase : group->allSummaryCases())
|
||||
{
|
||||
if (!rimCase->caseRealizationParameters().isNull())
|
||||
{
|
||||
double value = rimCase->caseRealizationParameters()->parameterValue(parameterName);
|
||||
if (value != HUGE_VAL)
|
||||
{
|
||||
if (value < minValue) minValue = value;
|
||||
if (value > maxValue) maxValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cvf::ScalarMapperContinuousLinear colorMapper;
|
||||
colorMapper.setRange(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->updateCurveAppearance();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_colorMode == SINGLE_COLOR)
|
||||
{
|
||||
for (auto& curve : m_curves)
|
||||
{
|
||||
curve->setColor(m_color);
|
||||
curve->updateCurveAppearance();
|
||||
}
|
||||
}
|
||||
|
||||
RimSummaryPlot* plot;
|
||||
firstAncestorOrThisOfType(plot);
|
||||
if (plot && plot->qwtPlot()) plot->qwtPlot()->replot();
|
||||
}
|
||||
|
@@ -56,9 +56,10 @@ public:
|
||||
virtual ~RimEnsambleCurveSet();
|
||||
|
||||
bool isCurvesVisible();
|
||||
void setColor(cvf::Color3f color);
|
||||
|
||||
void loadDataAndUpdate(bool updateParentPlot);
|
||||
void setParentQwtPlotAndReplot(QwtPlot* plot);
|
||||
void setParentQwtPlotNoReplot(QwtPlot* plot);
|
||||
void detachQwtCurves();
|
||||
|
||||
RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const;
|
||||
@@ -90,11 +91,14 @@ private:
|
||||
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue, const QVariant& newValue) override;
|
||||
virtual void initAfterRead() override;
|
||||
|
||||
static void getOptionsForSummaryAddresses(std::map<QString, RifEclipseSummaryAddress>* options,
|
||||
RimSummaryCase* summaryCase,
|
||||
RimSummaryFilter* summaryFilter);
|
||||
|
||||
void updateCurveColors();
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_showCurves;
|
||||
caf::PdmChildArrayField<RimSummaryCurve*> m_curves; // Convert to PtrField ?
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include "RimEnsambleCurveSetCollection.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaColorTables.h"
|
||||
|
||||
#include "RifReaderEclipseSummary.h"
|
||||
|
||||
@@ -29,6 +30,7 @@
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotSourceStepping.h"
|
||||
#include "RimSummaryCurveAppearanceCalculator.h"
|
||||
|
||||
#include "RiuLineSegmentQwtPlotCurve.h"
|
||||
#include "RiuSummaryQwtPlot.h"
|
||||
@@ -120,6 +122,19 @@ void RimEnsambleCurveSetCollection::loadDataAndUpdate(bool updateParentPlot)
|
||||
//}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsambleCurveSetCollection::setParentQwtPlotAndReplot(QwtPlot* plot)
|
||||
{
|
||||
for (RimEnsambleCurveSet* curveSet : m_curveSets)
|
||||
{
|
||||
curveSet->setParentQwtPlotNoReplot(plot);
|
||||
}
|
||||
|
||||
if (plot) plot->replot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -136,9 +151,15 @@ void RimEnsambleCurveSetCollection::detachQwtCurves()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEnsambleCurveSetCollection::addCurveSet(RimEnsambleCurveSet* curveSet)
|
||||
{
|
||||
static int nextAutoColorIndex = 1;
|
||||
static int numberOfColors = (int)RiaColorTables::summaryCurveDefaultPaletteColors().size();
|
||||
|
||||
if (curveSet)
|
||||
{
|
||||
curveSet->setColor(RimSummaryCurveAppearanceCalculator::cycledPaletteColor(nextAutoColorIndex));
|
||||
m_curveSets.push_back(curveSet);
|
||||
|
||||
nextAutoColorIndex = (++nextAutoColorIndex) % numberOfColors;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
class RimSummaryCase;
|
||||
class RimEnsambleCurveSet;
|
||||
class QwtPlot;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -42,7 +43,7 @@ public:
|
||||
bool isCurveSetsVisible();
|
||||
|
||||
void loadDataAndUpdate(bool updateParentPlot);
|
||||
//void setParentQwtPlotAndReplot(QwtPlot* plot);
|
||||
void setParentQwtPlotAndReplot(QwtPlot* plot);
|
||||
void detachQwtCurves();
|
||||
|
||||
//RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const;
|
||||
|
@@ -965,6 +965,8 @@ void RimSummaryPlot::addCurveNoUpdate(RimSummaryCurve* curve)
|
||||
//{
|
||||
// if (curveSet && curve)
|
||||
// {
|
||||
// curve->setColor(RimSummaryCurveAppearanceCalculator::cycledPaletteColor((int)m_ensambleCurveSetCollection->curveSets().size()));
|
||||
//
|
||||
// const_cast<RimEnsambleCurveSet*>(curveSet)->addCurve(curve);
|
||||
// curve->setParentQwtPlotAndReplot(m_qwtPlot);
|
||||
// }
|
||||
@@ -1186,17 +1188,18 @@ void RimSummaryPlot::onLoadDataAndUpdate()
|
||||
|
||||
for (RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves)
|
||||
{
|
||||
curve->loadDataAndUpdate(true);
|
||||
curve->loadDataAndUpdate(false);
|
||||
}
|
||||
|
||||
for (RimAsciiDataCurve* curve : m_asciiDataCurves)
|
||||
{
|
||||
curve->loadDataAndUpdate(true);
|
||||
curve->loadDataAndUpdate(false);
|
||||
}
|
||||
|
||||
if (m_qwtPlot) m_qwtPlot->updateLegend();
|
||||
this->updateAxes();
|
||||
updateZoomInQwt();
|
||||
if(m_qwtPlot) m_qwtPlot->replot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1354,6 +1357,11 @@ QWidget* RimSummaryPlot::createViewWidget(QWidget* mainWindowParent)
|
||||
{
|
||||
m_summaryCurveCollection->setParentQwtPlotAndReplot(m_qwtPlot);
|
||||
}
|
||||
|
||||
if (m_ensambleCurveSetCollection)
|
||||
{
|
||||
m_ensambleCurveSetCollection->setParentQwtPlotAndReplot(m_qwtPlot);
|
||||
}
|
||||
}
|
||||
|
||||
return m_qwtPlot;
|
||||
|
@@ -38,6 +38,7 @@ class RimGridTimeHistoryCurve;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryCurve;
|
||||
class RimSummaryCurveCollection;
|
||||
class RimEnsambleCurveSet;
|
||||
class RimEnsambleCurveSetCollection;
|
||||
class RimSummaryCurveFilter_OBSOLETE;
|
||||
class RimSummaryTimeAxisProperties;
|
||||
|
Reference in New Issue
Block a user