From d1fc39a51c63e066d588af99e323ae7aac6ce6dd Mon Sep 17 00:00:00 2001 From: Ruben Thoms Date: Fri, 13 Nov 2020 10:56:25 +0100 Subject: [PATCH] Merged in VFP-tables commit 95f1742eab2b9dae391a253a5452b0f143d07abd. --- .../ProjectDataModel/CMakeLists_files.cmake | 4 + .../RimMainPlotCollection.cpp | 14 + .../ProjectDataModel/RimMainPlotCollection.h | 3 + .../ProjectDataModel/RimProject.cpp | 6 + .../ProjectDataModel/RimVfpPlot.cpp | 472 ++++++++++++++++++ ApplicationCode/ProjectDataModel/RimVfpPlot.h | 95 ++++ .../ProjectDataModel/RimVfpPlotCollection.cpp | 74 +++ .../ProjectDataModel/RimVfpPlotCollection.h | 43 ++ 8 files changed, 711 insertions(+) create mode 100644 ApplicationCode/ProjectDataModel/RimVfpPlot.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimVfpPlot.h create mode 100644 ApplicationCode/ProjectDataModel/RimVfpPlotCollection.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimVfpPlotCollection.h diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index f6c824cb33..d42ecd41ea 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -77,6 +77,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RimMainPlotCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlotCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimRftPlotCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimPltPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimVfpPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot.h ${CMAKE_CURRENT_LIST_DIR}/RimPlot.h ${CMAKE_CURRENT_LIST_DIR}/RimPlotWindow.h ${CMAKE_CURRENT_LIST_DIR}/RimMultiPlot.h @@ -241,6 +243,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RimMainPlotCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlotCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimRftPlotCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPltPlotCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimVfpPlotCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimVfpPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPlot.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPlotWindow.cpp ${CMAKE_CURRENT_LIST_DIR}/RimMultiPlot.cpp diff --git a/ApplicationCode/ProjectDataModel/RimMainPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimMainPlotCollection.cpp index 65bada910b..ae4129c880 100644 --- a/ApplicationCode/ProjectDataModel/RimMainPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimMainPlotCollection.cpp @@ -35,6 +35,7 @@ #include "RimSummaryAddress.h" #include "RimSummaryCrossPlotCollection.h" #include "RimSummaryPlotCollection.h" +#include "RimVfpPlotCollection.h" #include "RimViewWindow.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotCollection.h" @@ -98,6 +99,9 @@ RimMainPlotCollection::RimMainPlotCollection() CAF_PDM_InitFieldNoDefault( &m_stimPlanModelPlotCollection, "StimPlanModelPlotCollection", "", "", "", "" ); m_stimPlanModelPlotCollection.uiCapability()->setUiHidden( true ); + CAF_PDM_InitFieldNoDefault( &m_vfpPlotCollection, "VfpPlotCollection", "", "", "", "" ); + m_vfpPlotCollection.uiCapability()->setUiHidden( true ); + m_wellLogPlotCollection = new RimWellLogPlotCollection(); m_rftPlotCollection = new RimRftPlotCollection(); m_pltPlotCollection = new RimPltPlotCollection(); @@ -110,6 +114,7 @@ RimMainPlotCollection::RimMainPlotCollection() m_analysisPlotCollection = new RimAnalysisPlotCollection; m_correlationPlotCollection = new RimCorrelationPlotCollection; m_stimPlanModelPlotCollection = new RimStimPlanModelPlotCollection; + m_vfpPlotCollection = new RimVfpPlotCollection(); } //-------------------------------------------------------------------------------------------------- @@ -208,6 +213,14 @@ RimMultiPlotCollection* RimMainPlotCollection::multiPlotCollection() return m_multiPlotCollection(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpPlotCollection* RimMainPlotCollection::vfpPlotCollection() +{ + return m_vfpPlotCollection(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -246,6 +259,7 @@ void RimMainPlotCollection::deleteAllContainedObjects() m_flowPlotCollection()->closeDefaultPlotWindowAndDeletePlots(); m_saturationPressurePlotCollection()->deleteAllChildObjects(); m_multiPlotCollection()->deleteAllChildObjects(); + m_vfpPlotCollection()->deleteAllChildObjects(); m_analysisPlotCollection()->deleteAllPlots(); m_correlationPlotCollection()->deleteAllPlots(); m_stimPlanModelPlotCollection()->deleteAllPlots(); diff --git a/ApplicationCode/ProjectDataModel/RimMainPlotCollection.h b/ApplicationCode/ProjectDataModel/RimMainPlotCollection.h index 32db568641..b0b62cd76e 100644 --- a/ApplicationCode/ProjectDataModel/RimMainPlotCollection.h +++ b/ApplicationCode/ProjectDataModel/RimMainPlotCollection.h @@ -41,6 +41,7 @@ class RimEclipseResultCase; class RimFlowPlotCollection; class RimSaturationPressurePlotCollection; class RimStimPlanModelPlotCollection; +class RimVfpPlotCollection; //================================================================================================== /// @@ -66,6 +67,7 @@ public: RimSaturationPressurePlotCollection* saturationPressurePlotCollection(); RimMultiPlotCollection* multiPlotCollection(); RimStimPlanModelPlotCollection* stimPlanModelPlotCollection(); + RimVfpPlotCollection* vfpPlotCollection(); void deleteAllContainedObjects(); void updateCurrentTimeStepInPlots(); @@ -93,6 +95,7 @@ private: caf::PdmChildField m_saturationPressurePlotCollection; caf::PdmChildField m_multiPlotCollection; caf::PdmChildField m_stimPlanModelPlotCollection; + caf::PdmChildField m_vfpPlotCollection; caf::PdmField m_show; }; diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index b7ad18ec24..ca33534a16 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -81,6 +81,7 @@ #include "RimUserDefinedPolylinesAnnotation.h" #include "RimValveTemplate.h" #include "RimValveTemplateCollection.h" +#include "RimVfpPlotCollection.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" #include "RimViewWindow.h" @@ -1453,6 +1454,11 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q { itemCollection->add( mainPlotCollection->stimPlanModelPlotCollection() ); } + + if ( mainPlotCollection->vfpPlotCollection() ) + { + itemCollection->add( mainPlotCollection->vfpPlotCollection() ); + } } uiTreeOrdering.add( scriptCollection() ); diff --git a/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp b/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp new file mode 100644 index 0000000000..45c1875c51 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp @@ -0,0 +1,472 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimVfpPlot.h" + +#include "RimEclipseResultCase.h" +#include "RimFlowDiagSolution.h" +#include "RimProject.h" +#include "RimTools.h" + +#include "RigEclipseCaseData.h" +#include "RigTofWellDistributionCalculator.h" + +#include "RiaColorTools.h" + +#include "RiuQwtPlotWidget.h" + +#include "qwt_legend.h" +#include "qwt_legend_label.h" +#include "qwt_plot.h" +#include "qwt_plot_curve.h" + +#include +#include +#include + +#include + +#include "cvfDebugTimer.h" +#include "cvfTrace.h" + +//================================================================================================== +// +// +// +//================================================================================================== + +CAF_PDM_SOURCE_INIT( RimVfpPlot, "VfpPlot" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpPlot::RimVfpPlot() +{ + // TODO: add icon + CAF_PDM_InitObject( "VFP Plot", "", "", "" ); + + CAF_PDM_InitFieldNoDefault( &m_case, "Case", "Case", "", "", "" ); + CAF_PDM_InitField( &m_wellName, "WellName", QString( "None" ), "Well", "", "", "" ); + + m_showWindow = false; + m_showPlotLegends = true; + + setAsPlotMdiWindow(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpPlot::~RimVfpPlot() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::setDataSourceParameters( RimEclipseResultCase* eclipseResultCase, QString targetWellName ) +{ + m_case = eclipseResultCase; + m_wellName = targetWellName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuQwtPlotWidget* RimVfpPlot::viewer() +{ + return m_plotWidget; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::setAutoScaleXEnabled( bool /*enabled*/ ) +{ + cvf::Trace::show( "RimVfpPlot::setAutoScaleXEnabled()" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::setAutoScaleYEnabled( bool /*enabled*/ ) +{ + cvf::Trace::show( "RimVfpPlot::setAutoScaleYEnabled()" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::updateAxes() +{ + cvf::Trace::show( "RimVfpPlot::updateAxes()" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::updateLegend() +{ + if ( !m_plotWidget ) + { + return; + } + + // Hide the legend when in multiplot mode, as the legend is handeled by the multi plot grid layout + bool doShowLegend = false; + if ( isMdiWindow() ) + { + doShowLegend = m_showPlotLegends; + } + + if ( doShowLegend ) + { + QwtLegend* legend = new QwtLegend( m_plotWidget ); + m_plotWidget->insertLegend( legend, QwtPlot::BottomLegend ); + } + else + { + m_plotWidget->insertLegend( nullptr ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::updateZoomInQwt() +{ + cvf::Trace::show( "RimVfpPlot::updateZoomInQwt()" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::updateZoomFromQwt() +{ + cvf::Trace::show( "RimVfpPlot::updateZoomFromQwt()" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimVfpPlot::asciiDataForPlotExport() const +{ + cvf::Trace::show( "RimVfpPlot::asciiDataForPlotExport()" ); + return QString(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::reattachAllCurves() +{ + cvf::Trace::show( "RimVfpPlot::reattachAllCurves()" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::detachAllCurves() +{ + cvf::Trace::show( "RimVfpPlot::detachAllCurves()" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmObject* RimVfpPlot::findPdmObjectFromQwtCurve( const QwtPlotCurve* /*curve*/ ) const +{ + cvf::Trace::show( "RimVfpPlot::findPdmObjectFromQwtCurve()" ); + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::onAxisSelected( int /*axis*/, bool /*toggle*/ ) +{ + cvf::Trace::show( "RimVfpPlot::onAxisSelected()" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimVfpPlot::description() const +{ + return uiName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* RimVfpPlot::viewWidget() +{ + cvf::Trace::show( "RimVfpPlot::viewWidget()" ); + return m_plotWidget; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QImage RimVfpPlot::snapshotWindowContent() +{ + cvf::Trace::show( "RimVfpPlot::snapshotWindowContent()" ); + + QImage image; + + if ( m_plotWidget ) + { + QPixmap pix = m_plotWidget->grab(); + image = pix.toImage(); + } + + return image; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::zoomAll() +{ + cvf::Trace::show( "RimVfpPlot::zoomAll()" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::doRemoveFromCollection() +{ + cvf::Trace::show( "RimVfpPlot::doRemoveFromCollection()" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuQwtPlotWidget* RimVfpPlot::doCreatePlotViewWidget( QWidget* mainWindowParent ) +{ + cvf::Trace::show( "RimVfpPlot::createViewWidget()" ); + + // It seems we risk being called multiple times + if ( m_plotWidget ) + { + return m_plotWidget; + } + + m_plotWidget = new RiuQwtPlotWidget( this, mainWindowParent ); + + // m_plotWidget->setAutoReplot( false ); + + updateLegend(); + onLoadDataAndUpdate(); + + return m_plotWidget; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::deleteViewWidget() +{ + cvf::Trace::show( "RimVfpPlot::deleteViewWidget()" ); + + if ( m_plotWidget ) + { + m_plotWidget->setParent( nullptr ); + delete m_plotWidget; + m_plotWidget = nullptr; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::onLoadDataAndUpdate() +{ + cvf::Trace::show( "RimVfpPlot::onLoadDataAndUpdate()" ); + cvf::DebugTimer tim( "RimVfpPlot::onLoadDataAndUpdate()" ); + + if ( isMdiWindow() ) + { + updateMdiWindowVisibility(); + } + else + { + updateParentLayout(); + } + + if ( !m_plotWidget ) + { + return; + } + + m_plotWidget->detachItems( QwtPlotItem::Rtti_PlotCurve ); + + updateLegend(); + + QString phaseString = "N/A"; + if ( m_case && m_case->ensureReservoirCaseIsOpen() ) + { + // TODO: extract data from data file + + // TODO: populate with real data + populatePlotWidgetWithCurveData( m_plotWidget ); + + // TODO: Maybe display the phase? + // if ( m_phase == RiaDefines::OIL_PHASE ) + // phaseString = "Oil"; + // else if ( m_phase == RiaDefines::GAS_PHASE ) + // phaseString = "Gas"; + // else if ( m_phase == RiaDefines::WATER_PHASE ) + // phaseString = "Water"; + } + + const QString plotTitleStr = QString( "%1 Vertical Flow Performance Plot" ).arg( m_wellName ); + m_plotWidget->setTitle( plotTitleStr ); + + m_plotWidget->setAxisTitleText( QwtPlot::xBottom, "Liquid Flow Rate [sm3/d]" ); + m_plotWidget->setAxisTitleText( QwtPlot::yLeft, "Bottom Hole Pressure [Bar]" ); + m_plotWidget->setAxisTitleEnabled( QwtPlot::xBottom, true ); + m_plotWidget->setAxisTitleEnabled( QwtPlot::yLeft, true ); + + m_plotWidget->scheduleReplot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget ) +{ + cvf::Trace::show( "RimVfpPlot::populatePlotWidgetWithCurves()" ); + + plotWidget->detachItems( QwtPlotItem::Rtti_PlotCurve ); + plotWidget->setAxisScale( QwtPlot::xBottom, 0, 1 ); + plotWidget->setAxisScale( QwtPlot::yLeft, 0, 1 ); + plotWidget->setAxisAutoScale( QwtPlot::xBottom, true ); + plotWidget->setAxisAutoScale( QwtPlot::yLeft, true ); + + size_t numTables = 4; + + for ( size_t i = 0; i < numTables; i++ ) + { + // Just create some dummy values for now + int numDummyValues = 100; + std::vector xVals( numDummyValues, 10 * i ); + std::vector yVals( numDummyValues, 100 * i ); + + cvf::Color3f cvfClr = cvf::Color3::BLUE; + QColor qtClr = RiaColorTools::toQColor( cvfClr ); + + QwtPlotCurve* curve = new QwtPlotCurve; + curve->setTitle( QString( "Table: %1" ).arg( i ) ); + curve->setBrush( qtClr ); + + curve->setSamples( xVals.data(), yVals.data(), numDummyValues ); + curve->attach( plotWidget ); + curve->show(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_case ); + uiOrdering.add( &m_wellName ); + + RimPlot::defineUiOrdering( uiConfigName, uiOrdering ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimVfpPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly ) +{ + QList options = RimPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); + + if ( fieldNeedingOptions == &m_case ) + { + RimProject* ownerProj = nullptr; + firstAncestorOrThisOfType( ownerProj ); + if ( ownerProj ) + { + std::vector caseArr; + ownerProj->descendantsIncludingThisOfType( caseArr ); + for ( RimEclipseResultCase* c : caseArr ) + { + options.push_back( caf::PdmOptionItemInfo( c->caseUserDescription(), c, true, c->uiIconProvider() ) ); + } + } + } + + else if ( fieldNeedingOptions == &m_wellName ) + { + if ( m_case && m_case->eclipseCaseData() ) + { + caf::QIconProvider simWellIcon( ":/Well.png" ); + const std::set sortedWellNameSet = m_case->eclipseCaseData()->findSortedWellNames(); + for ( const QString& name : sortedWellNameSet ) + { + options.push_back( caf::PdmOptionItemInfo( name, name, true, simWellIcon ) ); + } + } + + if ( options.size() == 0 ) + { + options.push_back( caf::PdmOptionItemInfo( "None", QVariant() ) ); + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) +{ + RimPlot::fieldChangedByUi( changedField, oldValue, newValue ); + + if ( changedField == &m_case ) + { + fixupDependentFieldsAfterCaseChange(); + } + + loadDataAndUpdate(); + updateLayout(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlot::fixupDependentFieldsAfterCaseChange() +{ + QString newWellName; + + if ( m_case ) + { + const std::set sortedWellNameSet = m_case->eclipseCaseData()->findSortedWellNames(); + if ( sortedWellNameSet.size() > 0 ) + { + newWellName = *sortedWellNameSet.begin(); + } + } + + m_wellName = newWellName; +} diff --git a/ApplicationCode/ProjectDataModel/RimVfpPlot.h b/ApplicationCode/ProjectDataModel/RimVfpPlot.h new file mode 100644 index 0000000000..1683401f46 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimVfpPlot.h @@ -0,0 +1,95 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RimPlot.h" + +#include "cafPdmPtrField.h" + +#include + +class RimEclipseResultCase; +class RimFlowDiagSolution; +class RigTofWellDistributionCalculator; +class RiuQwtPlotWidget; + +//-------------------------------------------------------------------------------------------------- +/// Vertical Flow Performance Plot +//-------------------------------------------------------------------------------------------------- +class RimVfpPlot : public RimPlot +{ + CAF_PDM_HEADER_INIT; + +public: + RimVfpPlot(); + ~RimVfpPlot() override; + + void setDataSourceParameters( RimEclipseResultCase* eclipseResultCase, QString targetWellName ); + // void setPlotOptions( bool groupSmallContributions, double smallContributionsRelativeThreshold, double maximumTof ); + + RiaDefines::PhaseType phase() const; + + // RimPlot implementations + RiuQwtPlotWidget* viewer() override; + void setAutoScaleXEnabled( bool enabled ) override; + void setAutoScaleYEnabled( bool enabled ) override; + void updateAxes() override; + void updateLegend() override; + void updateZoomInQwt() override; + void updateZoomFromQwt() override; + QString asciiDataForPlotExport() const override; + void reattachAllCurves() override; + void detachAllCurves() override; + caf::PdmObject* findPdmObjectFromQwtCurve( const QwtPlotCurve* curve ) const override; + void onAxisSelected( int axis, bool toggle ) override; + + // RimPlotWindow implementations + QString description() const override; + + // RimViewWindow implementations + QWidget* viewWidget() override; + QImage snapshotWindowContent() override; + void zoomAll() override; + +private: + // RimPlot implementations + void doRemoveFromCollection() override; + + // RimViewWindow implementations + void deleteViewWidget() override; + void onLoadDataAndUpdate() override; + +private: + RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent ) override; + + void fixupDependentFieldsAfterCaseChange(); + static void populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget ); + + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; + + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly ) override; + +private: + caf::PdmPtrField m_case; + caf::PdmField m_wellName; + + QPointer m_plotWidget; +}; diff --git a/ApplicationCode/ProjectDataModel/RimVfpPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimVfpPlotCollection.cpp new file mode 100644 index 0000000000..e26679a74c --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimVfpPlotCollection.cpp @@ -0,0 +1,74 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimVfpPlotCollection.h" + +#include "RiaApplication.h" + +#include "RigCaseCellResultsData.h" +#include "RigEclipseCaseData.h" +#include "RigEclipseResultAddress.h" +#include "RigEquil.h" + +#include "RimEclipseResultCase.h" +#include "RimProject.h" +#include "RimVfpPlot.h" + +CAF_PDM_SOURCE_INIT( RimVfpPlotCollection, "RimVfpPlotCollection" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpPlotCollection::RimVfpPlotCollection() +{ + CAF_PDM_InitObject( "VFP Plots", ":/SummaryXPlotsLight16x16.png", "", "" ); + + CAF_PDM_InitFieldNoDefault( &m_vfpPlots, "VfpPlots", "Vertical Flow Performance Plots", "", "", "" ); + m_vfpPlots.uiCapability()->setUiHidden( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVfpPlotCollection::~RimVfpPlotCollection() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlotCollection::addPlot( RimVfpPlot* newPlot ) +{ + m_vfpPlots.push_back( newPlot ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimVfpPlotCollection::plots() +{ + return m_vfpPlots.childObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVfpPlotCollection::deleteAllChildObjects() +{ + m_vfpPlots.deleteAllChildObjects(); +} diff --git a/ApplicationCode/ProjectDataModel/RimVfpPlotCollection.h b/ApplicationCode/ProjectDataModel/RimVfpPlotCollection.h new file mode 100644 index 0000000000..a4a8676b78 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimVfpPlotCollection.h @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "cafPdmChildArrayField.h" +#include "cafPdmObject.h" + +class RimVfpPlot; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimVfpPlotCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimVfpPlotCollection(); + ~RimVfpPlotCollection() override; + + void addPlot( RimVfpPlot* newPlot ); + std::vector plots(); + void deleteAllChildObjects(); + +private: + caf::PdmChildArrayField m_vfpPlots; +};