[qet] [2886] Basic Shapes: DXF Export added.

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


Revision: 2886
Author:   abhishekm71
Date:     2014-02-28 09:20:00 +0100 (Fri, 28 Feb 2014)
Log Message:
-----------
Basic Shapes: DXF Export added.

Modified Paths:
--------------
    trunk/sources/exportdialog.cpp
    trunk/sources/qetgraphicsitem/qetshapeitem.cpp
    trunk/sources/qetgraphicsitem/qetshapeitem.h

Modified: trunk/sources/exportdialog.cpp
===================================================================
--- trunk/sources/exportdialog.cpp	2014-02-27 19:07:19 UTC (rev 2885)
+++ trunk/sources/exportdialog.cpp	2014-02-28 08:20:00 UTC (rev 2886)
@@ -33,6 +33,7 @@
 #include "qetgraphicsitem/ghostelement.h"
 #include "qetgraphicsitem/independenttextitem.h"
 #include "qetgraphicsitem/diagramimageitem.h"
+#include "qetgraphicsitem/qetshapeitem.h"
 #include "diagramfoliolist.h"
 
 /**
@@ -420,6 +421,7 @@
 	QList<DiagramImageItem *> list_images;
 	QList<QLineF *> list_lines;
 	QList<QRectF *> list_rectangles;
+	QList<QRectF *> list_ellipses;
 
 	DiagramFolioList *ptr;
 	if (ptr = dynamic_cast<DiagramFolioList *>(diagram)) {
@@ -479,6 +481,14 @@
 				list_texts << iti;
 			} else if (DiagramImageItem *dii = qgraphicsitem_cast<DiagramImageItem *>(qgi)) {
 				list_images << dii;
+			} else if (QetShapeItem *dii = qgraphicsitem_cast<QetShapeItem *>(qgi)) {
+				if (dii -> getType() == QetShapeItem::Line && dii -> getLine()) {
+					list_lines << dii -> getLine();
+				} else if (dii -> getType() == QetShapeItem::Rectangle && dii -> getRectangle()) {
+					list_rectangles << dii -> getRectangle();
+				} else if (dii -> getEllipse()){
+					 list_ellipses << dii -> getEllipse();
+				}
 			}
 		}
 	}
@@ -501,6 +511,17 @@
 		Createdxf::drawRectangle(file_path, x1, y1, w, h, 0);
 	}
 
+	//draw independent ellipses
+	foreach(QRectF *rect, list_ellipses) {
+		qreal x1 = (rect -> topLeft().x()) * Createdxf::xScale;
+		qreal y1 = Createdxf::sheetHeight - (rect -> topLeft().y()) * Createdxf::yScale;
+		qreal w = rect -> width() * Createdxf::xScale;
+		qreal h = rect -> height() * Createdxf::yScale;
+		qreal startAngle = 0;
+		qreal spanAngle = 360;
+		drawDxfArcEllipse(file_path, x1, y1, w, h, startAngle, spanAngle, 0, 0, 0);
+	}
+
 	//Draw elements
 	foreach(Element *elmt, list_elements) {
 
@@ -627,22 +648,6 @@
 			qreal startAngle = arc -> at(4);
 			qreal spanAngle = arc -> at(5);
 			drawDxfArcEllipse(file_path, x, y, w, h, startAngle, spanAngle, hotspot_x, hotspot_y, rotation_angle);
-			/*
-			// approximate this to center_x, center_y, radius, start angle and end angle.
-			qreal center_x = x + w/2;
-			qreal center_y = y - w/2;
-			qreal radius = (w+h)/4;
-			qreal endAngle = startAngle + spanAngle;
-			QPointF transformed_point = rotation_transformed(center_x, center_y, hotspot_x, hotspot_y, rotation_angle);
-			center_x = transformed_point.x();
-			center_y = transformed_point.y();
-			if (startAngle == 0 && spanAngle == 360)
-				Createdxf::drawCircle(file_path, radius, center_x, center_y, 0);
-			else {
-				endAngle += rotation_angle;
-				startAngle += rotation_angle;
-				Createdxf::drawArc(file_path, center_x, center_y, radius, endAngle, startAngle, 0);
-			}*/
 		}
 	}
 

Modified: trunk/sources/qetgraphicsitem/qetshapeitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/qetshapeitem.cpp	2014-02-27 19:07:19 UTC (rev 2885)
+++ trunk/sources/qetgraphicsitem/qetshapeitem.cpp	2014-02-28 08:20:00 UTC (rev 2886)
@@ -25,6 +25,37 @@
 	setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
 }
 
+QLineF *QetShapeItem::getLine()
+{
+	QRectF rect = boundingRect();
+	QLineF *line = 0;
+	if (_shapeType == Line) {
+		if (_lineAngle)
+			line = new QLineF(rect.topRight(), rect.bottomLeft());
+		else
+			line = new QLineF(rect.topLeft(), rect.bottomRight());
+	}
+	return line;
+}
+
+QRectF *QetShapeItem::getRectangle()
+{
+	QRectF rect = boundingRect();
+	QRectF *rec = 0;
+	if (_shapeType == Rectangle)
+		rec = new QRectF(rect);
+	return rec;
+}
+
+QRectF *QetShapeItem::getEllipse()
+{
+	QRectF rect = boundingRect();
+	QRectF *rec = 0;
+	if (_shapeType == Ellipse)
+		rec = new QRectF(rect);
+	return rec;
+}
+
 QRectF QetShapeItem::boundingRect() const
 {
 	return _boundingRect;

Modified: trunk/sources/qetgraphicsitem/qetshapeitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/qetshapeitem.h	2014-02-27 19:07:19 UTC (rev 2885)
+++ trunk/sources/qetgraphicsitem/qetshapeitem.h	2014-02-28 08:20:00 UTC (rev 2886)
@@ -17,11 +17,14 @@
 	virtual ~QetShapeItem();
 
 	void setStyle(Qt::PenStyle);
-	Qt::PenStyle getStyle() const	 { return _shapeStyle;	   }
-	ShapeType getType()		const	 { return _shapeType;	   }
-	void setBoundingRect(QRectF rec) { _boundingRect = rec;	   }
-	void setLineAngle(bool lineAngle){ _lineAngle = lineAngle; }
+	Qt::PenStyle getStyle() const		{ return _shapeStyle;	   }
+	ShapeType getType()		const		{ return _shapeType;	   }
+	void setBoundingRect(QRectF rec)	{ _boundingRect = rec;	   }
+	void setLineAngle(bool lineAngle)	{ _lineAngle = lineAngle;  }
 	void setFullyBuilt(bool isBuilt);
+	QLineF *getLine();
+	QRectF *getRectangle();
+	QRectF *getEllipse();
 
 	private:
 	ShapeType    _shapeType;
@@ -30,6 +33,8 @@
 	bool		 _lineAngle;  // false if line from topleft corner to bottomright corner
 							  // and true if line from topright corner to bottomleft corner
 	bool		 _isFullyBuilt;
+	QPointF		 _lineP1;
+	QPointF		 _lineP2;
 
 	virtual void editProperty() {}
 


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