Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions ApplicationLibCode/ProjectDataModel/RimDockWindowController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,32 @@ void RimDockWindowController::setAsActiveViewer( bool allowSelectionChange )
auto view3d = dynamic_cast<Rim3dView*>( pdmView );
auto viewPlot = dynamic_cast<RimPlotWindow*>( 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<Rim3dView>() )
{
deactivate( view );
}
}
else
{
for ( auto view : project->descendantsOfType<RimViewWindow>() )
{
if ( !dynamic_cast<Rim3dView*>( view ) ) deactivate( view );
}
}
}

Expand All @@ -235,8 +251,11 @@ void RimDockWindowController::setAsActiveViewer( bool allowSelectionChange )

if ( view3d )
{
RiaApplication::instance()->setActiveReservoirView( view3d );
if ( auto mainWin = dynamic_cast<RiuMainWindow*>( 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();
Expand Down
29 changes: 28 additions & 1 deletion ApplicationLibCode/UserInterface/RiuMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -1285,9 +1286,10 @@ std::vector<RimViewWindow*> 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<Rim3dView>() )
{
if ( v->dockWidget() ) views.push_back( v );
if ( v->dockWidget() && !v->isDockedInPlotView() ) views.push_back( v );
}
}

Expand Down Expand Up @@ -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<Rim3dView>() )
{
if ( view->isDockedInPlotView() && view->dockWindowName() == viewerName )
{
const bool wasBlocking = plotWindow->isBlockingViewSelectionOnSubWindowActivated();
plotWindow->setBlockViewSelectionOnSubWindowActivated( isBlockingViewSelectionOnSubWindowActivated() );
plotWindow->setActiveViewer( viewerName );
plotWindow->setBlockViewSelectionOnSubWindowActivated( wasBlocking );
return;
}
}
}

RiuMainWindowBase::setActiveViewer( viewerName );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions ApplicationLibCode/UserInterface/RiuMainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<RimViewWindow*> viewWindows() override;

Expand Down
7 changes: 5 additions & 2 deletions ApplicationLibCode/UserInterface/RiuPlotMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,9 +860,12 @@ std::vector<RimViewWindow*> RiuPlotMainWindow::viewWindows()
// Project can be null while it is being torn down.
if ( auto project = RimProject::current() )
{
for ( auto v : project->descendantsOfType<RimPlotWindow>() )
// 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<RimViewWindow>() )
{
if ( v->dockWidget() ) views.push_back( v );
if ( !v->dockWidget() ) continue;
if ( dynamic_cast<RimPlotWindow*>( v ) || v->isDockedInPlotView() ) views.push_back( v );
}
}

Expand Down
7 changes: 4 additions & 3 deletions ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "RiaGuiApplication.h"

#include "Rim3dView.h"
#include "RimViewWindow.h"

#include "RiuMainWindow.h"
Expand Down Expand Up @@ -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<Rim3dView*>( view ) && view->isDockedInPlotView() )
{
view->setShowWindow( false );
view->removeWindowFromDock();
Expand Down