mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-12 08:25:03 -05:00
#3975 Avoid wrapping header lines in eclipse output + well plan
This commit is contained in:
1 parent
b800510568
commit
4cd43d76d2
4 files changed
+40
-16
No files matched your search
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include "cvfAssert.h"
|
#include "cvfAssert.h"
|
||||||
|
|
||||||
|
#define MAX_ECLIPSE_DATA_ROW_WIDTH 132 // Maximum eclipse data row width
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -29,6 +31,7 @@ RifEclipseDataTableFormatter::RifEclipseDataTableFormatter(QTextStream& out)
|
|||||||
, m_tableRowPrependText(" ")
|
, m_tableRowPrependText(" ")
|
||||||
, m_tableRowAppendText(" /")
|
, m_tableRowAppendText(" /")
|
||||||
, m_commentPrefix("--")
|
, m_commentPrefix("--")
|
||||||
|
, m_maxDataRowWidth(MAX_ECLIPSE_DATA_ROW_WIDTH)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +120,30 @@ void RifEclipseDataTableFormatter::setCommentPrefix(const QString& commentPrefix
|
|||||||
m_commentPrefix = commentPrefix;
|
m_commentPrefix = commentPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RifEclipseDataTableFormatter::setUnlimitedDataRowWidth()
|
||||||
|
{
|
||||||
|
m_maxDataRowWidth = std::numeric_limits<int>::max();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RifEclipseDataTableFormatter::setMaxDataRowWidth(int maxWidth)
|
||||||
|
{
|
||||||
|
m_maxDataRowWidth = maxWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
int RifEclipseDataTableFormatter::maxDataRowWidth() const
|
||||||
|
{
|
||||||
|
return m_maxDataRowWidth;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -145,6 +172,7 @@ void RifEclipseDataTableFormatter::outputBuffer()
|
|||||||
else if (line.lineType == CONTENTS)
|
else if (line.lineType == CONTENTS)
|
||||||
{
|
{
|
||||||
QString lineText = m_tableRowPrependText;
|
QString lineText = m_tableRowPrependText;
|
||||||
|
bool isComment = m_tableRowPrependText.startsWith(m_commentPrefix);
|
||||||
QString appendText = (line.appendTextSet ? line.appendText : m_tableRowAppendText);
|
QString appendText = (line.appendTextSet ? line.appendText : m_tableRowAppendText);
|
||||||
|
|
||||||
for (size_t i = 0; i < line.data.size(); ++i)
|
for (size_t i = 0; i < line.data.size(); ++i)
|
||||||
@@ -155,7 +183,7 @@ void RifEclipseDataTableFormatter::outputBuffer()
|
|||||||
{
|
{
|
||||||
newLineText += appendText;
|
newLineText += appendText;
|
||||||
}
|
}
|
||||||
if (newLineText.length() > maxEclipseRowWidth())
|
if (!isComment && newLineText.length() > maxDataRowWidth())
|
||||||
{
|
{
|
||||||
m_out << lineText << "\n";
|
m_out << lineText << "\n";
|
||||||
lineText = m_tableRowPrependText;
|
lineText = m_tableRowPrependText;
|
||||||
@@ -483,14 +511,6 @@ int RifEclipseDataTableFormatter::tableWidth() const
|
|||||||
return characterCount;
|
return characterCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
int RifEclipseDataTableFormatter::maxEclipseRowWidth()
|
|
||||||
{
|
|
||||||
return 132;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -119,6 +119,9 @@ public:
|
|||||||
void setTableRowLineAppendText(const QString& text);
|
void setTableRowLineAppendText(const QString& text);
|
||||||
QString commentPrefix() const;
|
QString commentPrefix() const;
|
||||||
void setCommentPrefix(const QString& commentPrefix);
|
void setCommentPrefix(const QString& commentPrefix);
|
||||||
|
void setUnlimitedDataRowWidth();
|
||||||
|
void setMaxDataRowWidth(int maxWidth);
|
||||||
|
int maxDataRowWidth() const;
|
||||||
|
|
||||||
RifEclipseDataTableFormatter& keyword(const QString& keyword);
|
RifEclipseDataTableFormatter& keyword(const QString& keyword);
|
||||||
RifEclipseDataTableFormatter& header(std::vector<RifEclipseOutputTableColumn> tableHeader);
|
RifEclipseDataTableFormatter& header(std::vector<RifEclipseOutputTableColumn> tableHeader);
|
||||||
@@ -138,7 +141,6 @@ public:
|
|||||||
static void addValueTable(QTextStream& stream, const QString& keyword, size_t columns, const std::vector<double>& values);
|
static void addValueTable(QTextStream& stream, const QString& keyword, size_t columns, const std::vector<double>& values);
|
||||||
|
|
||||||
int tableWidth() const;
|
int tableWidth() const;
|
||||||
static int maxEclipseRowWidth();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int measure(const QString str);
|
int measure(const QString str);
|
||||||
@@ -166,4 +168,5 @@ private:
|
|||||||
QString m_tableRowPrependText;
|
QString m_tableRowPrependText;
|
||||||
QString m_tableRowAppendText;
|
QString m_tableRowAppendText;
|
||||||
QString m_commentPrefix;
|
QString m_commentPrefix;
|
||||||
|
int m_maxDataRowWidth;
|
||||||
};
|
};
|
||||||
@@ -127,6 +127,7 @@ QString RimModeledWellPath::wellPlanText()
|
|||||||
QTextStream qtxtStream(&planText);
|
QTextStream qtxtStream(&planText);
|
||||||
|
|
||||||
RifEclipseDataTableFormatter formatter(qtxtStream);
|
RifEclipseDataTableFormatter formatter(qtxtStream);
|
||||||
|
formatter.setUnlimitedDataRowWidth();
|
||||||
formatter.setTableRowPrependText("");
|
formatter.setTableRowPrependText("");
|
||||||
formatter.setTableRowLineAppendText("");
|
formatter.setTableRowLineAppendText("");
|
||||||
|
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ TEST(RifEclipseDataTableFormatter, LongLine)
|
|||||||
50 + 8 * 10 + formatter.tableRowAppendText().length();
|
50 + 8 * 10 + formatter.tableRowAppendText().length();
|
||||||
int tableWidth = formatter.tableWidth();
|
int tableWidth = formatter.tableWidth();
|
||||||
EXPECT_EQ(tableWidth, fullLineLength);
|
EXPECT_EQ(tableWidth, fullLineLength);
|
||||||
EXPECT_GT(tableWidth, RifEclipseDataTableFormatter::maxEclipseRowWidth());
|
EXPECT_GT(tableWidth, formatter.maxDataRowWidth());
|
||||||
|
|
||||||
formatter.rowCompleted();
|
formatter.rowCompleted();
|
||||||
formatter.tableCompleted();
|
formatter.tableCompleted();
|
||||||
@@ -117,7 +117,7 @@ TEST(RifEclipseDataTableFormatter, LongLine)
|
|||||||
std::cout << QString("Line: \"%1\"").arg(line).toStdString() << std::endl;
|
std::cout << QString("Line: \"%1\"").arg(line).toStdString() << std::endl;
|
||||||
if (!line.startsWith(formatter.commentPrefix()))
|
if (!line.startsWith(formatter.commentPrefix()))
|
||||||
{
|
{
|
||||||
EXPECT_LE(line.length(), RifEclipseDataTableFormatter::maxEclipseRowWidth());
|
EXPECT_LE(line.length(), formatter.maxDataRowWidth());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ TEST(RifEclipseDataTableFormatter, LongLine132)
|
|||||||
formatter.tableRowAppendText().length();
|
formatter.tableRowAppendText().length();
|
||||||
int tableWidth = formatter.tableWidth();
|
int tableWidth = formatter.tableWidth();
|
||||||
EXPECT_GE(tableWidth, fullLineLength);
|
EXPECT_GE(tableWidth, fullLineLength);
|
||||||
EXPECT_EQ(RifEclipseDataTableFormatter::maxEclipseRowWidth(), fullLineLength);
|
EXPECT_EQ(formatter.maxDataRowWidth(), fullLineLength);
|
||||||
|
|
||||||
formatter.rowCompleted();
|
formatter.rowCompleted();
|
||||||
formatter.tableCompleted();
|
formatter.tableCompleted();
|
||||||
@@ -164,7 +164,7 @@ TEST(RifEclipseDataTableFormatter, LongLine132)
|
|||||||
std::cout << QString("Line: \"%1\"").arg(line).toStdString() << std::endl;
|
std::cout << QString("Line: \"%1\"").arg(line).toStdString() << std::endl;
|
||||||
if (line.startsWith("0"))
|
if (line.startsWith("0"))
|
||||||
{
|
{
|
||||||
EXPECT_EQ(line.length(), RifEclipseDataTableFormatter::maxEclipseRowWidth());
|
EXPECT_EQ(line.length(), formatter.maxDataRowWidth());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,7 +200,7 @@ TEST(RifEclipseDataTableFormatter, LongLine133)
|
|||||||
formatter.tableRowAppendText().length();
|
formatter.tableRowAppendText().length();
|
||||||
int tableWidth = formatter.tableWidth();
|
int tableWidth = formatter.tableWidth();
|
||||||
EXPECT_GE(tableWidth, fullLineLength);
|
EXPECT_GE(tableWidth, fullLineLength);
|
||||||
EXPECT_LT(RifEclipseDataTableFormatter::maxEclipseRowWidth(), fullLineLength);
|
EXPECT_LT(formatter.maxDataRowWidth(), fullLineLength);
|
||||||
|
|
||||||
formatter.rowCompleted();
|
formatter.rowCompleted();
|
||||||
formatter.tableCompleted();
|
formatter.tableCompleted();
|
||||||
@@ -211,7 +211,7 @@ TEST(RifEclipseDataTableFormatter, LongLine133)
|
|||||||
std::cout << QString("Line: \"%1\"").arg(line).toStdString() << std::endl;
|
std::cout << QString("Line: \"%1\"").arg(line).toStdString() << std::endl;
|
||||||
if (line.startsWith("0"))
|
if (line.startsWith("0"))
|
||||||
{
|
{
|
||||||
EXPECT_LE(line.length(), RifEclipseDataTableFormatter::maxEclipseRowWidth());
|
EXPECT_LE(line.length(), formatter.maxDataRowWidth());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user