From ff40662366bbd7e369286736c7ecfba988f56fb9 Mon Sep 17 00:00:00 2001 From: jonjenssen Date: Fri, 15 May 2026 02:25:56 +0200 Subject: [PATCH] Work in progress --- .../RiaCompletionTypeCalculationScheduler.cpp | 2 +- .../Application/RiaGuiApplication.cpp | 2 +- .../RicSnapshotAllPlotsToFileFeature.cpp | 8 +-- .../RicSnapshotAllViewsToFileFeature.cpp | 11 ++-- .../RimDockWindowController.cpp | 4 ++ .../ProjectDataModel/RimViewWindow.cpp | 1 - .../UserInterface/Riu3DMainWindowTools.cpp | 4 +- .../UserInterface/Riu3DMainWindowTools.h | 5 +- .../UserInterface/RiuMainWindow.cpp | 13 +---- .../UserInterface/RiuMainWindow.h | 1 - .../UserInterface/RiuMainWindowBase.cpp | 56 +++++++++++++++---- .../UserInterface/RiuMainWindowBase.h | 6 +- .../UserInterface/RiuPlotMainWindow.cpp | 11 +--- .../UserInterface/RiuPlotMainWindow.h | 1 - .../UserInterface/RiuPlotMainWindowTools.cpp | 4 +- .../UserInterface/RiuPlotMainWindowTools.h | 4 +- 16 files changed, 77 insertions(+), 56 deletions(-) diff --git a/ApplicationLibCode/Application/RiaCompletionTypeCalculationScheduler.cpp b/ApplicationLibCode/Application/RiaCompletionTypeCalculationScheduler.cpp index 8cc14aec1b..9b6c0bd280 100644 --- a/ApplicationLibCode/Application/RiaCompletionTypeCalculationScheduler.cpp +++ b/ApplicationLibCode/Application/RiaCompletionTypeCalculationScheduler.cpp @@ -151,7 +151,7 @@ void RiaCompletionTypeCalculationScheduler::performScheduledUpdates() RiaApplication::instance()->setActiveReservoirView( activeView ); if ( RiuMainWindow::instance() ) { - RiuMainWindow::instance()->setActiveViewer( activeView->viewer()->layoutWidget() ); + RiuMainWindow::instance()->setActiveViewer( activeView->dockWindowName() ); } } } diff --git a/ApplicationLibCode/Application/RiaGuiApplication.cpp b/ApplicationLibCode/Application/RiaGuiApplication.cpp index d2525739db..44b0cd88bd 100644 --- a/ApplicationLibCode/Application/RiaGuiApplication.cpp +++ b/ApplicationLibCode/Application/RiaGuiApplication.cpp @@ -231,7 +231,7 @@ RiaGuiApplication::~RiaGuiApplication() delete m_mainWindow.data(); m_mainWindow.clear(); - m_mainPlotWindow.reset(); + // m_mainPlotWindow.reset(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp index 2a1999ef50..3f78477baa 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp @@ -120,17 +120,17 @@ void RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( const QS //-------------------------------------------------------------------------------------------------- void RicSnapshotAllPlotsToFileFeature::onActionTriggered( bool isChecked ) { - QWidget* currentActiveWidget = nullptr; + QString currentActiveViewerName; if ( RiaGuiApplication::activeViewWindow() ) { - currentActiveWidget = RiaGuiApplication::activeViewWindow()->viewWidget(); + currentActiveViewerName = RiaGuiApplication::activeViewWindow()->dockWindowName(); } RicSnapshotAllPlotsToFileFeature::saveAllPlots(); - if ( currentActiveWidget ) + if ( !currentActiveViewerName.isEmpty() ) { - RiuPlotMainWindowTools::setActiveViewer( currentActiveWidget ); + RiuPlotMainWindowTools::setActiveViewer( currentActiveViewerName ); } } diff --git a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp index 91daaf1dde..08ec3afc27 100644 --- a/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp +++ b/ApplicationLibCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp @@ -117,10 +117,11 @@ void RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( const QS { RiuViewer* viewer = riv->viewer(); if ( !viewer ) continue; + if ( !viewer->ownerViewWindow() ) continue; RiaApplication::instance()->setActiveReservoirView( riv ); - Riu3DMainWindowTools::setActiveViewer( viewer->layoutWidget() ); + Riu3DMainWindowTools::setActiveViewer( viewer->ownerViewWindow()->dockWindowName() ); RiaViewRedrawScheduler::instance()->clearViewsScheduledForUpdate(); RiaPlotWindowRedrawScheduler::instance()->clearAllScheduledUpdates(); @@ -152,17 +153,17 @@ void RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( const QS //-------------------------------------------------------------------------------------------------- void RicSnapshotAllViewsToFileFeature::onActionTriggered( bool isChecked ) { - QWidget* currentActiveWidget = nullptr; + QString currentActiveViewerName; if ( RiaGuiApplication::activeViewWindow() ) { - currentActiveWidget = RiaGuiApplication::activeViewWindow()->viewWidget(); + currentActiveViewerName = RiaGuiApplication::activeViewWindow()->dockWindowName(); } RicSnapshotAllViewsToFileFeature::saveAllViews(); - if ( currentActiveWidget ) + if ( !currentActiveViewerName.isEmpty() ) { - Riu3DMainWindowTools::setActiveViewer( currentActiveWidget ); + Riu3DMainWindowTools::setActiveViewer( currentActiveViewerName ); } } diff --git a/ApplicationLibCode/ProjectDataModel/RimDockWindowController.cpp b/ApplicationLibCode/ProjectDataModel/RimDockWindowController.cpp index 381b5759b7..4118735266 100644 --- a/ApplicationLibCode/ProjectDataModel/RimDockWindowController.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimDockWindowController.cpp @@ -21,7 +21,9 @@ #include "RiaGuiApplication.h" #include "RimProject.h" #include "RimViewWindow.h" + #include "RiuMainWindowBase.h" +#include "RiuViewer.h" #include "DockManager.h" #include "DockWidget.h" @@ -129,6 +131,8 @@ void RimDockWindowController::updateViewerWidget() dockWidget->setObjectName( viewPdmObject()->dockWindowName() ); mainWindow->initializeViewer( dockWidget, viewWidget ); + mainWindow->connect( dockWidget, SIGNAL( visibilityChanged( bool ) ), mainWindow, SLOT( slotDockViewerVisibilityChanged( bool ) ) ); + viewPdmObject()->updateViewWidgetAfterCreation(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp b/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp index ddd1225942..daf346da44 100644 --- a/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimViewWindow.cpp @@ -26,7 +26,6 @@ #include "RicfCommandObject.h" -#include "Rim3dView.h" #include "RimDockWindowController.h" #include "RimProject.h" diff --git a/ApplicationLibCode/UserInterface/Riu3DMainWindowTools.cpp b/ApplicationLibCode/UserInterface/Riu3DMainWindowTools.cpp index a883657e89..12cf7f8b4c 100644 --- a/ApplicationLibCode/UserInterface/Riu3DMainWindowTools.cpp +++ b/ApplicationLibCode/UserInterface/Riu3DMainWindowTools.cpp @@ -37,9 +37,9 @@ QWidget* Riu3DMainWindowTools::mainWindowWidget() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Riu3DMainWindowTools::setActiveViewer( QWidget* subWindow ) +void Riu3DMainWindowTools::setActiveViewer( QString viewerName ) { - if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->setActiveViewer( subWindow ); + if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->setActiveViewer( viewerName ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/Riu3DMainWindowTools.h b/ApplicationLibCode/UserInterface/Riu3DMainWindowTools.h index 3201a809d6..2c4644aa5a 100644 --- a/ApplicationLibCode/UserInterface/Riu3DMainWindowTools.h +++ b/ApplicationLibCode/UserInterface/Riu3DMainWindowTools.h @@ -19,7 +19,8 @@ #pragma once class QWidget; -class QString; + +#include namespace caf { @@ -31,7 +32,7 @@ class Riu3DMainWindowTools { public: static QWidget* mainWindowWidget(); - static void setActiveViewer( QWidget* subWindow ); + static void setActiveViewer( QString viewerName ); static void setExpanded( const caf::PdmUiItem* uiItem, bool expanded = true ); static void selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange = true ); static void reportAndShowWarning( const QString& warningDialogHeader, const QString& warningtext ); diff --git a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp index 9e27fd143d..dd98f9861b 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuMainWindow.cpp @@ -1402,15 +1402,6 @@ void RiuMainWindow::selectViewInProjectTreePreservingSubItemSelection( const Rim } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMainWindow::setActiveViewer( QWidget* viewer ) -{ - // QMdiSubWindow* swin = findMdiSubWindow( viewer ); - // if ( swin ) m_mdiArea->setActiveSubWindow( swin ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1483,10 +1474,10 @@ void RiuMainWindow::selectedObjectsChanged() if ( selectedReservoirView ) { // Set focus in MDI area to this window if it exists - if ( selectedReservoirView->viewer() ) + if ( selectedReservoirView->viewer() && selectedReservoirView->viewer()->ownerViewWindow() ) { setBlockViewSelectionOnSubWindowActivated( true ); - setActiveViewer( selectedReservoirView->viewer()->layoutWidget() ); + setActiveViewer( selectedReservoirView->viewer()->ownerViewWindow()->dockWindowName() ); setBlockViewSelectionOnSubWindowActivated( false ); isActiveViewChanged = true; diff --git a/ApplicationLibCode/UserInterface/RiuMainWindow.h b/ApplicationLibCode/UserInterface/RiuMainWindow.h index 43c7df1467..af36ae73c3 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindow.h +++ b/ApplicationLibCode/UserInterface/RiuMainWindow.h @@ -94,7 +94,6 @@ public: void removeViewer( QWidget* viewer ) override; void initializeViewer( ads::CDockWidget* dockWidget, QWidget* viewer ) override; - void setActiveViewer( QWidget* subWindow ) override; ads::CDockWidget* initializeDockingViewer( QWidget* viewer ) override; diff --git a/ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp b/ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp index b9efe68156..857fbed813 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp +++ b/ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp @@ -31,7 +31,9 @@ #include "RiuDockWidgetTools.h" #include "RiuDragDrop.h" #include "RiuGuiTheme.h" +#include "RiuInterfaceToViewWindow.h" #include "RiuMainWindowTools.h" +#include "RiuViewer.h" #include "cafCmdFeatureManager.h" #include "cafPdmObject.h" @@ -113,18 +115,16 @@ ads::CDockManager* RiuMainWindowBase::dockManager() const return m_dockManager; } -////-------------------------------------------------------------------------------------------------- -///// -////-------------------------------------------------------------------------------------------------- -// QMdiSubWindow* RiuMainWindowBase::createViewWindow() -//{ -// RiuMdiSubWindow* subWin = -// new RiuMdiSubWindow( nullptr, Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint | Qt::WindowMaximizeButtonHint ); -// subWin->setAttribute( Qt::WA_DeleteOnClose ); // Make sure the contained widget is destroyed when the MDI window -// // is closed -// -// return subWin; -// } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindowBase::setActiveViewer( QString viewerName ) +{ + if ( auto dockWidget = dockManager()->findDockWidget( viewerName ) ) + { + dockWidget->setAsCurrentTab(); + } +} //-------------------------------------------------------------------------------------------------- /// @@ -413,6 +413,38 @@ void RiuMainWindowBase::slotDockWidgetToggleViewActionTriggered() } } +//-------------------------------------------------------------------------------------------------- +/// +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindowBase::slotDockViewerVisibilityChanged( bool visible ) +{ + if ( visible ) return; + + // TODO - handle undocking views + + if ( auto dockWidget = dynamic_cast( sender() ) ) + { + auto mainWidget = dockWidget->widget(); + RimViewWindow* viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget( mainWidget ); + if ( !viewWindow ) + { + RiuViewer* viewer = mainWidget->findChild(); + if ( viewer ) + { + viewWindow = viewer->ownerViewWindow(); + } + } + + if ( viewWindow ) + { + viewWindow->setShowWindow( false ); + viewWindow->removeWindowFromDock(); + viewWindow->updateConnectedEditors(); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuMainWindowBase.h b/ApplicationLibCode/UserInterface/RiuMainWindowBase.h index 5ae3823bcc..4e9c5878b5 100644 --- a/ApplicationLibCode/UserInterface/RiuMainWindowBase.h +++ b/ApplicationLibCode/UserInterface/RiuMainWindowBase.h @@ -20,6 +20,8 @@ #include #include +#include +#include #include "cafPdmUiDragDropInterface.h" @@ -63,7 +65,7 @@ public: virtual void removeViewer( QWidget* viewer ) = 0; virtual void initializeViewer( ads::CDockWidget* dockWidget, QWidget* viewer ) {}; - virtual void setActiveViewer( QWidget* subWindow ) = 0; + virtual void setActiveViewer( QString viewerName ); virtual ads::CDockWidget* initializeDockingViewer( QWidget* viewer ) = 0; @@ -112,6 +114,8 @@ protected slots: void slotDockWidgetToggleViewActionTriggered(); void slotRefreshHelpActions(); + void slotDockViewerVisibilityChanged( bool ); + void slotRedo(); void slotUndo(); void slotRefreshUndoRedoActions(); diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp index c79023548f..c41816a0b1 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp @@ -824,15 +824,6 @@ void RiuPlotMainWindow::setPdmRoot( caf::PdmObject* pdmRoot ) // updateMultiPlotToolBar(); // } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuPlotMainWindow::setActiveViewer( QWidget* viewer ) -{ - // QMdiSubWindow* swin = findMdiSubWindow( viewer ); - // if ( swin ) m_mdiArea->setActiveSubWindow( swin ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -906,7 +897,7 @@ void RiuPlotMainWindow::selectedObjectsChanged( caf::PdmUiTreeView* projectTree, if ( selectedWindow->viewWidget() ) { setBlockViewSelectionOnSubWindowActivated( true ); - setActiveViewer( selectedWindow->viewWidget() ); + setActiveViewer( selectedWindow->dockWindowName() ); setBlockViewSelectionOnSubWindowActivated( false ); } diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.h b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.h index f75979d861..ced6ac9a11 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindow.h +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindow.h @@ -70,7 +70,6 @@ public: void removeViewer( QWidget* viewer ) override; void initializeViewer( ads::CDockWidget* dockWidget, QWidget* viewer ) override; - void setActiveViewer( QWidget* subWindow ) override; ads::CDockWidget* initializeDockingViewer( QWidget* viewer ) override; void setDefaultWindowSize(); diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp b/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp index 2d95e094f5..0eb5029ef2 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp @@ -36,13 +36,13 @@ void RiuPlotMainWindowTools::showPlotMainWindow() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuPlotMainWindowTools::setActiveViewer( QWidget* subWindow ) +void RiuPlotMainWindowTools::setActiveViewer( QString viewerName ) { if ( RiaGuiApplication::isRunning() ) { RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow(); - if ( mpw ) mpw->setActiveViewer( subWindow ); + if ( mpw ) mpw->setActiveViewer( viewerName ); } } diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.h b/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.h index a530a3e6cf..a8b955ec45 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.h +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.h @@ -18,7 +18,7 @@ #pragma once -class QWidget; +#include namespace caf { @@ -30,7 +30,7 @@ class RiuPlotMainWindowTools { public: static void showPlotMainWindow(); - static void setActiveViewer( QWidget* subWindow ); + static void setActiveViewer( QString viewerName ); static void setExpanded( const caf::PdmUiItem* uiItem ); static void selectAsCurrentItem( const caf::PdmObject* object ); static void selectOrToggleObject( const caf::PdmObject* object, bool toggle );