diff --git a/sources/diagram.cpp b/sources/diagram.cpp index 588068227..369219377 100644 --- a/sources/diagram.cpp +++ b/sources/diagram.cpp @@ -766,6 +766,8 @@ void Diagram::addDiagramImageItem(DiagramImageItem *dii) { void Diagram::removeElement(Element *element) { if (!element || isReadOnly()) return; + // remove all links of element + element->unLinkAllElements(); // enleve l'element au schema removeItem(element); diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index 9c66585b1..0d7e9b465 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -969,6 +969,7 @@ void DiagramView::editConductor(Conductor *edited_conductor) { QVBoxLayout *dialog_layout = new QVBoxLayout(&conductor_dialog); dialog_layout -> addWidget(cpw); QCheckBox *cb_apply_all = new QCheckBox(tr("Appliquer les propri\351t\351s \340 l'ensemble des conducteurs de ce potentiel"), &conductor_dialog); + cb_apply_all->setChecked(true); dialog_layout -> addStretch(); dialog_layout -> addWidget(cb_apply_all); QDialogButtonBox *dbb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp index 1050b04ce..7a47bfbf9 100644 --- a/sources/qetgraphicsitem/conductor.cpp +++ b/sources/qetgraphicsitem/conductor.cpp @@ -1335,6 +1335,14 @@ QSet Conductor::relatedPotentialConductors(QList *t_li if (!t_list -> contains(terminal1)) { t_list -> append(terminal1); QList other_conductors_list_t1 = terminal1 -> conductors(); + + //get terminal share the same potential of terminal1 + Terminal *t1_bis = relatedPotentialTerminal(terminal1); + if (t1_bis && !t_list->contains(t1_bis)) { + t_list -> append(t1_bis); + other_conductors_list_t1 += t1_bis->conductors(); + } + other_conductors_list_t1.removeAll(this); //recherche les conducteurs connecté au conducteur déjà trouvé foreach (Conductor *c, other_conductors_list_t1) { @@ -1342,10 +1350,19 @@ QSet Conductor::relatedPotentialConductors(QList *t_li } other_conductors += other_conductors_list_t1.toSet(); } + //renvoie tous les conducteurs du terminal 2 if (!t_list -> contains(terminal2)) { t_list -> append(terminal2); QList other_conductors_list_t2 = terminal2 -> conductors(); + + //get terminal share the same potential of terminal1 + Terminal *t2_bis = relatedPotentialTerminal(terminal2); + if (t2_bis && !t_list->contains(t2_bis)) { + t_list -> append(t2_bis); + other_conductors_list_t2 += t2_bis->conductors(); + } + other_conductors_list_t2.removeAll(this); //recherche les conducteurs connecté au conducteur déjà trouvé foreach (Conductor *c, other_conductors_list_t2) { @@ -1359,6 +1376,21 @@ QSet Conductor::relatedPotentialConductors(QList *t_li return(other_conductors); } +/** + * @brief Conductor::relatedPotentialTerminal + * find another terminal in the same electric potential of terminal @t + */ +Terminal * Conductor::relatedPotentialTerminal (Terminal *t) { + //terminal must have a folio report parent. + if (t->parentElement()->linkType() & Element::Report) { + QList elmt_list = t->parentElement()->linkedElements(); + if (!elmt_list.isEmpty()) { + return (elmt_list.first()->terminals().first()); + } + } + return 0; +} + /** * @return l'editeur de schemas parent ou 0 */ diff --git a/sources/qetgraphicsitem/conductor.h b/sources/qetgraphicsitem/conductor.h index 26343a628..78cec22b0 100644 --- a/sources/qetgraphicsitem/conductor.h +++ b/sources/qetgraphicsitem/conductor.h @@ -166,5 +166,6 @@ class Conductor : public QObject, public QGraphicsPathItem { static qreal conductor_bound(qreal, qreal, bool); static Qt::Corner movementType(const QPointF &, const QPointF &); static QPointF movePointIntoPolygon(const QPointF &, const QPainterPath &); + Terminal * relatedPotentialTerminal (Terminal *); }; #endif diff --git a/sources/qetgraphicsitem/element.h b/sources/qetgraphicsitem/element.h index fb0e4f654..089147a14 100644 --- a/sources/qetgraphicsitem/element.h +++ b/sources/qetgraphicsitem/element.h @@ -91,6 +91,7 @@ class Element : public QetGraphicsItem { virtual void linkToElement(Element *) {} virtual void unLinkAllElements() {} void initLink(QETProject *); + QList linkedElements () const; /** Draw this element @@ -187,4 +188,8 @@ inline QUuid Element::uuid() const { return uuid_; } +inline QList Element::linkedElements() const { + return connected_elements; +} + #endif