Merge remote-tracking branch 'refs/remotes/origin/dev'

Conflicts:
	ApplicationCode/CMakeLists.txt
	ApplicationCode/ProjectDataModel/CMakeLists_files.cmake
	ApplicationCode/ProjectDataModel/RimEclipseWell.h
	ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake
This commit is contained in:
Magne Sjaastad
2017-01-24 15:23:02 +01:00
70 changed files with 2948 additions and 871 deletions

View File

@@ -83,6 +83,7 @@ ${CEE_CURRENT_LIST_DIR}RimPlotCurve.h
${CEE_CURRENT_LIST_DIR}RimEclipseInputCaseOpm.h
${CEE_CURRENT_LIST_DIR}RimIntersectionBox.h
${CEE_CURRENT_LIST_DIR}RimMultiSnapshotDefinition.h
${CEE_CURRENT_LIST_DIR}RimMdiWindowController.h
${CEE_CURRENT_LIST_DIR}RimEllipseFractureTemplate.h
${CEE_CURRENT_LIST_DIR}RimFractureDefinitionCollection.h
${CEE_CURRENT_LIST_DIR}RimFracture.h
@@ -173,6 +174,7 @@ ${CEE_CURRENT_LIST_DIR}RimPlotCurve.cpp
${CEE_CURRENT_LIST_DIR}RimEclipseInputCaseOpm.cpp
${CEE_CURRENT_LIST_DIR}RimIntersectionBox.cpp
${CEE_CURRENT_LIST_DIR}RimMultiSnapshotDefinition.cpp
${CEE_CURRENT_LIST_DIR}RimMdiWindowController.cpp
${CEE_CURRENT_LIST_DIR}RimEllipseFractureTemplate.cpp
${CEE_CURRENT_LIST_DIR}RimFractureDefinitionCollection.cpp
${CEE_CURRENT_LIST_DIR}RimFracture.cpp

View File

