diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 56db5633bc..1b322609e6 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -92,6 +92,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicExportStimPlanModelToFileFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicStackSelectedCurvesFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicUnstackSelectedCurvesFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicThemeColorEditorFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewVfpPlotFeature.h ) @@ -188,6 +189,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicExportStimPlanModelToFileFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicStackSelectedCurvesFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicUnstackSelectedCurvesFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicThemeColorEditorFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewVfpPlotFeature.cpp ) diff --git a/ApplicationCode/Commands/RicNewVfpPlotFeature.cpp b/ApplicationCode/Commands/RicNewVfpPlotFeature.cpp new file mode 100644 index 0000000000..31febe1b21 --- /dev/null +++ b/ApplicationCode/Commands/RicNewVfpPlotFeature.cpp @@ -0,0 +1,79 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicNewVfpPlotFeature.h" + +#include "RiaApplication.h" + +#include "RimMainPlotCollection.h" +#include "RimProject.h" +#include "RimSimWellInView.h" +#include "RimVfpPlot.h" +#include "RimVfpPlotCollection.h" +#include "RimWellLogPlot.h" +#include "RimWellLogTrack.h" +#include "RimWellPath.h" + +#include "RiuPlotMainWindowTools.h" + +#include "cafSelectionManagerTools.h" + +#include + +#include + +CAF_CMD_SOURCE_INIT( RicNewVfpPlotFeature, "RicNewVfpPlotFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewVfpPlotFeature::isCommandEnabled() +{ + RimVfpPlotCollection* plotColl = caf::firstAncestorOfTypeFromSelectedObject(); + return ( plotColl != nullptr ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewVfpPlotFeature::onActionTriggered( bool isChecked ) +{ + RimProject* proj = RiaApplication::instance()->project(); + + RimVfpPlotCollection* vfpPlotColl = proj->mainPlotCollection()->vfpPlotCollection(); + if ( vfpPlotColl ) + { + RimVfpPlot* vfpPlot = new RimVfpPlot(); + vfpPlotColl->addPlot( vfpPlot ); + vfpPlotColl->updateConnectedEditors(); + vfpPlot->loadDataAndUpdate(); + + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem( vfpPlot ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewVfpPlotFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "New VFP Plot" ); + // TODO: add icon + // actionToSetup->setIcon( QIcon( ":/VerticalFlowPerformancePlot16x16.png" ) ); +} diff --git a/ApplicationCode/Commands/RicNewVfpPlotFeature.h b/ApplicationCode/Commands/RicNewVfpPlotFeature.h new file mode 100644 index 0000000000..dbebfd4a4d --- /dev/null +++ b/ApplicationCode/Commands/RicNewVfpPlotFeature.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 RicNewVfpPlotFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +private: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + + static QString selectedWellName(); +}; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index e174203b6c..a2c402e80c 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -125,6 +125,7 @@ #include "RimSurfaceCollection.h" #include "RimValveTemplate.h" #include "RimValveTemplateCollection.h" +#include "RimVfpPlotCollection.h" #include "RimViewController.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" @@ -534,6 +535,10 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { menuBuilder << "RicNewPltPlotFeature"; } + else if ( dynamic_cast( firstUiItem ) ) + { + menuBuilder << "RicNewVfpPlotFeature"; + } else if ( dynamic_cast( firstUiItem ) ) { menuBuilder << "RicPasteSummaryPlotFeature";