mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
218 lines
7.3 KiB
C++
218 lines
7.3 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 "RimWellAllocationPlot.h"
|
|
|
|
#include "RiaApplication.h"
|
|
#include "RimEclipseWell.h"
|
|
#include "RiuMainPlotWindow.h"
|
|
#include "RiuWellAllocationPlot.h"
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimWellAllocationPlot, "WellAllocationPlot");
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimWellAllocationPlot::RimWellAllocationPlot()
|
|
{
|
|
CAF_PDM_InitObject("Well Allocation Plot", ":/newIcon16x16.png", "", "");
|
|
CAF_PDM_InitField(&m_showWindow, "ShowWindow", true, "Show Flow Diagnostics Plot", "", "", "");
|
|
m_showWindow.uiCapability()->setUiHidden(true);
|
|
|
|
CAF_PDM_InitField(&m_userName, "PlotDescription", QString("Flow Diagnostics Plot"), "Name", "", "", "");
|
|
CAF_PDM_InitField(&m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "");
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_simulationWell, "SimulationWell", "Simulation Well", "", "", "");
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimWellAllocationPlot::~RimWellAllocationPlot()
|
|
{
|
|
if (RiaApplication::instance()->mainPlotWindow())
|
|
{
|
|
RiaApplication::instance()->mainPlotWindow()->removeViewer(m_wellAllocationPlot);
|
|
}
|
|
|
|
deletePlotWidget();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellAllocationPlot::setSimulationWell(RimEclipseWell* simWell)
|
|
{
|
|
m_simulationWell = simWell;
|
|
|
|
setDescription(simWell->name());
|
|
|
|
updateViewerWidget();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellAllocationPlot::deletePlotWidget()
|
|
{
|
|
if (m_wellAllocationPlot)
|
|
{
|
|
m_wellAllocationPlot->deleteLater();
|
|
m_wellAllocationPlot = nullptr;
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QWidget* RimWellAllocationPlot::viewWidget()
|
|
{
|
|
return m_wellAllocationPlot;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellAllocationPlot::zoomAll()
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellAllocationPlot::handleViewerDeletion()
|
|
{
|
|
m_showWindow = false;
|
|
|
|
uiCapability()->updateUiIconFromToggleField();
|
|
updateConnectedEditors();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellAllocationPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
{
|
|
if (changedField == &m_showWindow)
|
|
{
|
|
updateViewerWidget();
|
|
|
|
uiCapability()->updateUiIconFromToggleField();
|
|
}
|
|
else if (changedField == &m_userName ||
|
|
changedField == &m_showPlotTitle)
|
|
{
|
|
updateViewerWidgetWindowTitle();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellAllocationPlot::setupBeforeSave()
|
|
{
|
|
if (m_wellAllocationPlot && RiaApplication::instance()->mainPlotWindow())
|
|
{
|
|
this->setMdiWindowGeometry(RiaApplication::instance()->mainPlotWindow()->windowGeometryForViewer(m_wellAllocationPlot));
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QImage RimWellAllocationPlot::snapshotWindowContent()
|
|
{
|
|
QImage image;
|
|
|
|
// TODO
|
|
|
|
return image;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellAllocationPlot::setDescription(const QString& description)
|
|
{
|
|
m_userName = description;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QString RimWellAllocationPlot::description() const
|
|
{
|
|
return m_userName();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellAllocationPlot::updateViewerWidget()
|
|
{
|
|
RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow();
|
|
if (!mainPlotWindow) return;
|
|
|
|
if (m_showWindow())
|
|
{
|
|
if (!m_wellAllocationPlot)
|
|
{
|
|
m_wellAllocationPlot = new RiuWellAllocationPlot(this, mainPlotWindow);
|
|
|
|
mainPlotWindow->addViewer(m_wellAllocationPlot, this->mdiWindowGeometry());
|
|
mainPlotWindow->setActiveViewer(m_wellAllocationPlot);
|
|
}
|
|
|
|
updateViewerWidgetWindowTitle();
|
|
}
|
|
else
|
|
{
|
|
if (m_wellAllocationPlot)
|
|
{
|
|
this->setMdiWindowGeometry(mainPlotWindow->windowGeometryForViewer(m_wellAllocationPlot));
|
|
|
|
mainPlotWindow->removeViewer(m_wellAllocationPlot);
|
|
|
|
deletePlotWidget();
|
|
}
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellAllocationPlot::updateViewerWidgetWindowTitle()
|
|
{
|
|
if (m_wellAllocationPlot)
|
|
{
|
|
m_wellAllocationPlot->setWindowTitle(m_userName);
|
|
|
|
if (m_showPlotTitle)
|
|
{
|
|
m_wellAllocationPlot->setTitle(m_userName);
|
|
}
|
|
else
|
|
{
|
|
m_wellAllocationPlot->setTitle("");
|
|
}
|
|
}
|
|
}
|
|
|