mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#7862 Export Completion: Add ResInsight project file to file header
This commit is contained in:
parent
8e6733d9e0
commit
0f87c9760d
@ -895,7 +895,10 @@ void RicWellPathExportCompletionDataFeatureImpl::sortAndExportCompletionsToFile(
|
||||
{
|
||||
QFileInfo fi( fileName );
|
||||
std::shared_ptr<QFile> exportFile =
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( folderName, fi.baseName(), fi.suffix() );
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( folderName,
|
||||
fi.baseName(),
|
||||
fi.suffix(),
|
||||
exportDataSourceAsComment );
|
||||
|
||||
std::map<QString, std::vector<RigCompletionData>> completionsForGrid;
|
||||
completionsForGrid.insert( std::pair<QString, std::vector<RigCompletionData>>( "", completionsForMainGrid ) );
|
||||
@ -920,7 +923,10 @@ void RicWellPathExportCompletionDataFeatureImpl::sortAndExportCompletionsToFile(
|
||||
|
||||
QString lgrFileName = fi.baseName() + "_LGR";
|
||||
std::shared_ptr<QFile> exportFile =
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( folderName, lgrFileName, fi.suffix() );
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( folderName,
|
||||
lgrFileName,
|
||||
fi.suffix(),
|
||||
exportDataSourceAsComment );
|
||||
|
||||
exportWellPathFractureReport( eclipseCase, exportFile, wellPathFractureReportItems );
|
||||
if ( exportWelspec )
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include "RiaFilePathTools.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaRegressionTestRunner.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
#include "RimWellPath.h"
|
||||
@ -27,7 +29,9 @@
|
||||
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QTextStream>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -40,16 +44,7 @@ RicWellPathExportCompletionsFileTools::OpenFileException::OpenFileException( con
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::shared_ptr<QFile> RicWellPathExportCompletionsFileTools::openFileForExport( const QString& fullFileName )
|
||||
{
|
||||
std::pair<QString, QString> folderAndFileName = RiaFilePathTools::toFolderAndFileName( fullFileName );
|
||||
return openFileForExport( folderAndFileName.first, folderAndFileName.second );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::shared_ptr<QFile> RicWellPathExportCompletionsFileTools::openFileForExport( const QString& folderName,
|
||||
std::shared_ptr<QFile> RicWellPathExportCompletionsFileTools::openFile( const QString& folderName,
|
||||
const QString& fileName,
|
||||
const QString& suffix )
|
||||
{
|
||||
@ -81,15 +76,6 @@ std::shared_ptr<QFile> RicWellPathExportCompletionsFileTools::openFileForExport(
|
||||
return exportFile;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::shared_ptr<QFile> RicWellPathExportCompletionsFileTools::openFileForExport( const QString& folderName,
|
||||
const QString& fileName )
|
||||
{
|
||||
return openFileForExport( folderName, fileName, "" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -103,3 +89,60 @@ const RimWellPath* RicWellPathExportCompletionsFileTools::findWellPathFromExport
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::shared_ptr<QFile> RicWellPathExportCompletionsFileTools::openFileForExport( const QString& folderName,
|
||||
const QString& fileName,
|
||||
const QString& suffix,
|
||||
bool writeInfoHeader )
|
||||
{
|
||||
auto file = openFile( folderName, fileName, suffix );
|
||||
|
||||
// Do not write header when running regression tests to make sure the text content is stable
|
||||
if ( file && writeInfoHeader && !RiaRegressionTestRunner::instance()->isRunningRegressionTests() )
|
||||
{
|
||||
QString header = createProjectFileHeader();
|
||||
if ( !header.isEmpty() )
|
||||
{
|
||||
QTextStream stream( file.get() );
|
||||
|
||||
stream << header;
|
||||
}
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicWellPathExportCompletionsFileTools::createProjectFileHeader()
|
||||
{
|
||||
QString txt = QString( "-- Exported from ResInsight " );
|
||||
|
||||
auto dateTimeFormatString = RiaPreferences::current()->dateTimeFormat();
|
||||
if ( !dateTimeFormatString.isEmpty() )
|
||||
{
|
||||
auto currentDateTime = QDateTime::currentDateTime();
|
||||
auto dateStampString = currentDateTime.toString( dateTimeFormatString );
|
||||
txt += dateStampString;
|
||||
}
|
||||
|
||||
txt += "\n";
|
||||
|
||||
auto proj = RimProject::current();
|
||||
if ( proj && !proj->fileName().isEmpty() )
|
||||
{
|
||||
QString fileName = proj->fileName();
|
||||
if ( !fileName.isEmpty() )
|
||||
{
|
||||
txt += "-- " + fileName + "\n";
|
||||
}
|
||||
|
||||
txt += "\n";
|
||||
}
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
@ -35,9 +35,13 @@ public:
|
||||
QString message;
|
||||
};
|
||||
|
||||
static std::shared_ptr<QFile> openFileForExport( const QString& folderName, const QString& fileName );
|
||||
static std::shared_ptr<QFile>
|
||||
openFileForExport( const QString& folderName, const QString& fileName, const QString& suffix );
|
||||
static std::shared_ptr<QFile> openFileForExport( const QString& fullFileName );
|
||||
static const RimWellPath* findWellPathFromExportName( const QString& wellNameForExport );
|
||||
|
||||
static std::shared_ptr<QFile>
|
||||
openFileForExport( const QString& folderName, const QString& fileName, const QString& suffix, bool writeInfoHeader );
|
||||
|
||||
private:
|
||||
static std::shared_ptr<QFile> openFile( const QString& folderName, const QString& fileName, const QString& suffix );
|
||||
|
||||
static QString createProjectFileHeader();
|
||||
};
|
||||
|
@ -87,7 +87,10 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions(
|
||||
}
|
||||
|
||||
unifiedExportFile =
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( folderName, fileName, fi.suffix() );
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( folderName,
|
||||
fileName,
|
||||
fi.suffix(),
|
||||
exportSettings.exportDataSourceAsComment() );
|
||||
}
|
||||
|
||||
{
|
||||
@ -107,7 +110,10 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions(
|
||||
}
|
||||
|
||||
unifiedLgrExportFile =
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( folderName, lgrFileName, fi.suffix() );
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( folderName,
|
||||
lgrFileName,
|
||||
fi.suffix(),
|
||||
exportSettings.exportDataSourceAsComment() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,9 +142,15 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions(
|
||||
QString wellFileName = QString( "%1_UnifiedCompletions_MSW_%2" )
|
||||
.arg( wellPath->name(), exportSettings.caseToApply->caseUserDescription() );
|
||||
unifiedWellPathFile =
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, wellFileName );
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder,
|
||||
wellFileName,
|
||||
"",
|
||||
exportSettings.exportDataSourceAsComment() );
|
||||
unifiedLgrWellPathFile =
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, wellFileName + "_LGR" );
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder,
|
||||
wellFileName + "_LGR",
|
||||
"",
|
||||
exportSettings.exportDataSourceAsComment() );
|
||||
}
|
||||
|
||||
{
|
||||
@ -171,9 +183,16 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions(
|
||||
QString fileName =
|
||||
QString( "%1_%2MSW_%3" )
|
||||
.arg( wellPath->name(), perforationText, exportSettings.caseToApply->caseUserDescription() );
|
||||
exportFile = RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName );
|
||||
exportFile =
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder,
|
||||
fileName,
|
||||
"",
|
||||
exportSettings.exportDataSourceAsComment() );
|
||||
lgrExportFile =
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName + "_LGR" );
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder,
|
||||
fileName + "_LGR",
|
||||
"",
|
||||
exportSettings.exportDataSourceAsComment() );
|
||||
}
|
||||
exportWellSegmentsForPerforations( exportSettings.caseToApply,
|
||||
exportFile,
|
||||
@ -203,9 +222,16 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions(
|
||||
{
|
||||
QString fileName =
|
||||
QString( "%1_Fracture_MSW_%2" ).arg( wellPath->name(), exportSettings.caseToApply->caseUserDescription() );
|
||||
exportFile = RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName );
|
||||
exportFile =
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder,
|
||||
fileName,
|
||||
"",
|
||||
exportSettings.exportDataSourceAsComment() );
|
||||
lgrExportFile =
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName + "_LGR" );
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder,
|
||||
fileName + "_LGR",
|
||||
"",
|
||||
exportSettings.exportDataSourceAsComment() );
|
||||
}
|
||||
exportWellSegmentsForFractures( exportSettings.caseToApply,
|
||||
exportFile,
|
||||
@ -234,9 +260,16 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions(
|
||||
{
|
||||
QString fileName =
|
||||
QString( "%1_Fishbones_MSW_%2" ).arg( wellPath->name(), exportSettings.caseToApply->caseUserDescription() );
|
||||
exportFile = RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName );
|
||||
exportFile =
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder,
|
||||
fileName,
|
||||
"",
|
||||
exportSettings.exportDataSourceAsComment() );
|
||||
lgrExportFile =
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder, fileName + "_LGR" );
|
||||
RicWellPathExportCompletionsFileTools::openFileForExport( exportSettings.folder,
|
||||
fileName + "_LGR",
|
||||
"",
|
||||
exportSettings.exportDataSourceAsComment() );
|
||||
}
|
||||
exportWellSegmentsForFishbones( exportSettings.caseToApply,
|
||||
exportFile,
|
||||
|
Loading…
Reference in New Issue
Block a user