mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
192 lines
6.7 KiB
C++
192 lines
6.7 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2017 Statoil ASA
|
|
//
|
|
// 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 "RimWellFlowRateCurve.h"
|
|
|
|
#include "RimWellAllocationPlot.h"
|
|
|
|
#include "RiuLineSegmentQwtPlotCurve.h"
|
|
|
|
#include "qwt_plot.h"
|
|
#include "RimWellLogPlot.h"
|
|
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
|
|
#include "RimWellLogTrack.h"
|
|
|
|
|
|
|
|
//==================================================================================================
|
|
///
|
|
///
|
|
//==================================================================================================
|
|
|
|
CAF_PDM_SOURCE_INIT(RimWellFlowRateCurve, "RimWellFlowRateCurve");
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimWellFlowRateCurve::RimWellFlowRateCurve()
|
|
{
|
|
CAF_PDM_InitObject("Flow Rate Curve", "", "", "");
|
|
m_curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimWellFlowRateCurve::~RimWellFlowRateCurve()
|
|
{
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QString RimWellFlowRateCurve::wellName() const
|
|
{
|
|
QString name;
|
|
|
|
RimWellAllocationPlot* wap = wellAllocationPlot();
|
|
|
|
if (wap)
|
|
{
|
|
name = wap->wellName();
|
|
}
|
|
else
|
|
{
|
|
name = "Undefined";
|
|
}
|
|
|
|
return name;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QString RimWellFlowRateCurve::wellLogChannelName() const
|
|
{
|
|
return "AccumulatedFlowRate";
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QString RimWellFlowRateCurve::createCurveAutoName()
|
|
{
|
|
return m_tracerName;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellFlowRateCurve::onLoadDataAndUpdate()
|
|
{
|
|
RimWellLogCurve::updateCurvePresentation();
|
|
|
|
if (isCurveVisible())
|
|
{
|
|
m_qwtPlotCurve->setTitle(createCurveAutoName());
|
|
|
|
updateStackedPlotData();
|
|
|
|
updateZoomInParentPlot();
|
|
|
|
if (m_parentQwtPlot) m_parentQwtPlot->replot();
|
|
}
|
|
}
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellFlowRateCurve::updateCurveAppearance()
|
|
{
|
|
RimWellLogCurve::updateCurveAppearance();
|
|
|
|
m_qwtPlotCurve->setStyle(QwtPlotCurve::Steps);
|
|
QColor curveQColor = QColor (m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte());
|
|
m_qwtPlotCurve->setBrush(QBrush( curveQColor));
|
|
|
|
QPen curvePen = m_qwtPlotCurve->pen();
|
|
curvePen.setColor(curveQColor.darker());
|
|
m_qwtPlotCurve->setPen(curvePen);
|
|
m_qwtPlotCurve->setOrientation(Qt::Horizontal);
|
|
m_qwtPlotCurve->setBaseline(0.0);
|
|
m_qwtPlotCurve->setCurveAttribute(QwtPlotCurve::Inverted, true);
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellFlowRateCurve::updateStackedPlotData()
|
|
{
|
|
RimWellLogTrack* wellLogTrack;
|
|
firstAncestorOrThisOfType(wellLogTrack);
|
|
|
|
RimDefines::DepthUnitType displayUnit = RimDefines::UNIT_METER;
|
|
|
|
std::vector<double> depthValues = m_curveData->measuredDepthPlotValues(displayUnit);
|
|
if (depthValues.size()) depthValues.insert(depthValues.begin(), depthValues[0]); // Insert the first depth position again, to make room for a real 0 value
|
|
std::vector<double> stackedValues(depthValues.size(), 0.0);
|
|
|
|
std::vector<RimWellFlowRateCurve*> stackedCurves = wellLogTrack->visibleStackedCurves();
|
|
double zPos = -0.1;
|
|
for ( RimWellFlowRateCurve * stCurve: stackedCurves )
|
|
{
|
|
std::vector<double> values = stCurve->curveData()->xPlotValues();
|
|
for ( size_t i = 0; i < values.size(); ++i )
|
|
{
|
|
stackedValues[i+1] += values[i];
|
|
}
|
|
|
|
if ( stCurve == this ) break;
|
|
zPos -= 1.0;
|
|
}
|
|
|
|
|
|
m_qwtPlotCurve->setSamples(stackedValues.data(), depthValues.data(), static_cast<int>(depthValues.size()));
|
|
|
|
std::vector< std::pair<size_t, size_t> > polyLineStartStopIndices = m_curveData->polylineStartStopIndices();
|
|
polyLineStartStopIndices.front().second += 1;
|
|
m_qwtPlotCurve->setLineSegmentStartStopIndices(polyLineStartStopIndices);
|
|
|
|
m_qwtPlotCurve->setZ(zPos);
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimWellAllocationPlot* RimWellFlowRateCurve::wellAllocationPlot() const
|
|
{
|
|
RimWellAllocationPlot* wap = nullptr;
|
|
this->firstAncestorOrThisOfType(wap);
|
|
|
|
return wap;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellFlowRateCurve::setFlowValues(const QString& tracerName, const std::vector<double>& measuredDepths, const std::vector<double>& flowRates)
|
|
{
|
|
m_curveData = new RigWellLogCurveData;
|
|
m_curveData->setValuesAndMD(flowRates, measuredDepths, RimDefines::UNIT_METER, false);
|
|
|
|
m_tracerName = tracerName;
|
|
}
|
|
|