Tell apart two terminals at one point; qet_diff: same wire in both forms

Review of the previous commit:
- The load fallback compared a saved uuid with occurrence 0 only, so a
  wire on the second of two terminals at one point of a symbol was lost
  once the definition was replaced, and one on the first could go to
  either of the pair (Element::m_terminals is sorted, not in definition
  order). Element::parseTerminal() now records each terminal's rank among
  the terminals of the definition at the same point, derivedUuid() uses
  it, and fillMissing() starts from the same rank.
  derivedUuidFoundAfterReplacement runs on perceuse.qet and industrial.qet
  too: 154/156 and 670/671 wires without the rank, all with it.

qet-mcp: the first save of an older project now rewrites its wires from
the numbered form to the uuid form, and qet_diff keyed the two forms
differently, so an untouched resave showed every wire removed and added
(4 failures in test_qet_mcp.py). A uuid end is now resolved to the same
key as a numbered one: the terminal's definition position, moved to where
the wire docks, is the placed symbol's <terminal> record.
test_conductor_key_same_in_both_forms fails without it; 253/253 pass on
this build and on the previous stage's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-09-29 09:10:38 +13:00
parent 4e6f59e011
commit eb3b10a48e
7 changed files with 156 additions and 17 deletions
+14 -9
View File
@@ -42,6 +42,15 @@ QList<QDomElement> terminalsOf(const QDomElement &collection_element)
return terminals;
}
//Place and orientation, "10" and "10.0" being the same place
QString terminalPlace(const QDomElement &terminal)
{
return QStringLiteral("%1|%2|%3")
.arg(QString::number(terminal.attribute(QStringLiteral("x")).toDouble()),
QString::number(terminal.attribute(QStringLiteral("y")).toDouble()),
terminal.attribute(QStringLiteral("orientation")));
}
//Qet::orientationFromString(), without pulling in qet.cpp
int orientationOf(const QDomElement &terminal)
{
@@ -65,7 +74,11 @@ int fillDefinition(const QDomElement &collection_element)
}
int filled = 0;
QHash<QString, int> seen_at;
for (QDomElement t : terminals) {
//Same count as Terminal::setPlaceRank(): every terminal before
//this one at the same point, with or without a uuid
const int rank = seen_at[terminalPlace(t)]++;
if (!QUuid(t.attribute(QStringLiteral("uuid"))).isNull()) {
continue;
}
@@ -73,7 +86,7 @@ int fillDefinition(const QDomElement &collection_element)
const qreal y = t.attribute(QStringLiteral("y")).toDouble();
const int orientation = orientationOf(t);
QUuid uuid;
for (int occurrence = 0 ; uuid.isNull() || taken.contains(uuid) ; ++occurrence) {
for (int occurrence = rank ; uuid.isNull() || taken.contains(uuid) ; ++occurrence) {
uuid = TerminalUuids::derived(x, y, orientation, occurrence);
}
taken << uuid;
@@ -98,14 +111,6 @@ int fillDirectory(const QDomElement &directory)
return filled;
}
//Place and orientation, "10" and "10.0" being the same place
QString terminalPlace(const QDomElement &terminal)
{
return QStringLiteral("%1|%2|%3")
.arg(QString::number(terminal.attribute(QStringLiteral("x")).toDouble()),
QString::number(terminal.attribute(QStringLiteral("y")).toDouble()),
terminal.attribute(QStringLiteral("orientation")));
}
}
/**