(#459) Added support for plotting of discontinuous curves

This commit is contained in:
Pål Hagen committed 2015-09-17 18:42:35 +02:00
1 parent 3d09ceb92b
commit ffbc4f13e7
8 files changed
+233 -28

No files matched your search

@@ -36,7 +36,8 @@
#include "RimWellLogPlotTrace.h"
#include "RiuWellLogTracePlot.h"
#include "qwt_plot_curve.h"
#include "RiuWellLogPlotCurve.h"
#include "RimWellLogPlotCollection.h"
#include "cafPdmUiTreeOrdering.h"
#include "RigGeoMechWellLogExtractor.h"
@@ -132,6 +133,7 @@ void RimWellLogExtractionCurve::updatePlotData()
std::vector<double> filteredValues;
std::vector<double> filteredDepths;
std::vector< std::pair<size_t, size_t> > plotIntervals;
if (eclExtractor.notNull())
{
@@ -157,24 +159,34 @@ void RimWellLogExtractionCurve::updatePlotData()
eclExtractor->curveData(resAcc.p(), &values);
}
filterPlotValues( depthValues, filteredDepths,
values, filteredValues );
if (values.size() == depthValues.size())
{
validCurvePointIntervals(depthValues, values, plotIntervals);
addValuesFromIntervals(depthValues, plotIntervals, &filteredDepths);
addValuesFromIntervals(values, plotIntervals, &filteredValues);
}
}
else if (geomExtractor.notNull()) // geomExtractor
{
const std::vector<double>& depthValues = geomExtractor->measuredDepth();
m_geomResultDefinition->loadResult();
std::vector<double> values;
geomExtractor->curveData(m_geomResultDefinition->resultAddress() , m_timeStep, &values);
geomExtractor->curveData(m_geomResultDefinition->resultAddress(), m_timeStep, &values);
filterPlotValues( depthValues, filteredDepths,
values, filteredValues );
if (values.size() == depthValues.size())
{
validCurvePointIntervals(depthValues, values, plotIntervals);
addValuesFromIntervals(depthValues, plotIntervals, &filteredDepths);
addValuesFromIntervals(values, plotIntervals, &filteredValues);
}
}
m_plotCurve->setSamples(filteredValues.data(), filteredDepths.data(), (int)filteredValues.size());
std::vector< std::pair<size_t, size_t> > fltrIntervals;
filteredIntervals(plotIntervals, &fltrIntervals);
m_plotCurve->setPlotIntervals(fltrIntervals);
if (filteredValues.size())
{
@@ -331,23 +343,97 @@ void RimWellLogExtractionCurve::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiT
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::filterPlotValues(const std::vector<double>& depthValues, std::vector<double> &filteredDepths,
const std::vector<double> &values, std::vector<double> &filteredValues )
void RimWellLogExtractionCurve::validCurvePointIntervals(const std::vector<double>& depthValues, const std::vector<double>& values, std::vector< std::pair<size_t, size_t> >& intervals)
{
// Remove values that are too difficult for Qwt to handle
const size_t valuesCount = values.size();
CVF_ASSERT(valuesCount == depthValues.size());
filteredValues.reserve(values.size());
filteredDepths.reserve(values.size());
for (size_t vIdx = 0; vIdx < values.size(); ++vIdx)
// !! TODO: Find a reasonable tolerance
const double depthDiffTolerance = 0.1;
// Find intervals containing valid depth values
std::vector< std::pair<size_t, size_t> > validDepthIntervals;
size_t validDepthStartIdx = 0;
for (size_t vIdx = 1; vIdx < valuesCount - 1; vIdx += 2)
{
if (values[vIdx] == HUGE_VAL || values[vIdx] == -HUGE_VAL || (values[vIdx] != values[vIdx]))
if (abs(depthValues[vIdx + 1] - depthValues[vIdx]) > depthDiffTolerance)
{
continue;
validDepthIntervals.push_back(std::make_pair(validDepthStartIdx, vIdx));
validDepthStartIdx = vIdx + 1;
}
}
filteredDepths.push_back(depthValues[vIdx]);
filteredValues.push_back(values[vIdx]);
if (validDepthStartIdx > 0 && validDepthStartIdx < valuesCount)
{
validDepthIntervals.push_back(std::make_pair(validDepthStartIdx, valuesCount - 1));
}
// Find intervals containing valid values within intervals of valid depth values
for (size_t intIdx = 0; intIdx < validDepthIntervals.size(); intIdx++)
{
size_t intervalIdx1 = validDepthIntervals[intIdx].first;
bool prevValueValid = false;
for (size_t vIdx = validDepthIntervals[intIdx].first; vIdx <= validDepthIntervals[intIdx].second; vIdx++)
{
double value = values[vIdx];
if (value == HUGE_VAL || value == -HUGE_VAL || value != value)
{
if (prevValueValid && vIdx > intervalIdx1)
{
intervals.push_back(std::make_pair(intervalIdx1, vIdx - 1));
}
else intervalIdx1 = vIdx + 1;
prevValueValid = false;
}
else
{
prevValueValid = true;
}
}
if (intIdx == validDepthIntervals.size() - 1)
{
if (intervalIdx1 >= validDepthIntervals[intIdx].first && intervalIdx1 <= validDepthIntervals[intIdx].second)
{
intervals.push_back(std::make_pair(intervalIdx1, validDepthIntervals[intIdx].second));
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::addValuesFromIntervals(const std::vector<double>& values, std::vector< std::pair<size_t, size_t> >& intervals, std::vector<double>* filteredValues)
{
CVF_ASSERT(filteredValues);
for (size_t intIdx = 0; intIdx < intervals.size(); intIdx++)
{
for (size_t vIdx = intervals[intIdx].first; vIdx <= intervals[intIdx].second; vIdx++)
{
filteredValues->push_back(values[vIdx]);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::filteredIntervals(const std::vector< std::pair<size_t, size_t> >& intervals, std::vector< std::pair<size_t, size_t> >* fltrIntervals)
{
CVF_ASSERT(fltrIntervals);
const size_t intervalCount = intervals.size();
if (intervalCount < 1) return;
size_t index = 0;
for (size_t intIdx = 0; intIdx < intervalCount; intIdx++)
{
size_t intervalSize = intervals[intIdx].second - intervals[intIdx].first + 1;
fltrIntervals->push_back(std::make_pair(index, index + intervalSize - 1));
index += intervalSize;
}
}
@@ -53,14 +53,16 @@ protected:
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "");
void filterPlotValues(const std::vector<double>& depthValues, std::vector<double> &filteredDepths,
const std::vector<double> &values, std::vector<double> &filteredValues );
caf::PdmPtrField<RimWellPath*> m_wellPath;
caf::PdmPtrField<RimCase*> m_case;
caf::PdmChildField<RimEclipseResultDefinition*> m_eclipseResultDefinition;
caf::PdmChildField<RimGeoMechResultDefinition*> m_geomResultDefinition;
caf::PdmField<int> m_timeStep;
private:
static void validCurvePointIntervals(const std::vector<double>& depthValues, const std::vector<double>& values, std::vector< std::pair<size_t, size_t> >& intervals);
static void addValuesFromIntervals(const std::vector<double>& values, std::vector< std::pair<size_t, size_t> >& intervals, std::vector<double>* filteredValues);
static void filteredIntervals(const std::vector< std::pair<size_t, size_t> >& intervals, std::vector< std::pair<size_t, size_t> >* fltrIntervals);
};
@@ -29,13 +29,12 @@
#include "RimWellLogPlot.h"
#include "RiuWellLogTracePlot.h"
#include "RiuWellLogPlotCurve.h"
#include "RiaApplication.h"
#include "cafPdmUiTreeOrdering.h"
#include "qwt_plot_curve.h"
CAF_PDM_SOURCE_INIT(RimWellLogFileCurve, "WellLogFileCurve");
@@ -20,7 +20,8 @@
#include "RimWellLogPlotCurve.h"
#include "RimWellLogPlot.h"
#include "RiuWellLogTracePlot.h"
#include "qwt_plot_curve.h"
#include "RiuWellLogPlotCurve.h"
#include "cvfAssert.h"
CAF_PDM_SOURCE_INIT(RimWellLogPlotCurve, "WellLogPlotCurve");
@@ -38,7 +39,7 @@ RimWellLogPlotCurve::RimWellLogPlotCurve()
CAF_PDM_InitField(&m_curveColor, "Color", cvf::Color3f(cvf::Color3::BLACK), "Color", "", "", "");
m_plotCurve = new QwtPlotCurve;
m_plotCurve = new RiuWellLogPlotCurve;
m_plotCurve->setXAxis(QwtPlot::xTop);
m_plotCurve->setYAxis(QwtPlot::yLeft);
}
@@ -172,3 +173,11 @@ void RimWellLogPlotCurve::detachCurve()
m_plotCurve->detach();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QwtPlotCurve* RimWellLogPlotCurve::plotCurve() const
{
return m_plotCurve;
}
@@ -26,6 +26,7 @@
#include <vector>
class RiuWellLogTracePlot;
class RiuWellLogPlotCurve;
class QwtPlotCurve;
class QString;
@@ -48,7 +49,7 @@ public:
void setPlot(RiuWellLogTracePlot* plot);
void detachCurve();
QwtPlotCurve* plotCurve() const { return m_plotCurve; }
QwtPlotCurve* plotCurve() const;
virtual void updatePlotData();
@@ -68,5 +69,5 @@ protected:
// caf::PdmField<int> m_lineWidth;
RiuWellLogTracePlot* m_plot;
QwtPlotCurve* m_plotCurve;
RiuWellLogPlotCurve* m_plotCurve;
};