Folio List: DXF Export long text corrected and

Alignment changed for Title: Center aligned for heading 
and left aligned for entries


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2842 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
abhishekm71
2014-02-09 17:47:18 +00:00
parent a43d3ae67e
commit 23970c9473
4 changed files with 41 additions and 24 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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())

View File

@@ -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) {