Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjenssen committed Sep 13, 2023
1 parent 51138ce commit 141e7b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "RimProject.h"

#include "Riu3DMainWindowTools.h"
#include "Riu3dSelectionManager.h"
#include "RiuFileDialogTools.h"

#include "cafProgressInfo.h"
Expand All @@ -53,13 +52,10 @@ bool RicRunFaultReactModelingFeature::isCommandEnabled() const
void RicRunFaultReactModelingFeature::onActionTriggered( bool isChecked )
{
RimFaultReactivationModel* model = dynamic_cast<RimFaultReactivationModel*>( caf::SelectionManager::instance()->selectedItem() );

if ( model == nullptr ) return;

const QString frmTitle( "Fault Reactivation Modeling" );

QString outErrorText;

caf::ProgressInfo runProgress( 3, frmTitle + " running , please wait..." );

runProgress.setProgressDescription( "Writing input files." );
Expand All @@ -81,7 +77,8 @@ void RicRunFaultReactModelingFeature::onActionTriggered( bool isChecked )

if ( !result )
{
outErrorText = QString( "Failed to export INP model to file %1.\n\n%2" ).arg( exportFile ).arg( QString::fromStdString( errText ) );
QString outErrorText =
QString( "Failed to export INP model to file %1.\n\n%2" ).arg( exportFile ).arg( QString::fromStdString( errText ) );
QMessageBox::critical( nullptr, frmTitle, outErrorText );
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@
#include "RimFaultReactivationModel.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechView.h"
#include "RimProcess.h"
#include "RimProject.h"

#include "Riu3DMainWindowTools.h"
#include "Riu3dSelectionManager.h"
#include "RiuFileDialogTools.h"

#include "cafProgressInfo.h"
#include "cafSelectionManagerTools.h"

#include <QAction>
Expand All @@ -55,26 +51,23 @@ bool RicShowFaultReactModelFeature::isCommandEnabled() const
void RicShowFaultReactModelFeature::onActionTriggered( bool isChecked )
{
RimFaultReactivationModel* model = dynamic_cast<RimFaultReactivationModel*>( caf::SelectionManager::instance()->selectedItem() );

if ( model == nullptr ) return;

const QString frmTitle( "Fault Reactivation Modeling" );
const QString exportFile = model->inputFilename();

QString outErrorText;

QString exportFile = model->inputFilename();
auto [result, errText] = RifFaultReactivationModelExporter::exportToFile( exportFile.toStdString(), *model->model() );

if ( !result )
{
outErrorText = QString( "Failed to export INP model to file %1.\n\n%2" ).arg( exportFile ).arg( QString::fromStdString( errText ) );
QString outErrorText =
QString( "Failed to export INP model to file %1.\n\n%2" ).arg( exportFile ).arg( QString::fromStdString( errText ) );
QMessageBox::critical( nullptr, frmTitle, outErrorText );
return;
}

for ( auto gCase : RimProject::current()->geoMechCases() )
{
if ( model->inputFilename() == gCase->gridFileName() )
if ( exportFile == gCase->gridFileName() )
{
gCase->reloadDataAndUpdate();
auto& views = gCase->geoMechViews();
Expand All @@ -91,12 +84,11 @@ void RicShowFaultReactModelFeature::onActionTriggered( bool isChecked )
}

RiaApplication* app = RiaApplication::instance();
if ( !app->openOdbCaseFromFile( model->inputFilename() ) )
if ( !app->openOdbCaseFromFile( exportFile ) )
{
QMessageBox::critical( nullptr,
frmTitle,
"Failed to load INP model from file \"" + model->inputFilename() +
"\". Check log window for additional information." );
"Failed to load INP model from file \"" + exportFile + "\". Check log window for additional information." );
}
}

Expand Down

0 comments on commit 141e7b3

Please sign in to comment.