mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-04-25 14:09:59 +02:00
DXF Export: Added some parts of elements:
1. lines 2. rectangles 3. circles 4. polygons Coordinate accuracy to be checked. More element parts to be added. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2732 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -73,7 +73,13 @@ CustomElement::CustomElement(const ElementsLocation &location, QGraphicsItem *qg
|
||||
elmt_state = 3;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//Start from empty lists.
|
||||
list_lines_.clear();
|
||||
list_rectangles_.clear();
|
||||
list_circles_.clear();
|
||||
list_polygons_.clear();
|
||||
|
||||
buildFromXml(element_definition -> xml(), &elmt_state);
|
||||
if (state) *state = elmt_state;
|
||||
if (elmt_state) return;
|
||||
@@ -219,6 +225,26 @@ QList<ElementTextItem *> CustomElement::texts() const {
|
||||
return(list_texts_);
|
||||
}
|
||||
|
||||
/// @return the list of lines
|
||||
QList<QLineF *> CustomElement::lines() const {
|
||||
return(list_lines_);
|
||||
}
|
||||
|
||||
/// @return the list of rectangles
|
||||
QList<QRectF *> CustomElement::rectangles() const {
|
||||
return(list_rectangles_);
|
||||
}
|
||||
|
||||
/// @return the list of bounding rectangles for circles
|
||||
QList<QRectF *> CustomElement::circles() const {
|
||||
return(list_circles_);
|
||||
}
|
||||
|
||||
/// @return the list of bounding rectangles for circles
|
||||
QList<QVector<QPointF> *> CustomElement::polygons() const {
|
||||
return(list_polygons_);
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le nombre de bornes que l'element possede
|
||||
*/
|
||||
@@ -296,6 +322,11 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
|
||||
qp.setPen(t);
|
||||
|
||||
QLineF line(x1, y1, x2, y2);
|
||||
|
||||
//Add line to the list
|
||||
QLineF *newLine = new QLineF(line);
|
||||
list_lines_ << newLine;
|
||||
|
||||
QPointF point1(line.p1());
|
||||
QPointF point2(line.p2());
|
||||
|
||||
@@ -391,6 +422,11 @@ bool CustomElement::parseRect(QDomElement &e, QPainter &qp) {
|
||||
if (!QET::attributeIsAReal(e, QString("y"), &rect_y)) return(false);
|
||||
if (!QET::attributeIsAReal(e, QString("width"), &rect_w)) return(false);
|
||||
if (!QET::attributeIsAReal(e, QString("height"), &rect_h)) return(false);
|
||||
|
||||
//Add rectangle to the list
|
||||
QRectF *rect = new QRectF(rect_x, rect_y, rect_w, rect_h);
|
||||
list_rectangles_ << rect;
|
||||
|
||||
qp.save();
|
||||
setPainterStyle(e, qp);
|
||||
|
||||
@@ -424,7 +460,13 @@ bool CustomElement::parseCircle(QDomElement &e, QPainter &qp) {
|
||||
if (!QET::attributeIsAReal(e, QString("diameter"), &cercle_r)) return(false);
|
||||
qp.save();
|
||||
setPainterStyle(e, qp);
|
||||
qp.drawEllipse(QRectF(cercle_x, cercle_y, cercle_r, cercle_r));
|
||||
QRectF circle_bounding_rect(cercle_x, cercle_y, cercle_r, cercle_r);
|
||||
|
||||
// Add circle to list
|
||||
QRectF *circle = new QRectF(circle_bounding_rect);
|
||||
list_circles_ << circle;
|
||||
|
||||
qp.drawEllipse(circle_bounding_rect);
|
||||
qp.restore();
|
||||
return(true);
|
||||
}
|
||||
@@ -515,10 +557,25 @@ bool CustomElement::parsePolygon(QDomElement &e, QPainter &qp) {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
qp.save();
|
||||
setPainterStyle(e, qp);
|
||||
if (e.attribute("closed") == "false") qp.drawPolyline(points.data(), i-1);
|
||||
else qp.drawPolygon(points.data(), i-1);
|
||||
else {
|
||||
qp.drawPolygon(points.data(), i-1);
|
||||
// insert first point at the end again for DXF export.
|
||||
points.push_back(
|
||||
QPointF(
|
||||
e.attribute(QString("x%1").arg(1)).toDouble(),
|
||||
e.attribute(QString("y%1").arg(1)).toDouble()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Add to list of polygons.
|
||||
QVector<QPointF> *poly = new QVector<QPointF>(points);
|
||||
list_polygons_ << poly;
|
||||
|
||||
qp.restore();
|
||||
return(true);
|
||||
}
|
||||
|
||||
@@ -50,12 +50,21 @@ class CustomElement : public FixedElement {
|
||||
QList<Terminal *> list_terminals;
|
||||
QList<ElementTextItem *> list_texts_;
|
||||
bool forbid_antialiasing;
|
||||
|
||||
QList<QLineF *> list_lines_;
|
||||
QList<QRectF *> list_rectangles_;
|
||||
QList<QRectF *> list_circles_;
|
||||
QList<QVector<QPointF> *> list_polygons_;
|
||||
|
||||
// methods
|
||||
public:
|
||||
virtual QList<Terminal *> terminals() const;
|
||||
virtual QList<Conductor *> conductors() const;
|
||||
virtual QList<ElementTextItem *> texts() const;
|
||||
virtual QList<QLineF *> lines() const;
|
||||
virtual QList<QRectF *> rectangles() const;
|
||||
virtual QList<QRectF *> circles() const;
|
||||
virtual QList<QVector<QPointF> *> polygons() const;
|
||||
virtual int terminalsCount() const;
|
||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *);
|
||||
QString typeId() const;
|
||||
|
||||
@@ -81,6 +81,14 @@ class Element : public QetGraphicsItem {
|
||||
virtual QList<Conductor *> conductors() const = 0;
|
||||
/// @return the list of text items attached to this element
|
||||
virtual QList<ElementTextItem *> texts() const = 0;
|
||||
/// @return the list of lines items in this element
|
||||
virtual QList<QLineF *> lines() const = 0;
|
||||
/// @return the list of rectangles items in this element
|
||||
virtual QList<QRectF *> rectangles() const = 0;
|
||||
/// @return the list of bounding rectangles for circles items in this element
|
||||
virtual QList<QRectF *> circles() const = 0;
|
||||
/// @return the list of polygons in this element
|
||||
virtual QList<QVector<QPointF> *> polygons() const = 0;
|
||||
/// @return the current number of terminals of this element
|
||||
virtual int terminalsCount() const = 0;
|
||||
/// @return the minimum number of terminals for this element
|
||||
|
||||
Reference in New Issue
Block a user