diff --git a/sources/createdxf.cpp b/sources/createdxf.cpp index f51d0e1a6..2a7ff2922 100644 --- a/sources/createdxf.cpp +++ b/sources/createdxf.cpp @@ -489,7 +489,7 @@ void Createdxf::drawText(QString fileName, QString text,double x, double y, doub /* draw aligned text in DXF Format */ void Createdxf::drawTextAligned(QString fileName, QString text,double x, double y, double height, double rotation, double oblique,int hAlign, int vAlign, double xAlign,int colour, - float scale) + bool leftAlign, float scale) { if (!fileName.isEmpty()) { QFile file(fileName); @@ -520,19 +520,21 @@ void Createdxf::drawTextAligned(QString fileName, QString text,double x, double To_Dxf << text << "\r\n"; // Text Value To_Dxf << 50 << "\r\n"; To_Dxf << rotation << "\r\n"; // Text Rotation + // If "Fit to width", then check if width of text < width specified then change it "center align or left align" + if (hAlign == 5) { + int xDiff = xAlign - x; + if (text.length() < xDiff/height && !leftAlign) { + hAlign = 1; + xAlign = (x+xAlign) / 2; + } else if (text.length() < xDiff/height && leftAlign) { + file.close(); + return; + } + } + To_Dxf << 51 << "\r\n"; To_Dxf << oblique << "\r\n"; // Text Obliqueness - To_Dxf << 72 << "\r\n"; - - // If "Fit to width", then check if width of text < width specified then change it "center align" - if (hAlign == 5) { - int xDiff = xAlign - x; - if (text.length() < xDiff/height) { - hAlign = 1; - xAlign = (x+xAlign) / 2; - } - } - + To_Dxf << 72 << "\r\n"; To_Dxf << hAlign << "\r\n"; // Text Horizontal Alignment To_Dxf << 73 << "\r\n"; To_Dxf << vAlign << "\r\n"; // Text Vertical Alignment diff --git a/sources/createdxf.h b/sources/createdxf.h index f2b91da2a..b9fd2a2b3 100644 --- a/sources/createdxf.h +++ b/sources/createdxf.h @@ -38,7 +38,7 @@ class Createdxf static void drawLine(QString,double,double,double,double,int); static void drawText(QString,QString,double,double,double,double,int); static void drawTextAligned(QString fileName, QString text,double x, double y, double height, double rotation, double oblique,int hAlign, int vAlign, double xAlign, int colour, - float scale = 0); + bool leftAlign = false, float scale = 0); static const double sheetWidth; static const double sheetHeight; diff --git a/sources/diagramfoliolist.cpp b/sources/diagramfoliolist.cpp index a77092339..911fe746d 100644 --- a/sources/diagramfoliolist.cpp +++ b/sources/diagramfoliolist.cpp @@ -147,7 +147,12 @@ void DiagramFolioList::fillRow(QPainter *qp, const QRectF &row_rect, QString aut else workingFont.setPointSizeF(origFontSize); qp -> setFont(workingFont); - qp -> drawText(QRectF(x+0.01*row_rect.width(), y, colWidths[1]*row_rect.width()*0.99, row_rect.height()), Qt::AlignLeft | Qt::AlignVCenter, title); + QString heading = tr("Titre"); + if (title == heading) + qp -> drawText(QRectF(x, y, colWidths[1]*row_rect.width(),row_rect.height()), Qt::AlignCenter, title); + else + qp -> drawText(QRectF(x+0.01*row_rect.width(), y, colWidths[1]*row_rect.width()*0.99, + row_rect.height()), Qt::AlignLeft | Qt::AlignVCenter, title); x += colWidths[1]*row_rect.width(); if (origFontMetrics.width(author) > 0.95*colWidths[2]*row_rect.width()) diff --git a/sources/exportdialog.cpp b/sources/exportdialog.cpp index d5b4e48ea..2b436390f 100644 --- a/sources/exportdialog.cpp +++ b/sources/exportdialog.cpp @@ -821,23 +821,33 @@ void ExportDialog::fillRow(QString file_path, const QRectF &row_rect, QString au x *= Createdxf::xScale; y = Createdxf::sheetHeight - y * Createdxf::yScale; - qreal height = row_rect.height() * Createdxf::yScale *0.75; + qreal height = row_rect.height() * Createdxf::yScale *0.7; y += height*0.2; - Createdxf::drawTextAligned(file_path, folio, x, y+height*0.1, height*0.8, 0, 0, 1, 0, - x + DiagramFolioList::colWidths[0]*row_rect.width()*Createdxf::xScale/2, 0); + Createdxf::drawTextAligned(file_path, folio, + x + 0.05*DiagramFolioList::colWidths[0]*row_rect.width()*Createdxf::xScale, y, height, 0, 0, 5, 0, + x + 0.95*DiagramFolioList::colWidths[0]*row_rect.width()*Createdxf::xScale, 0); + x += DiagramFolioList::colWidths[0]*row_rect.width()*Createdxf::xScale; + QString heading = tr("Titre"); + if (title == heading) + Createdxf::drawTextAligned(file_path, title, + x + 0.05*DiagramFolioList::colWidths[1]*row_rect.width()*Createdxf::xScale, y, height, 0, 0, 5, 0, + x + 0.95*DiagramFolioList::colWidths[1]*row_rect.width()*Createdxf::xScale, 0); + else + Createdxf::drawTextAligned(file_path, title, + x + 0.05*DiagramFolioList::colWidths[1]*row_rect.width()*Createdxf::xScale, y, height, 0, 0, 5, 0, + x + 0.95*DiagramFolioList::colWidths[1]*row_rect.width()*Createdxf::xScale, 0, true); - Createdxf::drawTextAligned(file_path, title, x, y+height*0.1, height*0.8, 0, 0, 1, 0, - x + DiagramFolioList::colWidths[1]*row_rect.width()*Createdxf::xScale/2, 0); x += DiagramFolioList::colWidths[1]*row_rect.width()*Createdxf::xScale; + Createdxf::drawTextAligned(file_path, author, + x + 0.05*DiagramFolioList::colWidths[2]*row_rect.width()*Createdxf::xScale, y, height, 0, 0, 5, 0, + x + 0.95*DiagramFolioList::colWidths[2]*row_rect.width()*Createdxf::xScale, 0); - Createdxf::drawTextAligned(file_path, author, x, y+height*0.1, height*0.8, 0, 0, 1, 0, - x + DiagramFolioList::colWidths[2]*row_rect.width()*Createdxf::xScale/2, 0); x += DiagramFolioList::colWidths[2]*row_rect.width()*Createdxf::xScale; - - Createdxf::drawTextAligned(file_path, date, x, y+height*0.1, height*0.8, 0, 0, 1, 0, - x + DiagramFolioList::colWidths[3]*row_rect.width()*Createdxf::xScale/2, 0); + Createdxf::drawTextAligned(file_path, date, + x + 0.05*DiagramFolioList::colWidths[3]*row_rect.width()*Createdxf::xScale, y, height, 0, 0, 5, 0, + x + 0.95*DiagramFolioList::colWidths[3]*row_rect.width()*Createdxf::xScale, 0); } QPointF ExportDialog::rotation_transformed(qreal px, qreal py , qreal origin_x, qreal origin_y, qreal angle) {