Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjenssen committed Jan 2, 2024
1 parent a4db175 commit 5ba5065
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ void RicExportInpFileFeature::onActionTriggered( bool isChecked )
auto faultReactivationModel = caf::SelectionManager::instance()->selectedItemOfType<RimFaultReactivationModel>();
if ( faultReactivationModel )
{
QString exportFile = faultReactivationModel->baseDir() + "/faultreactivation.inp";
auto [isOk, errorMessage] = RifFaultReactivationModelExporter::exportToFile( exportFile.toStdString(), *faultReactivationModel );
std::string exportFile = faultReactivationModel->inputFilename();
auto [isOk, errorMessage] = RifFaultReactivationModelExporter::exportToFile( exportFile, *faultReactivationModel );
if ( !isOk )
{
const QString frmTitle( "Fault Reactivation Modeling" );
QString outErrorText =
QString( "Failed to export INP model to file %1.\n\n%2" ).arg( exportFile ).arg( QString::fromStdString( errorMessage ) );
QString outErrorText = QString( "Failed to export INP model to file %1.\n\n%2" )
.arg( QString::fromStdString( exportFile ) )
.arg( QString::fromStdString( errorMessage ) );
QMessageBox::critical( nullptr, frmTitle, outErrorText );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ bool RifFaultReactivationModelExporter::exportModelSettings( const RimFaultReact
faultNormal = faultNormal ^ cvf::Vec3d::Z_AXIS;

RimFaultReactivationTools::addSettingsToMap( settings, faultNormal, topPosition, bottomPosition );
return ResInsightInternalJson::JsonWriter::encodeFile( rimModel.settingsFilename(), settings );
return ResInsightInternalJson::JsonWriter::encodeFile( QString::fromStdString( rimModel.settingsFilename() ), settings );
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,54 +625,81 @@ QStringList RimFaultReactivationModel::commandParameters() const
QStringList retlist;

retlist << baseDir();
retlist << inputFilename();
retlist << outputOdbFilename();
retlist << QString::fromStdString( inputFilename() );
retlist << QString::fromStdString( outputOdbFilename() );

return retlist;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimFaultReactivationModel::outputOdbFilename() const
std::string RimFaultReactivationModel::outputOdbFilename() const
{
QDir directory( baseDir() );
return directory.absoluteFilePath( baseFilename() + ".odb" );
return directory.absoluteFilePath( QString::fromStdString( baseFilename() + ".odb" ) ).toStdString();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimFaultReactivationModel::inputFilename() const
std::string RimFaultReactivationModel::inputFilename() const
{
QDir directory( baseDir() );
return directory.absoluteFilePath( baseFilename() + ".inp" );
return directory.absoluteFilePath( QString::fromStdString( baseFilename() + ".inp" ) ).toStdString();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimFaultReactivationModel::settingsFilename() const
std::string RimFaultReactivationModel::includeFilename( const std::string propertyName, const std::string timeStep ) const
{
QDir directory( baseDir() );
std::string name = baseFilename();
if ( !propertyName.empty() )
{
name += "_" + cleanUpName( propertyName );
}
if ( !timeStep.empty() )
{
name += "_" + cleanUpName( timeStep );
}

return directory.absoluteFilePath( QString::fromStdString( name + ".inp" ) ).toStdString();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RimFaultReactivationModel::settingsFilename() const
{
QDir directory( baseDir() );
return directory.absoluteFilePath( baseFilename() + ".settings.json" );
return directory.absoluteFilePath( QString::fromStdString( baseFilename() + ".settings.json" ) ).toStdString();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimFaultReactivationModel::baseFilename() const
std::string RimFaultReactivationModel::cleanUpName( const std::string candidate )
{
QString tmp = m_userDescription();
QString tmp = QString::fromStdString( candidate );

if ( tmp.isEmpty() ) return "faultReactivation";
if ( tmp.isEmpty() ) return "unknown";

tmp.replace( ' ', '_' );
tmp.replace( '/', '_' );
tmp.replace( '\\', '_' );
tmp.replace( ':', '_' );

return tmp;
return tmp.toStdString();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RimFaultReactivationModel::baseFilename() const
{
return cleanUpName( m_userDescription().toStdString() );
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ class RimFaultReactivationModel : public RimCheckableNamedObject, public RimPoly

QStringList commandParameters() const;

QString outputOdbFilename() const;
QString inputFilename() const;
QString settingsFilename() const;
std::string outputOdbFilename() const;
std::string inputFilename() const;
std::string includeFilename( const std::string propertyName, const std::string timeStep = "" ) const;
std::string settingsFilename() const;

void updateTimeSteps();

Expand All @@ -137,7 +138,9 @@ class RimFaultReactivationModel : public RimCheckableNamedObject, public RimPoly
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;

QString baseFilename() const;
std::string baseFilename() const;

static std::string cleanUpName( const std::string candidate );

private:
std::shared_ptr<RicPolylineTargetsPickEventHandler> m_pickTargetsEventHandler;
Expand Down

0 comments on commit 5ba5065

Please sign in to comment.