diff --git a/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake index 08a748ed6b..69b955ab2c 100644 --- a/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake @@ -10,6 +10,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicShowContributingWellsFeatureImpl.h ${CMAKE_CURRENT_LIST_DIR}/RicPlotProductionRateFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicSelectViewUI.h ${CMAKE_CURRENT_LIST_DIR}/RicShowTotalAllocationDataFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowCumulativePhasePlotFeature.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -23,6 +24,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicShowContributingWellsFeatureImpl.cpp ${CMAKE_CURRENT_LIST_DIR}/RicPlotProductionRateFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSelectViewUI.cpp ${CMAKE_CURRENT_LIST_DIR}/RicShowTotalAllocationDataFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowCumulativePhasePlotFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Commands/FlowCommands/RicShowCumulativePhasePlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicShowCumulativePhasePlotFeature.cpp new file mode 100644 index 0000000000..26bf15268a --- /dev/null +++ b/ApplicationCode/Commands/FlowCommands/RicShowCumulativePhasePlotFeature.cpp @@ -0,0 +1,68 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicShowCumulativePhasePlotFeature.h" + +#include "RimFlowPlotCollection.h" +#include "RimWellAllocationPlot.h" +#include "RimWellDistributionPlotCollection.h" + +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT( RicShowCumulativePhasePlotFeature, "RicShowCumulativePhasePlotFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicShowCumulativePhasePlotFeature::isCommandEnabled() +{ + RimWellAllocationPlot* plot = caf::SelectionManager::instance()->selectedItemAncestorOfType(); + + return plot != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowCumulativePhasePlotFeature::onActionTriggered( bool isChecked ) +{ + RimWellAllocationPlot* plot = caf::SelectionManager::instance()->selectedItemAncestorOfType(); + + if ( !plot ) return; + + RimFlowPlotCollection* flowPlotColl = nullptr; + plot->firstAncestorOrThisOfType( flowPlotColl ); + + if ( !flowPlotColl ) return; + + RimWellDistributionPlotCollection* wdp = flowPlotColl->wellDistributionPlotCollection(); + wdp->setData( plot->rimCase(), plot->wellName(), plot->timeStep() ); + wdp->setShowWindow( true ); + wdp->loadDataAndUpdate(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowCumulativePhasePlotFeature::setupActionLook( QAction* actionToSetup ) +{ + // actionToSetup->setIcon(QIcon(":/new_icon16x16.png")); + actionToSetup->setText( "Show Cumulative Phase Distribution Plot" ); +} diff --git a/ApplicationCode/Commands/FlowCommands/RicShowCumulativePhasePlotFeature.h b/ApplicationCode/Commands/FlowCommands/RicShowCumulativePhasePlotFeature.h new file mode 100644 index 0000000000..28c16c155f --- /dev/null +++ b/ApplicationCode/Commands/FlowCommands/RicShowCumulativePhasePlotFeature.h @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicShowCumulativePhasePlotFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp b/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp index 76e3f1a560..dda7142a1a 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.cpp @@ -190,6 +190,14 @@ RimFlowCharacteristicsPlot* RimFlowPlotCollection::defaultFlowCharacteristicsPlo return m_flowCharacteristicsPlot(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellDistributionPlotCollection* RimFlowPlotCollection::wellDistributionPlotCollection() const +{ + return m_wellDistributionPlotCollection(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.h b/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.h index 1c22796dda..4dbfe1302a 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimFlowPlotCollection.h @@ -43,11 +43,12 @@ public: void loadDataAndUpdate(); size_t plotCount() const; - void addWellAllocPlotToStoredPlots( RimWellAllocationPlot* plot ); - void addFlowCharacteristicsPlotToStoredPlots( RimFlowCharacteristicsPlot* plot ); - RimWellAllocationPlot* defaultWellAllocPlot(); - RimFlowCharacteristicsPlot* defaultFlowCharacteristicsPlot(); - void ensureDefaultFlowPlotsAreCreated(); + void addWellAllocPlotToStoredPlots( RimWellAllocationPlot* plot ); + void addFlowCharacteristicsPlotToStoredPlots( RimFlowCharacteristicsPlot* plot ); + RimWellAllocationPlot* defaultWellAllocPlot(); + RimFlowCharacteristicsPlot* defaultFlowCharacteristicsPlot(); + RimWellDistributionPlotCollection* wellDistributionPlotCollection() const; + void ensureDefaultFlowPlotsAreCreated(); private: caf::PdmChildField m_flowCharacteristicsPlot; diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.cpp index 6dd754554c..becbf9644d 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.cpp @@ -91,6 +91,18 @@ RimWellDistributionPlotCollection::RimWellDistributionPlotCollection() //-------------------------------------------------------------------------------------------------- RimWellDistributionPlotCollection::~RimWellDistributionPlotCollection() {} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellDistributionPlotCollection::setData( RimEclipseResultCase* eclipseCase, QString wellName, int timeStepIndex ) +{ + m_case = eclipseCase; + m_wellName = wellName; + m_timeStepIndex = timeStepIndex; + + applyPlotParametersToContainedPlots(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.h b/ApplicationCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.h index a0b03adab7..bb28cc3afe 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellDistributionPlotCollection.h @@ -47,6 +47,8 @@ public: RimWellDistributionPlotCollection(); ~RimWellDistributionPlotCollection() override; + void setData( RimEclipseResultCase* eclipseCase, QString wellName, int timeStepIndex ); + private: // RimPlotWindow overrides QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, diff --git a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp index 4edf19053f..a1aa6e1c00 100644 --- a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp @@ -185,6 +185,7 @@ void RiuWellAllocationPlot::contextMenuEvent( QContextMenuEvent* event ) caf::CmdFeatureMenuBuilder menuBuilder; menuBuilder << "RicShowContributingWellsFromPlotFeature"; + menuBuilder << "RicShowCumulativePhasePlotFeature"; menuBuilder.appendToMenu( &menu );