mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-25 00:39:58 +01:00
Element editor : replace home made property by Q_PROPERTY for all primitive,
Add combo box for input to set the tagg (nothing or label, actually) Remove terminal text because unused. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3088 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -162,7 +162,7 @@ void Conductor::segmentsToPath() {
|
||||
@param p2 Coordonnees du point d'amarrage de la borne 2
|
||||
@param o2 Orientation de la borne 2
|
||||
*/
|
||||
void Conductor::updateConductorPath(const QPointF &p1, QET::Orientation o1, const QPointF &p2, QET::Orientation o2) {
|
||||
void Conductor::updateConductorPath(const QPointF &p1, Qet::Orientation o1, const QPointF &p2, Qet::Orientation o2) {
|
||||
Q_UNUSED(o1);
|
||||
Q_UNUSED(o2);
|
||||
|
||||
@@ -290,9 +290,9 @@ QHash<ConductorSegmentProfile *, qreal> Conductor::shareOffsetBetweenSegments(
|
||||
@param p2 Coordonnees du point d'amarrage de la borne 2
|
||||
@param o2 Orientation de la borne 2
|
||||
*/
|
||||
void Conductor::generateConductorPath(const QPointF &p1, QET::Orientation o1, const QPointF &p2, QET::Orientation o2) {
|
||||
void Conductor::generateConductorPath(const QPointF &p1, Qet::Orientation o1, const QPointF &p2, Qet::Orientation o2) {
|
||||
QPointF sp1, sp2, depart, newp1, newp2, arrivee, depart0, arrivee0;
|
||||
QET::Orientation ori_depart, ori_arrivee;
|
||||
Qet::Orientation ori_depart, ori_arrivee;
|
||||
|
||||
// s'assure qu'il n'y a ni points
|
||||
QList<QPointF> points;
|
||||
@@ -331,38 +331,38 @@ void Conductor::generateConductorPath(const QPointF &p1, QET::Orientation o1, co
|
||||
// commence le vrai trajet
|
||||
if (depart.y() < arrivee.y()) {
|
||||
// trajet descendant
|
||||
if ((ori_depart == QET::North && (ori_arrivee == QET::South || ori_arrivee == QET::West)) || (ori_depart == QET::East && ori_arrivee == QET::West)) {
|
||||
if ((ori_depart == Qet::North && (ori_arrivee == Qet::South || ori_arrivee == Qet::West)) || (ori_depart == Qet::East && ori_arrivee == Qet::West)) {
|
||||
// cas "3"
|
||||
int ligne_inter_x = qRound(depart.x() + arrivee.x()) / 2;
|
||||
while (ligne_inter_x % Diagram::xGrid) -- ligne_inter_x;
|
||||
points << QPointF(ligne_inter_x, depart.y());
|
||||
points << QPointF(ligne_inter_x, arrivee.y());
|
||||
} else if ((ori_depart == QET::South && (ori_arrivee == QET::North || ori_arrivee == QET::East)) || (ori_depart == QET::West && ori_arrivee == QET::East)) {
|
||||
} else if ((ori_depart == Qet::South && (ori_arrivee == Qet::North || ori_arrivee == Qet::East)) || (ori_depart == Qet::West && ori_arrivee == Qet::East)) {
|
||||
// cas "4"
|
||||
int ligne_inter_y = qRound(depart.y() + arrivee.y()) / 2;
|
||||
while (ligne_inter_y % Diagram::yGrid) -- ligne_inter_y;
|
||||
points << QPointF(depart.x(), ligne_inter_y);
|
||||
points << QPointF(arrivee.x(), ligne_inter_y);
|
||||
} else if ((ori_depart == QET::North || ori_depart == QET::East) && (ori_arrivee == QET::North || ori_arrivee == QET::East)) {
|
||||
} else if ((ori_depart == Qet::North || ori_depart == Qet::East) && (ori_arrivee == Qet::North || ori_arrivee == Qet::East)) {
|
||||
points << QPointF(arrivee.x(), depart.y()); // cas "2"
|
||||
} else {
|
||||
points << QPointF(depart.x(), arrivee.y()); // cas "1"
|
||||
}
|
||||
} else {
|
||||
// trajet montant
|
||||
if ((ori_depart == QET::West && (ori_arrivee == QET::East || ori_arrivee == QET::South)) || (ori_depart == QET::North && ori_arrivee == QET::South)) {
|
||||
if ((ori_depart == Qet::West && (ori_arrivee == Qet::East || ori_arrivee == Qet::South)) || (ori_depart == Qet::North && ori_arrivee == Qet::South)) {
|
||||
// cas "3"
|
||||
int ligne_inter_y = qRound(depart.y() + arrivee.y()) / 2;
|
||||
while (ligne_inter_y % Diagram::yGrid) -- ligne_inter_y;
|
||||
points << QPointF(depart.x(), ligne_inter_y);
|
||||
points << QPointF(arrivee.x(), ligne_inter_y);
|
||||
} else if ((ori_depart == QET::East && (ori_arrivee == QET::West || ori_arrivee == QET::North)) || (ori_depart == QET::South && ori_arrivee == QET::North)) {
|
||||
} else if ((ori_depart == Qet::East && (ori_arrivee == Qet::West || ori_arrivee == Qet::North)) || (ori_depart == Qet::South && ori_arrivee == Qet::North)) {
|
||||
// cas "4"
|
||||
int ligne_inter_x = qRound(depart.x() + arrivee.x()) / 2;
|
||||
while (ligne_inter_x % Diagram::xGrid) -- ligne_inter_x;
|
||||
points << QPointF(ligne_inter_x, depart.y());
|
||||
points << QPointF(ligne_inter_x, arrivee.y());
|
||||
} else if ((ori_depart == QET::West || ori_depart == QET::North) && (ori_arrivee == QET::West || ori_arrivee == QET::North)) {
|
||||
} else if ((ori_depart == Qet::West || ori_depart == Qet::North) && (ori_arrivee == Qet::West || ori_arrivee == Qet::North)) {
|
||||
points << QPointF(depart.x(), arrivee.y()); // cas "2"
|
||||
} else {
|
||||
points << QPointF(arrivee.x(), depart.y()); // cas "1"
|
||||
@@ -393,19 +393,19 @@ void Conductor::generateConductorPath(const QPointF &p1, QET::Orientation o1, co
|
||||
@param ext_size la taille de la prolongation
|
||||
@return le point correspondant a la borne apres prolongation
|
||||
*/
|
||||
QPointF Conductor::extendTerminal(const QPointF &terminal, QET::Orientation terminal_orientation, qreal ext_size) {
|
||||
QPointF Conductor::extendTerminal(const QPointF &terminal, Qet::Orientation terminal_orientation, qreal ext_size) {
|
||||
QPointF extended_terminal;
|
||||
switch(terminal_orientation) {
|
||||
case QET::North:
|
||||
case Qet::North:
|
||||
extended_terminal = QPointF(terminal.x(), terminal.y() - ext_size);
|
||||
break;
|
||||
case QET::East:
|
||||
case Qet::East:
|
||||
extended_terminal = QPointF(terminal.x() + ext_size, terminal.y());
|
||||
break;
|
||||
case QET::South:
|
||||
case Qet::South:
|
||||
extended_terminal = QPointF(terminal.x(), terminal.y() + ext_size);
|
||||
break;
|
||||
case QET::West:
|
||||
case Qet::West:
|
||||
extended_terminal = QPointF(terminal.x() - ext_size, terminal.y());
|
||||
break;
|
||||
default: extended_terminal = terminal;
|
||||
|
||||
@@ -146,8 +146,8 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
||||
private:
|
||||
void segmentsToPath();
|
||||
void saveProfile(bool = true);
|
||||
void generateConductorPath(const QPointF &, QET::Orientation, const QPointF &, QET::Orientation);
|
||||
void updateConductorPath(const QPointF &, QET::Orientation, const QPointF &, QET::Orientation);
|
||||
void generateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
|
||||
void updateConductorPath(const QPointF &, Qet::Orientation, const QPointF &, Qet::Orientation);
|
||||
uint segmentsCount(QET::ConductorSegmentType = QET::Both) const;
|
||||
QList<QPointF> segmentsToPoints() const;
|
||||
QSet<Conductor *> relatedConductors() const;
|
||||
@@ -161,7 +161,7 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
||||
static int getCoeff(const qreal &, const qreal &);
|
||||
static int getSign(const qreal &);
|
||||
QHash<ConductorSegmentProfile *, qreal> shareOffsetBetweenSegments(const qreal &offset, const QList<ConductorSegmentProfile *> &, const qreal & = 0.01) const;
|
||||
static QPointF extendTerminal(const QPointF &, QET::Orientation, qreal = 9.0);
|
||||
static QPointF extendTerminal(const QPointF &, Qet::Orientation, qreal = 9.0);
|
||||
static qreal conductor_bound(qreal, qreal, qreal, qreal = 0.0);
|
||||
static qreal conductor_bound(qreal, qreal, bool);
|
||||
static Qt::Corner movementType(const QPointF &, const QPointF &);
|
||||
|
||||
@@ -323,8 +323,8 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
|
||||
if (!QET::attributeIsAReal(e, QString("x2"), &x2)) return(false);
|
||||
if (!QET::attributeIsAReal(e, QString("y2"), &y2)) return(false);
|
||||
|
||||
QET::EndType first_end = QET::endTypeFromString(e.attribute("end1"));
|
||||
QET::EndType second_end = QET::endTypeFromString(e.attribute("end2"));
|
||||
Qet::EndType first_end = Qet::endTypeFromString(e.attribute("end1"));
|
||||
Qet::EndType second_end = Qet::endTypeFromString(e.attribute("end2"));
|
||||
qreal length1, length2;
|
||||
if (!QET::attributeIsAReal(e, QString("length1"), &length1)) length1 = 1.5;
|
||||
if (!QET::attributeIsAReal(e, QString("length2"), &length2)) length2 = 1.5;
|
||||
@@ -362,23 +362,23 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
|
||||
QPointF start_point, stop_point;
|
||||
if (draw_1st_end) {
|
||||
QList<QPointF> four_points1(PartLine::fourEndPoints(point1, point2, length1));
|
||||
if (first_end == QET::Circle) {
|
||||
if (first_end == Qet::Circle) {
|
||||
qp.drawEllipse(QRectF(four_points1[0] - QPointF(length1, length1), QSizeF(length1 * 2.0, length1 * 2.0)));
|
||||
start_point = four_points1[1];
|
||||
} else if (first_end == QET::Diamond) {
|
||||
} else if (first_end == Qet::Diamond) {
|
||||
qp.drawPolygon(QPolygonF() << four_points1[1] << four_points1[2] << point1 << four_points1[3]);
|
||||
start_point = four_points1[1];
|
||||
} else if (first_end == QET::Simple) {
|
||||
} else if (first_end == Qet::Simple) {
|
||||
qp.drawPolyline(QPolygonF() << four_points1[3] << point1 << four_points1[2]);
|
||||
start_point = point1;
|
||||
|
||||
} else if (first_end == QET::Triangle) {
|
||||
} else if (first_end == Qet::Triangle) {
|
||||
qp.drawPolygon(QPolygonF() << four_points1[0] << four_points1[2] << point1 << four_points1[3]);
|
||||
start_point = four_points1[0];
|
||||
}
|
||||
|
||||
// ajuste le depart selon l'epaisseur du trait
|
||||
if (pen_width && (first_end == QET::Simple || first_end == QET::Circle)) {
|
||||
if (pen_width && (first_end == Qet::Simple || first_end == Qet::Circle)) {
|
||||
start_point = QLineF(start_point, point2).pointAt(pen_width / 2.0 / line_length);
|
||||
}
|
||||
} else {
|
||||
@@ -388,22 +388,22 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
|
||||
// dessine la seconde extremite
|
||||
if (draw_2nd_end) {
|
||||
QList<QPointF> four_points2(PartLine::fourEndPoints(point2, point1, length2));
|
||||
if (second_end == QET::Circle) {
|
||||
if (second_end == Qet::Circle) {
|
||||
qp.drawEllipse(QRectF(four_points2[0] - QPointF(length2, length2), QSizeF(length2 * 2.0, length2 * 2.0)));
|
||||
stop_point = four_points2[1];
|
||||
} else if (second_end == QET::Diamond) {
|
||||
} else if (second_end == Qet::Diamond) {
|
||||
qp.drawPolygon(QPolygonF() << four_points2[2] << point2 << four_points2[3] << four_points2[1]);
|
||||
stop_point = four_points2[1];
|
||||
} else if (second_end == QET::Simple) {
|
||||
} else if (second_end == Qet::Simple) {
|
||||
qp.drawPolyline(QPolygonF() << four_points2[3] << point2 << four_points2[2]);
|
||||
stop_point = point2;
|
||||
} else if (second_end == QET::Triangle) {
|
||||
} else if (second_end == Qet::Triangle) {
|
||||
qp.drawPolygon(QPolygonF() << four_points2[0] << four_points2[2] << point2 << four_points2[3] << four_points2[0]);
|
||||
stop_point = four_points2[0];
|
||||
}
|
||||
|
||||
// ajuste l'arrivee selon l'epaisseur du trait
|
||||
if (pen_width && (second_end == QET::Simple || second_end == QET::Circle)) {
|
||||
if (pen_width && (second_end == Qet::Simple || second_end == Qet::Circle)) {
|
||||
stop_point = QLineF(point1, stop_point).pointAt((line_length - (pen_width / 2.0)) / line_length);
|
||||
}
|
||||
} else {
|
||||
@@ -749,14 +749,14 @@ ElementTextItem *CustomElement::parseInput(QDomElement &e) {
|
||||
Terminal *CustomElement::parseTerminal(QDomElement &e) {
|
||||
// verifie la presence et la validite des attributs obligatoires
|
||||
qreal terminalx, terminaly;
|
||||
QET::Orientation terminalo;
|
||||
Qet::Orientation terminalo;
|
||||
if (!QET::attributeIsAReal(e, QString("x"), &terminalx)) return(0);
|
||||
if (!QET::attributeIsAReal(e, QString("y"), &terminaly)) return(0);
|
||||
if (!e.hasAttribute("orientation")) return(0);
|
||||
if (e.attribute("orientation") == "n") terminalo = QET::North;
|
||||
else if (e.attribute("orientation") == "s") terminalo = QET::South;
|
||||
else if (e.attribute("orientation") == "e") terminalo = QET::East;
|
||||
else if (e.attribute("orientation") == "w") terminalo = QET::West;
|
||||
if (e.attribute("orientation") == "n") terminalo = Qet::North;
|
||||
else if (e.attribute("orientation") == "s") terminalo = Qet::South;
|
||||
else if (e.attribute("orientation") == "e") terminalo = Qet::East;
|
||||
else if (e.attribute("orientation") == "w") terminalo = Qet::West;
|
||||
else return(0);
|
||||
Terminal *new_terminal = new Terminal(terminalx, terminaly, terminalo, this, qobject_cast<Diagram *>(scene()));
|
||||
new_terminal -> setZValue(420); // valeur arbitraire pour maintenir les bornes au-dessus des champs de texte
|
||||
|
||||
@@ -124,16 +124,16 @@ bool GhostElement::terminalsFromXml(QDomElement &e, QHash<int, Terminal *> &tabl
|
||||
// modifie certains attributs pour que l'analyse par la classe CustomElement reussisse
|
||||
int previous_x_value = qde.attribute("x").toInt();
|
||||
int previous_y_value = qde.attribute("y").toInt();
|
||||
int previous_ori_value = qde.attribute("orientation").toInt();
|
||||
Qet::Orientation previous_ori_value = static_cast<Qet::Orientation>(qde.attribute("orientation").toInt());
|
||||
|
||||
qreal x_add = 0.0, y_add = 0.0;
|
||||
if (previous_ori_value == QET::North) y_add = -Terminal::terminalSize;
|
||||
else if (previous_ori_value == QET::East) x_add = Terminal::terminalSize;
|
||||
else if (previous_ori_value == QET::South) y_add = Terminal::terminalSize;
|
||||
else if (previous_ori_value == QET::West) x_add = -Terminal::terminalSize;
|
||||
if (previous_ori_value == Qet::North) y_add = -Terminal::terminalSize;
|
||||
else if (previous_ori_value == Qet::East) x_add = Terminal::terminalSize;
|
||||
else if (previous_ori_value == Qet::South) y_add = Terminal::terminalSize;
|
||||
else if (previous_ori_value == Qet::West) x_add = -Terminal::terminalSize;
|
||||
qde.setAttribute("x", previous_x_value + x_add);
|
||||
qde.setAttribute("y", previous_y_value + y_add);
|
||||
qde.setAttribute("orientation", QET::orientationToString(static_cast<QET::Orientation>(previous_ori_value)));
|
||||
qde.setAttribute("orientation", previous_ori_value);
|
||||
|
||||
if (Terminal *new_terminal = CustomElement::parseTerminal(qde)) {
|
||||
table_id_adr.insert(qde.attribute("id").toInt(), new_terminal);
|
||||
|
||||
Reference in New Issue
Block a user