Scripting: add terminalPosition() and conductorPath()

A script laying out a drawing could read where a symbol is
(elementGeometry) but not where its terminals are, so it could not place
one symbol with a terminal exactly in line with another's -- the one
thing that makes the wire between them straight. And it could read a
wire's drawn path only through conductorSegments(), which names the wire
by a terminal and so refuses any terminal carrying two wires: 282 of the
3120 wires in the shipped examples.

terminalPosition(folio, element, terminal) returns where a wire docks on
the terminal, in folio coordinates, and which way it leaves (n/e/s/w,
the element's rotation included). conductorPath(folio, uuid) returns any
wire's drawn path as points, by its uuid.

tst_scriptlayoutreads checks the two against each other on every wire of
a fixture: each path starts and ends where its terminals' positions say,
and leaves each the way it faces; where conductorSegments() can name a
wire, both give the same points; and a quarter turn turns the facing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015FPuYPS4T7QuEwjNu22rXD
This commit is contained in:
ispyisail
2026-10-03 13:26:34 +13:00
parent 18568dfd53
commit cc23cf820f
4 changed files with 260 additions and 1 deletions
+9 -1
View File
@@ -289,7 +289,12 @@ class QetGraphicsTableItem;
is -- x, y (its origin), rotation, and the box it occupies on the folio
(left, top, right, bottom) -- so a script can lay one thing out relative
to another instead of only setting absolute coordinates, and can check
that a move landed. insertFolio() puts a new folio at a position
that a move landed. terminalPosition() is where a wire docks on one
terminal and which way it leaves, so a symbol can be placed with a
terminal exactly in line with another one before any wire exists;
conductorPath() is a wire's drawn path by its uuid, for any wire,
where conductorSegments() needs a terminal carrying only that one.
insertFolio() puts a new folio at a position
instead of at the end, which is what reordering is mostly for while
moving an existing folio still needs the application's project view.
- @b Images: place a picture from a file. The pixels are copied into
@@ -567,6 +572,9 @@ class QetScriptApi : public QObject
// -- read an element's geometry --
Q_INVOKABLE QVariantMap elementGeometry(int folioIndex, const QString &elementUuid) const;
Q_INVOKABLE QVariantMap terminalPosition(int folioIndex, const QString &elementUuid,
int terminalIndex) const;
Q_INVOKABLE QVariantList conductorPath(int folioIndex, const QString &conductorUuid) const;
// -- folios --
Q_INVOKABLE int addFolio();