DXF - Add terminals to plot (optional)

This commit is contained in:
David Varley 2020-09-10 18:35:22 +10:00
parent cd7f7eccec
commit 046d7c6b59
4 changed files with 26 additions and 0 deletions

View File

@ -438,6 +438,12 @@ int Createdxf::getcolorCode (const long red, const long green, const long blue)
}
return minndx;
}
int Createdxf::dxfColor(QColor color) {
return Createdxf::getcolorCode(color.red(), color.green(), color.blue());
}
int Createdxf::dxfColor(QPen pen) {
return Createdxf::dxfColor(pen.color());
}
/**
@brief Createdxf::drawLine

View File

@ -123,6 +123,8 @@ class Createdxf
const long green,
const long blue);
static long RGBcodeTable[];
static int dxfColor(QColor color);
static int dxfColor(QPen pen);
static const double sheetWidth;
static const double sheetHeight;

View File

@ -35,6 +35,7 @@
#include "elementpicturefactory.h"
#include "element.h"
#include "dynamicelementtextitem.h"
#include "terminal.h"
#include <QGraphicsSimpleTextItem>
@ -465,6 +466,7 @@ void ExportDialog::generateDxf(
//QList<QRectF *> list_ellipses;
QList <QetShapeItem *> list_shapes;
QList <QetGraphicsTableItem *> list_tables;
// QList <Terminal *> list_terminals;
// Determine les elements a "XMLiser"
foreach(QGraphicsItem *qgi, diagram -> items()) {
@ -485,6 +487,7 @@ void ExportDialog::generateDxf(
}
}
// Draw shapes
foreach (QetShapeItem *qsi, list_shapes) qsi->toDXF(file_path, qsi->pen());
// Draw tables
@ -619,6 +622,19 @@ void ExportDialog::generateDxf(
qreal spanAngle = arc .at(5);
Createdxf::drawArcEllipse(file_path, x, y, w, h, startAngle, spanAngle, hotspot_x, hotspot_y, rotation_angle, 0);
}
if (epw -> exportProperties().draw_terminals) {
// Draw terminals
QList<Terminal *> list_terminals = elmt->terminals();
QColor col("red");
foreach(Terminal *tp, list_terminals) {
qreal x = (elem_pos_x + tp->dock_elmt_.x()) * Createdxf::xScale;
qreal y = Createdxf::sheetHeight - (elem_pos_y + tp->dock_elmt_.y()) * Createdxf::yScale;
QPointF transformed_point = rotation_transformed(x, y, hotspot_x, hotspot_y, rotation_angle);
x = transformed_point.x();
y = transformed_point.y();
Createdxf::drawCircle(file_path, 3.0* Createdxf::xScale, x, y, Createdxf::dxfColor(col));
}
}
}
//Draw conductors

View File

@ -127,8 +127,10 @@ class Terminal : public QGraphicsObject
/// Parent electrical element
Element *parent_element_{nullptr};
public:
/// docking point for parent element
QPointF dock_elmt_;
private:
/// List of conductors attached to the terminal
QList<Conductor *> conductors_;
/**