[qet] [2842] Folio List: DXF Export long text corrected and

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 2842
Author:   abhishekm71
Date:     2014-02-09 18:47:18 +0100 (Sun, 09 Feb 2014)
Log Message:
-----------
Folio List: DXF Export long text corrected and 
Alignment changed for Title: Center aligned for heading 
and left aligned for entries

Modified Paths:
--------------
    trunk/sources/createdxf.cpp
    trunk/sources/createdxf.h
    trunk/sources/diagramfoliolist.cpp
    trunk/sources/exportdialog.cpp

Modified: trunk/sources/createdxf.cpp
===================================================================
--- trunk/sources/createdxf.cpp	2014-02-09 16:51:45 UTC (rev 2841)
+++ trunk/sources/createdxf.cpp	2014-02-09 17:47:18 UTC (rev 2842)
@@ -489,7 +489,7 @@
 
 /* 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 @@
             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

Modified: trunk/sources/createdxf.h
===================================================================
--- trunk/sources/createdxf.h	2014-02-09 16:51:45 UTC (rev 2841)
+++ trunk/sources/createdxf.h	2014-02-09 17:47:18 UTC (rev 2842)
@@ -38,7 +38,7 @@
 	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;

Modified: trunk/sources/diagramfoliolist.cpp
===================================================================
--- trunk/sources/diagramfoliolist.cpp	2014-02-09 16:51:45 UTC (rev 2841)
+++ trunk/sources/diagramfoliolist.cpp	2014-02-09 17:47:18 UTC (rev 2842)
@@ -147,7 +147,12 @@
 	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())

Modified: trunk/sources/exportdialog.cpp
===================================================================
--- trunk/sources/exportdialog.cpp	2014-02-09 16:51:45 UTC (rev 2841)
+++ trunk/sources/exportdialog.cpp	2014-02-09 17:47:18 UTC (rev 2842)
@@ -821,23 +821,33 @@
 
 	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) {


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/