mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#779 Added support for filtering of zero and negative values in setSamplesFromDateAndValues
This commit is contained in:
parent
ee367487de
commit
ae1eea4ac6
@ -377,13 +377,17 @@ void RimSummaryCurve::onLoadDataAndUpdate()
|
|||||||
std::vector<QDateTime> dateTimes;
|
std::vector<QDateTime> dateTimes;
|
||||||
std::vector<double> values;
|
std::vector<double> values;
|
||||||
|
|
||||||
|
RimSummaryPlot* plot = nullptr;
|
||||||
|
firstAncestorOrThisOfType(plot);
|
||||||
|
bool isLogCurve = plot->isLogarithmicScaleEnabled(this->associatedPlotAxis());
|
||||||
|
|
||||||
if(this->curveData(&dateTimes, &values))
|
if(this->curveData(&dateTimes, &values))
|
||||||
{
|
{
|
||||||
m_qwtPlotCurve->setSamplesFromDateAndValues(dateTimes, values);
|
m_qwtPlotCurve->setSamplesFromDateAndValues(dateTimes, values, isLogCurve);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_qwtPlotCurve->setSamplesFromDateAndValues(std::vector<QDateTime>(), std::vector<double>());
|
m_qwtPlotCurve->setSamplesFromDateAndValues(std::vector<QDateTime>(), std::vector<double>(), isLogCurve);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateZoomInParentPlot();
|
updateZoomInParentPlot();
|
||||||
|
@ -125,6 +125,21 @@ void RimSummaryPlot::updateAxes()
|
|||||||
updateZoomInQwt();
|
updateZoomInQwt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RimSummaryPlot::isLogarithmicScaleEnabled(RimDefines::PlotAxis plotAxis) const
|
||||||
|
{
|
||||||
|
if (plotAxis == RimDefines::PLOT_AXIS_LEFT)
|
||||||
|
{
|
||||||
|
return m_leftYAxisProperties->isLogarithmicScaleEnabled();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return m_rightYAxisProperties->isLogarithmicScaleEnabled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -72,6 +72,7 @@ public:
|
|||||||
void disableAutoZoom();
|
void disableAutoZoom();
|
||||||
|
|
||||||
void updateAxes();
|
void updateAxes();
|
||||||
|
bool isLogarithmicScaleEnabled(RimDefines::PlotAxis plotAxis) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overridden PDM methods
|
// Overridden PDM methods
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double>& values, std::vector< std::pair<size_t, size_t> >* intervals)
|
void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double>& values, std::vector< std::pair<size_t, size_t> >* intervals, bool removeNegativeValues)
|
||||||
{
|
{
|
||||||
CVF_ASSERT(intervals);
|
CVF_ASSERT(intervals);
|
||||||
|
|
||||||
@ -36,7 +36,19 @@ void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector<double
|
|||||||
while (vIdx < valueCount)
|
while (vIdx < valueCount)
|
||||||
{
|
{
|
||||||
double value = values[vIdx];
|
double value = values[vIdx];
|
||||||
|
|
||||||
|
bool isInvalidValueDetected = false;
|
||||||
if (value == HUGE_VAL || value == -HUGE_VAL || value != value)
|
if (value == HUGE_VAL || value == -HUGE_VAL || value != value)
|
||||||
|
{
|
||||||
|
isInvalidValueDetected = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (removeNegativeValues && value <= 0.0)
|
||||||
|
{
|
||||||
|
isInvalidValueDetected = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isInvalidValueDetected)
|
||||||
{
|
{
|
||||||
if (startIdx >= 0)
|
if (startIdx >= 0)
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,8 @@ class RigCurveDataTools
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void calculateIntervalsOfValidValues(const std::vector<double>& values,
|
static void calculateIntervalsOfValidValues(const std::vector<double>& values,
|
||||||
std::vector< std::pair<size_t, size_t> >* intervals);
|
std::vector< std::pair<size_t, size_t> >* intervals,
|
||||||
|
bool removeNegativeValues);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static void getValuesByIntervals(const std::vector<T>& values,
|
static void getValuesByIntervals(const std::vector<T>& values,
|
||||||
|
@ -250,7 +250,7 @@ cvf::ref<RigWellLogCurveData> RigWellLogCurveData::calculateResampledCurveData(d
|
|||||||
void RigWellLogCurveData::calculateIntervalsOfContinousValidValues()
|
void RigWellLogCurveData::calculateIntervalsOfContinousValidValues()
|
||||||
{
|
{
|
||||||
std::vector< std::pair<size_t, size_t> > intervalsOfValidValues;
|
std::vector< std::pair<size_t, size_t> > intervalsOfValidValues;
|
||||||
RigCurveDataTools::calculateIntervalsOfValidValues(m_xValues, &intervalsOfValidValues);
|
RigCurveDataTools::calculateIntervalsOfValidValues(m_xValues, &intervalsOfValidValues, false);
|
||||||
|
|
||||||
m_intervalsOfContinousValidValues.clear();
|
m_intervalsOfContinousValidValues.clear();
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ TEST(RimWellLogExtractionCurveImplTest, StripOffInvalidValAtEndsOfVector)
|
|||||||
values.push_back(HUGE_VAL);
|
values.push_back(HUGE_VAL);
|
||||||
|
|
||||||
std::vector< std::pair<size_t, size_t> > valuesIntervals;
|
std::vector< std::pair<size_t, size_t> > valuesIntervals;
|
||||||
RigCurveDataTools::calculateIntervalsOfValidValues(values, &valuesIntervals);
|
RigCurveDataTools::calculateIntervalsOfValidValues(values, &valuesIntervals, false);
|
||||||
|
|
||||||
EXPECT_EQ(1, static_cast<int>(valuesIntervals.size()));
|
EXPECT_EQ(1, static_cast<int>(valuesIntervals.size()));
|
||||||
EXPECT_EQ(2, static_cast<int>(valuesIntervals[0].first));
|
EXPECT_EQ(2, static_cast<int>(valuesIntervals[0].first));
|
||||||
@ -43,7 +43,7 @@ TEST(RimWellLogExtractionCurveImplTest, StripOffHugeValAtEndsAndInteriorOfVector
|
|||||||
values.push_back(HUGE_VAL);
|
values.push_back(HUGE_VAL);
|
||||||
|
|
||||||
std::vector< std::pair<size_t, size_t> > valuesIntervals;
|
std::vector< std::pair<size_t, size_t> > valuesIntervals;
|
||||||
RigCurveDataTools::calculateIntervalsOfValidValues(values, &valuesIntervals);
|
RigCurveDataTools::calculateIntervalsOfValidValues(values, &valuesIntervals, false);
|
||||||
|
|
||||||
EXPECT_EQ(2, static_cast<int>(valuesIntervals.size()));
|
EXPECT_EQ(2, static_cast<int>(valuesIntervals.size()));
|
||||||
EXPECT_EQ(2, static_cast<int>(valuesIntervals[0].first));
|
EXPECT_EQ(2, static_cast<int>(valuesIntervals[0].first));
|
||||||
|
@ -51,7 +51,7 @@ RiuLineSegmentQwtPlotCurve::~RiuLineSegmentQwtPlotCurve()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuLineSegmentQwtPlotCurve::setSamplesFromDateAndValues(const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues)
|
void RiuLineSegmentQwtPlotCurve::setSamplesFromDateAndValues(const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues, bool removeNegativeValues)
|
||||||
{
|
{
|
||||||
CVF_ASSERT(dateTimes.size() == timeHistoryValues.size());
|
CVF_ASSERT(dateTimes.size() == timeHistoryValues.size());
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ void RiuLineSegmentQwtPlotCurve::setSamplesFromDateAndValues(const std::vector<Q
|
|||||||
|
|
||||||
{
|
{
|
||||||
std::vector< std::pair<size_t, size_t> > intervalsOfValidValues;
|
std::vector< std::pair<size_t, size_t> > intervalsOfValidValues;
|
||||||
RigCurveDataTools::calculateIntervalsOfValidValues(timeHistoryValues, &intervalsOfValidValues);
|
RigCurveDataTools::calculateIntervalsOfValidValues(timeHistoryValues, &intervalsOfValidValues, removeNegativeValues);
|
||||||
|
|
||||||
RigCurveDataTools::getValuesByIntervals(timeHistoryValues, intervalsOfValidValues, &filteredTimeHistoryValues);
|
RigCurveDataTools::getValuesByIntervals(timeHistoryValues, intervalsOfValidValues, &filteredTimeHistoryValues);
|
||||||
RigCurveDataTools::getValuesByIntervals(dateTimes, intervalsOfValidValues, &filteredDateTimes);
|
RigCurveDataTools::getValuesByIntervals(dateTimes, intervalsOfValidValues, &filteredDateTimes);
|
||||||
@ -79,11 +79,8 @@ void RiuLineSegmentQwtPlotCurve::setSamplesFromDateAndValues(const std::vector<Q
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RiuLineSegmentQwtPlotCurve* plotCurve = new RiuLineSegmentQwtPlotCurve("Curve 1");
|
|
||||||
|
|
||||||
this->setSamples(points);
|
this->setSamples(points);
|
||||||
this->setLineSegmentStartStopIndices(filteredIntervals);
|
this->setLineSegmentStartStopIndices(filteredIntervals);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
explicit RiuLineSegmentQwtPlotCurve(const QString &title = QString::null);
|
explicit RiuLineSegmentQwtPlotCurve(const QString &title = QString::null);
|
||||||
virtual ~RiuLineSegmentQwtPlotCurve();
|
virtual ~RiuLineSegmentQwtPlotCurve();
|
||||||
|
|
||||||
void setSamplesFromDateAndValues(const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues);
|
void setSamplesFromDateAndValues(const std::vector<QDateTime>& dateTimes, const std::vector<double>& timeHistoryValues, bool removeNegativeValues);
|
||||||
|
|
||||||
void setLineSegmentStartStopIndices(const std::vector< std::pair<size_t, size_t> >& lineSegmentStartStopIndices);
|
void setLineSegmentStartStopIndices(const std::vector< std::pair<size_t, size_t> >& lineSegmentStartStopIndices);
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ void RiuResultQwtPlot::addCurve(const QString& curveName, const cvf::Color3f& cu
|
|||||||
{
|
{
|
||||||
RiuLineSegmentQwtPlotCurve* plotCurve = new RiuLineSegmentQwtPlotCurve("Curve 1");
|
RiuLineSegmentQwtPlotCurve* plotCurve = new RiuLineSegmentQwtPlotCurve("Curve 1");
|
||||||
|
|
||||||
plotCurve->setSamplesFromDateAndValues(dateTimes, timeHistoryValues);
|
plotCurve->setSamplesFromDateAndValues(dateTimes, timeHistoryValues, false);
|
||||||
plotCurve->setTitle(curveName);
|
plotCurve->setTitle(curveName);
|
||||||
|
|
||||||
plotCurve->setPen(QPen(QColor(curveColor.rByte(), curveColor.gByte(), curveColor.bByte())));
|
plotCurve->setPen(QPen(QColor(curveColor.rByte(), curveColor.gByte(), curveColor.bByte())));
|
||||||
|
Loading…
Reference in New Issue
Block a user