mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3853 Remove zero padding and unnecessary space at beginning and end of row for WSEGAICD
This commit is contained in:
parent
d90c5f07bd
commit
8821a37b90
@ -136,7 +136,7 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions(co
|
||||
else
|
||||
{
|
||||
QString fileName =
|
||||
QString("%1_Perforations_MSW_%2")
|
||||
QString("%1_Perforation_MSW_%2")
|
||||
.arg(wellPath->completions()->wellNameForExport(), exportSettings.caseToApply->caseUserDescription());
|
||||
perforationsExportFile = RicWellPathExportCompletionsFileTools::openFileForExport(exportSettings.folder, fileName);
|
||||
}
|
||||
@ -679,6 +679,9 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable(RifEclipseDataTa
|
||||
{
|
||||
int existingColSpacing = formatter.columnSpacing();
|
||||
formatter.setColumnSpacing(1);
|
||||
QString existingPrependText = formatter.tableRowPrependText();
|
||||
formatter.setTableRowPrependText("");
|
||||
|
||||
bool foundValve = false;
|
||||
|
||||
for (std::shared_ptr<RicMswSegment> location : exportInfo.wellSegmentLocations())
|
||||
@ -716,29 +719,14 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable(RifEclipseDataTa
|
||||
formatter.comment(QString("%1: %2").arg(i + 1, 2, 10, QChar('0')).arg(columnDescriptions[i]));
|
||||
}
|
||||
|
||||
std::vector<RifEclipseOutputTableColumn> header = {
|
||||
RifEclipseOutputTableColumn("01"),
|
||||
RifEclipseOutputTableColumn("02"),
|
||||
RifEclipseOutputTableColumn("03"),
|
||||
RifEclipseOutputTableColumn("04"),
|
||||
RifEclipseOutputTableColumn("05"),
|
||||
RifEclipseOutputTableColumn("06"),
|
||||
RifEclipseOutputTableColumn("07"),
|
||||
RifEclipseOutputTableColumn("08"),
|
||||
RifEclipseOutputTableColumn("09"),
|
||||
RifEclipseOutputTableColumn("10"),
|
||||
RifEclipseOutputTableColumn("11"),
|
||||
RifEclipseOutputTableColumn("12"),
|
||||
RifEclipseOutputTableColumn("13"),
|
||||
RifEclipseOutputTableColumn("14"),
|
||||
RifEclipseOutputTableColumn("15"),
|
||||
RifEclipseOutputTableColumn("16"),
|
||||
RifEclipseOutputTableColumn("17"),
|
||||
RifEclipseOutputTableColumn("18"),
|
||||
RifEclipseOutputTableColumn("19"),
|
||||
RifEclipseOutputTableColumn("20"),
|
||||
RifEclipseOutputTableColumn("21"),
|
||||
};
|
||||
std::vector<RifEclipseOutputTableColumn> header;
|
||||
for (size_t i = 1; i <= 21; ++i)
|
||||
{
|
||||
QString cName = QString("%1").arg(i, 2, 10, QChar('0'));
|
||||
RifEclipseOutputTableColumn col(cName,
|
||||
RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_CONSISE), RIGHT);
|
||||
header.push_back(col);
|
||||
}
|
||||
formatter.header(header);
|
||||
|
||||
foundValve = true;
|
||||
@ -783,6 +771,7 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable(RifEclipseDataTa
|
||||
formatter.tableCompleted();
|
||||
}
|
||||
formatter.setColumnSpacing(existingColSpacing);
|
||||
formatter.setTableRowPrependText(existingPrependText);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -57,6 +57,14 @@ void RifEclipseDataTableFormatter::setColumnSpacing(int spacing)
|
||||
m_colSpacing = spacing;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RifEclipseDataTableFormatter::tableRowPrependText() const
|
||||
{
|
||||
return m_tableRowPrependText;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -88,10 +96,14 @@ void RifEclipseDataTableFormatter::outputBuffer()
|
||||
{
|
||||
if (!m_columns.empty() && !isAllHeadersEmpty(m_columns))
|
||||
{
|
||||
m_out << m_commentPrefix << " ";
|
||||
for (RifEclipseOutputTableColumn& column : m_columns)
|
||||
for (size_t i = 0u; i < m_columns.size(); ++i)
|
||||
{
|
||||
m_out << formatColumn(column.title, column);
|
||||
QString colTitle = m_columns[i].title;
|
||||
if (i == 0u)
|
||||
{
|
||||
colTitle = m_commentPrefix + " " + colTitle;
|
||||
}
|
||||
m_out << formatColumn(colTitle, i);
|
||||
}
|
||||
m_out << "\n";
|
||||
}
|
||||
@ -112,7 +124,7 @@ void RifEclipseDataTableFormatter::outputBuffer()
|
||||
|
||||
for (size_t i = 0; i < line.data.size(); ++i)
|
||||
{
|
||||
m_out << formatColumn(line.data[i], m_columns[i]);
|
||||
m_out << formatColumn(line.data[i], i);
|
||||
}
|
||||
|
||||
m_out << (line.appendTextSet ? line.appendText : m_tableRowAppendText) << "\n";
|
||||
@ -234,9 +246,15 @@ RifEclipseDataTableFormatter& RifEclipseDataTableFormatter::header(const std::ve
|
||||
{
|
||||
outputBuffer();
|
||||
m_columns = header;
|
||||
for (RifEclipseOutputTableColumn& column : m_columns)
|
||||
|
||||
for (size_t colNumber = 0u; colNumber < m_columns.size(); ++colNumber)
|
||||
{
|
||||
column.width = measure(column.title);
|
||||
QString colTitle = m_columns[colNumber].title;
|
||||
if (colNumber == 0u)
|
||||
{
|
||||
colTitle = m_commentPrefix + " " + colTitle;
|
||||
}
|
||||
m_columns[colNumber].width = measure(colTitle);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@ -425,9 +443,9 @@ int RifEclipseDataTableFormatter::tableWidth() const
|
||||
{
|
||||
int characterCount = 0;
|
||||
|
||||
for (const auto& col : m_columns)
|
||||
for (size_t i = 0u; i < m_columns.size(); ++i)
|
||||
{
|
||||
characterCount += formatColumn(" ", col).size();
|
||||
characterCount += formatColumn(" ", i).size();
|
||||
}
|
||||
|
||||
return characterCount;
|
||||
@ -444,6 +462,8 @@ QString RifEclipseDataTableFormatter::format(double num, RifEclipseOutputTableDo
|
||||
return QString("%1").arg(num, 0, 'f', doubleFormat.width);
|
||||
case RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC:
|
||||
return QString("%1").arg(num, 0, 'E');
|
||||
case RifEclipseOutputTableDoubleFormat::RIF_CONSISE:
|
||||
return QString("%1").arg(num, doubleFormat.width, 'g');
|
||||
default:
|
||||
return QString("%1");
|
||||
}
|
||||
@ -468,14 +488,18 @@ QString RifEclipseDataTableFormatter::format(size_t num)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RifEclipseDataTableFormatter::formatColumn(const QString str, RifEclipseOutputTableColumn column) const
|
||||
QString RifEclipseDataTableFormatter::formatColumn(const QString str, size_t columnIndex) const
|
||||
{
|
||||
const RifEclipseOutputTableColumn& column = m_columns[columnIndex];
|
||||
|
||||
if (column.alignment == LEFT)
|
||||
{
|
||||
return str.leftJustified(column.width + m_colSpacing, ' ');
|
||||
int colSpacing = (columnIndex == m_columns.size() - 1) ? 0 : m_colSpacing;
|
||||
return str.leftJustified(column.width + colSpacing, ' ');
|
||||
}
|
||||
else
|
||||
{
|
||||
return str.rightJustified(column.width + m_colSpacing, ' ');
|
||||
int colSpacing = (columnIndex == 0) ? 0 : m_colSpacing;
|
||||
return str.rightJustified(column.width + colSpacing, ' ');
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ enum RifEclipseOutputTableDoubleFormat
|
||||
{
|
||||
RIF_SCIENTIFIC,
|
||||
RIF_FLOAT,
|
||||
RIF_CONSISE
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
@ -110,6 +111,7 @@ public:
|
||||
|
||||
int columnSpacing() const;
|
||||
void setColumnSpacing(int spacing);
|
||||
QString tableRowPrependText() const;
|
||||
void setTableRowPrependText(const QString& text);
|
||||
void setTableRowLineAppendText(const QString& text);
|
||||
void setCommentPrefix(const QString& commentPrefix);
|
||||
@ -142,7 +144,7 @@ private:
|
||||
QString format(double num, RifEclipseOutputTableDoubleFormatting doubleFormat);
|
||||
QString format(int num);
|
||||
QString format(size_t num);
|
||||
QString formatColumn(const QString str, RifEclipseOutputTableColumn column) const;
|
||||
QString formatColumn(const QString str, size_t columnIndex) const;
|
||||
|
||||
void outputBuffer();
|
||||
void outputComment(RifEclipseOutputTableLine& comment);
|
||||
|
Loading…
Reference in New Issue
Block a user