From 3c00a8394d19bf12dd352aa426061978cec38983 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 6 Nov 2015 08:32:58 +0100 Subject: [PATCH] Refactored and renamed to RuiLineSegmentQwtPlotCurve --- .../ProjectDataModel/RimWellLogCurve.cpp | 4 +-- .../ProjectDataModel/RimWellLogCurve.h | 4 +-- .../RimWellLogExtractionCurve.cpp | 2 +- .../ProjectDataModel/RimWellLogFileCurve.cpp | 2 +- ...rve.cpp => RiuLineSegmentQwtPlotCurve.cpp} | 26 ++++++++++------- ...ogCurve.h => RiuLineSegmentQwtPlotCurve.h} | 28 ++++++++++++++----- 6 files changed, 43 insertions(+), 23 deletions(-) rename ApplicationCode/UserInterface/{RiuWellLogCurve.cpp => RiuLineSegmentQwtPlotCurve.cpp} (70%) rename ApplicationCode/UserInterface/{RiuWellLogCurve.h => RiuLineSegmentQwtPlotCurve.h} (60%) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogCurve.cpp index 144b5021d8..1ff66f5720 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurve.cpp @@ -23,7 +23,7 @@ #include "RimWellLogTrack.h" -#include "RiuWellLogCurve.h" +#include "RiuLineSegmentQwtPlotCurve.h" #include "RiuWellLogTrack.h" #include "cvfAssert.h" @@ -49,7 +49,7 @@ RimWellLogCurve::RimWellLogCurve() CAF_PDM_InitField(&m_curveColor, "Color", cvf::Color3f(cvf::Color3::BLACK), "Color", "", "", ""); - m_qwtPlotCurve = new RiuWellLogCurve; + m_qwtPlotCurve = new RiuLineSegmentQwtPlotCurve; m_qwtPlotCurve->setXAxis(QwtPlot::xTop); m_qwtPlotCurve->setYAxis(QwtPlot::yLeft); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogCurve.h index cb4780bc34..c7ff0a6e43 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurve.h @@ -29,7 +29,7 @@ class RigWellLogCurveData; class RiuWellLogTrack; -class RiuWellLogCurve; +class RiuLineSegmentQwtPlotCurve; class QwtPlotCurve; class QString; @@ -82,7 +82,7 @@ protected: QPointer m_ownerQwtTrack; - RiuWellLogCurve* m_qwtPlotCurve; + RiuLineSegmentQwtPlotCurve* m_qwtPlotCurve; cvf::ref m_curveData; caf::PdmField m_showCurve; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index 16193b5098..fbca8f08ba 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp @@ -46,7 +46,7 @@ #include "RimGeoMechView.h" #include "RimGeoMechCellColors.h" -#include "RiuWellLogCurve.h" +#include "RiuLineSegmentQwtPlotCurve.h" #include "RiuWellLogTrack.h" #include "cafPdmUiTreeOrdering.h" diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp index 46aca9455b..ca8abfa5f5 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp @@ -29,7 +29,7 @@ #include "RimWellLogPlot.h" #include "RiuWellLogTrack.h" -#include "RiuWellLogCurve.h" +#include "RiuLineSegmentQwtPlotCurve.h" #include "RiaApplication.h" #include "RiaPreferences.h" diff --git a/ApplicationCode/UserInterface/RiuWellLogCurve.cpp b/ApplicationCode/UserInterface/RiuLineSegmentQwtPlotCurve.cpp similarity index 70% rename from ApplicationCode/UserInterface/RiuWellLogCurve.cpp rename to ApplicationCode/UserInterface/RiuLineSegmentQwtPlotCurve.cpp index a4ec3ea0e2..25ab39b761 100644 --- a/ApplicationCode/UserInterface/RiuWellLogCurve.cpp +++ b/ApplicationCode/UserInterface/RiuLineSegmentQwtPlotCurve.cpp @@ -17,7 +17,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RiuWellLogCurve.h" +#include "RiuLineSegmentQwtPlotCurve.h" #include "RigWellLogCurveData.h" @@ -25,21 +25,21 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuWellLogCurve::RiuWellLogCurve() +RiuLineSegmentQwtPlotCurve::RiuLineSegmentQwtPlotCurve() { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuWellLogCurve::~RiuWellLogCurve() +RiuLineSegmentQwtPlotCurve::~RiuLineSegmentQwtPlotCurve() { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellLogCurve::drawCurve(QPainter* p, int style, +void RiuLineSegmentQwtPlotCurve::drawCurve(QPainter* p, int style, const QwtScaleMap& xMap, const QwtScaleMap& yMap, const QRectF& canvasRect, int from, int to) const { @@ -57,13 +57,19 @@ void RiuWellLogCurve::drawCurve(QPainter* p, int style, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuWellLogCurve::setCurveData(const RigWellLogCurveData* curveData) +void RiuLineSegmentQwtPlotCurve::setCurveData(const RigWellLogCurveData* curveData) { CVF_ASSERT(curveData); - std::vector validXValues = curveData->xPlotValues(); - std::vector validYValues = curveData->depthPlotValues(); - - setSamples(validXValues.data(), validYValues.data(), (int) validXValues.size()); - m_polyLineStartStopIndices = curveData->polylineStartStopIndices(); + setCurveData(curveData->xPlotValues(), curveData->depthPlotValues(), curveData->polylineStartStopIndices()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuLineSegmentQwtPlotCurve::setCurveData(const std::vector& xValues, const std::vector& yValues, const std::vector< std::pair >& lineSegmentStartStopIndices) +{ + setSamples(xValues.data(), yValues.data(), static_cast(xValues.size())); + + m_polyLineStartStopIndices = lineSegmentStartStopIndices; } diff --git a/ApplicationCode/UserInterface/RiuWellLogCurve.h b/ApplicationCode/UserInterface/RiuLineSegmentQwtPlotCurve.h similarity index 60% rename from ApplicationCode/UserInterface/RiuWellLogCurve.h rename to ApplicationCode/UserInterface/RiuLineSegmentQwtPlotCurve.h index e08122864f..dd40ad1de7 100644 --- a/ApplicationCode/UserInterface/RiuWellLogCurve.h +++ b/ApplicationCode/UserInterface/RiuLineSegmentQwtPlotCurve.h @@ -26,20 +26,34 @@ class RigWellLogCurveData; //================================================================================================== -/// -/// +// +// The PlotCurve class is able to draw a curve using line segments. If inf data is present +// in the curve data, Qwt is not able to draw a nice curve. This class assumes that inf data is removed, +// and segments to be draw are indicated by start/stop indices into curve data. +// +// Here you can see the curve segments visualized. Curve segments are drawn between vector indices. +// +// 0 - 1 +// 5 - 7 +// 9 -10 +// +// * * +// / / \ +// Curve * * * *---* +// +// Values 1.0|2.0|inf|inf|inf|1.0|2.0|1.0|inf|1.0|1.0 +// Vec index 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 //================================================================================================== -class RiuWellLogCurve : public QwtPlotCurve +class RiuLineSegmentQwtPlotCurve : public QwtPlotCurve { public: - - RiuWellLogCurve(); - virtual ~RiuWellLogCurve(); + RiuLineSegmentQwtPlotCurve(); + virtual ~RiuLineSegmentQwtPlotCurve(); void setCurveData(const RigWellLogCurveData* curveData); + void setCurveData(const std::vector& xValues, const std::vector& yValues, const std::vector< std::pair >& lineSegmentStartStopIndices); protected: - virtual void drawCurve(QPainter* p, int style, const QwtScaleMap& xMap, const QwtScaleMap& yMap, const QRectF& canvasRect, int from, int to) const;