#3464 Well Path Export. Use formmatter to export data. Several formatting issues

This commit is contained in:
Bjørn Erik Jensen 2018-11-01 10:04:50 +01:00
parent 2bd70b705e
commit f90fed9aa1
3 changed files with 45 additions and 7 deletions

View File

@ -70,7 +70,7 @@ void RicfExportWellPaths::execute()
{
if (wellPath)
{
feature->exportWellPath(wellPath, m_mdStepSize, exportFolder);
feature->exportWellPath(wellPath, m_mdStepSize, exportFolder, false);
}
}
}

View File

@ -23,6 +23,8 @@
#include "RicExportWellPathsUi.h"
#include "RifEclipseDataTableFormatter.h"
#include "RigWellPath.h"
#include "RimWellPath.h"
@ -46,13 +48,16 @@ CAF_CMD_SOURCE_INIT(RicExportSelectedWellPathsFeature, "RicExportSelectedWellPat
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportSelectedWellPathsFeature::exportWellPath(const RimWellPath* wellPath, double mdStepSize, const QString& folder)
void RicExportSelectedWellPathsFeature::exportWellPath(const RimWellPath* wellPath,
double mdStepSize,
const QString& folder,
bool writeProjectInfo)
{
auto fileName = wellPath->name() + ".dev";
auto filePtr = openFileForExport(folder, fileName);
auto stream = createOutputFileStream(*filePtr);
writeWellPathGeometryToStream(*stream, wellPath->wellPathGeometry(), wellPath->name(), mdStepSize);
writeWellPathGeometryToStream(*stream, wellPath->wellPathGeometry(), wellPath->name(), mdStepSize, writeProjectInfo);
filePtr->close();
}
@ -62,13 +67,33 @@ void RicExportSelectedWellPathsFeature::exportWellPath(const RimWellPath* wellPa
void RicExportSelectedWellPathsFeature::writeWellPathGeometryToStream(QTextStream& stream,
const RigWellPath* geometry,
const QString& wellName,
double mdStepSize)
double mdStepSize,
bool writeProjectInfo)
{
double currMd = geometry->measureDepths().front() - mdStepSize;
double endMd = geometry->measureDepths().back();
RifEclipseDataTableFormatter formatter(stream);
formatter.setCommentPrefix("#");
formatter.setTableRowPrependText(" ");
if (writeProjectInfo)
{
formatter.comment("Project: " + RiaApplication::instance()->project()->fileName);
stream << endl;
}
stream << "WELLNAME: '" << caf::Utils::makeValidFileBasename(wellName) << "'" << endl;
auto numberFormat = RifEclipseOutputTableDoubleFormatting(RIF_FLOAT, 2);
formatter.header(
{
RifEclipseOutputTableColumn("X", numberFormat, RIGHT),
RifEclipseOutputTableColumn("Y", numberFormat, RIGHT),
RifEclipseOutputTableColumn("TVD", numberFormat, RIGHT),
RifEclipseOutputTableColumn("MD", numberFormat, RIGHT)
});
while (currMd < endMd)
{
currMd += mdStepSize;
@ -78,8 +103,14 @@ void RicExportSelectedWellPathsFeature::writeWellPathGeometryToStream(QTextStrea
double tvd = -pt.z();
// Write to file
stream << pt.x() << " " << pt.y() << " " << tvd << " " << currMd << endl;
formatter.add(pt.x());
formatter.add(pt.y());
formatter.add(tvd);
formatter.add(currMd);
formatter.rowCompleted("");
}
formatter.tableCompleted("", false);
stream << -999 << endl << endl;
}

View File

@ -43,12 +43,19 @@ class RicExportSelectedWellPathsFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;
static void handleAction(const std::vector<RimWellPath*>& wellPaths);
static void exportWellPath(const RimWellPath* wellPath, double mdStepSize, const QString& folder);
static void exportWellPath(const RimWellPath* wellPath,
double mdStepSize,
const QString& folder,
bool writeProjectInfo = true);
static RicExportWellPathsUi* openDialog();
static QFilePtr openFileForExport(const QString& folderName, const QString& fileName);
static QTextStreamPtr createOutputFileStream(QFile& file);
static void writeWellPathGeometryToStream(QTextStream& stream, const RigWellPath* geometry, const QString& wellName, double mdStepSize);
static void writeWellPathGeometryToStream(QTextStream& stream,
const RigWellPath* geometry,
const QString& wellName,
double mdStepSize,
bool writeProjectInfo = true);
private:
bool isCommandEnabled() override;