From ae1eea4ac67d2e794e834bbf2c706faa61ff7ddb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 12 Oct 2016 13:49:57 +0200 Subject: [PATCH] #779 Added support for filtering of zero and negative values in setSamplesFromDateAndValues --- .../ProjectDataModel/RimSummaryCurve.cpp | 8 ++++++-- .../ProjectDataModel/RimSummaryPlot.cpp | 15 +++++++++++++++ ApplicationCode/ProjectDataModel/RimSummaryPlot.h | 1 + .../ReservoirDataModel/RigCurveDataTools.cpp | 14 +++++++++++++- .../ReservoirDataModel/RigCurveDataTools.h | 3 ++- .../ReservoirDataModel/RigWellLogCurveData.cpp | 2 +- .../RimWellLogExtractionCurveImpl-Test.cpp | 4 ++-- .../UserInterface/RiuLineSegmentQwtPlotCurve.cpp | 7 ++----- .../UserInterface/RiuLineSegmentQwtPlotCurve.h | 2 +- .../UserInterface/RiuResultQwtPlot.cpp | 2 +- 10 files changed, 44 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCurve.cpp b/ApplicationCode/ProjectDataModel/RimSummaryCurve.cpp index c2516eb226..d28580b5f4 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimSummaryCurve.cpp @@ -377,13 +377,17 @@ void RimSummaryCurve::onLoadDataAndUpdate() std::vector dateTimes; std::vector values; + RimSummaryPlot* plot = nullptr; + firstAncestorOrThisOfType(plot); + bool isLogCurve = plot->isLogarithmicScaleEnabled(this->associatedPlotAxis()); + if(this->curveData(&dateTimes, &values)) { - m_qwtPlotCurve->setSamplesFromDateAndValues(dateTimes, values); + m_qwtPlotCurve->setSamplesFromDateAndValues(dateTimes, values, isLogCurve); } else { - m_qwtPlotCurve->setSamplesFromDateAndValues(std::vector(), std::vector()); + m_qwtPlotCurve->setSamplesFromDateAndValues(std::vector(), std::vector(), isLogCurve); } updateZoomInParentPlot(); diff --git a/ApplicationCode/ProjectDataModel/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/RimSummaryPlot.cpp index 1399d462ef..c773ce662b 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimSummaryPlot.cpp @@ -125,6 +125,21 @@ void RimSummaryPlot::updateAxes() updateZoomInQwt(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryPlot::isLogarithmicScaleEnabled(RimDefines::PlotAxis plotAxis) const +{ + if (plotAxis == RimDefines::PLOT_AXIS_LEFT) + { + return m_leftYAxisProperties->isLogarithmicScaleEnabled(); + } + else + { + return m_rightYAxisProperties->isLogarithmicScaleEnabled(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/RimSummaryPlot.h index 4b790bf62b..d83834722f 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/RimSummaryPlot.h @@ -72,6 +72,7 @@ public: void disableAutoZoom(); void updateAxes(); + bool isLogarithmicScaleEnabled(RimDefines::PlotAxis plotAxis) const; protected: // Overridden PDM methods diff --git a/ApplicationCode/ReservoirDataModel/RigCurveDataTools.cpp b/ApplicationCode/ReservoirDataModel/RigCurveDataTools.cpp index b9a856afa4..b9811afe78 100644 --- a/ApplicationCode/ReservoirDataModel/RigCurveDataTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCurveDataTools.cpp @@ -25,7 +25,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector& values, std::vector< std::pair >* intervals) +void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector& values, std::vector< std::pair >* intervals, bool removeNegativeValues) { CVF_ASSERT(intervals); @@ -36,7 +36,19 @@ void RigCurveDataTools::calculateIntervalsOfValidValues(const std::vector= 0) { diff --git a/ApplicationCode/ReservoirDataModel/RigCurveDataTools.h b/ApplicationCode/ReservoirDataModel/RigCurveDataTools.h index 8633ad0a05..e1a8155503 100644 --- a/ApplicationCode/ReservoirDataModel/RigCurveDataTools.h +++ b/ApplicationCode/ReservoirDataModel/RigCurveDataTools.h @@ -32,7 +32,8 @@ class RigCurveDataTools { public: static void calculateIntervalsOfValidValues(const std::vector& values, - std::vector< std::pair >* intervals); + std::vector< std::pair >* intervals, + bool removeNegativeValues); template static void getValuesByIntervals(const std::vector& values, diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp index d0c0a065c0..365d5ce437 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellLogCurveData.cpp @@ -250,7 +250,7 @@ cvf::ref RigWellLogCurveData::calculateResampledCurveData(d void RigWellLogCurveData::calculateIntervalsOfContinousValidValues() { std::vector< std::pair > intervalsOfValidValues; - RigCurveDataTools::calculateIntervalsOfValidValues(m_xValues, &intervalsOfValidValues); + RigCurveDataTools::calculateIntervalsOfValidValues(m_xValues, &intervalsOfValidValues, false); m_intervalsOfContinousValidValues.clear(); diff --git a/ApplicationCode/UnitTests/RimWellLogExtractionCurveImpl-Test.cpp b/ApplicationCode/UnitTests/RimWellLogExtractionCurveImpl-Test.cpp index f38c69b79c..22a772be70 100644 --- a/ApplicationCode/UnitTests/RimWellLogExtractionCurveImpl-Test.cpp +++ b/ApplicationCode/UnitTests/RimWellLogExtractionCurveImpl-Test.cpp @@ -19,7 +19,7 @@ TEST(RimWellLogExtractionCurveImplTest, StripOffInvalidValAtEndsOfVector) values.push_back(HUGE_VAL); std::vector< std::pair > valuesIntervals; - RigCurveDataTools::calculateIntervalsOfValidValues(values, &valuesIntervals); + RigCurveDataTools::calculateIntervalsOfValidValues(values, &valuesIntervals, false); EXPECT_EQ(1, static_cast(valuesIntervals.size())); EXPECT_EQ(2, static_cast(valuesIntervals[0].first)); @@ -43,7 +43,7 @@ TEST(RimWellLogExtractionCurveImplTest, StripOffHugeValAtEndsAndInteriorOfVector values.push_back(HUGE_VAL); std::vector< std::pair > valuesIntervals; - RigCurveDataTools::calculateIntervalsOfValidValues(values, &valuesIntervals); + RigCurveDataTools::calculateIntervalsOfValidValues(values, &valuesIntervals, false); EXPECT_EQ(2, static_cast(valuesIntervals.size())); EXPECT_EQ(2, static_cast(valuesIntervals[0].first)); diff --git a/ApplicationCode/UserInterface/RiuLineSegmentQwtPlotCurve.cpp b/ApplicationCode/UserInterface/RiuLineSegmentQwtPlotCurve.cpp index 67198f7a48..f8df499aad 100644 --- a/ApplicationCode/UserInterface/RiuLineSegmentQwtPlotCurve.cpp +++ b/ApplicationCode/UserInterface/RiuLineSegmentQwtPlotCurve.cpp @@ -51,7 +51,7 @@ RiuLineSegmentQwtPlotCurve::~RiuLineSegmentQwtPlotCurve() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuLineSegmentQwtPlotCurve::setSamplesFromDateAndValues(const std::vector& dateTimes, const std::vector& timeHistoryValues) +void RiuLineSegmentQwtPlotCurve::setSamplesFromDateAndValues(const std::vector& dateTimes, const std::vector& timeHistoryValues, bool removeNegativeValues) { CVF_ASSERT(dateTimes.size() == timeHistoryValues.size()); @@ -63,7 +63,7 @@ void RiuLineSegmentQwtPlotCurve::setSamplesFromDateAndValues(const std::vector > intervalsOfValidValues; - RigCurveDataTools::calculateIntervalsOfValidValues(timeHistoryValues, &intervalsOfValidValues); + RigCurveDataTools::calculateIntervalsOfValidValues(timeHistoryValues, &intervalsOfValidValues, removeNegativeValues); RigCurveDataTools::getValuesByIntervals(timeHistoryValues, intervalsOfValidValues, &filteredTimeHistoryValues); RigCurveDataTools::getValuesByIntervals(dateTimes, intervalsOfValidValues, &filteredDateTimes); @@ -79,11 +79,8 @@ void RiuLineSegmentQwtPlotCurve::setSamplesFromDateAndValues(const std::vectorsetSamples(points); this->setLineSegmentStartStopIndices(filteredIntervals); - } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuLineSegmentQwtPlotCurve.h b/ApplicationCode/UserInterface/RiuLineSegmentQwtPlotCurve.h index 687de79cd5..4f0439d24b 100644 --- a/ApplicationCode/UserInterface/RiuLineSegmentQwtPlotCurve.h +++ b/ApplicationCode/UserInterface/RiuLineSegmentQwtPlotCurve.h @@ -47,7 +47,7 @@ public: explicit RiuLineSegmentQwtPlotCurve(const QString &title = QString::null); virtual ~RiuLineSegmentQwtPlotCurve(); - void setSamplesFromDateAndValues(const std::vector& dateTimes, const std::vector& timeHistoryValues); + void setSamplesFromDateAndValues(const std::vector& dateTimes, const std::vector& timeHistoryValues, bool removeNegativeValues); void setLineSegmentStartStopIndices(const std::vector< std::pair >& lineSegmentStartStopIndices); diff --git a/ApplicationCode/UserInterface/RiuResultQwtPlot.cpp b/ApplicationCode/UserInterface/RiuResultQwtPlot.cpp index a7ec0e57c3..07b1b36ef7 100644 --- a/ApplicationCode/UserInterface/RiuResultQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuResultQwtPlot.cpp @@ -66,7 +66,7 @@ void RiuResultQwtPlot::addCurve(const QString& curveName, const cvf::Color3f& cu { RiuLineSegmentQwtPlotCurve* plotCurve = new RiuLineSegmentQwtPlotCurve("Curve 1"); - plotCurve->setSamplesFromDateAndValues(dateTimes, timeHistoryValues); + plotCurve->setSamplesFromDateAndValues(dateTimes, timeHistoryValues, false); plotCurve->setTitle(curveName); plotCurve->setPen(QPen(QColor(curveColor.rByte(), curveColor.gByte(), curveColor.bByte())));