Fix code style

This commit is contained in:
Simon De Backer 2020-09-18 23:05:57 +02:00
parent 176dcd376b
commit b7c8ae88e2

View File

@ -23,6 +23,8 @@
// uncomment the line below to get more debug information // uncomment the line below to get more debug information
//#define TITLEBLOCK_TEMPLATE_DEBUG //#define TITLEBLOCK_TEMPLATE_DEBUG
#include <QRegularExpression>
#include <QRegularExpressionMatch>
/** /**
@brief TitleBlockTemplate::TitleBlockTemplate @brief TitleBlockTemplate::TitleBlockTemplate
Constructor Constructor
@ -1825,14 +1827,15 @@ void TitleBlockTemplate::renderTextCell(QPainter &painter,
@param h @param h
@param color @param color
*/ */
void TitleBlockTemplate::renderTextCellDxf(QString &file_path, void TitleBlockTemplate::renderTextCellDxf(
const QString &text, QString &file_path,
const TitleBlockCell &cell, const QString &text,
qreal x, const TitleBlockCell &cell,
qreal y, qreal x,
qreal w, qreal y,
qreal h, qreal w,
int color) const qreal h,
int color) const
{ {
if (text.isEmpty()) return; if (text.isEmpty()) return;
QFont text_font = TitleBlockTemplate::fontForCell(cell); QFont text_font = TitleBlockTemplate::fontForCell(cell);
@ -1841,61 +1844,73 @@ void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
textHeight = text_font.pixelSize(); textHeight = text_font.pixelSize();
qreal x2 = x + w; qreal x2 = x + w;
qreal y1 = y; qreal y1 = y;
int vAlign = 0; int vAlign = 0;
int hAlign = 0; int hAlign = 0;
x2 = x; // default x2 = x; // default
if ( cell.alignment & Qt::AlignTop ) { if ( cell.alignment & Qt::AlignTop )
vAlign = 3; {
y1 = y + h - (textHeight*Createdxf::yScale / 8); vAlign = 3;
} else if ( cell.alignment & Qt::AlignVCenter ) { y1 = y + h - (textHeight*Createdxf::yScale / 8);
vAlign = 2; }
y1 = y + h/2; else if ( cell.alignment & Qt::AlignVCenter )
} else if ( cell.alignment & Qt::AlignBottom ) { {
y1 = y + (textHeight*Createdxf::yScale / 8); vAlign = 2;
} y1 = y + h/2;
}
else if ( cell.alignment & Qt::AlignBottom )
{
y1 = y + (textHeight*Createdxf::yScale / 8);
}
if ( cell.alignment & Qt::AlignRight ) { if ( cell.alignment & Qt::AlignRight )
{
hAlign = 2; hAlign = 2;
x2 = x + w; x2 = x + w;
} else if ( cell.alignment & Qt::AlignHCenter ) { }
else if ( cell.alignment & Qt::AlignHCenter )
{
hAlign = 1; hAlign = 1;
x2 = x + w/2; x2 = x + w/2;
} else if (cell.alignment & Qt::AlignJustify ) { }
else if (cell.alignment & Qt::AlignJustify )
{
hAlign = 5; hAlign = 5;
vAlign = 0; vAlign = 0;
x2 = x + w; x2 = x + w;
y1 = y + textHeight*Createdxf::yScale / 8; y1 = y + textHeight*Createdxf::yScale / 8;
} }
//painter.setFont(text_font); //painter.setFont(text_font);
qreal ratio = 1.0; qreal ratio = 1.0;
if (cell.hadjust) { if (cell.hadjust)
// Scale font width to fit string in cell width w {
// As DXF font aspect ratio is implementation dependent we add a fudge-factor based on tests with AutoCAD // Scale font width to fit string in cell width w
int len = text.length() * textHeight * Createdxf::xScale * 1.2; // As DXF font aspect ratio is implementation dependent we add a fudge-factor based on tests with AutoCAD
int len = text.length() * textHeight * Createdxf::xScale * 1.2;
if(len > w) if(len > w)
ratio = (w/len); ratio = (w/len);
} }
// x offset value below currently set heuristically based on appearance... // x offset value below currently set heuristically based on appearance...
Createdxf::drawTextAligned(file_path, Createdxf::drawTextAligned(
text, file_path,
x - 2*Createdxf::xScale, text,
y1, x - 2*Createdxf::xScale,
textHeight*Createdxf::yScale, y1,
0, textHeight*Createdxf::yScale,
0, 0,
hAlign, 0,
vAlign, hAlign,
x2, vAlign,
ratio, x2,
color); ratio,
color);
} }
/** /**
@ -2019,7 +2034,8 @@ bool TitleBlockTemplate::checkCellSpan(TitleBlockCell *cell) {
@param cell : @param cell :
Potentially spanning cell Potentially spanning cell
*/ */
void TitleBlockTemplate::applyCellSpan(TitleBlockCell *cell) { void TitleBlockTemplate::applyCellSpan(TitleBlockCell *cell)
{
if (!cell || (!cell -> row_span && !cell -> col_span)) return; if (!cell || (!cell -> row_span && !cell -> col_span)) return;
if (cell -> span_state == TitleBlockCell::Disabled) return; if (cell -> span_state == TitleBlockCell::Disabled) return;