mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-01 17:14:13 +02:00
Fix terminal grouping: use functiondefinition block, not pin designation
The previous grouping compared `connectionDesignation` values (e.g. "1", "2", "3") to detect group boundaries. Those values are pin position numbers within a terminal block, not functional group identifiers, so devices like the ABB ACS880 produced 11+ tiny single-pin "groups" instead of the ~8 functional blocks (AC-IN, Motor-OUT, DC-Bus, Brake-Resistor, Analog-I/O, Digital-I/O, ...) the reviewer identified. Fix: - Add `group` field to EdzPin, populated from the `functiondefinition` attribute on <functiontemplate> (newer EPLAN) or its parent <function> element (older EPLAN). - Sort pins by group first (preserving XML appearance order per group), then by designation within each group using natural sort. - Use `groupKey()` — group when present, designation as fallback — for the group-break detection that drives separator lines and Y-gaps. Parts without any functiondefinition data retain the previous designation-based behaviour unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -73,12 +73,16 @@ QDomDocument EdzElementBuilder::build(const EdzPart &part)
|
||||
const int pitch = 10;
|
||||
const int group_gap = 5; // extra px inserted between designation groups
|
||||
|
||||
// Pins arrive sorted by designation (see EdzPart::parse). Identify group
|
||||
// boundaries and compute per-pin Y coordinates, inserting group_gap extra
|
||||
// pixels before each new designation group so they read as distinct blocks.
|
||||
// Pins arrive sorted by functional group then by designation within each
|
||||
// group (see EdzPart::parse). A group break occurs when the
|
||||
// functiondefinition block changes; fall back to designation comparison for
|
||||
// parts that carry no functiondefinition information.
|
||||
auto groupKey = [](const EdzPin &p) {
|
||||
return p.group.isEmpty() ? p.designation : p.group;
|
||||
};
|
||||
QVector<bool> is_group_break(n, false);
|
||||
for (int i = 1; i < n; ++i)
|
||||
is_group_break[i] = (pins.at(i).designation != pins.at(i - 1).designation);
|
||||
is_group_break[i] = (groupKey(pins.at(i)) != groupKey(pins.at(i - 1)));
|
||||
|
||||
QVector<int> pin_y(n);
|
||||
int cur_y = 0;
|
||||
|
||||
Reference in New Issue
Block a user