@@ -8,12 +8,16 @@ set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RimFlowDiagSolution.h
${CEE_CURRENT_LIST_DIR}RimFlowPlotCollection.h
${CEE_CURRENT_LIST_DIR}RimWellAllocationPlot.h
${CEE_CURRENT_LIST_DIR}RimTotalWellAllocationPlot.h
${CEE_CURRENT_LIST_DIR}RimWellFlowRateCurve.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RimFlowDiagSolution.cpp
${CEE_CURRENT_LIST_DIR}RimFlowPlotCollection.cpp
${CEE_CURRENT_LIST_DIR}RimWellAllocationPlot.cpp
${CEE_CURRENT_LIST_DIR}RimTotalWellAllocationPlot.cpp
${CEE_CURRENT_LIST_DIR}RimWellFlowRateCurve.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -47,5 +47,17 @@ RimFlowPlotCollection::RimFlowPlotCollection()
//--------------------------------------------------------------------------------------------------
RimFlowPlotCollection::~RimFlowPlotCollection()
{
delete defaultPlot();
flowPlots.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFlowPlotCollection::closeDefaultPlotWindowAndDeletePlots()
{
defaultPlot->removeFromMdiAreaAndDeleteViewWidget();
flowPlots.deleteAllChildObjects();
}

View File

@@ -34,6 +34,8 @@ class RimFlowPlotCollection : public caf::PdmObject
public:
RimFlowPlotCollection();
virtual ~RimFlowPlotCollection();
void closeDefaultPlotWindowAndDeletePlots();
caf::PdmChildField<RimWellAllocationPlot*> defaultPlot;
caf::PdmChildArrayField<RimWellAllocationPlot*> flowPlots;

View File

@@ -0,0 +1,262 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimTotalWellAllocationPlot.h"
#include "RiaApplication.h"
#include "RimEclipseView.h"
#include "RimEclipseWell.h"
#include "RimEclipseWellCollection.h"
#include "RigSingleWellResultsData.h"
#include "RimWellLogPlot.h"
#include "RimWellLogTrack.h"
#include "RiuMainPlotWindow.h"
#include "RiuNightchartsWidget.h"
#include "RiuWellAllocationPlot.h"
CAF_PDM_SOURCE_INIT(RimTotalWellAllocationPlot, "TotalWellAllocationPlot");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimTotalWellAllocationPlot::RimTotalWellAllocationPlot()
{
CAF_PDM_InitObject("Total Well Allocation Plot", ":/newIcon16x16.png", "", "");
CAF_PDM_InitField(&m_userName, "PlotDescription", QString("Total Well Allocation Plot"), "Name", "", "", "");
m_userName.uiCapability()->setUiReadOnly(true);
CAF_PDM_InitField(&m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_simulationWell, "SimulationWell", "Simulation Well", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimTotalWellAllocationPlot::~RimTotalWellAllocationPlot()
{
removeMdiWindowFromMdiArea();
deleteViewWidget();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTotalWellAllocationPlot::setSimulationWell(RimEclipseWell* simWell)
{
m_simulationWell = simWell;
updateFromWell();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTotalWellAllocationPlot::deleteViewWidget()
{
if (m_wellTotalAllocationPlotWidget)
{
m_wellTotalAllocationPlotWidget->deleteLater();
m_wellTotalAllocationPlotWidget= nullptr;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTotalWellAllocationPlot::updateFromWell()
{
/*
QString simName = "None";
int branchCount = 0;
const RigWellResultFrame* wellResultFrame = nullptr;
if (m_simulationWell && m_simulationWell->wellResults() )// && Timestep Ok )
{
simName = m_simulationWell->name();
wellResultFrame = &(m_simulationWell->wellResults()->wellResultFrame(1));
branchCount = static_cast<int>( wellResultFrame->m_wellResultBranches.size());
// // Todo : Use this instead, and use to calculate accumulated flow
//
// size_t timeStep = 0; // make field
// std::vector< std::vector <cvf::Vec3d> > pipeBranchesCLCoords;
// std::vector< std::vector <RigWellResultPoint> > pipeBranchesCellIds;
// m_simulationWell->calculateWellPipeDynamicCenterLine(timeStep, pipeBranchesCLCoords, pipeBranchesCellIds);
// branchCount = static_cast<int>( pipeBranchesCLCoords.size());
}
int existingTrackCount = static_cast<int>(accumulatedWellFlowPlot()->trackCount());
accumulatedWellFlowPlot()->setDescription("Accumulated Well Flow (" + simName + ")");
int neededExtraTrackCount = branchCount - existingTrackCount;
for (int etc = 0; etc < neededExtraTrackCount; ++etc)
{
RimWellLogTrack* plotTrack = new RimWellLogTrack();
accumulatedWellFlowPlot()->addTrack(plotTrack);
}
for (int etc = branchCount; etc < existingTrackCount; ++etc)
{
accumulatedWellFlowPlot()->removeTrackByIndex(accumulatedWellFlowPlot()->trackCount()- 1);
}
for (size_t brIdx = 0; brIdx < branchCount; ++brIdx)
{
RimWellLogTrack* plotTrack = accumulatedWellFlowPlot()->trackByIndex(brIdx);
plotTrack->setDescription(QString("Branch %1").arg(brIdx+1));
}
setDescription("Well Allocation (" + simName + ")");
accumulatedWellFlowPlot()->updateConnectedEditors();
*/
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RimTotalWellAllocationPlot::viewWidget()
{
return m_wellTotalAllocationPlotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTotalWellAllocationPlot::zoomAll()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimTotalWellAllocationPlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> options;
if (fieldNeedingOptions == &m_simulationWell)
{
RimView* activeView = RiaApplication::instance()->activeReservoirView();
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>(activeView);
if (eclView && eclView->wellCollection())
{
RimEclipseWellCollection* coll = eclView->wellCollection();
caf::PdmChildArrayField<RimEclipseWell*>& eclWells = coll->wells;
QIcon simWellIcon(":/Well.png");
for (RimEclipseWell* eclWell : eclWells)
{
options.push_back(caf::PdmOptionItemInfo(eclWell->name(), eclWell, false, simWellIcon));
}
}
if (options.size() == 0)
{
options.push_front(caf::PdmOptionItemInfo("None", nullptr));
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTotalWellAllocationPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue);
if (changedField == &m_userName ||
changedField == &m_showPlotTitle)
{
updateMdiWindowTitle();
}
else if (changedField == &m_simulationWell)
{
updateFromWell();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QImage RimTotalWellAllocationPlot::snapshotWindowContent()
{
QImage image;
// TODO
return image;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTotalWellAllocationPlot::setDescription(const QString& description)
{
m_userName = description;
this->updateMdiWindowTitle();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimTotalWellAllocationPlot::description() const
{
return m_userName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTotalWellAllocationPlot::loadDataAndUpdate()
{
updateMdiWindowVisibility();
updateFromWell();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RimTotalWellAllocationPlot::createViewWidget(QWidget* mainWindowParent)
{
m_wellTotalAllocationPlotWidget = new RiuNightchartsWidget(mainWindowParent);
m_wellTotalAllocationPlotWidget->addItem("Item1", QColor(200, 10, 50), 34);
m_wellTotalAllocationPlotWidget->addItem("Item2", Qt::green, 27);
m_wellTotalAllocationPlotWidget->addItem("Item3", Qt::cyan, 14);
m_wellTotalAllocationPlotWidget->addItem("Item4", Qt::yellow, 7);
m_wellTotalAllocationPlotWidget->addItem("Item5", Qt::blue, 4);
return m_wellTotalAllocationPlotWidget;
}

View File

@@ -0,0 +1,87 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimViewWindow.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include <QPointer>
class RiuWellAllocationPlot;
class RimEclipseWell;
class RimWellLogPlot;
class RiuNightchartsWidget;
namespace caf {
class PdmOptionItemInfo;
}
//==================================================================================================
///
///
//==================================================================================================
class RimTotalWellAllocationPlot : public RimViewWindow
{
CAF_PDM_HEADER_INIT;
public:
RimTotalWellAllocationPlot();
virtual ~RimTotalWellAllocationPlot();
void setSimulationWell(RimEclipseWell* simWell);
void setDescription(const QString& description);
QString description() const;
void loadDataAndUpdate();
virtual QWidget* viewWidget() override;
virtual void zoomAll() override;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
// RimViewWindow overrides
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
virtual void deleteViewWidget() override;
protected:
// Overridden PDM methods
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual QImage snapshotWindowContent() override;
private:
void updateFromWell();
private:
caf::PdmField<bool> m_showPlotTitle;
caf::PdmField<QString> m_userName;
caf::PdmPtrField<RimEclipseWell*> m_simulationWell;
QPointer<RiuNightchartsWidget> m_wellTotalAllocationPlotWidget;
};

View File

@@ -20,14 +20,26 @@
#include "RiaApplication.h"
#include "RigEclipseCaseData.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 "RimTotalWellAllocationPlot.h"
#include "RimWellFlowRateCurve.h"
#include "RimWellLogPlot.h"
#include "RimWellLogTrack.h"
#include "RiuMainPlotWindow.h"
#include "RiuWellAllocationPlot.h"
CAF_PDM_SOURCE_INIT(RimWellAllocationPlot, "WellAllocationPlot");
@@ -37,15 +49,29 @@ 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", "", "", "");
m_userName.uiCapability()->setUiReadOnly(true);
CAF_PDM_InitField(&m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_simulationWell, "SimulationWell", "Simulation Well", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_case, "CurveCase", "Case", "", "", "");
m_case.uiCapability()->setUiTreeChildrenHidden(true);
CAF_PDM_InitField(&m_timeStep, "PlotTimeStep", 0, "Time Step", "", "", "");
CAF_PDM_InitField(&m_wellName, "WellName", QString("None"), "Well", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_flowDiagSolution, "FlowDiagSolution", "Flow Diag Solution", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_accumulatedWellFlowPlot, "AccumulatedWellFlowPlot", "Accumulated Well Flow", "", "", "");
m_accumulatedWellFlowPlot.uiCapability()->setUiHidden(true);
m_accumulatedWellFlowPlot = new RimWellLogPlot;
CAF_PDM_InitFieldNoDefault(&m_totalWellAllocationPlot, "TotalWellFlowPlot", "Total Well Flow", "", "", "");
m_totalWellAllocationPlot.uiCapability()->setUiHidden(true);
m_totalWellAllocationPlot = new RimTotalWellAllocationPlot;
this->setAsPlotMdiWindow();
}
//--------------------------------------------------------------------------------------------------
@@ -53,20 +79,29 @@ RimWellAllocationPlot::RimWellAllocationPlot()
//--------------------------------------------------------------------------------------------------
RimWellAllocationPlot::~RimWellAllocationPlot()
{
if (RiaApplication::instance()->mainPlotWindow())
{
RiaApplication::instance()->mainPlotWindow()->removeViewer(m_wellAllocationPlot);
}
removeMdiWindowFromMdiArea();
delete m_accumulatedWellFlowPlot();
delete m_totalWellAllocationPlot();
deletePlotWidget();
deleteViewWidget();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::setSimulationWell(RimEclipseWell* simWell)
void RimWellAllocationPlot::setFromSimulationWell(RimEclipseWell* simWell)
{
m_simulationWell = simWell;
RimEclipseView* eclView;
simWell->firstAncestorOrThisOfType(eclView);
RimEclipseResultCase* eclCase;
simWell->firstAncestorOrThisOfType(eclCase);
m_case = eclCase;
m_wellName = simWell->wellResults()->m_wellName;
m_timeStep = eclView->currentTimeStep();
m_flowDiagSolution = eclView->cellResult()->flowDiagSolution();
updateFromWell();
}
@@ -74,12 +109,12 @@ void RimWellAllocationPlot::setSimulationWell(RimEclipseWell* simWell)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::deletePlotWidget()
void RimWellAllocationPlot::deleteViewWidget()
{
if (m_wellAllocationPlot)
if (m_wellAllocationPlotWidget)
{
m_wellAllocationPlot->deleteLater();
m_wellAllocationPlot = nullptr;
m_wellAllocationPlotWidget->deleteLater();
m_wellAllocationPlotWidget = nullptr;
}
}
@@ -88,15 +123,93 @@ void RimWellAllocationPlot::deletePlotWidget()
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::updateFromWell()
{
QString simName = "None";
if (!m_case) return;
if (m_simulationWell)
const RigSingleWellResultsData* wellResults = nullptr;
wellResults = m_case->reservoirData()->findWellResult(m_wellName);
if (!wellResults) return;
const RigWellResultFrame* wellResultFrame = nullptr;
std::vector< std::vector <cvf::Vec3d> > pipeBranchesCLCoords;
std::vector< std::vector <RigWellResultPoint> > pipeBranchesCellIds;
RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellFrame(m_case->reservoirData(),
wellResults,
m_timeStep,
true,
true,
pipeBranchesCLCoords,
pipeBranchesCellIds);
accumulatedWellFlowPlot()->setDescription("Accumulated Well Flow (" + m_wellName + ")");
// Delete existing tracks
{
simName = m_simulationWell->name();
std::vector<RimWellLogTrack*> tracks;
accumulatedWellFlowPlot()->descendantsIncludingThisOfType(tracks);
for (RimWellLogTrack* t : tracks)
{
accumulatedWellFlowPlot()->removeTrack(t);
delete t;
}
}
setDescription(simName);
updateViewerWidget();
CVF_ASSERT(accumulatedWellFlowPlot()->trackCount() == 0);
size_t branchCount = pipeBranchesCLCoords.size();
for (size_t brIdx = 0; brIdx < branchCount; ++brIdx)
{
RimWellLogTrack* plotTrack = new RimWellLogTrack();
// TODO: Description is overwritten by RimWellLogPlot::updateTrackNames()
// Add flag to control if this behavior
plotTrack->setDescription(QString("Branch %1").arg(brIdx + 1));
accumulatedWellFlowPlot()->addTrack(plotTrack);
std::vector<cvf::Vec3d> curveCoords;
std::vector<double> flowRate;
{
std::vector<cvf::Vec3d> branchCoords = pipeBranchesCLCoords[brIdx];
std::vector<RigWellResultPoint> branchResultPoints = pipeBranchesCellIds[brIdx];
RigWellResultPoint prevResultPoint;
for (size_t i = 0; i < branchResultPoints.size(); i++)
{
const RigWellResultPoint& resultPoint = branchResultPoints[i];
if (i > 0 && prevResultPoint.m_gridCellIndex != resultPoint.m_gridCellIndex)
{
// Add an extra curve point when a cell transition is detected
curveCoords.push_back(branchCoords[i]);
flowRate.push_back(prevResultPoint.m_flowRate);
}
curveCoords.push_back(branchCoords[i]);
flowRate.push_back(branchResultPoints[i].m_flowRate);
prevResultPoint = resultPoint;
}
}
RigSimulationWellCoordsAndMD helper(curveCoords);
RimWellFlowRateCurve* curve = new RimWellFlowRateCurve;
curve->setFlowValues(helper.measuredDepths(), flowRate);
plotTrack->addCurve(curve);
curve->loadDataAndUpdate();
}
setDescription("Well Allocation (" + m_wellName + ")");
accumulatedWellFlowPlot()->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
@@ -104,7 +217,7 @@ void RimWellAllocationPlot::updateFromWell()
//--------------------------------------------------------------------------------------------------
QWidget* RimWellAllocationPlot::viewWidget()
{
return m_wellAllocationPlot;
return m_wellAllocationPlotWidget;
}
//--------------------------------------------------------------------------------------------------
@@ -114,6 +227,22 @@ void RimWellAllocationPlot::zoomAll()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogPlot* RimWellAllocationPlot::accumulatedWellFlowPlot()
{
return m_accumulatedWellFlowPlot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimTotalWellAllocationPlot* RimWellAllocationPlot::totalWellFlowPlot()
{
return m_totalWellAllocationPlot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -121,29 +250,44 @@ QList<caf::PdmOptionItemInfo> RimWellAllocationPlot::calculateValueOptions(const
{
QList<caf::PdmOptionItemInfo> options;
if (fieldNeedingOptions == &m_simulationWell)
if (fieldNeedingOptions == &m_wellName)
{
RimView* activeView = RiaApplication::instance()->activeReservoirView();
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>(activeView);
if (eclView && eclView->wellCollection())
std::set<QString> sortedWellNames;
if ( m_case && m_case->reservoirData() )
{
RimEclipseWellCollection* coll = eclView->wellCollection();
const cvf::Collection<RigSingleWellResultsData>& wellRes = m_case->reservoirData()->wellResults();
caf::PdmChildArrayField<RimEclipseWell*>& eclWells = coll->wells;
QIcon simWellIcon(":/Well.png");
for (RimEclipseWell* eclWell : eclWells)
for ( size_t wIdx = 0; wIdx < wellRes.size(); ++wIdx )
{
options.push_back(caf::PdmOptionItemInfo(eclWell->name(), eclWell, false, simWellIcon));
sortedWellNames.insert(wellRes[wIdx]->m_wellName);
}
}
QIcon simWellIcon(":/Well.png");
for ( const QString& wname: sortedWellNames )
{
options.push_back(caf::PdmOptionItemInfo(wname, wname, false, simWellIcon));
}
if (options.size() == 0)
{
options.push_front(caf::PdmOptionItemInfo("None", nullptr));
}
}
else if (fieldNeedingOptions == &m_timeStep)
{
QStringList timeStepNames;
if (m_case && m_case->reservoirData())
{
timeStepNames = m_case->timeStepStrings();
}
for (int i = 0; i < timeStepNames.size(); i++)
{
options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i));
}
}
return options;
}
@@ -151,12 +295,18 @@ QList<caf::PdmOptionItemInfo> RimWellAllocationPlot::calculateValueOptions(const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::handleViewerDeletion()
QString RimWellAllocationPlot::wellName() const
{
m_showWindow = false;
return m_wellName();
}
uiCapability()->updateUiIconFromToggleField();
updateConnectedEditors();
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::removeFromMdiAreaAndDeleteViewWidget()
{
removeMdiWindowFromMdiArea();
deleteViewWidget();
}
//--------------------------------------------------------------------------------------------------
@@ -164,34 +314,19 @@ void RimWellAllocationPlot::handleViewerDeletion()
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (changedField == &m_showWindow)
{
updateViewerWidget();
RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue);
uiCapability()->updateUiIconFromToggleField();
}
else if (changedField == &m_userName ||
if (changedField == &m_userName ||
changedField == &m_showPlotTitle)
{
updateViewerWidgetWindowTitle();
updateMdiWindowTitle();
}
else if (changedField == &m_simulationWell)
else if (changedField == &m_wellName)
{
updateFromWell();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::setupBeforeSave()
{
if (m_wellAllocationPlot && RiaApplication::instance()->mainPlotWindow())
{
this->setMdiWindowGeometry(RiaApplication::instance()->mainPlotWindow()->windowGeometryForViewer(m_wellAllocationPlot));
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -210,6 +345,7 @@ QImage RimWellAllocationPlot::snapshotWindowContent()
void RimWellAllocationPlot::setDescription(const QString& description)
{
m_userName = description;
this->updateMdiWindowTitle();
}
//--------------------------------------------------------------------------------------------------
@@ -225,59 +361,17 @@ QString RimWellAllocationPlot::description() const
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::loadDataAndUpdate()
{
updateViewerWidget();
updateMdiWindowVisibility();
updateFromWell();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::updateViewerWidget()
QWidget* RimWellAllocationPlot::createViewWidget(QWidget* mainWindowParent)
{
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();
}
}
m_wellAllocationPlotWidget = new RiuWellAllocationPlot(this, mainWindowParent);
return m_wellAllocationPlotWidget;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::updateViewerWidgetWindowTitle()
{
if (m_wellAllocationPlot)
{
m_wellAllocationPlot->setWindowTitle(m_userName);
if (m_showPlotTitle)
{
m_wellAllocationPlot->setTitle(m_userName);
}
else
{
m_wellAllocationPlot->setTitle("");
}
}
}

View File

@@ -27,8 +27,12 @@
#include <QPointer>
class RiuWellAllocationPlot;
class RimEclipseResultCase;
class RimEclipseWell;
class RimFlowDiagSolution;
class RimTotalWellAllocationPlot;
class RimWellLogPlot;
class RiuWellAllocationPlot;
namespace caf {
class PdmOptionItemInfo;
@@ -47,43 +51,51 @@ public:
RimWellAllocationPlot();
virtual ~RimWellAllocationPlot();
void setSimulationWell(RimEclipseWell* simWell);
void setFromSimulationWell(RimEclipseWell* simWell);
void setDescription(const QString& description);
QString description() const;
void loadDataAndUpdate();
void handleViewerDeletion();
virtual QWidget* viewWidget() override;
virtual void zoomAll() override;
RimWellLogPlot* accumulatedWellFlowPlot();
RimTotalWellAllocationPlot* totalWellFlowPlot();
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
QString wellName() const;
void removeFromMdiAreaAndDeleteViewWidget();
protected:
// Overridden PDM methods
virtual caf::PdmFieldHandle* objectToggleField() { return &m_showWindow; }
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void setupBeforeSave() override;
virtual QImage snapshotWindowContent() override;
private:
void updateViewerWidget();
void updateViewerWidgetWindowTitle();
void deletePlotWidget();
void updateFromWell();
private:
caf::PdmField<bool> m_showWindow;
// RimViewWindow overrides
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
virtual void deleteViewWidget() override;
private:
caf::PdmField<bool> m_showPlotTitle;
caf::PdmField<QString> m_userName;
caf::PdmPtrField<RimEclipseWell*> m_simulationWell;
caf::PdmPtrField<RimEclipseResultCase*> m_case;
caf::PdmField<QString> m_wellName;
caf::PdmField<int> m_timeStep;
caf::PdmPtrField<RimFlowDiagSolution*> m_flowDiagSolution;
QPointer<RiuWellAllocationPlot> m_wellAllocationPlot;
QPointer<RiuWellAllocationPlot> m_wellAllocationPlotWidget;
caf::PdmChildField<RimWellLogPlot*> m_accumulatedWellFlowPlot;
caf::PdmChildField<RimTotalWellAllocationPlot*> m_totalWellAllocationPlot;
};

View File

@@ -0,0 +1,135 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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"
//==================================================================================================
///
///
//==================================================================================================
CAF_PDM_SOURCE_INIT(RimWellFlowRateCurve, "RimWellFlowRateCurve");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellFlowRateCurve::RimWellFlowRateCurve()
{
CAF_PDM_InitObject("Flow Rate Curve", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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 "Flow Rate";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellFlowRateCurve::createCurveAutoName()
{
return QString("%1 (%2)").arg(wellLogChannelName()).arg(wellName());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellFlowRateCurve::onLoadDataAndUpdate()
{
RimWellLogCurve::updateCurvePresentation();
if (isCurveVisible())
{
RimWellLogPlot* wellLogPlot;
firstAncestorOrThisOfType(wellLogPlot);
CVF_ASSERT(wellLogPlot);
m_qwtPlotCurve->setTitle(createCurveAutoName());
RimDefines::DepthUnitType displayUnit = RimDefines::UNIT_METER;
m_qwtPlotCurve->setSamples(m_curveData->xPlotValues().data(), m_curveData->measuredDepthPlotValues(displayUnit).data(), static_cast<int>(m_curveData->xPlotValues().size()));
m_qwtPlotCurve->setLineSegmentStartStopIndices(m_curveData->polylineStartStopIndices());
updateZoomInParentPlot();
if (m_parentQwtPlot) m_parentQwtPlot->replot();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellAllocationPlot* RimWellFlowRateCurve::wellAllocationPlot() const
{
RimWellAllocationPlot* wap = nullptr;
this->firstAncestorOrThisOfType(wap);
return wap;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellFlowRateCurve::setFlowValues(const std::vector<double>& measuredDepths, const std::vector<double>& flowRates)
{
m_curveData = new RigWellLogCurveData;
m_curveData->setValuesAndMD(flowRates, measuredDepths, RimDefines::UNIT_METER, false);
}

View File

@@ -0,0 +1,53 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimWellLogCurve.h"
#include "cafPdmPtrField.h"
#include "cafPdmChildField.h"
class RimEclipseResultCase;
class RimWellAllocationPlot;
//==================================================================================================
///
///
//==================================================================================================
class RimWellFlowRateCurve : public RimWellLogCurve
{
CAF_PDM_HEADER_INIT;
public:
RimWellFlowRateCurve();
virtual ~RimWellFlowRateCurve();
void setFlowValues(const std::vector<double>& measuredDepths, const std::vector<double>& flowRates);
virtual QString wellName() const override;
virtual QString wellLogChannelName() const override;
protected:
virtual QString createCurveAutoName() override;
virtual void onLoadDataAndUpdate() override;
private:
RimWellAllocationPlot* wellAllocationPlot() const;
};

View File

@@ -332,7 +332,7 @@ QList<caf::PdmOptionItemInfo> RimEclipseResultDefinition::calculateValueOptions(
if ( !hasFlowDiagFluxes )
{
using ResCatEnum = caf::AppEnum< RimDefines::ResultCatType >;
for ( int i = 0; i < ResCatEnum::size(); ++i )
for ( size_t i = 0; i < ResCatEnum::size(); ++i )
{
RimDefines::ResultCatType resType = ResCatEnum::fromIndex(i);
if ( resType != RimDefines::FLOW_DIAGNOSTICS )

View File

@@ -162,26 +162,6 @@ RimEclipseView::~RimEclipseView()
m_reservoir = NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseView::updateViewerWidgetWindowTitle()
{
if (m_viewer)
{
QString windowTitle;
if (m_reservoir.notNull())
{
windowTitle = QString("%1 - %2").arg(m_reservoir->caseUserDescription()).arg(name);
}
else
{
windowTitle = name;
}
m_viewer->layoutWidget()->setWindowTitle(windowTitle);
}
}
//--------------------------------------------------------------------------------------------------
/// Clamp the current timestep to actual possibilities
@@ -206,34 +186,7 @@ void RimEclipseView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
{
RimView::fieldChangedByUi(changedField, oldValue, newValue);
if (changedField == &showWindow)
{
if (showWindow)
{
bool generateDisplayModel = (viewer() == NULL);
updateViewerWidget();
if (generateDisplayModel)
{
updateDisplayModelForWellResults();
}
}
else
{
if (m_viewer)
{
this->setMdiWindowGeometry( RiuMainWindow::instance()->windowGeometryForViewer(m_viewer->layoutWidget()));
RiuMainWindow::instance()->removeViewer(m_viewer->layoutWidget());
delete m_viewer;
m_viewer = NULL;
}
}
this->updateUiIconFromToggleField();
}
else if (changedField == &showInvalidCells)
if (changedField == &showInvalidCells)
{
this->scheduleGeometryRegen(INACTIVE);
this->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE);
@@ -721,7 +674,7 @@ void RimEclipseView::loadDataAndUpdate()
this->faultResultSettings()->customFaultResult()->loadResult();
updateViewerWidget();
updateMdiWindowVisibility();
this->m_propertyFilterCollection()->loadAndInitializePropertyFilters();
@@ -729,6 +682,8 @@ void RimEclipseView::loadDataAndUpdate()
this->faultCollection()->syncronizeFaults();
m_reservoirGridPartManager->clearGeometryCache();
m_pipesPartManager->clearGeometryCache();
m_wellSpheresPartManager->clearGeometryCache();
syncronizeWellsWithResults();
@@ -743,6 +698,8 @@ void RimEclipseView::loadDataAndUpdate()
//--------------------------------------------------------------------------------------------------
void RimEclipseView::initAfterRead()
{
RimViewWindow::initAfterRead();
this->faultResultSettings()->setReservoirView(this);
this->cellResult()->setReservoirView(this);
this->cellEdgeResult()->setReservoirView(this);

View File

@@ -167,7 +167,6 @@ private:
void updateLegends();
void updateMinMaxValuesAndAddLegendToView(QString legendLabel, RimEclipseCellColors* resultColors, RigCaseCellResultsData* cellResultsData);
virtual void resetLegendsInViewer();
virtual void updateViewerWidgetWindowTitle();
std::set<RivCellSetEnum> allVisibleFaultGeometryTypes() const;
void updateFaultColors();

View File

@@ -28,6 +28,7 @@
#include "RimSimWellFractureCollection.h"
#include "cvfMath.h"
#include "RigSimulationWellCenterLineCalculator.h"
CAF_PDM_SOURCE_INIT(RimEclipseWell, "Well");
@@ -120,6 +121,25 @@ caf::PdmFieldHandle* RimEclipseWell::objectToggleField()
return &showWell;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseWell::calculateWellPipeStaticCenterLine(std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds)
{
RigSimulationWellCenterLineCalculator::calculateWellPipeStaticCenterline(this, pipeBranchesCLCoords, pipeBranchesCellIds);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseWell::calculateWellPipeDynamicCenterLine(size_t timeStepIdx,
std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds)
{
RigSimulationWellCenterLineCalculator::calculateWellPipeDynamicCenterline(this, timeStepIdx, pipeBranchesCLCoords, pipeBranchesCellIds);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -302,6 +322,17 @@ bool RimEclipseWell::isWellSpheresVisible(size_t frameIndex)
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipseWell::isUsingCellCenterForPipe()
{
RimEclipseWellCollection* wellColl = nullptr;
this->firstAncestorOrThisOfType(wellColl);
return (wellColl && wellColl->wellPipeCoordType() == RimEclipseWellCollection::WELLPIPE_CELLCENTER);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -53,14 +53,19 @@ public:
bool isWellPipeVisible(size_t frameIndex);
bool isWellSpheresVisible(size_t frameIndex);
bool isUsingCellCenterForPipe();
bool visibleCellsInstersectsWell(size_t frameIndex);
virtual caf::PdmFieldHandle* userDescriptionField();
virtual caf::PdmFieldHandle* objectToggleField();
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering);
void calculateWellPipeStaticCenterLine( std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds);
void calculateWellPipeDynamicCenterLine(size_t timeStepIdx,
std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds);
caf::PdmField<bool> showWell;
@@ -78,6 +83,10 @@ public:
caf::PdmChildField<RimSimWellFractureCollection*> simwellFractureCollection;
protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering);
private:
cvf::ref<RigSingleWellResultsData> m_wellResults;
size_t m_resultWellIndex;

View File

@@ -99,28 +99,6 @@ RimGeoMechView::~RimGeoMechView(void)
delete m_propertyFilterCollection;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::updateViewerWidgetWindowTitle()
{
if (m_viewer)
{
QString windowTitle;
if (m_geomechCase.notNull())
{
windowTitle = QString("%1 - %2").arg(m_geomechCase->caseUserDescription()).arg(name);
}
else
{
windowTitle = name;
}
m_viewer->layoutWidget()->setWindowTitle(windowTitle);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -156,7 +134,7 @@ void RimGeoMechView::loadDataAndUpdate()
progress.incrementProgress();
progress.setProgressDescription("Create Display model");
updateViewerWidget();
updateMdiWindowVisibility();
this->geoMechPropertyFilterCollection()->loadAndInitializePropertyFilters();
@@ -498,33 +476,6 @@ cvf::Transform* RimGeoMechView::scaleTransform()
void RimGeoMechView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
RimView::fieldChangedByUi(changedField, oldValue, newValue);
if (changedField == &showWindow)
{
if (showWindow)
{
bool generateDisplayModel = (viewer() == NULL);
updateViewerWidget();
if (generateDisplayModel)
{
scheduleCreateDisplayModelAndRedraw();
}
}
else
{
if (m_viewer)
{
this->setMdiWindowGeometry( RiuMainWindow::instance()->windowGeometryForViewer(m_viewer->layoutWidget()));
RiuMainWindow::instance()->removeViewer(m_viewer->layoutWidget());
delete m_viewer;
m_viewer = NULL;
}
}
this->updateUiIconFromToggleField();
}
}
//--------------------------------------------------------------------------------------------------
@@ -532,6 +483,7 @@ void RimGeoMechView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
//--------------------------------------------------------------------------------------------------
void RimGeoMechView::initAfterRead()
{
RimViewWindow::initAfterRead();
this->cellResult()->setGeoMechCase(m_geomechCase);
this->updateUiIconFromToggleField();

View File

@@ -99,7 +99,6 @@ private:
virtual void updateCurrentTimeStep();
virtual void updateStaticCellColors();
virtual void updateViewerWidgetWindowTitle();
virtual void resetLegendsInViewer();
void updateLegends();

View File

@@ -393,7 +393,7 @@ void RimIntersection::updateWellCenterline() const
{
std::vector< std::vector <RigWellResultPoint> > pipeBranchesCellIds;
RigSimulationWellCenterLineCalculator::calculateWellPipeCenterline(simulationWell(), m_wellBranchCenterlines, pipeBranchesCellIds);
simulationWell->calculateWellPipeStaticCenterLine(m_wellBranchCenterlines, pipeBranchesCellIds);
}
}
else

View File

@@ -169,7 +169,8 @@ void RimMainPlotCollection::deleteAllContainedObjects()
{
m_wellLogPlotCollection()->wellLogPlots.deleteAllChildObjects();
m_summaryPlotCollection()->summaryPlots.deleteAllChildObjects();
m_flowPlotCollection()->flowPlots.deleteAllChildObjects();
m_flowPlotCollection()->closeDefaultPlotWindowAndDeletePlots();
}
#if 0

View File

@@ -0,0 +1,173 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimMdiWindowController.h"
#include "RiaApplication.h"
#include "RimViewWindow.h"
#include "RiuMainWindowBase.h"
CAF_PDM_XML_SOURCE_INIT(RimMdiWindowController, "MdiWindowController");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMdiWindowController::RimMdiWindowController()
{
CAF_PDM_InitField(&m_mainWindowID, "MainWindowID", -1, "", "", "", "" );
CAF_PDM_InitField(& m_x , "xPos", -1, "", "", "", "" );
CAF_PDM_InitField(& m_y , "yPos", -1, "", "", "", "" );
CAF_PDM_InitField(& m_width , "Width", -1, "", "", "", "" );
CAF_PDM_InitField(& m_height , "Height", -1, "", "", "", "" );
CAF_PDM_InitField(& m_isMaximized, "IsMaximized", false, "", "", "", "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMdiWindowController::~RimMdiWindowController()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMdiWindowController::setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry)
{
m_mainWindowID = windowGeometry.mainWindowID;
m_x = windowGeometry.x;
m_y = windowGeometry.y;
m_width = windowGeometry.width;
m_height = windowGeometry.height;
m_isMaximized = windowGeometry.isMaximized;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMdiWindowGeometry RimMdiWindowController::mdiWindowGeometry()
{
RimMdiWindowGeometry windowGeometry;
windowGeometry.mainWindowID = m_mainWindowID;
windowGeometry.x = m_x ;
windowGeometry.y = m_y ;
windowGeometry.width = m_width ;
windowGeometry.height = m_height ;
windowGeometry.isMaximized = m_isMaximized ;
return windowGeometry;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMdiWindowController::handleViewerDeletion()
{
viewPdmObject()->m_showWindow = false;
uiCapability()->updateUiIconFromToggleField();
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMdiWindowController::removeWindowFromMDI()
{
RiuMainWindowBase* mainWin = getMainWindow();
if (mainWin && viewWidget()) mainWin->removeViewer(viewWidget());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimViewWindow* RimMdiWindowController::viewPdmObject()
{
RimViewWindow * viewWindowObj;
this->firstAncestorOrThisOfType(viewWindowObj);
return viewWindowObj;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QWidget* RimMdiWindowController::viewWidget()
{
return viewPdmObject()->viewWidget();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuMainWindowBase* RimMdiWindowController::getMainWindow()
{
return RiaApplication::instance()->mainWindowByID(m_mainWindowID);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMdiWindowController::setupBeforeSave()
{
if ( viewWidget() && getMainWindow() )
{
this->setMdiWindowGeometry(getMainWindow()->windowGeometryForViewer(viewWidget()));
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMdiWindowController::updateViewerWidget()
{
RiuMainWindowBase* mainWindow = getMainWindow();
if ( !mainWindow ) return;
if ( viewPdmObject()->m_showWindow() )
{
if ( !viewWidget() )
{
QWidget * viewWidget = viewPdmObject()->createViewWidget(mainWindow);
mainWindow->addViewer(viewWidget, this->mdiWindowGeometry());
mainWindow->setActiveViewer(viewWidget);
viewPdmObject()->updateViewWidgetAfterCreation();
}
else
{
mainWindow->setActiveViewer(viewWidget());
}
viewPdmObject()->updateMdiWindowTitle();
}
else
{
if ( viewWidget() )
{
this->setMdiWindowGeometry(mainWindow->windowGeometryForViewer(viewWidget()));
mainWindow->removeViewer(viewWidget());
viewPdmObject()->deleteViewWidget();
}
}
}

View File

@@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmObject.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
class RimViewWindow;
class RiuMainWindowBase;
struct RimMdiWindowGeometry;
//==================================================================================================
///
///
//==================================================================================================
class RimMdiWindowController : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimMdiWindowController();
virtual ~RimMdiWindowController();
void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry);
RimMdiWindowGeometry mdiWindowGeometry();
void updateViewerWidget();
void handleViewerDeletion();
void removeWindowFromMDI();
protected:
RimViewWindow* viewPdmObject();
QWidget* viewWidget();
RiuMainWindowBase* getMainWindow();
// Overridden PDM methods
virtual void setupBeforeSave() override;
private:
caf::PdmField< int > m_mainWindowID;
caf::PdmField< int > m_x;
caf::PdmField< int > m_y;
caf::PdmField< int > m_width;
caf::PdmField< int > m_height;
caf::PdmField< bool> m_isMaximized;
};

View File

@@ -73,9 +73,6 @@ RimView::RimView(void)
CAF_PDM_InitField(&name, "UserDescription", QString(""), "Name", "", "", "");
CAF_PDM_InitField(&showWindow, "ShowWindow", true, "Show 3D viewer", "", "", "");
showWindow.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", "");
cameraPosition.uiCapability()->setUiHidden(true);
@@ -140,6 +137,8 @@ RimView::RimView(void)
m_wellPathPipeVizModel = new cvf::ModelBasicList;
m_wellPathPipeVizModel->setName("WellPathPipeModel");
this->setAs3DViewMdiWindow();
}
//--------------------------------------------------------------------------------------------------
@@ -169,12 +168,9 @@ RimView::~RimView(void)
delete this->m_overlayInfoConfig();
if (m_viewer)
{
RiuMainWindow::instance()->removeViewer(m_viewer->layoutWidget());
}
removeMdiWindowFromMdiArea();
delete m_viewer;
deleteViewWidget();
delete m_rangeFilterCollection;
delete m_overrideRangeFilterCollection;
@@ -193,64 +189,76 @@ RiuViewer* RimView::viewer()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::updateViewerWidget()
QWidget* RimView::createViewWidget(QWidget* mainWindowParent)
{
if (showWindow())
{
bool isViewerCreated = false;
if (!m_viewer)
{
QGLFormat glFormat;
glFormat.setDirectRendering(RiaApplication::instance()->useShaders());
QGLFormat glFormat;
glFormat.setDirectRendering(RiaApplication::instance()->useShaders());
m_viewer = new RiuViewer(glFormat, NULL);
m_viewer->setOwnerReservoirView(this);
m_viewer = new RiuViewer(glFormat, NULL);
m_viewer->setOwnerReservoirView(this);
RiuMainWindow::instance()->addViewer(m_viewer->layoutWidget(), mdiWindowGeometry());
m_viewer->setDefaultPerspectiveNearPlaneDistance(10);
this->resetLegendsInViewer();
m_viewer->updateNavigationPolicy();
m_viewer->enablePerfInfoHud(RiaApplication::instance()->showPerformanceInfo());
isViewerCreated = true;
}
RiuMainWindow::instance()->setActiveViewer(m_viewer->layoutWidget());
if(isViewerCreated)
{
m_viewer->mainCamera()->setViewMatrix(cameraPosition);
m_viewer->setPointOfInterest(cameraPointOfInterest());
m_viewer->enableParallelProjection(!isPerspectiveView());
}
m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor()));
this->updateGridBoxData();
this->createHighlightAndGridBoxDisplayModel();
m_viewer->update();
}
else
{
if (m_viewer && m_viewer->layoutWidget())
{
if (m_viewer->layoutWidget()->parentWidget())
{
m_viewer->layoutWidget()->parentWidget()->hide();
}
else
{
m_viewer->layoutWidget()->hide();
}
}
}
updateViewerWidgetWindowTitle();
return m_viewer->layoutWidget();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::updateViewWidgetAfterCreation()
{
m_viewer->setDefaultPerspectiveNearPlaneDistance(10);
this->resetLegendsInViewer();
m_viewer->updateNavigationPolicy();
m_viewer->enablePerfInfoHud(RiaApplication::instance()->showPerformanceInfo());
m_viewer->mainCamera()->setViewMatrix(cameraPosition);
m_viewer->setPointOfInterest(cameraPointOfInterest());
m_viewer->enableParallelProjection(!isPerspectiveView());
m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor()));
this->updateGridBoxData();
this->createHighlightAndGridBoxDisplayModel();
m_viewer->update();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::updateMdiWindowTitle()
{
if (m_viewer)
{
QString windowTitle;
if (ownerCase())
{
windowTitle = QString("%1 - %2").arg(ownerCase()->caseUserDescription()).arg(name);
}
else
{
windowTitle = name;
}
m_viewer->layoutWidget()->setWindowTitle(windowTitle);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::deleteViewWidget()
{
if (m_viewer)
{
m_viewer->deleteLater();
m_viewer = nullptr;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -367,8 +375,6 @@ void RimView::setupBeforeSave()
hasUserRequestedAnimation = m_viewer->isAnimationActive(); // JJS: This is not conceptually correct. The variable is updated as we go, and store the user intentions. But I guess that in practice...
cameraPosition = m_viewer->mainCamera()->viewMatrix();
cameraPointOfInterest = m_viewer->pointOfInterest();
setMdiWindowGeometry(RiuMainWindow::instance()->windowGeometryForViewer(m_viewer->layoutWidget()));
}
}
@@ -514,6 +520,8 @@ bool RimView::isLightingDisabled() const
//--------------------------------------------------------------------------------------------------
void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue);
if (changedField == &meshMode)
{
createDisplayModel();
@@ -586,7 +594,7 @@ void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV
}
else if (changedField == &name)
{
updateViewerWidgetWindowTitle();
updateMdiWindowTitle();
if (viewController())
{
@@ -617,9 +625,9 @@ void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV
}
else if (changedField == &backgroundColor)
{
if (viewer() != NULL)
if (m_viewer != nullptr)
{
updateViewerWidget();
m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor()));
}
}
else if (changedField == &maximumFrameRate)
@@ -956,6 +964,15 @@ cvf::ref<caf::DisplayCoordTransform> RimView::displayCoordTransform()
//--------------------------------------------------------------------------------------------------
QWidget* RimView::viewWidget()
{
return m_viewer;
if ( m_viewer ) return m_viewer->layoutWidget();
else return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimView::forceShowWindowOn()
{
m_showWindow.setValueWithFieldChanged(true);
}

View File

@@ -82,7 +82,6 @@ public:
caf::PdmField<QString> name;
caf::PdmField<double> scaleZ;
caf::PdmField<bool> showWindow;
caf::PdmField<cvf::Mat4d> cameraPosition;
caf::PdmField<cvf::Vec3d> cameraPointOfInterest;
caf::PdmField<bool> isPerspectiveView;
@@ -164,12 +163,12 @@ public:
cvf::ref<caf::DisplayCoordTransform> displayCoordTransform();
virtual QWidget* viewWidget() override;
void forceShowWindowOn();
public:
virtual void loadDataAndUpdate() = 0;
virtual RimCase* ownerCase() = 0;
virtual caf::PdmFieldHandle* objectToggleField() { return &showWindow; }
virtual caf::PdmFieldHandle* userDescriptionField() { return &name; }
protected:
@@ -199,9 +198,6 @@ protected:
virtual void updateScaleTransform() = 0;
virtual cvf::Transform* scaleTransform() = 0;
void updateViewerWidget();
virtual void updateViewerWidgetWindowTitle() = 0;
virtual void resetLegendsInViewer() = 0;
virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility) = 0;
@@ -217,8 +213,13 @@ protected:
// Overridden PDM methods:
virtual void setupBeforeSave();
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
virtual void updateViewWidgetAfterCreation() override;
virtual void updateMdiWindowTitle() override;
virtual void deleteViewWidget() override;
cvf::ref<cvf::UByteArray> m_currentReservoirCellVisibility;

View File

@@ -17,7 +17,9 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RimViewWindow.h"
#include "RimMdiWindowController.h"
#include "cvfAssert.h"
#include <QWidget>
CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimViewWindow, "ViewWindow"); // Do not use. Abstract class
@@ -26,9 +28,17 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimViewWindow, "ViewWindow"); // Do not use. Ab
//--------------------------------------------------------------------------------------------------
RimViewWindow::RimViewWindow(void)
{
CAF_PDM_InitFieldNoDefault(&m_windowGeometry, "WindowGeometry", "", "", "", "");
m_windowGeometry.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_windowController, "WindowController", "", "", "", "");
m_windowController.uiCapability()->setUiHidden(true);
m_windowController.uiCapability()->setUiTreeChildrenHidden(true);
CAF_PDM_InitField(&m_showWindow, "ShowWindow", true, "Show Window", "", "", "");
m_showWindow.uiCapability()->setUiHidden(true);
// Obsolete field
CAF_PDM_InitFieldNoDefault(&obsoleteField_windowGeometry, "WindowGeometry", "", "", "", "");
obsoleteField_windowGeometry.uiCapability()->setUiHidden(true);
obsoleteField_windowGeometry.xmlCapability()->setIOWritable(false);
}
//--------------------------------------------------------------------------------------------------
@@ -36,7 +46,48 @@ RimViewWindow::RimViewWindow(void)
//--------------------------------------------------------------------------------------------------
RimViewWindow::~RimViewWindow(void)
{
if ( m_windowController() ) delete m_windowController() ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimViewWindow::removeMdiWindowFromMdiArea()
{
if ( m_windowController() ) m_windowController->removeWindowFromMDI();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimViewWindow::handleMdiWindowClosed()
{
if ( m_windowController() ) m_windowController->handleViewerDeletion();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimViewWindow::updateMdiWindowVisibility()
{
if (m_windowController())
{
m_windowController->updateViewerWidget();
}
else
{
if (viewWidget())
{
if (m_showWindow)
{
viewWidget()->show();
}
else
{
viewWidget()->hide();
}
}
}
}
//--------------------------------------------------------------------------------------------------
@@ -44,17 +95,10 @@ RimViewWindow::~RimViewWindow(void)
//--------------------------------------------------------------------------------------------------
void RimViewWindow::setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry)
{
std::vector<int> geom;
geom.clear();
if (windowGeometry.isValid())
{
geom.push_back(windowGeometry.x);
geom.push_back(windowGeometry.y);
geom.push_back(windowGeometry.width);
geom.push_back(windowGeometry.height);
geom.push_back(windowGeometry.isMaximized);
}
m_windowGeometry.setValue(geom);
CVF_ASSERT(m_windowController());
if (m_windowController()) m_windowController()->setMdiWindowGeometry(windowGeometry);
}
//--------------------------------------------------------------------------------------------------
@@ -62,17 +106,97 @@ void RimViewWindow::setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeome
//--------------------------------------------------------------------------------------------------
RimMdiWindowGeometry RimViewWindow::mdiWindowGeometry()
{
CVF_ASSERT(m_windowController());
RimMdiWindowGeometry wg;
if (m_windowGeometry.value().size() == 5)
{
wg.x = m_windowGeometry.value()[0];
wg.y = m_windowGeometry.value()[1];
wg.width = m_windowGeometry.value()[2];
wg.height = m_windowGeometry.value()[3];
wg.isMaximized = m_windowGeometry.value()[4];
}
if (m_windowController()) return m_windowController()->mdiWindowGeometry();
else return RimMdiWindowGeometry();
return wg;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimViewWindow::objectToggleField()
{
return &m_showWindow;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimViewWindow::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if ( changedField == &m_showWindow )
{
if (m_showWindow)
{
loadDataAndUpdate();
}
else
{
updateMdiWindowVisibility();
}
uiCapability()->updateUiIconFromToggleField();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimViewWindow::updateMdiWindowTitle()
{
if ( viewWidget() )
{
caf::PdmUiFieldHandle* uiFieldHandle = this->userDescriptionField()->uiCapability();
if ( uiFieldHandle )
{
QVariant v = uiFieldHandle->uiValue();
viewWidget()->setWindowTitle(v.toString());
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimViewWindow::setAsMdiWindow(int mainWindowID)
{
if ( !m_windowController() )
{
m_windowController = new RimMdiWindowController;
RimMdiWindowGeometry mwg;
mwg.mainWindowID = mainWindowID;
setMdiWindowGeometry(mwg);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
#include "RimView.h"
void RimViewWindow::initAfterRead()
{
if (obsoleteField_windowGeometry.value().size() == 5)
{
RimMdiWindowGeometry wg;
int mainWindowID = -1;
if (dynamic_cast<RimView*> (this))
mainWindowID = 0;
else
mainWindowID = 1;
wg.mainWindowID = mainWindowID;
wg.x = obsoleteField_windowGeometry.value()[0];
wg.y = obsoleteField_windowGeometry.value()[1];
wg.width = obsoleteField_windowGeometry.value()[2];
wg.height = obsoleteField_windowGeometry.value()[3];
wg.isMaximized = obsoleteField_windowGeometry.value()[4];
setAsMdiWindow(mainWindowID);
setMdiWindowGeometry(wg);
}
}

View File

@@ -20,13 +20,18 @@
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cafPdmChildField.h"
#include <vector>
class RimMdiWindowController;
struct RimMdiWindowGeometry
{
RimMdiWindowGeometry() : x(0), y(0), width(-1), height(-1) {}
bool isValid() const { return (width >= 0 && height >= 0);}
RimMdiWindowGeometry() : mainWindowID(-1), x(0), y(0), width(-1), height(-1) {}
bool isValid() const { return (mainWindowID >= 0 && width >= 0 && height >= 0);}
int mainWindowID;
int x;
int y;
@@ -42,15 +47,49 @@ public:
RimViewWindow(void);
virtual ~RimViewWindow(void);
void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry);
RimMdiWindowGeometry mdiWindowGeometry();
void handleMdiWindowClosed();
void setAs3DViewMdiWindow() { setAsMdiWindow(0); }
void setAsPlotMdiWindow() { setAsMdiWindow(1); }
void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry);
RimMdiWindowGeometry mdiWindowGeometry();
virtual QWidget* viewWidget() = 0;
virtual QImage snapshotWindowContent() = 0;
virtual void zoomAll() = 0;
virtual QImage snapshotWindowContent() = 0;
virtual void zoomAll() = 0;
protected:
void removeMdiWindowFromMdiArea();
void updateMdiWindowVisibility();
virtual QWidget* viewWidget() = 0;
///////// Interface for the Window controller
friend class RimMdiWindowController;
private:
caf::PdmField< std::vector<int> > m_windowGeometry;
virtual QWidget* createViewWidget(QWidget* mainWindowParent) = 0;
virtual void updateViewWidgetAfterCreation() {};
virtual void updateMdiWindowTitle(); // Has real default implementation
virtual void deleteViewWidget() = 0;
virtual void loadDataAndUpdate() = 0;
//////////
// Derived classes are not supposed to override this function. The intention is to always use m_showWindow
// as the objectToggleField for this class. This way the visibility of a widget being part of a composite widget
// can be controlled from the project tree using check box toggles
virtual caf::PdmFieldHandle* objectToggleField() override final;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void initAfterRead() override;
caf::PdmField<bool> m_showWindow;
private:
void setAsMdiWindow(int mainWindowID);
caf::PdmChildField<RimMdiWindowController*> m_windowController;
// Obsoleted field
caf::PdmField< std::vector<int> > obsoleteField_windowGeometry;
};

View File

@@ -59,9 +59,6 @@ RimWellLogPlot::RimWellLogPlot()
m_viewer = NULL;
CAF_PDM_InitField(&m_showWindow, "ShowWindow", true, "Show well log plot", "", "", "");
m_showWindow.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_userName, "PlotDescription", QString("Well Log Plot"),"Name", "", "", "");
caf::AppEnum< RimWellLogPlot::DepthTypeEnum > depthType = MEASURED_DEPTH;
@@ -86,52 +83,11 @@ RimWellLogPlot::RimWellLogPlot()
//--------------------------------------------------------------------------------------------------
RimWellLogPlot::~RimWellLogPlot()
{
if (RiaApplication::instance()->mainPlotWindow())
{
RiaApplication::instance()->mainPlotWindow()->removeViewer(m_viewer);
}
removeMdiWindowFromMdiArea();
detachAllCurves();
m_tracks.deleteAllChildObjects();
delete m_viewer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::updateViewerWidget()
{
RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow();
if (!mainPlotWindow) return;
if (m_showWindow())
{
if (!m_viewer)
{
m_viewer = new RiuWellLogPlot(this, mainPlotWindow);
recreateTrackPlots();
mainPlotWindow->addViewer(m_viewer, this->mdiWindowGeometry());
mainPlotWindow->setActiveViewer(m_viewer);
}
updateViewerWidgetWindowTitle();
}
else
{
if (m_viewer)
{
this->setMdiWindowGeometry(mainPlotWindow->windowGeometryForViewer(m_viewer));
mainPlotWindow->removeViewer(m_viewer);
detachAllCurves();
delete m_viewer;
m_viewer = NULL;
}
}
deleteViewWidget();
}
//--------------------------------------------------------------------------------------------------
@@ -139,20 +95,9 @@ void RimWellLogPlot::updateViewerWidget()
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (changedField == &m_showWindow)
{
if (m_showWindow)
{
loadDataAndUpdate();
}
else
{
updateViewerWidget();
}
RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue);
uiCapability()->updateUiIconFromToggleField();
}
else if (changedField == &m_minVisibleDepth || changedField == &m_maxVisibleDepth)
if (changedField == &m_minVisibleDepth || changedField == &m_maxVisibleDepth)
{
applyDepthZoomFromVisibleDepth();
@@ -164,7 +109,7 @@ void RimWellLogPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
}
else if (changedField == &m_userName)
{
updateViewerWidgetWindowTitle();
updateMdiWindowTitle();
}
if (changedField == &m_depthType ||
changedField == &m_depthUnit)
@@ -173,14 +118,6 @@ void RimWellLogPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimWellLogPlot::objectToggleField()
{
return &m_showWindow;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -240,6 +177,17 @@ void RimWellLogPlot::removeTrack(RimWellLogTrack* track)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::removeTrackByIndex(size_t index)
{
CVF_ASSERT(index < m_tracks.size());
RimWellLogTrack* track = m_tracks[index];
this->removeTrack(track);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -269,6 +217,14 @@ void RimWellLogPlot::moveTracks(RimWellLogTrack* insertAfterTrack, const std::ve
updateTrackNames();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogTrack* RimWellLogPlot::trackByIndex(size_t index)
{
return m_tracks[index];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -391,21 +347,6 @@ void RimWellLogPlot::depthZoomMinMax(double* minimumDepth, double* maximumDepth)
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::setupBeforeSave()
{
if (m_viewer)
{
if (RiaApplication::instance()->mainPlotWindow())
{
this->setMdiWindowGeometry(RiaApplication::instance()->mainPlotWindow()->windowGeometryForViewer(m_viewer));
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -427,7 +368,7 @@ void RimWellLogPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::loadDataAndUpdate()
{
updateViewerWidget();
updateMdiWindowVisibility();
updateTracks();
}
@@ -548,29 +489,27 @@ QString RimWellLogPlot::description() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::updateViewerWidgetWindowTitle()
QWidget* RimWellLogPlot::createViewWidget(QWidget* mainWindowParent)
{
if (m_viewer)
{
m_viewer->setWindowTitle(m_userName);
}
m_viewer = new RiuWellLogPlot(this, mainWindowParent);
recreateTrackPlots();
return m_viewer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogPlot::handleViewerDeletion()
void RimWellLogPlot::deleteViewWidget()
{
m_showWindow = false;
detachAllCurves();
if (m_viewer)
{
detachAllCurves();
m_viewer = NULL;
}
uiCapability()->updateUiIconFromToggleField();
updateConnectedEditors();
if (m_viewer)
{
m_viewer->deleteLater();
m_viewer = nullptr;
}
}
//--------------------------------------------------------------------------------------------------

View File

@@ -24,11 +24,11 @@
#include "cafPdmChildArrayField.h"
#include "cafAppEnum.h"
#include <QPointer>
#include "RimDefines.h"
#include "RimViewWindow.h"
#include <QPointer>
class RiuWellLogPlot;
class RimWellLogTrack;
@@ -66,10 +66,14 @@ public:
void addTrack(RimWellLogTrack* track);
void insertTrack(RimWellLogTrack* track, size_t index);
size_t trackCount() { return m_tracks.size();}
void removeTrackByIndex(size_t index);
void removeTrack(RimWellLogTrack* track);
size_t trackIndex(RimWellLogTrack* track);
void moveTracks(RimWellLogTrack* insertAfterTrack, const std::vector<RimWellLogTrack*>& tracksToMove);
RimWellLogTrack* trackByIndex(size_t index);
void loadDataAndUpdate();
void updateTracks();
void updateTrackNames();
@@ -91,25 +95,25 @@ protected:
// Overridden PDM methods
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual void setupBeforeSave();
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering);
virtual caf::PdmFieldHandle* objectToggleField();
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
virtual QImage snapshotWindowContent() override;
private:
void updateViewerWidget();
void updateViewerWidgetWindowTitle();
void applyZoomAllDepths();
void applyDepthZoomFromVisibleDepth();
void recreateTrackPlots();
void detachAllCurves();
void handleViewerDeletion();
public: // Needed by RiuWellAllocation Plot
// RimViewWindow overrides
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
virtual void deleteViewWidget() override;
private:
caf::PdmField<bool> m_showWindow;
caf::PdmField<QString> m_userName;
caf::PdmField< caf::AppEnum< DepthTypeEnum > > m_depthType;

View File

@@ -72,7 +72,11 @@ RimWellLogTrack::~RimWellLogTrack()
{
curves.deleteAllChildObjects();
delete m_wellLogTrackPlotWidget;
if (m_wellLogTrackPlotWidget)
{
m_wellLogTrackPlotWidget->deleteLater();
m_wellLogTrackPlotWidget = nullptr;
}
}
//--------------------------------------------------------------------------------------------------

View File

@@ -51,8 +51,6 @@ CAF_PDM_SOURCE_INIT(RimSummaryPlot, "SummaryPlot");
RimSummaryPlot::RimSummaryPlot()
{
CAF_PDM_InitObject("Summary Plot", ":/SummaryPlot16x16.png", "", "");
CAF_PDM_InitField(&m_showWindow, "ShowWindow", true, "Show Summary Plot", "", "", "");
m_showWindow.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_userName, "PlotDescription", QString("Summary Plot"), "Name", "", "", "");
CAF_PDM_InitField(&m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "");
@@ -85,6 +83,8 @@ RimSummaryPlot::RimSummaryPlot()
CAF_PDM_InitField(&m_isAutoZoom, "AutoZoom", true, "Auto Zoom", "", "", "");
m_isAutoZoom.uiCapability()->setUiHidden(true);
setAsPlotMdiWindow();
}
//--------------------------------------------------------------------------------------------------
@@ -92,29 +92,14 @@ RimSummaryPlot::RimSummaryPlot()
//--------------------------------------------------------------------------------------------------
RimSummaryPlot::~RimSummaryPlot()
{
if (RiaApplication::instance()->mainPlotWindow())
{
RiaApplication::instance()->mainPlotWindow()->removeViewer(m_qwtPlot);
}
removeMdiWindowFromMdiArea();
deletePlotWidget();
deleteViewWidget();
m_curves.deleteAllChildObjects();
m_curveFilters.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::deletePlotWidget()
{
if (m_qwtPlot)
{
m_qwtPlot->deleteLater();
m_qwtPlot = NULL;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -367,22 +352,6 @@ void RimSummaryPlot::updateTimeAxis()
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::handleViewerDeletion()
{
m_showWindow = false;
if (m_qwtPlot)
{
detachAllCurves();
}
uiCapability()->updateUiIconFromToggleField();
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -504,36 +473,15 @@ void RimSummaryPlot::addCurveFilter(RimSummaryCurveFilter* curveFilter)
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (changedField == &m_showWindow)
{
if (m_showWindow)
{
loadDataAndUpdate();
}
else
{
updateViewerWidget();
}
RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue);
uiCapability()->updateUiIconFromToggleField();
}
else if (changedField == &m_userName ||
changedField == &m_showPlotTitle)
if (changedField == &m_userName ||
changedField == &m_showPlotTitle)
{
updateViewerWidgetWindowTitle();
updateMdiWindowTitle();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::setupBeforeSave()
{
if (m_qwtPlot && RiaApplication::instance()->mainPlotWindow())
{
this->setMdiWindowGeometry(RiaApplication::instance()->mainPlotWindow()->windowGeometryForViewer(m_qwtPlot));
}
}
//--------------------------------------------------------------------------------------------------
///
@@ -578,7 +526,7 @@ void RimSummaryPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::loadDataAndUpdate()
{
updateViewerWidget();
updateMdiWindowVisibility();
for (RimSummaryCurveFilter* curveFilter: m_curveFilters)
{
@@ -669,51 +617,44 @@ QString RimSummaryPlot::description() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateViewerWidget()
QWidget* RimSummaryPlot::createViewWidget(QWidget* mainWindowParent)
{
RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow();
if (!mainPlotWindow) return;
if (m_showWindow())
if (!m_qwtPlot)
{
if (!m_qwtPlot)
m_qwtPlot = new RiuSummaryQwtPlot(this, mainWindowParent);
for(RimSummaryCurveFilter* curveFilter: m_curveFilters)
{
m_qwtPlot = new RiuSummaryQwtPlot(this, mainPlotWindow);
for(RimSummaryCurveFilter* curveFilter: m_curveFilters)
{
curveFilter->setParentQwtPlot(m_qwtPlot);
}
for(RimSummaryCurve* curve : m_curves)
{
curve->setParentQwtPlot(m_qwtPlot);
}
mainPlotWindow->addViewer(m_qwtPlot, this->mdiWindowGeometry());
mainPlotWindow->setActiveViewer(m_qwtPlot);
curveFilter->setParentQwtPlot(m_qwtPlot);
}
updateViewerWidgetWindowTitle();
for(RimSummaryCurve* curve : m_curves)
{
curve->setParentQwtPlot(m_qwtPlot);
}
}
else
return m_qwtPlot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::deleteViewWidget()
{
detachAllCurves();
if (m_qwtPlot)
{
if (m_qwtPlot)
{
this->setMdiWindowGeometry(mainPlotWindow->windowGeometryForViewer(m_qwtPlot));
mainPlotWindow->removeViewer(m_qwtPlot);
detachAllCurves();
deletePlotWidget();
}
m_qwtPlot->deleteLater();
m_qwtPlot = nullptr;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryPlot::updateViewerWidgetWindowTitle()
void RimSummaryPlot::updateMdiWindowTitle()
{
if (m_qwtPlot)
{

View File

@@ -64,7 +64,7 @@ public:
void loadDataAndUpdate();
void handleViewerDeletion();
void detachAllCurves();
void updateCaseNameHasChanged();
void updateAxes();
@@ -88,19 +88,13 @@ public:
protected:
// Overridden PDM methods
virtual caf::PdmFieldHandle* objectToggleField() { return &m_showWindow; }
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void setupBeforeSave() override;
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override;
virtual QImage snapshotWindowContent() override;
private:
void updateViewerWidget();
void updateViewerWidgetWindowTitle();
void detachAllCurves();
void deletePlotWidget();
void updateAxis(RimDefines::PlotAxis plotAxis);
std::vector<RimSummaryCurve*> curvesForAxis(RimDefines::PlotAxis plotAxis) const;
@@ -109,10 +103,13 @@ private:
void updateTimeAxis();
void setZoomIntervalsInQwtPlot();
// RimViewWindow overrides
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
void updateMdiWindowTitle() override;
virtual void deleteViewWidget() override;
private:
caf::PdmField<bool> m_showWindow;
caf::PdmField<bool> m_showPlotTitle;
caf::PdmField<QString> m_userName;