2017-09-27 05:39:28 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// 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 "RimWellRftPlot.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
|
|
|
#include "RigAccWellFlowCalculator.h"
|
|
|
|
#include "RigEclipseCaseData.h"
|
|
|
|
#include "RigFlowDiagResultAddress.h"
|
|
|
|
#include "RigFlowDiagResults.h"
|
|
|
|
#include "RigSimulationWellCenterLineCalculator.h"
|
|
|
|
#include "RigSimulationWellCoordsAndMD.h"
|
|
|
|
#include "RigSingleWellResultsData.h"
|
|
|
|
|
|
|
|
#include "RimEclipseCase.h"
|
|
|
|
#include "RimEclipseCellColors.h"
|
|
|
|
#include "RimEclipseResultCase.h"
|
|
|
|
#include "RimEclipseView.h"
|
|
|
|
#include "RimEclipseWell.h"
|
|
|
|
#include "RimEclipseWellCollection.h"
|
|
|
|
#include "RimFlowDiagSolution.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimTotalWellAllocationPlot.h"
|
|
|
|
#include "RimWellFlowRateCurve.h"
|
|
|
|
#include "RimWellLogPlot.h"
|
|
|
|
#include "RimWellLogTrack.h"
|
|
|
|
#include "RimTofAccumulatedPhaseFractionsPlot.h"
|
2017-09-29 04:24:18 -05:00
|
|
|
#include "RimOilField.h"
|
2017-09-27 05:39:28 -05:00
|
|
|
#include "RiuMainPlotWindow.h"
|
|
|
|
#include "RiuWellRftPlot.h"
|
|
|
|
#include "RiuWellLogTrack.h"
|
2017-09-29 04:24:18 -05:00
|
|
|
#include "RimWellPathCollection.h"
|
|
|
|
#include "RimWellPath.h"
|
|
|
|
#include "RimWellLogFile.h"
|
|
|
|
#include "RimWellLogFileChannel.h"
|
|
|
|
#include "cafPdmUiTreeSelectionEditor.h"
|
|
|
|
#include "SummaryPlotCommands/RicSummaryCurveCreatorUiKeywords.h"
|
|
|
|
#include "cafPdmChildArrayField.h"
|
2017-09-27 05:39:28 -05:00
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimWellRftPlot, "WellRftPlot");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
2017-09-29 04:24:18 -05:00
|
|
|
//namespace caf
|
|
|
|
//{
|
|
|
|
//
|
|
|
|
//template<>
|
|
|
|
//void AppEnum<RimWellRftPlot::FlowType>::setUp()
|
|
|
|
//{
|
|
|
|
// addItem(RimWellRftPlot::ACCUMULATED, "ACCUMULATED", "Accumulated");
|
|
|
|
// addItem(RimWellRftPlot::INFLOW, "INFLOW", "Inflow Rates");
|
|
|
|
// setDefault(RimWellRftPlot::ACCUMULATED);
|
|
|
|
//
|
|
|
|
//}
|
|
|
|
//}
|
2017-09-27 05:39:28 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellRftPlot::RimWellRftPlot()
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("Well Allocation Plot", ":/WellAllocPlot16x16.png", "", "");
|
|
|
|
|
2017-09-29 04:24:18 -05:00
|
|
|
CAF_PDM_InitField(&m_userName, "PlotDescription", QString("RFT Plot"), "Name", "", "", "");
|
2017-09-27 05:39:28 -05:00
|
|
|
m_userName.uiCapability()->setUiReadOnly(true);
|
|
|
|
|
|
|
|
CAF_PDM_InitField(&m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "");
|
|
|
|
|
2017-09-27 07:05:14 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_wellLogPlot, "WellLog", "WellLog", "", "", "");
|
|
|
|
m_wellLogPlot.uiCapability()->setUiHidden(true);
|
|
|
|
m_wellLogPlot = new RimWellLogPlot();
|
|
|
|
|
2017-09-29 04:24:18 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_wellName, "WellName", "WellName", "", "", "");
|
2017-09-27 07:05:14 -05:00
|
|
|
|
2017-09-29 04:24:18 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_selectedSources, "Sources", "Sources", "", "", "");
|
|
|
|
m_selectedSources.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
|
|
|
|
m_selectedSources.xmlCapability()->setIOReadable(false);
|
|
|
|
m_selectedSources.xmlCapability()->setIOWritable(false);
|
|
|
|
m_selectedSources.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
2017-09-27 05:39:28 -05:00
|
|
|
|
2017-09-29 04:24:18 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_selectedTimeSteps, "TimeSteps", "TimeSteps", "", "", "");
|
|
|
|
m_selectedTimeSteps.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
|
|
|
|
m_selectedTimeSteps.xmlCapability()->setIOReadable(false);
|
|
|
|
m_selectedTimeSteps.xmlCapability()->setIOWritable(false);
|
|
|
|
m_selectedTimeSteps.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
|
|
|
//this->setAsPlotMdiWindow();
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellRftPlot::~RimWellRftPlot()
|
|
|
|
{
|
|
|
|
removeMdiWindowFromMdiArea();
|
|
|
|
|
|
|
|
deleteViewWidget();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellRftPlot::deleteViewWidget()
|
|
|
|
{
|
2017-09-27 07:05:14 -05:00
|
|
|
if (m_wellLogPlotWidget)
|
2017-09-27 05:39:28 -05:00
|
|
|
{
|
2017-09-27 07:05:14 -05:00
|
|
|
m_wellLogPlotWidget->deleteLater();
|
|
|
|
m_wellLogPlotWidget = nullptr;
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellRftPlot::updateFromWell()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellRftPlot::updateWidgetTitleWindowTitle()
|
|
|
|
{
|
|
|
|
updateMdiWindowTitle();
|
|
|
|
|
2017-09-27 07:05:14 -05:00
|
|
|
if (m_wellLogPlotWidget)
|
2017-09-27 05:39:28 -05:00
|
|
|
{
|
|
|
|
if (m_showPlotTitle)
|
|
|
|
{
|
2017-09-27 07:05:14 -05:00
|
|
|
m_wellLogPlotWidget->showTitle(m_userName);
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-27 07:05:14 -05:00
|
|
|
m_wellLogPlotWidget->hideTitle();
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QWidget* RimWellRftPlot::viewWidget()
|
|
|
|
{
|
2017-09-27 07:05:14 -05:00
|
|
|
return m_wellLogPlotWidget;
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellRftPlot::zoomAll()
|
|
|
|
{
|
2017-09-27 07:05:14 -05:00
|
|
|
m_wellLogPlot()->zoomAll();
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-29 04:24:18 -05:00
|
|
|
RimWellLogPlot* RimWellRftPlot::wellLogPlot() const
|
2017-09-27 05:39:28 -05:00
|
|
|
{
|
2017-09-27 07:05:14 -05:00
|
|
|
return m_wellLogPlot();
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-29 04:24:18 -05:00
|
|
|
void RimWellRftPlot::setCurrentWellName(const QString& currWellName)
|
2017-09-27 05:39:28 -05:00
|
|
|
{
|
2017-09-29 04:24:18 -05:00
|
|
|
m_wellName = currWellName;
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-29 04:24:18 -05:00
|
|
|
QString RimWellRftPlot::currentWellName() const
|
2017-09-27 05:39:28 -05:00
|
|
|
{
|
2017-09-29 04:24:18 -05:00
|
|
|
return m_wellName;
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QList<caf::PdmOptionItemInfo> RimWellRftPlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> options;
|
|
|
|
|
|
|
|
if (fieldNeedingOptions == &m_wellName)
|
|
|
|
{
|
2017-09-29 04:24:18 -05:00
|
|
|
calculateValueOptionsForWells(options);
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
2017-09-29 04:24:18 -05:00
|
|
|
else if (fieldNeedingOptions == &m_selectedSources)
|
2017-09-27 05:39:28 -05:00
|
|
|
{
|
2017-09-29 04:24:18 -05:00
|
|
|
calculateValueOptionsForObservedData(options);
|
2017-09-27 05:39:28 -05:00
|
|
|
|
|
|
|
}
|
2017-09-29 04:24:18 -05:00
|
|
|
else if (fieldNeedingOptions == &m_selectedTimeSteps)
|
2017-09-27 05:39:28 -05:00
|
|
|
{
|
2017-09-29 04:24:18 -05:00
|
|
|
options.push_back(caf::PdmOptionItemInfo("TimeStep 1", "TimeStep 1"));
|
|
|
|
options.push_back(caf::PdmOptionItemInfo("TimeStep 2", "TimeStep 2"));
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-29 04:24:18 -05:00
|
|
|
void RimWellRftPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
2017-09-27 05:39:28 -05:00
|
|
|
{
|
2017-09-29 04:24:18 -05:00
|
|
|
//RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue);
|
2017-09-27 05:39:28 -05:00
|
|
|
|
2017-09-29 04:24:18 -05:00
|
|
|
//if (changedField == &m_userName ||
|
|
|
|
// changedField == &m_showPlotTitle)
|
|
|
|
//{
|
|
|
|
// updateWidgetTitleWindowTitle();
|
|
|
|
//}
|
|
|
|
//else if ( changedField == &m_case)
|
|
|
|
//{
|
|
|
|
// if ( m_flowDiagSolution && m_case )
|
|
|
|
// {
|
|
|
|
// m_flowDiagSolution = m_case->defaultFlowDiagSolution();
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// m_flowDiagSolution = nullptr;
|
|
|
|
// }
|
2017-09-27 05:39:28 -05:00
|
|
|
|
2017-09-29 04:24:18 -05:00
|
|
|
// if (!m_case) m_timeStep = 0;
|
|
|
|
// else if (m_timeStep >= static_cast<int>(m_case->timeStepDates().size()))
|
|
|
|
// {
|
|
|
|
// m_timeStep = std::max(0, ((int)m_case->timeStepDates().size()) - 1);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// std::set<QString> sortedWellNames = findSortedWellNames();
|
|
|
|
// if (!sortedWellNames.size()) m_wellName = "";
|
|
|
|
// else if ( sortedWellNames.count(m_wellName()) == 0 ){ m_wellName = *sortedWellNames.begin();}
|
|
|
|
|
|
|
|
// loadDataAndUpdate();
|
|
|
|
//}
|
|
|
|
//else if ( changedField == &m_wellName
|
|
|
|
// || changedField == &m_timeStep
|
|
|
|
// || changedField == &m_flowDiagSolution
|
|
|
|
// || changedField == &m_groupSmallContributions
|
|
|
|
// || changedField == &m_smallContributionsThreshold
|
|
|
|
// || changedField == &m_flowType )
|
|
|
|
//{
|
|
|
|
// loadDataAndUpdate();
|
|
|
|
//}
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-29 04:24:18 -05:00
|
|
|
QImage RimWellRftPlot::snapshotWindowContent()
|
2017-09-27 05:39:28 -05:00
|
|
|
{
|
2017-09-29 04:24:18 -05:00
|
|
|
QImage image;
|
2017-09-27 05:39:28 -05:00
|
|
|
|
2017-09-29 04:24:18 -05:00
|
|
|
if (m_wellLogPlotWidget)
|
2017-09-27 05:39:28 -05:00
|
|
|
{
|
2017-09-29 04:24:18 -05:00
|
|
|
QPixmap pix = QPixmap::grabWidget(m_wellLogPlotWidget);
|
|
|
|
image = pix.toImage();
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
|
2017-09-29 04:24:18 -05:00
|
|
|
return image;
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-29 04:24:18 -05:00
|
|
|
void RimWellRftPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
2017-09-27 05:39:28 -05:00
|
|
|
{
|
2017-09-29 04:24:18 -05:00
|
|
|
uiOrdering.add(&m_userName);
|
|
|
|
uiOrdering.add(&m_wellName);
|
2017-09-27 05:39:28 -05:00
|
|
|
|
2017-09-29 04:24:18 -05:00
|
|
|
caf::PdmUiGroup* sourcesGroup = uiOrdering.addNewGroupWithKeyword("Sources", "Sources");
|
|
|
|
sourcesGroup->add(&m_selectedSources);
|
|
|
|
|
|
|
|
caf::PdmUiGroup* timeStepsGroup = uiOrdering.addNewGroupWithKeyword("Time Steps", "TimeSteps");
|
|
|
|
timeStepsGroup->add(&m_selectedTimeSteps);
|
2017-09-27 05:39:28 -05:00
|
|
|
|
2017-09-29 04:24:18 -05:00
|
|
|
uiOrdering.add(&m_showPlotTitle);
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-29 04:24:18 -05:00
|
|
|
void RimWellRftPlot::calculateValueOptionsForWells(QList<caf::PdmOptionItemInfo>& options)
|
2017-09-27 05:39:28 -05:00
|
|
|
{
|
2017-09-29 04:24:18 -05:00
|
|
|
auto project = RiaApplication::instance()->project();
|
2017-09-27 05:39:28 -05:00
|
|
|
|
2017-09-29 04:24:18 -05:00
|
|
|
for (RimOilField* oilField : project->oilFields)
|
2017-09-27 05:39:28 -05:00
|
|
|
{
|
2017-09-29 04:24:18 -05:00
|
|
|
auto wellPathColl = oilField->wellPathCollection();
|
|
|
|
for (const auto& wellPath : wellPathColl->wellPaths)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(wellPath->name(), wellPath->name()));
|
|
|
|
}
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-29 04:24:18 -05:00
|
|
|
void RimWellRftPlot::calculateValueOptionsForObservedData(QList<caf::PdmOptionItemInfo>& options)
|
2017-09-27 05:39:28 -05:00
|
|
|
{
|
2017-09-29 04:24:18 -05:00
|
|
|
auto project = RiaApplication::instance()->project();
|
2017-09-27 05:39:28 -05:00
|
|
|
|
2017-09-29 04:24:18 -05:00
|
|
|
for (RimOilField* oilField : project->oilFields)
|
|
|
|
{
|
|
|
|
auto wellPathColl = oilField->wellPathCollection();
|
|
|
|
for (const auto& wellPath : wellPathColl->wellPaths)
|
|
|
|
{
|
|
|
|
const auto& wellLogFile = wellPath->wellLogFile();
|
|
|
|
const auto& channels = wellLogFile->wellLogChannelNames();
|
|
|
|
|
|
|
|
for (const auto& channel : *channels)
|
|
|
|
{
|
|
|
|
auto name = channel->name();
|
|
|
|
|
|
|
|
if (QString::compare(name, "GR") == 0) // Test code
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(name, name));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellRftPlot::setDescription(const QString& description)
|
|
|
|
{
|
|
|
|
m_userName = description;
|
|
|
|
|
|
|
|
updateWidgetTitleWindowTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimWellRftPlot::description() const
|
|
|
|
{
|
|
|
|
return m_userName();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellRftPlot::loadDataAndUpdate()
|
|
|
|
{
|
|
|
|
updateMdiWindowVisibility();
|
|
|
|
updateFromWell();
|
2017-09-27 07:05:14 -05:00
|
|
|
m_wellLogPlot->loadDataAndUpdate();
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QWidget* RimWellRftPlot::createViewWidget(QWidget* mainWindowParent)
|
|
|
|
{
|
2017-09-27 07:05:14 -05:00
|
|
|
m_wellLogPlotWidget = new RiuWellRftPlot(this, mainWindowParent);
|
|
|
|
return m_wellLogPlotWidget;
|
2017-09-27 05:39:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::Color3f RimWellRftPlot::getTracerColor(const QString& tracerName)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (tracerName == RIG_FLOW_OIL_NAME) return cvf::Color3f::DARK_GREEN;
|
|
|
|
if (tracerName == RIG_FLOW_GAS_NAME) return cvf::Color3f::DARK_RED;
|
|
|
|
if (tracerName == RIG_FLOW_WATER_NAME) return cvf::Color3f::BLUE;
|
|
|
|
return cvf::Color3f::DARK_GRAY;
|
|
|
|
}
|
|
|
|
|