From 6d3ed7bda2e6f642da9ef5f7730f5d9af3895298 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 17 Dec 2024 08:37:26 +0100 Subject: [PATCH] Add command to create linked property filter --- .../EclipseCommands/CMakeLists_files.cmake | 2 + ...cAddLinkedEclipsePropertyFilterFeature.cpp | 70 +++++++++++++++++++ ...RicAddLinkedEclipsePropertyFilterFeature.h | 34 +++++++++ .../CellFilters/RimEclipsePropertyFilter.cpp | 10 ++- .../RimEclipsePropertyFilterCollection.cpp | 19 +++++ .../RimEclipsePropertyFilterCollection.h | 3 +- 6 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 ApplicationLibCode/Commands/EclipseCommands/RicAddLinkedEclipsePropertyFilterFeature.cpp create mode 100644 ApplicationLibCode/Commands/EclipseCommands/RicAddLinkedEclipsePropertyFilterFeature.h diff --git a/ApplicationLibCode/Commands/EclipseCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/EclipseCommands/CMakeLists_files.cmake index b829a33814..013f875647 100644 --- a/ApplicationLibCode/Commands/EclipseCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/EclipseCommands/CMakeLists_files.cmake @@ -22,6 +22,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicImportRoffCaseFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicAddGridCalculationFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCaseEnsemblesFromFilesFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicAddLinkedEclipsePropertyFilterFeature.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -48,6 +49,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicImportRoffCaseFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicAddGridCalculationFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCaseEnsemblesFromFilesFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicAddLinkedEclipsePropertyFilterFeature.cpp ) list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicAddLinkedEclipsePropertyFilterFeature.cpp b/ApplicationLibCode/Commands/EclipseCommands/RicAddLinkedEclipsePropertyFilterFeature.cpp new file mode 100644 index 0000000000..48c6ef1cc9 --- /dev/null +++ b/ApplicationLibCode/Commands/EclipseCommands/RicAddLinkedEclipsePropertyFilterFeature.cpp @@ -0,0 +1,70 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 "RicAddLinkedEclipsePropertyFilterFeature.h" + +#include "RicEclipsePropertyFilterFeatureImpl.h" + +#include "RimEclipsePropertyFilter.h" +#include "RimEclipsePropertyFilterCollection.h" + +#include "Riu3DMainWindowTools.h" + +#include + +CAF_CMD_SOURCE_INIT( RicAddLinkedEclipsePropertyFilterFeature, "RicAddLinkedEclipsePropertyFilterFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAddLinkedEclipsePropertyFilterFeature::isCommandEnabled() const +{ + auto filterCollections = RicEclipsePropertyFilterFeatureImpl::selectedPropertyFilterCollections(); + if ( filterCollections.size() == 1 ) + { + return RicEclipsePropertyFilterFeatureImpl::isPropertyFilterCommandAvailable( filterCollections[0] ); + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAddLinkedEclipsePropertyFilterFeature::onActionTriggered( bool isChecked ) +{ + auto filterCollections = RicEclipsePropertyFilterFeatureImpl::selectedPropertyFilterCollections(); + + if ( filterCollections.size() == 1 ) + { + auto coll = filterCollections[0]; + auto filter = coll->addFilterLinkedToCellResult(); + coll->updateAllRequiredEditors(); + + Riu3DMainWindowTools::setExpanded( filter ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAddLinkedEclipsePropertyFilterFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setIcon( QIcon( ":/CellFilter_Values.png" ) ); + actionToSetup->setText( "Add Property Filter Linked to Cell Result" ); +} diff --git a/ApplicationLibCode/Commands/EclipseCommands/RicAddLinkedEclipsePropertyFilterFeature.h b/ApplicationLibCode/Commands/EclipseCommands/RicAddLinkedEclipsePropertyFilterFeature.h new file mode 100644 index 0000000000..fa7624920c --- /dev/null +++ b/ApplicationLibCode/Commands/EclipseCommands/RicAddLinkedEclipsePropertyFilterFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2024- 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 RicAddLinkedEclipsePropertyFilterFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() const override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilter.cpp index c4a48ba811..ca6579fe32 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilter.cpp @@ -40,6 +40,7 @@ #include "RiuMainWindow.h" +#include "cafPdmUiCheckBoxEditor.h" #include "cafPdmUiDoubleSliderEditor.h" #include "cafPdmUiSliderEditor.h" #include "cafPdmUiTreeAttributes.h" @@ -66,6 +67,7 @@ RimEclipsePropertyFilter::RimEclipsePropertyFilter() m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( true ); CAF_PDM_InitFieldNoDefault( &m_linkedWithCellResult, "LinkedWithCellResult", "Linked With Cell Result" ); + caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_linkedWithCellResult ); CAF_PDM_InitField( &m_rangeLabelText, "Dummy_keyword", QString( "Range Type" ), "Range Type" ); m_rangeLabelText.xmlCapability()->disableIO(); @@ -225,9 +227,15 @@ void RimEclipsePropertyFilter::defineUiOrdering( QString uiConfigName, caf::PdmU // Fields declared in RimCellFilter uiOrdering.add( &m_name ); + uiOrdering.add( &m_linkedWithCellResult ); + if ( m_linkedWithCellResult ) + { + uiOrdering.skipRemainingFields( true ); + return; + } + // Fields declared in Rimm_resultDefinition caf::PdmUiGroup* group1 = uiOrdering.addNewGroup( "Result" ); - group1->add( &m_linkedWithCellResult ); if ( !m_linkedWithCellResult ) { diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.cpp index 883286e210..968ab649a4 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.cpp @@ -215,3 +215,22 @@ void RimEclipsePropertyFilterCollection::updateDefaultResult( const RimEclipseCe filter->setToDefaultValues(); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipsePropertyFilter* RimEclipsePropertyFilterCollection::addFilterLinkedToCellResult() +{ + RimEclipsePropertyFilter* propertyFilter = new RimEclipsePropertyFilter(); + propertyFilter->setLinkedWithCellResult( true ); + m_propertyFilters.push_back( propertyFilter ); + + auto view = reservoirView(); + if ( view && view->eclipseCase() ) + { + propertyFilter->resultDefinition()->setEclipseCase( view->eclipseCase() ); + updateDefaultResult( view->cellResult() ); + } + + return propertyFilter; +} diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.h index 13f9439f06..2f2dd0d300 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimEclipsePropertyFilterCollection.h @@ -54,7 +54,8 @@ class RimEclipsePropertyFilterCollection : public RimPropertyFilterCollection void updateIconState() override; void updateFromCurrentTimeStep(); - void updateDefaultResult( const RimEclipseCellColors* result ); + void updateDefaultResult( const RimEclipseCellColors* result ); + RimEclipsePropertyFilter* addFilterLinkedToCellResult(); protected: void initAfterRead() override;