From 2aeeb74e7292d4c73c3d204af63d7b57cb7a6502 Mon Sep 17 00:00:00 2001 From: Shane Ringrose Date: Sun, 21 Jun 2026 02:57:14 +1200 Subject: [PATCH] edz: group terminals by physical connector (terminalNr), drop separator lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EPLAN 2022-style part.xml files (e.g. IFM AL1122) use a numeric functiondefgroup attribute and do not carry the text functiondefinition block name that the previous grouping logic relied on. Those parts fell back to grouping by pin designation, producing symbols with all pin "1"s stacked together, then all "2"s, etc. — the bug reported in PR #513. Fix: read terminalNr first (the physical M12/connector socket identifier, e.g. "X01", "X31") as the primary group key; fall back to functiondefinition text for older EPLAN formats that omit terminalNr. Pins within each connector group are still sorted by designation using natural sort. Also remove the dashed inter-group separator lines; the existing 5 px gap between groups provides sufficient visual separation. Co-Authored-By: Claude Sonnet 4.6 --- sources/import/edz/edzelementbuilder.cpp | 17 ----------------- sources/import/edz/edzpart.cpp | 18 +++++++++++------- sources/import/edz/edzpart.h | 2 +- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/sources/import/edz/edzelementbuilder.cpp b/sources/import/edz/edzelementbuilder.cpp index 84fda9a17..98f543729 100644 --- a/sources/import/edz/edzelementbuilder.cpp +++ b/sources/import/edz/edzelementbuilder.cpp @@ -209,23 +209,6 @@ QDomDocument EdzElementBuilder::build(const EdzPart &part) : QStringLiteral("PART")); desc.appendChild(makeText(doc, body_left + 6, body_top + 7, title, TITLE_FONT)); - // Group separator lines — thin dashed line halfway through each inter-group - // gap so the eye can immediately see which terminals belong together. - const QString SEP_STYLE = - QStringLiteral("line-style:dashed;line-weight:thin;filling:none;color:black"); - for (int i = 1; i < n; ++i) { - if (!is_group_break[i]) continue; - const int sep_y = (pin_y[i - 1] + pitch + pin_y[i]) / 2; - QDomElement sep = doc.createElement(QStringLiteral("line")); - sep.setAttribute(QStringLiteral("x1"), body_left + 2); - sep.setAttribute(QStringLiteral("y1"), sep_y); - sep.setAttribute(QStringLiteral("x2"), body_right - 2); - sep.setAttribute(QStringLiteral("y2"), sep_y); - sep.setAttribute(QStringLiteral("style"), SEP_STYLE); - sep.setAttribute(QStringLiteral("antialias"), QStringLiteral("false")); - desc.appendChild(sep); - } - // Per-pin labels. for (int i = 0; i < n; ++i) { QString label = pins.at(i).designation; diff --git a/sources/import/edz/edzpart.cpp b/sources/import/edz/edzpart.cpp index a3e39e026..230153263 100644 --- a/sources/import/edz/edzpart.cpp +++ b/sources/import/edz/edzpart.cpp @@ -204,13 +204,17 @@ bool EdzPart::parse(const QString &part_xml_path) pin.designation = desig; pin.description = ft.attribute(QStringLiteral("connectiondescription")).trimmed(); - // functiondefinition identifies the functional block (FINP, MOUT, …). - // It lives on directly in newer EPLAN versions, or on - // the parent wrapper element in older ones. - pin.group = ft.attribute(QStringLiteral("functiondefinition")).trimmed(); - if (pin.group.isEmpty()) - pin.group = ft.parentNode().toElement() - .attribute(QStringLiteral("functiondefinition")).trimmed(); + // terminalNr identifies the physical connector socket (X01, X31, …) and + // is the preferred group key. Older EPLAN formats may omit it and carry + // a text functiondefinition block name (FINP, MOUT, …) instead, either on + // the itself or on its parent wrapper element. + pin.group = ft.attribute(QStringLiteral("terminalNr")).trimmed(); + if (pin.group.isEmpty()) { + pin.group = ft.attribute(QStringLiteral("functiondefinition")).trimmed(); + if (pin.group.isEmpty()) + pin.group = ft.parentNode().toElement() + .attribute(QStringLiteral("functiondefinition")).trimmed(); + } m_pins.append(pin); } diff --git a/sources/import/edz/edzpart.h b/sources/import/edz/edzpart.h index a2d02e46f..107f942d9 100644 --- a/sources/import/edz/edzpart.h +++ b/sources/import/edz/edzpart.h @@ -26,7 +26,7 @@ struct EdzPin { QString designation; ///< terminal id, e.g. "1", "PE" QString description; ///< function label, e.g. "L+" - QString group; ///< functiondefinition block, e.g. "FINP", "MOUT" + QString group; ///< connector group: terminalNr if present, else functiondefinition }; /**