mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#459) Added support for plotting of discontinuous curves
This commit is contained in:
parent
3d09ceb92b
commit
ffbc4f13e7
@ -81,6 +81,8 @@ set( USER_INTERFACE_FILES
|
||||
UserInterface/RiuTreeViewEventFilter.h
|
||||
UserInterface/RiuWellLogPlot.cpp
|
||||
UserInterface/RiuWellLogPlot.h
|
||||
UserInterface/RiuWellLogPlotCurve.cpp
|
||||
UserInterface/RiuWellLogPlotCurve.h
|
||||
UserInterface/RiuWellLogTracePlot.cpp
|
||||
UserInterface/RiuWellLogTracePlot.h
|
||||
UserInterface/RiuProjectPropertyView.h
|
||||
|
@ -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;
|
||||
};
|
||||
|
60
ApplicationCode/UserInterface/RiuWellLogPlotCurve.cpp
Normal file
60
ApplicationCode/UserInterface/RiuWellLogPlotCurve.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiuWellLogPlotCurve.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWellLogPlotCurve::RiuWellLogPlotCurve()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWellLogPlotCurve::~RiuWellLogPlotCurve()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlotCurve::setPlotIntervals(const std::vector<std::pair<size_t, size_t>>& intervals)
|
||||
{
|
||||
m_intervals = intervals;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuWellLogPlotCurve::drawCurve(QPainter* p, int style,
|
||||
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
|
||||
const QRectF& canvasRect, int from, int to) const
|
||||
{
|
||||
size_t intervalCount = m_intervals.size();
|
||||
if (intervalCount > 0)
|
||||
{
|
||||
for (size_t intIdx = 0; intIdx < intervalCount; intIdx++)
|
||||
{
|
||||
QwtPlotCurve::drawCurve(p, style, xMap, yMap, canvasRect, (int) m_intervals[intIdx].first, (int) m_intervals[intIdx].second);
|
||||
}
|
||||
}
|
||||
else QwtPlotCurve::drawCurve(p, style, xMap, yMap, canvasRect, from, to);
|
||||
};
|
46
ApplicationCode/UserInterface/RiuWellLogPlotCurve.h
Normal file
46
ApplicationCode/UserInterface/RiuWellLogPlotCurve.h
Normal file
@ -0,0 +1,46 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "qwt_plot_curve.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RiuWellLogPlotCurve : public QwtPlotCurve
|
||||
{
|
||||
public:
|
||||
RiuWellLogPlotCurve();
|
||||
virtual ~RiuWellLogPlotCurve();
|
||||
|
||||
void setPlotIntervals(const std::vector<std::pair<size_t, size_t>>& intervals);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void drawCurve(QPainter* p, int style,
|
||||
const QwtScaleMap& xMap, const QwtScaleMap& yMap,
|
||||
const QRectF& canvasRect, int from, int to) const;
|
||||
|
||||
private:
|
||||
std::vector< std::pair<size_t, size_t> > m_intervals;
|
||||
};
|
Loading…
Reference in New Issue
Block a user