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
//#define TITLEBLOCK_TEMPLATE_DEBUG
#include <QRegularExpression>
#include <QRegularExpressionMatch>
/**
@brief TitleBlockTemplate::TitleBlockTemplate
Constructor
@ -1825,14 +1827,15 @@ void TitleBlockTemplate::renderTextCell(QPainter &painter,
@param h
@param color
*/
void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
const QString &text,
const TitleBlockCell &cell,
qreal x,
qreal y,
qreal w,
qreal h,
int color) const
void TitleBlockTemplate::renderTextCellDxf(
QString &file_path,
const QString &text,
const TitleBlockCell &cell,
qreal x,
qreal y,
qreal w,
qreal h,
int color) const
{
if (text.isEmpty()) return;
QFont text_font = TitleBlockTemplate::fontForCell(cell);
@ -1841,61 +1844,73 @@ void TitleBlockTemplate::renderTextCellDxf(QString &file_path,
textHeight = text_font.pixelSize();
qreal x2 = x + w;
qreal y1 = y;
qreal y1 = y;
int vAlign = 0;
int hAlign = 0;
x2 = x; // default
x2 = x; // default
if ( cell.alignment & Qt::AlignTop ) {
vAlign = 3;
y1 = y + h - (textHeight*Createdxf::yScale / 8);
} else if ( cell.alignment & Qt::AlignVCenter ) {
vAlign = 2;
y1 = y + h/2;
} else if ( cell.alignment & Qt::AlignBottom ) {
y1 = y + (textHeight*Createdxf::yScale / 8);
}
if ( cell.alignment & Qt::AlignTop )
{
vAlign = 3;
y1 = y + h - (textHeight*Createdxf::yScale / 8);
}
else if ( cell.alignment & Qt::AlignVCenter )
{
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;
x2 = x + w;
} else if ( cell.alignment & Qt::AlignHCenter ) {
x2 = x + w;
}
else if ( cell.alignment & Qt::AlignHCenter )
{
hAlign = 1;
x2 = x + w/2;
} else if (cell.alignment & Qt::AlignJustify ) {
}
else if (cell.alignment & Qt::AlignJustify )
{
hAlign = 5;
vAlign = 0;
x2 = x + w;
y1 = y + textHeight*Createdxf::yScale / 8;
vAlign = 0;
x2 = x + w;
y1 = y + textHeight*Createdxf::yScale / 8;
}
//painter.setFont(text_font);
qreal ratio = 1.0;
qreal ratio = 1.0;
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
int len = text.length() * textHeight * Createdxf::xScale * 1.2;
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
int len = text.length() * textHeight * Createdxf::xScale * 1.2;
if(len > w)
ratio = (w/len);
if(len > w)
ratio = (w/len);
}
// x offset value below currently set heuristically based on appearance...
Createdxf::drawTextAligned(file_path,
text,
x - 2*Createdxf::xScale,
y1,
textHeight*Createdxf::yScale,
0,
0,
hAlign,
vAlign,
x2,
ratio,
color);
// x offset value below currently set heuristically based on appearance...
Createdxf::drawTextAligned(
file_path,
text,
x - 2*Createdxf::xScale,
y1,
textHeight*Createdxf::yScale,
0,
0,
hAlign,
vAlign,
x2,
ratio,
color);
}
/**
@ -2019,7 +2034,8 @@ bool TitleBlockTemplate::checkCellSpan(TitleBlockCell *cell) {
@param 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 -> span_state == TitleBlockCell::Disabled) return;