Solves problem that terminals are not placed at the correct place

This commit is contained in:
Martin Marmsoler
2020-10-01 16:31:15 +02:00
parent 10e767c3e0
commit 91a56799a7
3 changed files with 18 additions and 2 deletions

View File

@@ -650,8 +650,14 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
for(QGraphicsItem *qgi: childItems()) { // TODO: Where the Terminals are added as childs?
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) {
bool terminal_trouvee = false;
foreach(QDomElement qde, liste_terminals) {
if (p -> fromXml(qde)) { // TODO: is there validXML enough? Because the Terminal was already read in the ElementCreation function
for(QDomElement qde: liste_terminals) {
Terminal diagramTerminal(0,0, Qet::Orientation::East);
diagramTerminal.fromXml(qde);
QPointF dockPos1 = diagramTerminal.originPos(); // position here is directly the dock_elmt_ position (stored in the diagram)
QPointF dockPos2 = p->dockPos();
if (qFuzzyCompare(dockPos1.x(), dockPos2.x()) &&
qFuzzyCompare(dockPos1.y(), dockPos2.y()) &&
p->orientation() == diagramTerminal.orientation()) { // check if the part in the collection is the same as in the diagram stored
qDebug() << "Matching Terminal found.";
priv_id_adr.insert(qde.attribute("id").toInt(), p);
terminal_trouvee = true;

View File

@@ -811,6 +811,14 @@ QUuid Terminal::uuid() const {
return d->m_uuid;
}
QPointF Terminal::dockPos() {
return dock_elmt_;
}
QPointF Terminal::originPos() {
return d->m_pos;
}
/**
@brief Conductor::relatedPotentialTerminal
Return terminal at the same potential from the same

View File

@@ -77,6 +77,8 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
Diagram *diagram () const;
Element *parentElement () const;
QUuid uuid () const;
QPointF dockPos();
QPointF originPos();
QList<Conductor *> conductors() const;
Qet::Orientation orientation() const;