[qet] [2689] Electric potential search: folio report are take into account

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 2689
Author:   blacksun
Date:     2013-12-31 18:01:14 +0100 (Tue, 31 Dec 2013)
Log Message:
-----------
Electric potential search: folio report are take into account

Modified Paths:
--------------
    trunk/sources/diagram.cpp
    trunk/sources/diagramview.cpp
    trunk/sources/qetgraphicsitem/conductor.cpp
    trunk/sources/qetgraphicsitem/conductor.h
    trunk/sources/qetgraphicsitem/element.h

Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp	2013-12-31 14:39:34 UTC (rev 2688)
+++ trunk/sources/diagram.cpp	2013-12-31 17:01:14 UTC (rev 2689)
@@ -766,6 +766,8 @@
 void Diagram::removeElement(Element *element) {
 	if (!element || isReadOnly()) return;
 	
+	// remove all links of element
+	element->unLinkAllElements();
 	// enleve l'element au schema
 	removeItem(element);
 	

Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp	2013-12-31 14:39:34 UTC (rev 2688)
+++ trunk/sources/diagramview.cpp	2013-12-31 17:01:14 UTC (rev 2689)
@@ -969,6 +969,7 @@
 	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);

Modified: trunk/sources/qetgraphicsitem/conductor.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.cpp	2013-12-31 14:39:34 UTC (rev 2688)
+++ trunk/sources/qetgraphicsitem/conductor.cpp	2013-12-31 17:01:14 UTC (rev 2689)
@@ -1335,6 +1335,14 @@
 	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 @@
 		}
 		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) {
@@ -1360,6 +1377,21 @@
 }
 
 /**
+ * @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
  */
 QETDiagramEditor* Conductor::diagramEditor() const {

Modified: trunk/sources/qetgraphicsitem/conductor.h
===================================================================
--- trunk/sources/qetgraphicsitem/conductor.h	2013-12-31 14:39:34 UTC (rev 2688)
+++ trunk/sources/qetgraphicsitem/conductor.h	2013-12-31 17:01:14 UTC (rev 2689)
@@ -166,5 +166,6 @@
 	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

Modified: trunk/sources/qetgraphicsitem/element.h
===================================================================
--- trunk/sources/qetgraphicsitem/element.h	2013-12-31 14:39:34 UTC (rev 2688)
+++ trunk/sources/qetgraphicsitem/element.h	2013-12-31 17:01:14 UTC (rev 2689)
@@ -91,6 +91,7 @@
 	virtual void linkToElement(Element *) {}
 	virtual void unLinkAllElements() {}
 	void initLink(QETProject *);
+	QList<Element *> linkedElements () const;
 
 	/**
 		Draw this element
@@ -187,4 +188,8 @@
 	return uuid_;
 }
 
+inline QList <Element *> Element::linkedElements() const {
+	return connected_elements;
+}
+
 #endif


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/