From b7b2a73721cdac6baacd0b37f674b49777dc84ab Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 12 Mar 2026 13:24:09 +0100 Subject: [PATCH] Add context menu actions to hide/show all geometry for well visibility Two new actions added to the well path context menu: - "Hide All Geometry (Show Wells)": hides grid cells, faults, and intersections, then forces simulation wells and well paths visible. - "Show All Geometry": restores grid cells, faults, and intersections visibility. Added RimIntersectionCollection::setActive() for direct state control. --- .../WellPathCommands/CMakeLists_files.cmake | 4 + .../RicHideGridGeometryFeature.cpp | 101 ++++++++++++++++++ .../RicHideGridGeometryFeature.h | 34 ++++++ .../RicShowAllGeometryFeature.cpp | 90 ++++++++++++++++ .../RicShowAllGeometryFeature.h | 34 ++++++ .../RimIntersectionCollection.cpp | 8 ++ .../Intersections/RimIntersectionCollection.h | 1 + .../UserInterface/RiuViewerCommands.cpp | 3 + 8 files changed, 275 insertions(+) create mode 100644 ApplicationLibCode/Commands/WellPathCommands/RicHideGridGeometryFeature.cpp create mode 100644 ApplicationLibCode/Commands/WellPathCommands/RicHideGridGeometryFeature.h create mode 100644 ApplicationLibCode/Commands/WellPathCommands/RicShowAllGeometryFeature.cpp create mode 100644 ApplicationLibCode/Commands/WellPathCommands/RicShowAllGeometryFeature.h diff --git a/ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake index 04960d2e14..2f23111827 100644 --- a/ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/WellPathCommands/CMakeLists_files.cmake @@ -32,6 +32,8 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.h ${CMAKE_CURRENT_LIST_DIR}/RicDuplicateWellPathFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicSetParentWellPathFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicHideGridGeometryFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicShowAllGeometryFeature.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -68,6 +70,8 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPolylineTarget3dEditor.cpp ${CMAKE_CURRENT_LIST_DIR}/RicDuplicateWellPathFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSetParentWellPathFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicHideGridGeometryFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicShowAllGeometryFeature.cpp ) list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicHideGridGeometryFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicHideGridGeometryFeature.cpp new file mode 100644 index 0000000000..f64ea62bf5 --- /dev/null +++ b/ApplicationLibCode/Commands/WellPathCommands/RicHideGridGeometryFeature.cpp @@ -0,0 +1,101 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2026- 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 "RicHideGridGeometryFeature.h" + +#include "RiaApplication.h" + +#include "RimEclipseView.h" +#include "RimFaultInViewCollection.h" +#include "RimGridCollection.h" +#include "RimGridView.h" +#include "RimIntersectionCollection.h" +#include "RimSimWellInViewCollection.h" +#include "RimTools.h" +#include "WellPath/RimWellPathCollection.h" + +#include "RiuMainWindow.h" + +#include + +CAF_CMD_SOURCE_INIT( RicHideGridGeometryFeature, "RicHideGridGeometryFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicHideGridGeometryFeature::isCommandEnabled() const +{ + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); + return dynamic_cast( view ) != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicHideGridGeometryFeature::onActionTriggered( bool isChecked ) +{ + Rim3dView* view = RiaApplication::instance()->activeMainOrComparisonGridView(); + if ( !view ) return; + + RimGridView* gridView = dynamic_cast( view ); + if ( !gridView ) return; + + // Hide faults (Eclipse views only) + if ( auto eclipseView = dynamic_cast( gridView ) ) + { + eclipseView->faultCollection()->setActive( false ); + eclipseView->faultCollection()->updateConnectedEditors(); + + // Force simulation wells visible + if ( auto simWellColl = eclipseView->wellCollection() ) + { + simWellColl->isActive = true; + simWellColl->updateConnectedEditors(); + } + } + + // Hide intersections + gridView->intersectionCollection()->setActive( false ); + gridView->intersectionCollection()->updateConnectedEditors(); + + // Hide all reservoir geometry + gridView->gridCollection()->setActive( false ); + gridView->gridCollection()->updateConnectedEditors(); + + RiuMainWindow::instance()->refreshDrawStyleActions(); + RiuMainWindow::instance()->refreshAnimationActions(); + + gridView->scheduleCreateDisplayModelAndRedraw(); + + // Force all well paths visible + if ( auto wellPathColl = RimTools::wellPathCollection() ) + { + wellPathColl->isActive = true; + wellPathColl->wellPathVisibility = RimWellPathCollection::FORCE_ALL_ON; + wellPathColl->updateConnectedEditors(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicHideGridGeometryFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Hide Grid Geometry" ); + actionToSetup->setIcon( QIcon( ":/Well.svg" ) ); +} diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicHideGridGeometryFeature.h b/ApplicationLibCode/Commands/WellPathCommands/RicHideGridGeometryFeature.h new file mode 100644 index 0000000000..3679427cc7 --- /dev/null +++ b/ApplicationLibCode/Commands/WellPathCommands/RicHideGridGeometryFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2026- 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 RicHideGridGeometryFeature : 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/Commands/WellPathCommands/RicShowAllGeometryFeature.cpp b/ApplicationLibCode/Commands/WellPathCommands/RicShowAllGeometryFeature.cpp new file mode 100644 index 0000000000..5fb018735a --- /dev/null +++ b/ApplicationLibCode/Commands/WellPathCommands/RicShowAllGeometryFeature.cpp @@ -0,0 +1,90 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2026- 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 "RicShowAllGeometryFeature.h" + +#include "RiaApplication.h" + +#include "RimEclipseView.h" +#include "RimFaultInViewCollection.h" +#include "RimGridView.h" +#include "RimIntersectionCollection.h" +#include "RimTools.h" +#include "WellPath/RimWellPathCollection.h" + +#include "RiuMainWindow.h" + +#include + +CAF_CMD_SOURCE_INIT( RicShowAllGeometryFeature, "RicShowAllGeometryFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicShowAllGeometryFeature::isCommandEnabled() const +{ + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); + return dynamic_cast( view ) != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowAllGeometryFeature::onActionTriggered( bool isChecked ) +{ + Rim3dView* view = RiaApplication::instance()->activeMainOrComparisonGridView(); + if ( !view ) return; + + RimGridView* gridView = dynamic_cast( view ); + if ( !gridView ) return; + + // Show faults (Eclipse views only) + if ( auto eclipseView = dynamic_cast( gridView ) ) + { + eclipseView->faultCollection()->setActive( true ); + eclipseView->faultCollection()->updateConnectedEditors(); + } + + // Show intersections + gridView->intersectionCollection()->setActive( true ); + gridView->intersectionCollection()->updateConnectedEditors(); + + // Show all reservoir geometry + gridView->showGridCells( true ); + + RiuMainWindow::instance()->refreshDrawStyleActions(); + RiuMainWindow::instance()->refreshAnimationActions(); + + gridView->scheduleCreateDisplayModelAndRedraw(); + + // Restore well path visibility to individual control + if ( auto wellPathColl = RimTools::wellPathCollection() ) + { + wellPathColl->wellPathVisibility = RimWellPathCollection::ALL_ON; + wellPathColl->updateConnectedEditors(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicShowAllGeometryFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Show All Geometry" ); + actionToSetup->setIcon( QIcon( ":/draw_style_surface_24x24.png" ) ); +} diff --git a/ApplicationLibCode/Commands/WellPathCommands/RicShowAllGeometryFeature.h b/ApplicationLibCode/Commands/WellPathCommands/RicShowAllGeometryFeature.h new file mode 100644 index 0000000000..092fe65b69 --- /dev/null +++ b/ApplicationLibCode/Commands/WellPathCommands/RicShowAllGeometryFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2026- 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 RicShowAllGeometryFeature : 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/Intersections/RimIntersectionCollection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp index fad6e63760..bdf425f621 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.cpp @@ -95,6 +95,14 @@ bool RimIntersectionCollection::isActive() const return m_isActive(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionCollection::setActive( bool active ) +{ + m_isActive = active; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h index 697f749543..016e69e368 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimIntersectionCollection.h @@ -89,6 +89,7 @@ public: void onChildAdded( caf::PdmFieldHandle* containerForNewObject ) override; bool isActive() const; + void setActive( bool active ); protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; diff --git a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp index 151b705185..07dbb2aa89 100644 --- a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp @@ -632,6 +632,9 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event ) menuBuilder << "RicShowGridStatisticsFeature"; menuBuilder << "RicCopyGridStatisticsToClipboardFeature"; menuBuilder << "RicSelectColorResult"; + menuBuilder.addSeparator(); + menuBuilder << "RicHideGridGeometryFeature"; + menuBuilder << "RicShowAllGeometryFeature"; } }