mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
Basic Shapes: DXF Export added.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2886 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
#include "qetgraphicsitem/ghostelement.h"
|
#include "qetgraphicsitem/ghostelement.h"
|
||||||
#include "qetgraphicsitem/independenttextitem.h"
|
#include "qetgraphicsitem/independenttextitem.h"
|
||||||
#include "qetgraphicsitem/diagramimageitem.h"
|
#include "qetgraphicsitem/diagramimageitem.h"
|
||||||
|
#include "qetgraphicsitem/qetshapeitem.h"
|
||||||
#include "diagramfoliolist.h"
|
#include "diagramfoliolist.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -420,6 +421,7 @@ void ExportDialog::generateDxf(Diagram *diagram, int width, int height, bool kee
|
|||||||
QList<DiagramImageItem *> list_images;
|
QList<DiagramImageItem *> list_images;
|
||||||
QList<QLineF *> list_lines;
|
QList<QLineF *> list_lines;
|
||||||
QList<QRectF *> list_rectangles;
|
QList<QRectF *> list_rectangles;
|
||||||
|
QList<QRectF *> list_ellipses;
|
||||||
|
|
||||||
DiagramFolioList *ptr;
|
DiagramFolioList *ptr;
|
||||||
if (ptr = dynamic_cast<DiagramFolioList *>(diagram)) {
|
if (ptr = dynamic_cast<DiagramFolioList *>(diagram)) {
|
||||||
@@ -479,6 +481,14 @@ void ExportDialog::generateDxf(Diagram *diagram, int width, int height, bool kee
|
|||||||
list_texts << iti;
|
list_texts << iti;
|
||||||
} else if (DiagramImageItem *dii = qgraphicsitem_cast<DiagramImageItem *>(qgi)) {
|
} else if (DiagramImageItem *dii = qgraphicsitem_cast<DiagramImageItem *>(qgi)) {
|
||||||
list_images << dii;
|
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 @@ void ExportDialog::generateDxf(Diagram *diagram, int width, int height, bool kee
|
|||||||
Createdxf::drawRectangle(file_path, x1, y1, w, h, 0);
|
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
|
//Draw elements
|
||||||
foreach(Element *elmt, list_elements) {
|
foreach(Element *elmt, list_elements) {
|
||||||
|
|
||||||
@@ -627,22 +648,6 @@ void ExportDialog::generateDxf(Diagram *diagram, int width, int height, bool kee
|
|||||||
qreal startAngle = arc -> at(4);
|
qreal startAngle = arc -> at(4);
|
||||||
qreal spanAngle = arc -> at(5);
|
qreal spanAngle = arc -> at(5);
|
||||||
drawDxfArcEllipse(file_path, x, y, w, h, startAngle, spanAngle, hotspot_x, hotspot_y, rotation_angle);
|
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);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,37 @@ void QetShapeItem::setFullyBuilt(bool isBuilt)
|
|||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
|
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
|
QRectF QetShapeItem::boundingRect() const
|
||||||
{
|
{
|
||||||
return _boundingRect;
|
return _boundingRect;
|
||||||
|
|||||||
@@ -20,8 +20,11 @@ class QetShapeItem : public QetGraphicsItem
|
|||||||
Qt::PenStyle getStyle() const { return _shapeStyle; }
|
Qt::PenStyle getStyle() const { return _shapeStyle; }
|
||||||
ShapeType getType() const { return _shapeType; }
|
ShapeType getType() const { return _shapeType; }
|
||||||
void setBoundingRect(QRectF rec) { _boundingRect = rec; }
|
void setBoundingRect(QRectF rec) { _boundingRect = rec; }
|
||||||
void setLineAngle(bool lineAngle){ _lineAngle = lineAngle; }
|
void setLineAngle(bool lineAngle) { _lineAngle = lineAngle; }
|
||||||
void setFullyBuilt(bool isBuilt);
|
void setFullyBuilt(bool isBuilt);
|
||||||
|
QLineF *getLine();
|
||||||
|
QRectF *getRectangle();
|
||||||
|
QRectF *getEllipse();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ShapeType _shapeType;
|
ShapeType _shapeType;
|
||||||
@@ -30,6 +33,8 @@ class QetShapeItem : public QetGraphicsItem
|
|||||||
bool _lineAngle; // false if line from topleft corner to bottomright corner
|
bool _lineAngle; // false if line from topleft corner to bottomright corner
|
||||||
// and true if line from topright corner to bottomleft corner
|
// and true if line from topright corner to bottomleft corner
|
||||||
bool _isFullyBuilt;
|
bool _isFullyBuilt;
|
||||||
|
QPointF _lineP1;
|
||||||
|
QPointF _lineP2;
|
||||||
|
|
||||||
virtual void editProperty() {}
|
virtual void editProperty() {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user