From e00412e07733dd00d5721f1a24bbfcce331a3675 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 29 Oct 2026 09:34:58 +0100 Subject: [PATCH] Show flow diagnostics plots in plot window after project load Flow plots derive from RimViewWindow, not RimPlotWindow, and were missing from RiuPlotMainWindow::viewWindows(). Applying the default dock layout on project open therefore did not re-add their dock widgets. 3D views docked in the plot window are now listed by the plot main window only, and are still activated as the active 3D view so the 3D main window toolbars (e.g. time step animation) are refreshed. --- .../RimDockWindowController.cpp | 37 ++++++++++++++----- .../UserInterface/RiuMainWindow.cpp | 29 ++++++++++++++- .../UserInterface/RiuMainWindow.h | 1 + .../UserInterface/RiuPlotMainWindow.cpp | 7 +++- .../UserInterface/RiuPlotMainWindowTools.cpp | 7 ++-- 5 files changed, 66 insertions(+), 15 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimDockWindowController.cpp b/ApplicationLibCode/ProjectDataModel/RimDockWindowController.cpp index e20b239603a..24a594baa49 100644 --- a/ApplicationLibCode/ProjectDataModel/RimDockWindowController.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimDockWindowController.cpp @@ -217,16 +217,32 @@ void RimDockWindowController::setAsActiveViewer( bool allowSelectionChange ) auto view3d = dynamic_cast( pdmView ); auto viewPlot = dynamic_cast( pdmView ); - RiuMainWindowBase* mainWindow = RiaGuiApplication::instance()->mainWindow(); - if ( viewPlot ) mainWindow = RiaGuiApplication::instance()->mainPlotWindow(); - if ( !mainWindow ) return; + auto app = RiaGuiApplication::instance(); - for ( auto view : mainWindow->viewWindows() ) + auto deactivate = []( RimViewWindow* view ) { - if ( view->isActiveViewer() ) + if ( !view->isActiveViewer() ) return; + view->setActive( false ); + view->updateWindowTitle(); + }; + + // The active 3D view and the active plot are tracked separately + if ( auto project = RimProject::current() ) + { + if ( view3d ) { - view->setActive( false ); - view->updateWindowTitle(); + // Search the project, as a 3D view can be docked in both the 3D window and the plot window + for ( auto view : project->descendantsOfType() ) + { + deactivate( view ); + } + } + else + { + for ( auto view : project->descendantsOfType() ) + { + if ( !dynamic_cast( view ) ) deactivate( view ); + } } } @@ -235,8 +251,11 @@ void RimDockWindowController::setAsActiveViewer( bool allowSelectionChange ) if ( view3d ) { - RiaApplication::instance()->setActiveReservoirView( view3d ); - if ( auto mainWin = dynamic_cast( mainWindow ) ) + app->setActiveReservoirView( view3d ); + + // The toolbars controlling 3D views (e.g. time step animation) are only available in the 3D main window, also + // for 3D views docked in the plot window + if ( auto mainWin = app->mainWindow() ) { mainWin->refreshViewActions(); mainWin->refreshAnimationActions(); diff --git a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp index 95f7ace8d96..122d3ee8c23 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp @@ -64,6 +64,7 @@ #include "RiuMenuBarBuildTools.h" #include "RiuMessagePanel.h" #include "RiuMohrsCirclePlot.h" +#include "RiuPlotMainWindow.h" #include "RiuProcessMonitor.h" #include "RiuProjectPropertyView.h" #include "RiuPropertyViewTabWidget.h" @@ -1285,9 +1286,10 @@ std::vector RiuMainWindow::viewWindows() // Project can be null while it is being torn down. if ( auto project = RimProject::current() ) { + // 3D views docked in the plot window are handled by RiuPlotMainWindow for ( auto v : project->descendantsOfType() ) { - if ( v->dockWidget() ) views.push_back( v ); + if ( v->dockWidget() && !v->isDockedInPlotView() ) views.push_back( v ); } } @@ -2326,6 +2328,31 @@ RimViewWindow* RiuMainWindow::activeViewer() return RiaApplication::instance()->activeReservoirView(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindow::setActiveViewer( QString viewerName ) +{ + // 3D views docked in the plot window are managed by the plot main window + auto plotWindow = RiaGuiApplication::instance()->mainPlotWindow(); + if ( auto project = RimProject::current(); project && plotWindow ) + { + for ( auto view : project->descendantsOfType() ) + { + if ( view->isDockedInPlotView() && view->dockWindowName() == viewerName ) + { + const bool wasBlocking = plotWindow->isBlockingViewSelectionOnSubWindowActivated(); + plotWindow->setBlockViewSelectionOnSubWindowActivated( isBlockingViewSelectionOnSubWindowActivated() ); + plotWindow->setActiveViewer( viewerName ); + plotWindow->setBlockViewSelectionOnSubWindowActivated( wasBlocking ); + return; + } + } + } + + RiuMainWindowBase::setActiveViewer( viewerName ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuMainWindow.h b/ApplicationLibCode/UserInterface/RiuMainWindow.h index f545a90ce34..6a838d2dc29 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindow.h +++ b/ApplicationLibCode/UserInterface/RiuMainWindow.h @@ -101,6 +101,7 @@ class RiuMainWindow : public RiuMainWindowBase void onViewerRemoved() override; void initializeViewer( ads::CDockWidget* dockWidget, QWidget* viewer ) override; RimViewWindow* activeViewer() override; + void setActiveViewer( QString viewerName ) override; std::vector viewWindows() override; diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp index 6d7b1f325ec..f950b8ccf12 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp @@ -860,9 +860,12 @@ std::vector RiuPlotMainWindow::viewWindows() // Project can be null while it is being torn down. if ( auto project = RimProject::current() ) { - for ( auto v : project->descendantsOfType() ) + // Some plots (e.g. flow diagnostics plots) derive directly from RimViewWindow, and are identified by being docked in the plot + // window + for ( auto v : project->descendantsOfType() ) { - if ( v->dockWidget() ) views.push_back( v ); + if ( !v->dockWidget() ) continue; + if ( dynamic_cast( v ) || v->isDockedInPlotView() ) views.push_back( v ); } } diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp b/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp index 588a30cda78..895c93de8e1 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp @@ -20,6 +20,7 @@ #include "RiaGuiApplication.h" +#include "Rim3dView.h" #include "RimViewWindow.h" #include "RiuMainWindow.h" @@ -169,11 +170,11 @@ void RiuPlotMainWindowTools::remove3dViewsFromDocking() { if ( !RiaGuiApplication::isRunning() ) return; - if ( auto mainWnd = RiaGuiApplication::instance()->mainWindow() ) + if ( auto plotWnd = RiaGuiApplication::instance()->mainPlotWindow() ) { - for ( auto view : mainWnd->viewWindows() ) + for ( auto view : plotWnd->viewWindows() ) { - if ( view->isDockedInPlotView() ) + if ( dynamic_cast( view ) && view->isDockedInPlotView() ) { view->setShowWindow( false ); view->removeWindowFromDock();