mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4569 Add normalize functionality to summary plot. Toggle button in Summary Plot. No command line option yet.
This commit is contained in:
committed by
Gaute Lindkvist
parent
c628fcd5f4
commit
421cbb3e74
@@ -265,6 +265,22 @@ std::vector<double> RimSummaryCurve::valuesY() const
|
||||
RifEclipseSummaryAddress addr = m_yValuesCurveVariable()->address();
|
||||
reader->values(addr, &values);
|
||||
|
||||
RimSummaryPlot* plot = nullptr;
|
||||
firstAncestorOrThisOfTypeAsserted(plot);
|
||||
bool isNormalized = plot->isNormalizationEnabled();
|
||||
if (isNormalized)
|
||||
{
|
||||
auto minMaxPair = std::minmax_element(values.begin(), values.end());
|
||||
double min = *minMaxPair.first;
|
||||
double max = *minMaxPair.second;
|
||||
double range = max - min;
|
||||
|
||||
for (double & v: values)
|
||||
{
|
||||
v = (v - min)/range;
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
|
||||
@@ -140,6 +140,9 @@ RimSummaryPlot::RimSummaryPlot()
|
||||
CAF_PDM_InitField(&m_useAutoPlotTitle, "IsUsingAutoName", true, "Auto Name", "", "", "");
|
||||
m_useAutoPlotTitle.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
||||
|
||||
CAF_PDM_InitField(&m_normalizeCurveYValues, "normalizeCurveYValues", false, "Normalize all curves", "", "", "");
|
||||
m_normalizeCurveYValues.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_curveFilters_OBSOLETE, "SummaryCurveFilters", "", "", "", "");
|
||||
m_curveFilters_OBSOLETE.uiCapability()->setUiTreeHidden(true);
|
||||
|
||||
@@ -635,6 +638,14 @@ bool RimSummaryPlot::applyFontSize(RiaDefines::FontSettingType fontSettingType,
|
||||
return anyChange;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryPlot::isNormalizationEnabled()
|
||||
{
|
||||
return m_normalizeCurveYValues();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1227,6 +1238,11 @@ void RimSummaryPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
|
||||
c->updateCurveNameNoLegendUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
if (changedField == &m_normalizeCurveYValues)
|
||||
{
|
||||
this->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1510,6 +1526,8 @@ void RimSummaryPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
|
||||
uiOrdering.add(&m_legendFontSize);
|
||||
}
|
||||
|
||||
uiOrdering.add(&m_normalizeCurveYValues);
|
||||
|
||||
m_userDefinedPlotTitle.uiCapability()->setUiReadOnly(m_useAutoPlotTitle);
|
||||
|
||||
uiOrdering.skipRemainingFields(true);
|
||||
@@ -1817,7 +1835,8 @@ void RimSummaryPlot::defineEditorAttribute(const caf::PdmFieldHandle* field, QSt
|
||||
{
|
||||
if (field == &m_showLegend ||
|
||||
field == &m_showPlotTitle ||
|
||||
field == &m_useAutoPlotTitle)
|
||||
field == &m_useAutoPlotTitle ||
|
||||
field == &m_normalizeCurveYValues)
|
||||
{
|
||||
caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast<caf::PdmUiCheckBoxEditorAttribute*>(attribute);
|
||||
if (myAttr)
|
||||
|
||||
@@ -140,6 +140,8 @@ public:
|
||||
bool hasCustomFontSizes(RiaDefines::FontSettingType fontSettingType, int defaultFontSize) const override;
|
||||
bool applyFontSize(RiaDefines::FontSettingType fontSettingType, int oldFontSize, int fontSize, bool forceChange = false) override;
|
||||
|
||||
bool isNormalizationEnabled();
|
||||
void showLegend(bool enable);
|
||||
public:
|
||||
// Rim2dPlotInterface overrides
|
||||
void updateAxisScaling() override;
|
||||
@@ -148,7 +150,6 @@ public:
|
||||
void selectAxisInPropertyEditor(int axis) override;
|
||||
void setAutoZoomForAllAxes(bool enableAutoZoom) override;
|
||||
caf::PdmObject* findRimPlotObjectFromQwtCurve(const QwtPlotCurve* curve) const override;
|
||||
void showLegend(bool enable);
|
||||
|
||||
public:
|
||||
// RimViewWindow overrides
|
||||
@@ -195,6 +196,8 @@ private:
|
||||
private:
|
||||
caf::PdmField<bool> m_showPlotTitle;
|
||||
caf::PdmField<bool> m_showLegend;
|
||||
caf::PdmField<bool> m_normalizeCurveYValues;
|
||||
|
||||
caf::PdmField<int> m_legendFontSize;
|
||||
|
||||
caf::PdmField<bool> m_useAutoPlotTitle;
|
||||
|
||||
Reference in New Issue
Block a user