mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-01 07:14:14 +02:00
Add polygon and path shapes to the scripting API
addShape()'s own "polygon" only ever produces the degenerate two-point form -- it shares addShape()'s p1/p2 constructor and nothing else. addPolygon()/setShapePolygon() take an arbitrary point list through QetShapeItem's public setPolygon(), pushed via the existing "polygon" Q_PROPERTY the same way a point-handle drag would. addPath()/setShapePathNodes() add the Path shape type: a polygon's points plus, per node, a kind (corner/smooth/symmetric) and optional bezier in/out handles, the same model the pen tool and node-edit mode build. PathNode holds std::optional<QPointF> members and isn't Q_PROPERTY-friendly, so setShapePathNodes() reuses PromoteShapeCommand's before/after XML snapshot mechanism instead -- the same fallback QetShapeItem::associatedUndoCommand() already uses for the identical reason on a PathAnchor/PathControlIn/PathControlOut handle drag. setShapeClosed() opens or closes a polygon or path through the existing "close" Q_PROPERTY. shapePolygon()/shapePathNodes() read a shape's current geometry back in scene coordinates, refusing (empty) on the wrong shape type. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -446,6 +446,15 @@ class QetScriptApi : public QObject
|
||||
Q_INVOKABLE bool setShapeProperty(int folioIndex, int shapeIndex,
|
||||
const QString &property, const QString &value);
|
||||
|
||||
// -- polygon and path shapes: more than addShape()'s two-point box --
|
||||
Q_INVOKABLE int addPolygon(int folioIndex, const QVariantList &points, bool closed);
|
||||
Q_INVOKABLE QVariantList shapePolygon(int folioIndex, int shapeIndex) const;
|
||||
Q_INVOKABLE bool setShapePolygon(int folioIndex, int shapeIndex, const QVariantList &points);
|
||||
Q_INVOKABLE int addPath(int folioIndex, const QVariantList &nodes, bool closed);
|
||||
Q_INVOKABLE QVariantList shapePathNodes(int folioIndex, int shapeIndex) const;
|
||||
Q_INVOKABLE bool setShapePathNodes(int folioIndex, int shapeIndex, const QVariantList &nodes);
|
||||
Q_INVOKABLE bool setShapeClosed(int folioIndex, int shapeIndex, bool closed);
|
||||
|
||||
// -- query the project database --
|
||||
Q_INVOKABLE QStringList tables() const;
|
||||
Q_INVOKABLE QVariantList query(const QString &sql);
|
||||
|
||||
Reference in New Issue
Block a user