mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Always use export folder if defined
Rename to m_customFileNameIncludingPath, and split into folder and file name for export object
This commit is contained in:
parent
947185bdcc
commit
6ad42817c6
@ -36,6 +36,8 @@
|
||||
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RicfExportWellPathCompletions, "exportWellPathCompletions" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -81,7 +83,7 @@ RicfExportWellPathCompletions::RicfExportWellPathCompletions()
|
||||
|
||||
CAF_PDM_InitScriptableField( &m_exportDataSourceAsComments, "exportComments", true, "Export Data Source as Comments" );
|
||||
CAF_PDM_InitScriptableField( &m_exportWelspec, "exportWelspec", true, "Export WELSPEC keyword" );
|
||||
CAF_PDM_InitScriptableField( &m_customFileName, "customFileName", QString(), "Custom Filename" );
|
||||
CAF_PDM_InitScriptableField( &m_customFileNameIncludingPath, "customFileName", QString(), "Custom Filename" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -121,7 +123,32 @@ caf::PdmScriptResponse RicfExportWellPathCompletions::execute()
|
||||
|
||||
exportSettings.setExportDataSourceAsComment( m_exportDataSourceAsComments );
|
||||
exportSettings.setExportWelspec( m_exportWelspec );
|
||||
exportSettings.setCustomFileName( m_customFileName );
|
||||
|
||||
QString exportFolderPath;
|
||||
if ( m_customFileNameIncludingPath().isEmpty() )
|
||||
{
|
||||
exportFolderPath =
|
||||
RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::ExportType::COMPLETIONS );
|
||||
if ( exportFolderPath.isNull() )
|
||||
{
|
||||
exportFolderPath = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath( "completions" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QFileInfo fi( m_customFileNameIncludingPath );
|
||||
auto fileName = fi.fileName();
|
||||
|
||||
exportSettings.setCustomFileName( fileName );
|
||||
|
||||
auto pathCandidate = fi.path();
|
||||
if ( pathCandidate.size() > 2 )
|
||||
{
|
||||
exportFolderPath = pathCandidate;
|
||||
}
|
||||
}
|
||||
|
||||
exportSettings.folder = exportFolderPath;
|
||||
|
||||
{
|
||||
auto eclipseCase = TOOLS::caseFromId( m_caseId() );
|
||||
@ -134,14 +161,6 @@ caf::PdmScriptResponse RicfExportWellPathCompletions::execute()
|
||||
exportSettings.caseToApply = eclipseCase;
|
||||
}
|
||||
|
||||
QString exportFolder =
|
||||
RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::ExportType::COMPLETIONS );
|
||||
if ( exportFolder.isNull() )
|
||||
{
|
||||
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath( "completions" );
|
||||
}
|
||||
exportSettings.folder = exportFolder;
|
||||
|
||||
caf::PdmScriptResponse response;
|
||||
|
||||
std::vector<RimWellPath*> wellPaths;
|
||||
|
@ -62,5 +62,8 @@ private:
|
||||
|
||||
caf::PdmField<bool> m_exportDataSourceAsComments;
|
||||
caf::PdmField<bool> m_exportWelspec;
|
||||
caf::PdmField<QString> m_customFileName;
|
||||
|
||||
// This text field can contain a file name, optionally including the full path. When the full path is specified,
|
||||
// the path and file name is split in RicfExportWellPathCompletions::execute()
|
||||
caf::PdmField<QString> m_customFileNameIncludingPath;
|
||||
};
|
||||
|
@ -268,22 +268,14 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions( const std::v
|
||||
|
||||
if ( exportSettings.fileSplit == RicExportCompletionDataSettingsUi::ExportSplit::UNIFIED_FILE )
|
||||
{
|
||||
QString fileName;
|
||||
QString folderName;
|
||||
if ( exportSettings.customFileName().isEmpty() )
|
||||
QString fileName = exportSettings.customFileName();
|
||||
if ( fileName.isEmpty() )
|
||||
{
|
||||
fileName = QString( "UnifiedCompletions_%1" ).arg( eclipseCaseName );
|
||||
folderName = exportSettings.folder;
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = exportSettings.customFileName();
|
||||
QFileInfo fi( fileName );
|
||||
folderName = fi.absolutePath();
|
||||
}
|
||||
|
||||
sortAndExportCompletionsToFile( exportSettings.caseToApply,
|
||||
folderName,
|
||||
exportSettings.folder,
|
||||
fileName,
|
||||
completions,
|
||||
fractureDataReportItems,
|
||||
|
@ -72,22 +72,19 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions(
|
||||
{
|
||||
{
|
||||
QString fileName;
|
||||
QString folderName;
|
||||
|
||||
QFileInfo fi( exportSettings.customFileName() );
|
||||
if ( !exportSettings.customFileName().isEmpty() )
|
||||
{
|
||||
fileName = fi.baseName() + "_MSW";
|
||||
folderName = fi.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = QString( "UnifiedCompletions_MSW_%1" ).arg( exportSettings.caseToApply->caseUserDescription() );
|
||||
folderName = exportSettings.folder;
|
||||
}
|
||||
|
||||
unifiedExportFile =
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( folderName,
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder,
|
||||
fileName,
|
||||
fi.suffix(),
|
||||
exportSettings.exportDataSourceAsComment() );
|
||||
@ -95,22 +92,19 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions(
|
||||
|
||||
{
|
||||
QString lgrFileName;
|
||||
QString folderName;
|
||||
QFileInfo fi( exportSettings.customFileName() );
|
||||
if ( !exportSettings.customFileName().isEmpty() )
|
||||
{
|
||||
lgrFileName = fi.baseName() + "_LGR_MSW";
|
||||
folderName = fi.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
lgrFileName =
|
||||
QString( "UnifiedCompletions_LGR_MSW_%1" ).arg( exportSettings.caseToApply->caseUserDescription() );
|
||||
folderName = exportSettings.folder;
|
||||
}
|
||||
|
||||
unifiedLgrExportFile =
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( folderName,
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder,
|
||||
lgrFileName,
|
||||
fi.suffix(),
|
||||
exportSettings.exportDataSourceAsComment() );
|
||||
|
Loading…
Reference in New Issue
Block a user