Electric potential search: folio report are take into account

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2689 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2013-12-31 17:01:14 +00:00
parent 5ad42fb491
commit cd9e78a49f
5 changed files with 41 additions and 0 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -1335,6 +1335,14 @@ QSet<Conductor *> Conductor::relatedPotentialConductors(QList <Terminal *> *t_li
if (!t_list -> contains(terminal1)) {
t_list -> append(terminal1);
QList <Conductor *> 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 *> Conductor::relatedPotentialConductors(QList <Terminal *> *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 <Conductor *> 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 *> Conductor::relatedPotentialConductors(QList <Terminal *> *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 <Element *> 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
*/

View File

@@ -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

View File

@@ -91,6 +91,7 @@ class Element : public QetGraphicsItem {
virtual void linkToElement(Element *) {}
virtual void unLinkAllElements() {}
void initLink(QETProject *);
QList<Element *> linkedElements () const;
/**
Draw this element
@@ -187,4 +188,8 @@ inline QUuid Element::uuid() const {
return uuid_;
}
inline QList <Element *> Element::linkedElements() const {
return connected_elements;
}
#endif