2019-11-12 07:29:06 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2019- Equinor 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 "RimWellDistributionPlot.h"
|
2019-12-11 02:38:25 -06:00
|
|
|
#include "RimEclipseResultCase.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimFlowDiagSolution.h"
|
2019-11-12 07:29:06 -06:00
|
|
|
|
2019-12-11 02:38:25 -06:00
|
|
|
#include "RigEclipseCaseData.h"
|
|
|
|
#include "RigTofWellDistributionCalculator.h"
|
|
|
|
|
|
|
|
#include "RiaColorTools.h"
|
|
|
|
|
2019-12-17 02:20:40 -06:00
|
|
|
#include "RiuQwtPlotWidget.h"
|
2019-12-11 02:38:25 -06:00
|
|
|
|
|
|
|
#include "qwt_plot.h"
|
|
|
|
#include "qwt_legend.h"
|
2019-12-17 02:20:40 -06:00
|
|
|
#include "qwt_legend_label.h"
|
2019-12-11 02:38:25 -06:00
|
|
|
#include "qwt_plot_curve.h"
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QTextBrowser>
|
|
|
|
|
2019-12-17 02:20:40 -06:00
|
|
|
//#include "cvfBase.h"
|
|
|
|
//#include "cvfTrace.h"
|
|
|
|
//#include "cvfDebugTimer.h"
|
|
|
|
|
|
|
|
#include <array>
|
2019-11-12 07:29:06 -06:00
|
|
|
|
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==================================================================================================
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimWellDistributionPlot, "WellDistributionPlot");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-12-17 02:20:40 -06:00
|
|
|
RimWellDistributionPlot::RimWellDistributionPlot(RiaDefines::PhaseType phase)
|
2019-11-12 07:29:06 -06:00
|
|
|
{
|
2019-12-17 02:20:40 -06:00
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::RimWellDistributionPlot()");
|
2019-12-11 02:38:25 -06:00
|
|
|
|
2019-11-12 07:29:06 -06:00
|
|
|
CAF_PDM_InitObject("Well Distribution Plot", "", "", "");
|
2019-12-11 02:38:25 -06:00
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_case, "Case", "Case", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_timeStepIndex, "TimeStepIndex", -1, "Time Step", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_wellName, "WellName", QString("None"), "Well", "", "", "");
|
2019-12-17 02:20:40 -06:00
|
|
|
CAF_PDM_InitField(&m_phase, "Phase", caf::AppEnum<RiaDefines::PhaseType>(phase), "Phase", "", "", "");
|
2019-12-17 08:43:05 -06:00
|
|
|
CAF_PDM_InitField(&m_groupSmallContributions, "GroupSmallContributions", true, "Group Small Contributions", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_smallContributionsRelativeThreshold, "SmallContributionsRelativeThreshold", 0.005, "Relative Threshold [0, 1]", "", "", "");
|
2019-12-11 02:38:25 -06:00
|
|
|
|
|
|
|
m_showWindow = false;
|
2019-12-17 02:20:40 -06:00
|
|
|
m_showPlotLegends = true;
|
2019-11-12 07:29:06 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellDistributionPlot::~RimWellDistributionPlot()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-12-17 02:20:40 -06:00
|
|
|
void RimWellDistributionPlot::setDataSourceParameters(RimEclipseResultCase* eclipseResultCase, int timeStepIndex, QString targetWellName)
|
2019-11-12 07:29:06 -06:00
|
|
|
{
|
2019-12-17 02:20:40 -06:00
|
|
|
m_case = eclipseResultCase;
|
|
|
|
m_timeStepIndex = timeStepIndex;
|
|
|
|
m_wellName = targetWellName;
|
2019-11-12 07:29:06 -06:00
|
|
|
}
|
|
|
|
|
2019-12-17 08:43:05 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellDistributionPlot::setPlotOptions(bool groupSmallContributions, double smallContributionsRelativeThreshold)
|
|
|
|
{
|
|
|
|
m_groupSmallContributions = groupSmallContributions;
|
|
|
|
m_smallContributionsRelativeThreshold = smallContributionsRelativeThreshold;
|
|
|
|
}
|
|
|
|
|
2019-11-12 07:29:06 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-12-17 02:20:40 -06:00
|
|
|
RiuQwtPlotWidget* RimWellDistributionPlot::viewer()
|
2019-11-12 07:29:06 -06:00
|
|
|
{
|
2019-12-17 02:20:40 -06:00
|
|
|
return m_plotWidget;
|
2019-11-12 07:29:06 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-12-17 02:20:40 -06:00
|
|
|
void RimWellDistributionPlot::setAutoScaleXEnabled(bool /*enabled*/)
|
2019-11-12 07:29:06 -06:00
|
|
|
{
|
2019-12-17 02:20:40 -06:00
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::setAutoScaleXEnabled()");
|
2019-11-12 07:29:06 -06:00
|
|
|
}
|
|
|
|
|
2019-12-11 02:38:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-12-17 02:20:40 -06:00
|
|
|
void RimWellDistributionPlot::setAutoScaleYEnabled(bool /*enabled*/)
|
2019-11-12 07:29:06 -06:00
|
|
|
{
|
2019-12-17 02:20:40 -06:00
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::setAutoScaleYEnabled()");
|
2019-11-12 07:29:06 -06:00
|
|
|
}
|
|
|
|
|
2019-12-11 02:38:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-12-17 02:20:40 -06:00
|
|
|
void RimWellDistributionPlot::updateAxes()
|
|
|
|
{
|
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::updateAxes()");
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellDistributionPlot::updateLegend()
|
2019-11-12 07:29:06 -06:00
|
|
|
{
|
2019-12-17 02:20:40 -06:00
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::updateLegend()");
|
2019-11-12 07:29:06 -06:00
|
|
|
|
2019-12-17 02:20:40 -06:00
|
|
|
if (!m_plotWidget)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2019-11-12 07:29:06 -06:00
|
|
|
|
2019-12-17 02:20:40 -06:00
|
|
|
// For now we always show the legend when in multiplot mode
|
|
|
|
bool doShowLegend = true;
|
|
|
|
if (isMdiWindow())
|
|
|
|
{
|
|
|
|
doShowLegend = m_showPlotLegends;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (doShowLegend)
|
|
|
|
{
|
|
|
|
QwtLegend* legend = new QwtLegend(m_plotWidget);
|
|
|
|
m_plotWidget->insertLegend(legend, QwtPlot::BottomLegend);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_plotWidget->insertLegend(nullptr);
|
|
|
|
}
|
|
|
|
}
|
2019-11-12 07:29:06 -06:00
|
|
|
|
2019-12-17 02:20:40 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellDistributionPlot::updateZoomInQwt()
|
|
|
|
{
|
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::updateZoomInQwt()");
|
|
|
|
}
|
2019-11-12 07:29:06 -06:00
|
|
|
|
2019-12-17 02:20:40 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellDistributionPlot::updateZoomFromQwt()
|
|
|
|
{
|
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::updateZoomFromQwt()");
|
|
|
|
}
|
2019-11-12 07:29:06 -06:00
|
|
|
|
2019-12-17 02:20:40 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimWellDistributionPlot::asciiDataForPlotExport() const
|
|
|
|
{
|
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::asciiDataForPlotExport()");
|
|
|
|
return QString();
|
|
|
|
}
|
2019-11-12 07:29:06 -06:00
|
|
|
|
2019-12-17 02:20:40 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellDistributionPlot::reattachAllCurves()
|
|
|
|
{
|
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::reattachAllCurves()");
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellDistributionPlot::detachAllCurves()
|
|
|
|
{
|
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::detachAllCurves()");
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
caf::PdmObject* RimWellDistributionPlot::findPdmObjectFromQwtCurve(const QwtPlotCurve* /*curve*/) const
|
|
|
|
{
|
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::findPdmObjectFromQwtCurve()");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellDistributionPlot::onAxisSelected(int /*axis*/, bool /*toggle*/)
|
|
|
|
{
|
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::onAxisSelected()");
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimWellDistributionPlot::description() const
|
|
|
|
{
|
|
|
|
return uiName();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QWidget* RimWellDistributionPlot::viewWidget()
|
|
|
|
{
|
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::viewWidget()");
|
|
|
|
return m_plotWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QImage RimWellDistributionPlot::snapshotWindowContent()
|
|
|
|
{
|
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::snapshotWindowContent()");
|
|
|
|
|
|
|
|
QImage image;
|
|
|
|
|
|
|
|
if (m_plotWidget)
|
|
|
|
{
|
|
|
|
QPixmap pix = m_plotWidget->grab();
|
|
|
|
image = pix.toImage();
|
|
|
|
}
|
2019-11-12 07:29:06 -06:00
|
|
|
|
2019-12-17 02:20:40 -06:00
|
|
|
return image;
|
2019-11-12 07:29:06 -06:00
|
|
|
}
|
|
|
|
|
2019-12-11 02:38:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-12-17 02:20:40 -06:00
|
|
|
void RimWellDistributionPlot::zoomAll()
|
|
|
|
{
|
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::zoomAll()");
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellDistributionPlot::doRemoveFromCollection()
|
|
|
|
{
|
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::doRemoveFromCollection()");
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QWidget* RimWellDistributionPlot::createViewWidget(QWidget* mainWindowParent)
|
2019-11-12 07:29:06 -06:00
|
|
|
{
|
2019-12-17 02:20:40 -06:00
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::createViewWidget()");
|
|
|
|
|
|
|
|
// It seems we risk being called multiple times
|
|
|
|
if (m_plotWidget)
|
2019-12-11 02:38:25 -06:00
|
|
|
{
|
2019-12-17 02:20:40 -06:00
|
|
|
return m_plotWidget;
|
|
|
|
}
|
2019-11-12 07:29:06 -06:00
|
|
|
|
2019-12-17 02:20:40 -06:00
|
|
|
m_plotWidget = new RiuQwtPlotWidget(this, mainWindowParent);
|
2019-11-12 07:29:06 -06:00
|
|
|
|
2019-12-17 02:20:40 -06:00
|
|
|
m_plotWidget->setAutoReplot(false);
|
|
|
|
m_plotWidget->setDraggable(false);
|
2019-12-11 02:38:25 -06:00
|
|
|
|
2019-12-17 02:20:40 -06:00
|
|
|
updateLegend();
|
|
|
|
onLoadDataAndUpdate();
|
|
|
|
|
|
|
|
return m_plotWidget;
|
2019-11-12 07:29:06 -06:00
|
|
|
}
|
|
|
|
|
2019-12-11 02:38:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellDistributionPlot::deleteViewWidget()
|
2019-11-12 07:29:06 -06:00
|
|
|
{
|
2019-12-17 02:20:40 -06:00
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::deleteViewWidget()");
|
|
|
|
|
|
|
|
if (m_plotWidget)
|
|
|
|
{
|
|
|
|
m_plotWidget->setParent(nullptr);
|
|
|
|
delete m_plotWidget;
|
|
|
|
m_plotWidget = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellDistributionPlot::onLoadDataAndUpdate()
|
|
|
|
{
|
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::onLoadDataAndUpdate()");
|
|
|
|
//cvf::DebugTimer tim("RimWellDistributionPlot::onLoadDataAndUpdate()");
|
|
|
|
|
|
|
|
if (isMdiWindow())
|
|
|
|
{
|
|
|
|
updateMdiWindowVisibility();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
updateParentLayout();
|
|
|
|
}
|
2019-12-11 02:38:25 -06:00
|
|
|
|
2019-12-17 02:20:40 -06:00
|
|
|
if (!m_plotWidget)
|
2019-12-11 02:38:25 -06:00
|
|
|
{
|
2019-12-17 02:20:40 -06:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_plotWidget->detachItems(QwtPlotItem::Rtti_PlotCurve);
|
|
|
|
|
|
|
|
updateLegend();
|
|
|
|
|
|
|
|
if (m_case)
|
|
|
|
{
|
|
|
|
//tim.reportLapTimeMS("about to start calc");
|
|
|
|
RigTofWellDistributionCalculator calc(m_case, m_wellName, m_timeStepIndex, m_phase());
|
|
|
|
//tim.reportLapTimeMS("calc");
|
|
|
|
|
2019-12-17 08:43:05 -06:00
|
|
|
if (m_groupSmallContributions)
|
|
|
|
{
|
|
|
|
calc.groupSmallContributions(m_smallContributionsRelativeThreshold);
|
|
|
|
//tim.reportLapTimeMS("group");
|
|
|
|
}
|
2019-12-17 02:20:40 -06:00
|
|
|
|
|
|
|
const RimFlowDiagSolution* flowDiagSolution = m_case->defaultFlowDiagSolution();
|
|
|
|
|
2019-12-17 05:41:11 -06:00
|
|
|
//cvf::Trace::show("Populating plot for phase '%s'", m_phase == RiaDefines::OIL_PHASE ? "oil" : (m_phase == RiaDefines::GAS_PHASE ? "gas" : "water"));
|
2019-12-17 02:20:40 -06:00
|
|
|
populatePlotWidgetWithCurveData(calc, *flowDiagSolution, m_plotWidget);
|
2019-12-11 02:38:25 -06:00
|
|
|
}
|
2019-12-17 02:20:40 -06:00
|
|
|
|
|
|
|
QString phaseString = "N/A";
|
|
|
|
if (m_phase == RiaDefines::OIL_PHASE) phaseString = "Oil";
|
|
|
|
else if (m_phase == RiaDefines::GAS_PHASE) phaseString = "Gas";
|
|
|
|
else if (m_phase == RiaDefines::WATER_PHASE) phaseString = "Water";
|
|
|
|
|
|
|
|
const QString timeStepName = m_case ? m_case->timeStepName(m_timeStepIndex) : "N/A";
|
|
|
|
|
|
|
|
const QString plotTitleStr = QString("%1 Distribution: %2, %3").arg(phaseString).arg(m_wellName).arg(timeStepName);
|
|
|
|
m_plotWidget->setTitle(plotTitleStr);
|
|
|
|
|
|
|
|
m_plotWidget->setAxisTitleText(QwtPlot::xBottom, "TOF [years]");
|
|
|
|
m_plotWidget->setAxisTitleText(QwtPlot::yLeft, "Reservoir Volume [m3]");
|
|
|
|
m_plotWidget->setAxisTitleEnabled(QwtPlot::xBottom, true);
|
|
|
|
m_plotWidget->setAxisTitleEnabled(QwtPlot::yLeft, true);
|
|
|
|
|
|
|
|
m_plotWidget->scheduleReplot();
|
2019-11-12 07:29:06 -06:00
|
|
|
}
|
|
|
|
|
2019-12-11 02:38:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-12-17 02:20:40 -06:00
|
|
|
void RimWellDistributionPlot::populatePlotWidgetWithCurveData(const RigTofWellDistributionCalculator& calculator, const RimFlowDiagSolution& flowDiagSolution, RiuQwtPlotWidget* plotWidget)
|
2019-11-12 07:29:06 -06:00
|
|
|
{
|
2019-12-17 02:20:40 -06:00
|
|
|
//cvf::Trace::show("RimWellDistributionPlot::populatePlotWidgetWithCurves()");
|
2019-12-11 02:38:25 -06:00
|
|
|
|
|
|
|
// Currently select this value so that the grid appears on top of the curves
|
|
|
|
const double baseCurveZValue = 9.5;
|
|
|
|
|
|
|
|
plotWidget->detachItems(QwtPlotItem::Rtti_PlotCurve);
|
|
|
|
plotWidget->setAxisScale(QwtPlot::xBottom, 0, 1);
|
|
|
|
plotWidget->setAxisScale(QwtPlot::yLeft, 0, 1);
|
|
|
|
plotWidget->setAxisAutoScale(QwtPlot::xBottom, true);
|
|
|
|
plotWidget->setAxisAutoScale(QwtPlot::yLeft, true);
|
|
|
|
|
|
|
|
const std::vector<double>& tofValuesDays = calculator.sortedUniqueTOFValues();
|
|
|
|
if (tofValuesDays.size() == 0)
|
|
|
|
{
|
2019-12-17 02:20:40 -06:00
|
|
|
//cvf::Trace::show("No TOF values!");
|
2019-12-11 02:38:25 -06:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<double> tofValuesYears;
|
|
|
|
for (double tofDays : tofValuesDays)
|
|
|
|
{
|
2019-12-17 02:20:40 -06:00
|
|
|
const double tofYears = tofDays / 365.2425;
|
2019-12-11 02:38:25 -06:00
|
|
|
tofValuesYears.push_back(tofYears);
|
|
|
|
}
|
|
|
|
|
2019-12-17 02:20:40 -06:00
|
|
|
//cvf::Trace::show("numTofValues: %d (min, max: %f, %f)", static_cast<int>(tofValuesYears.size()), tofValuesYears.front(), tofValuesYears.back());
|
2019-12-11 02:38:25 -06:00
|
|
|
|
|
|
|
const size_t numWells = calculator.contributingWellCount();
|
2019-12-17 02:20:40 -06:00
|
|
|
//cvf::Trace::show("numContribWells: %d", static_cast<int>(numWells));
|
2019-12-11 02:38:25 -06:00
|
|
|
|
|
|
|
std::vector<double> yVals(tofValuesYears.size(), 0);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < numWells; i++)
|
|
|
|
{
|
|
|
|
QString wellName = calculator.contributingWellName(i);
|
2019-12-17 02:20:40 -06:00
|
|
|
const std::vector<double>& volArr = calculator.accumulatedVolumeForContributingWell(i);
|
2019-12-11 02:38:25 -06:00
|
|
|
|
|
|
|
cvf::Color3f cvfClr = flowDiagSolution.tracerColor(wellName);
|
|
|
|
QColor qtClr = RiaColorTools::toQColor(cvfClr);
|
|
|
|
|
|
|
|
for (size_t j = 0; j < yVals.size(); j++)
|
|
|
|
{
|
|
|
|
yVals[j] += volArr[j];
|
|
|
|
}
|
|
|
|
|
2019-12-17 05:41:11 -06:00
|
|
|
//cvf::Trace::show("wellName min, max: %15s %12.3f, %12.3f maxAggrY: %12.3f", wellName.toStdString().c_str(), volArr.front(), volArr.back(), yVals.back());
|
|
|
|
|
2019-12-11 02:38:25 -06:00
|
|
|
QwtPlotCurve* curve = new QwtPlotCurve;
|
|
|
|
curve->setTitle(wellName);
|
|
|
|
curve->setBrush(qtClr);
|
|
|
|
curve->setZ(baseCurveZValue - i * 0.0001);
|
|
|
|
curve->setSamples(tofValuesYears.data(), yVals.data(), static_cast<int>(tofValuesYears.size()));
|
|
|
|
curve->attach(plotWidget);
|
|
|
|
}
|
2019-11-12 07:29:06 -06:00
|
|
|
}
|
|
|
|
|
2019-12-11 02:38:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellDistributionPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
2019-11-12 07:29:06 -06:00
|
|
|
{
|
2019-12-17 08:43:05 -06:00
|
|
|
uiOrdering.add(&m_case);
|
|
|
|
uiOrdering.add(&m_timeStepIndex);
|
|
|
|
uiOrdering.add(&m_wellName);
|
|
|
|
uiOrdering.add(&m_phase);
|
|
|
|
uiOrdering.add(&m_groupSmallContributions);
|
|
|
|
uiOrdering.add(&m_smallContributionsRelativeThreshold);
|
|
|
|
|
|
|
|
m_smallContributionsRelativeThreshold.uiCapability()->setUiReadOnly(m_groupSmallContributions == false);
|
2019-12-11 02:38:25 -06:00
|
|
|
|
2019-12-17 02:20:40 -06:00
|
|
|
RimPlot::defineUiOrdering(uiConfigName, uiOrdering);
|
|
|
|
//uiOrdering.skipRemainingFields();
|
2019-11-12 07:29:06 -06:00
|
|
|
}
|
|
|
|
|
2019-12-11 02:38:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-12-17 02:20:40 -06:00
|
|
|
QList<caf::PdmOptionItemInfo> RimWellDistributionPlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
|
2019-11-12 07:29:06 -06:00
|
|
|
{
|
2019-12-17 02:20:40 -06:00
|
|
|
QList<caf::PdmOptionItemInfo> options = RimPlot::calculateValueOptions(fieldNeedingOptions, useOptionsOnly);
|
2019-12-11 02:38:25 -06:00
|
|
|
|
|
|
|
if (fieldNeedingOptions == &m_case)
|
|
|
|
{
|
|
|
|
RimProject* ownerProj = nullptr;
|
|
|
|
firstAncestorOrThisOfType(ownerProj);
|
|
|
|
if (ownerProj)
|
|
|
|
{
|
|
|
|
std::vector<RimEclipseResultCase*> caseArr;
|
|
|
|
ownerProj->descendantsIncludingThisOfType(caseArr);
|
|
|
|
for (RimEclipseResultCase* c : caseArr)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(c->caseUserDescription(), c, true, c->uiIconProvider()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (fieldNeedingOptions == &m_timeStepIndex)
|
|
|
|
{
|
|
|
|
if (m_case && m_case->eclipseCaseData())
|
|
|
|
{
|
|
|
|
const QStringList timeStepNames = m_case->timeStepStrings();
|
|
|
|
for (int i = 0; i < timeStepNames.size(); i++)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.size() == 0)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo("None", -1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (fieldNeedingOptions == &m_wellName)
|
|
|
|
{
|
|
|
|
if (m_case && m_case->eclipseCaseData())
|
|
|
|
{
|
|
|
|
caf::QIconProvider simWellIcon(":/Well.png");
|
|
|
|
const std::set<QString> sortedWellNameSet = m_case->eclipseCaseData()->findSortedWellNames();
|
|
|
|
for (const QString& name : sortedWellNameSet)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(name, name, true, simWellIcon));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.size() == 0)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo("None", QVariant()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return options;
|
2019-11-12 07:29:06 -06:00
|
|
|
}
|
|
|
|
|
2019-12-11 02:38:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellDistributionPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
2019-11-12 07:29:06 -06:00
|
|
|
{
|
2019-12-17 02:20:40 -06:00
|
|
|
RimPlot::fieldChangedByUi(changedField, oldValue, newValue);
|
|
|
|
|
2019-12-11 02:38:25 -06:00
|
|
|
if (changedField == &m_case)
|
|
|
|
{
|
|
|
|
fixupDependentFieldsAfterCaseChange();
|
|
|
|
}
|
|
|
|
|
2019-12-17 02:20:40 -06:00
|
|
|
loadDataAndUpdate();
|
2019-11-12 07:29:06 -06:00
|
|
|
}
|
|
|
|
|
2019-12-11 02:38:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellDistributionPlot::fixupDependentFieldsAfterCaseChange()
|
2019-11-12 07:29:06 -06:00
|
|
|
{
|
2019-12-11 02:38:25 -06:00
|
|
|
int newTimeStepIndex = -1;
|
|
|
|
QString newWellName;
|
|
|
|
|
|
|
|
if (m_case)
|
|
|
|
{
|
|
|
|
const int timeStepCount = m_case->timeStepStrings().size();
|
|
|
|
if (timeStepCount > 0)
|
|
|
|
{
|
|
|
|
newTimeStepIndex = timeStepCount - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::set<QString> sortedWellNameSet = m_case->eclipseCaseData()->findSortedWellNames();
|
|
|
|
if (sortedWellNameSet.size() > 0)
|
|
|
|
{
|
|
|
|
newWellName = *sortedWellNameSet.begin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_timeStepIndex = newTimeStepIndex;
|
|
|
|
m_wellName = newWellName;
|
2019-11-12 07:29:06 -06:00
|
|
|
}
|
|
|
|
|
2019-12-11 02:38:25 -06:00
|
|
|
|