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
|
else
|
||||||
{
|
{
|
||||||
QString fileName =
|
QString fileName =
|
||||||
QString("%1_Perforations_MSW_%2")
|
QString("%1_Perforation_MSW_%2")
|
||||||
.arg(wellPath->completions()->wellNameForExport(), exportSettings.caseToApply->caseUserDescription());
|
.arg(wellPath->completions()->wellNameForExport(), exportSettings.caseToApply->caseUserDescription());
|
||||||
perforationsExportFile = RicWellPathExportCompletionsFileTools::openFileForExport(exportSettings.folder, fileName);
|
perforationsExportFile = RicWellPathExportCompletionsFileTools::openFileForExport(exportSettings.folder, fileName);
|
||||||
}
|
}
|
||||||
@ -679,6 +679,9 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable(RifEclipseDataTa
|
|||||||
{
|
{
|
||||||
int existingColSpacing = formatter.columnSpacing();
|
int existingColSpacing = formatter.columnSpacing();
|
||||||
formatter.setColumnSpacing(1);
|
formatter.setColumnSpacing(1);
|
||||||
|
QString existingPrependText = formatter.tableRowPrependText();
|
||||||
|
formatter.setTableRowPrependText("");
|
||||||
|
|
||||||
bool foundValve = false;
|
bool foundValve = false;
|
||||||
|
|
||||||
for (std::shared_ptr<RicMswSegment> location : exportInfo.wellSegmentLocations())
|
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]));
|
formatter.comment(QString("%1: %2").arg(i + 1, 2, 10, QChar('0')).arg(columnDescriptions[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<RifEclipseOutputTableColumn> header = {
|
std::vector<RifEclipseOutputTableColumn> header;
|
||||||
RifEclipseOutputTableColumn("01"),
|
for (size_t i = 1; i <= 21; ++i)
|
||||||
RifEclipseOutputTableColumn("02"),
|
{
|
||||||
RifEclipseOutputTableColumn("03"),
|
QString cName = QString("%1").arg(i, 2, 10, QChar('0'));
|
||||||
RifEclipseOutputTableColumn("04"),
|
RifEclipseOutputTableColumn col(cName,
|
||||||
RifEclipseOutputTableColumn("05"),
|
RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_CONSISE), RIGHT);
|
||||||
RifEclipseOutputTableColumn("06"),
|
header.push_back(col);
|
||||||
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"),
|
|
||||||
};
|
|
||||||
formatter.header(header);
|
formatter.header(header);
|
||||||
|
|
||||||
foundValve = true;
|
foundValve = true;
|
||||||
@ -783,6 +771,7 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable(RifEclipseDataTa
|
|||||||
formatter.tableCompleted();
|
formatter.tableCompleted();
|
||||||
}
|
}
|
||||||
formatter.setColumnSpacing(existingColSpacing);
|
formatter.setColumnSpacing(existingColSpacing);
|
||||||
|
formatter.setTableRowPrependText(existingPrependText);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -57,6 +57,14 @@ void RifEclipseDataTableFormatter::setColumnSpacing(int spacing)
|
|||||||
m_colSpacing = 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))
|
if (!m_columns.empty() && !isAllHeadersEmpty(m_columns))
|
||||||
{
|
{
|
||||||
m_out << m_commentPrefix << " ";
|
for (size_t i = 0u; i < m_columns.size(); ++i)
|
||||||
for (RifEclipseOutputTableColumn& column : m_columns)
|
|
||||||
{
|
{
|
||||||
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";
|
m_out << "\n";
|
||||||
}
|
}
|
||||||
@ -112,7 +124,7 @@ void RifEclipseDataTableFormatter::outputBuffer()
|
|||||||
|
|
||||||
for (size_t i = 0; i < line.data.size(); ++i)
|
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";
|
m_out << (line.appendTextSet ? line.appendText : m_tableRowAppendText) << "\n";
|
||||||
@ -234,9 +246,15 @@ RifEclipseDataTableFormatter& RifEclipseDataTableFormatter::header(const std::ve
|
|||||||
{
|
{
|
||||||
outputBuffer();
|
outputBuffer();
|
||||||
m_columns = header;
|
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;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -425,9 +443,9 @@ int RifEclipseDataTableFormatter::tableWidth() const
|
|||||||
{
|
{
|
||||||
int characterCount = 0;
|
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;
|
return characterCount;
|
||||||
@ -444,6 +462,8 @@ QString RifEclipseDataTableFormatter::format(double num, RifEclipseOutputTableDo
|
|||||||
return QString("%1").arg(num, 0, 'f', doubleFormat.width);
|
return QString("%1").arg(num, 0, 'f', doubleFormat.width);
|
||||||
case RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC:
|
case RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC:
|
||||||
return QString("%1").arg(num, 0, 'E');
|
return QString("%1").arg(num, 0, 'E');
|
||||||
|
case RifEclipseOutputTableDoubleFormat::RIF_CONSISE:
|
||||||
|
return QString("%1").arg(num, doubleFormat.width, 'g');
|
||||||
default:
|
default:
|
||||||
return QString("%1");
|
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)
|
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
|
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_SCIENTIFIC,
|
||||||
RIF_FLOAT,
|
RIF_FLOAT,
|
||||||
|
RIF_CONSISE
|
||||||
};
|
};
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
@ -110,6 +111,7 @@ public:
|
|||||||
|
|
||||||
int columnSpacing() const;
|
int columnSpacing() const;
|
||||||
void setColumnSpacing(int spacing);
|
void setColumnSpacing(int spacing);
|
||||||
|
QString tableRowPrependText() const;
|
||||||
void setTableRowPrependText(const QString& text);
|
void setTableRowPrependText(const QString& text);
|
||||||
void setTableRowLineAppendText(const QString& text);
|
void setTableRowLineAppendText(const QString& text);
|
||||||
void setCommentPrefix(const QString& commentPrefix);
|
void setCommentPrefix(const QString& commentPrefix);
|
||||||
@ -142,7 +144,7 @@ private:
|
|||||||
QString format(double num, RifEclipseOutputTableDoubleFormatting doubleFormat);
|
QString format(double num, RifEclipseOutputTableDoubleFormatting doubleFormat);
|
||||||
QString format(int num);
|
QString format(int num);
|
||||||
QString format(size_t 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 outputBuffer();
|
||||||
void outputComment(RifEclipseOutputTableLine& comment);
|
void outputComment(RifEclipseOutputTableLine& comment);
|
||||||
|
Loading…
Reference in New Issue
Block a user