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: 31 additions & 6 deletions ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "RiaEclipseFileNameTools.h"
#include "RiaFractureDefines.h"
#include "RiaGuiApplication.h"
#include "RiaImportEclipseCaseTools.h"
#include "RiaLogging.h"
#include "RiaPreferencesGrid.h"
Expand Down Expand Up @@ -48,10 +49,12 @@
#include "RimSummaryCaseMainCollection.h"

#include "Riu3DMainWindowTools.h"
#include "RiuMainWindow.h"

#include "cafAssert.h"

#include <QFileInfo>
#include <QTimer>

//--------------------------------------------------------------------------------------------------
///
Expand Down Expand Up @@ -229,6 +232,8 @@ bool RimReloadCaseTools::openOrImportGridModelFromSummaryCase( const RimSummaryC
{
RiaLogging::info( std::format( "Imported {}", candidateGridFileName ) );

activateFirstView( RimProject::current()->eclipseCaseFromCaseId( id ) );

return true;
}
}
Expand All @@ -254,15 +259,35 @@ bool RimReloadCaseTools::findGridModelAndActivateFirstView( const RimSummaryCase
auto gridCase = RimReloadCaseTools::gridModelFromSummaryCase( summaryCase );
if ( gridCase )
{
if ( !gridCase->gridViews().empty() )
{
RicShowMainWindowFeature::showMainWindow();

Riu3DMainWindowTools::selectAsCurrentItem( gridCase->gridViews().front() );
}
activateFirstView( gridCase );

return true;
}

return false;
}

//--------------------------------------------------------------------------------------------------
/// Bring the 3D main window to front, and make the first view of the given case the active view
//--------------------------------------------------------------------------------------------------
void RimReloadCaseTools::activateFirstView( RimEclipseCase* eclipseCase )
{
if ( !eclipseCase || eclipseCase->gridViews().empty() ) return;

RicShowMainWindowFeature::showMainWindow();

Riu3DMainWindowTools::selectAsCurrentItem( eclipseCase->gridViews().front() );

if ( auto mainWindow = RiaGuiApplication::isRunning() ? RiuMainWindow::instance() : nullptr )
{
// Defer the raise until the already queued events have been processed. Activating the window directly ends up
// with the plot window on top.
QTimer::singleShot( 0,
mainWindow,
[mainWindow]()
{
mainWindow->raise();
mainWindow->activateWindow();
} );
}
}
1 change: 1 addition & 0 deletions ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ class RimReloadCaseTools
static void updateAllPlots();

static bool findGridModelAndActivateFirstView( const RimSummaryCase* summaryCase );
static void activateFirstView( RimEclipseCase* eclipseCase );
};