QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
qetshapeitem.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2026 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef QETSHAPEITEM_H
19#define QETSHAPEITEM_H
20
22#include "qetgraphicsitem.h"
23#include "shapetransform.h"
24
25#include <QPen>
26#include <optional>
27#include <utility>
28
29class QDomElement;
30class QDomDocument;
32class QAction;
33
42{
43 Q_OBJECT
44
45 Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged)
46 Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
47 Q_PROPERTY(QRectF rect READ rect WRITE setRect)
48 Q_PROPERTY(QLineF line READ line WRITE setLine)
49 Q_PROPERTY(QPolygonF polygon READ polygon WRITE setPolygon)
50 Q_PROPERTY(bool close READ isClosed WRITE setClosed NOTIFY closeChanged)
51 Q_PROPERTY(qreal xRadius READ XRadius WRITE setXRadius NOTIFY XRadiusChanged)
52 Q_PROPERTY(qreal yRadius READ YRadius WRITE setYRadius NOTIFY YRadiusChanged)
53
54 // One property per ShapeTransform scalar -- this is what lets a plain
55 // QPropertyUndoCommand(this, "rotation", oldValue, newValue) work for
56 // every handle, exactly like xRadius/yRadius already do for corner
57 // rounding.
58 Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY transformChanged)
59 Q_PROPERTY(qreal skewX READ skewX WRITE setSkewX NOTIFY transformChanged)
60 Q_PROPERTY(qreal skewY READ skewY WRITE setSkewY NOTIFY transformChanged)
61 Q_PROPERTY(qreal scaleFactorX READ scaleFactorX WRITE setScaleFactorX NOTIFY transformChanged)
62 Q_PROPERTY(qreal scaleFactorY READ scaleFactorY WRITE setScaleFactorY NOTIFY transformChanged)
63 Q_PROPERTY(QPointF pivot READ pivot WRITE setPivot NOTIFY transformChanged)
64
65 Q_PROPERTY(qreal startAngle READ startAngle WRITE setStartAngle NOTIFY arcChanged)
66 Q_PROPERTY(qreal endAngle READ endAngle WRITE setEndAngle NOTIFY arcChanged)
67
68 signals:
69 void penChanged();
75 void arcChanged();
76 void geometryChanged(); // P1/P2, polygon points, or path nodes changed -- lets the properties panel stay in sync while a handle is dragged, not just when it's typed into
77
78 public:
79 enum ShapeType {Line =1,
83 Path =16 };
84 Q_ENUM (ShapeType)
85
86 enum ArcClosure {NoClosure = 0, Chord = 1, Pie = 2};
87 Q_ENUM (ArcClosure)
88
89 // Point of a Path shape. Anchors are in the same local coordinate
90 // frame as an ordinary Polygon's points; handle offsets are stored
91 // *relative to the anchor*, so moving a node never has to rewrite
92 // its own handle coordinates.
94 struct PathNode {
95 QPointF anchor;
97 std::optional<QPointF> inHandle;
98 std::optional<QPointF> outHandle;
99
100 bool operator==(const PathNode &other) const {
101 return anchor == other.anchor && kind == other.kind
102 && inHandle == other.inHandle && outHandle == other.outHandle;
103 }
104 };
105
106 // Orthogonal to ShapeType: which handle set is currently shown.
107 // Cycled by clicking an already-selected shape without dragging:
108 // Size -> Corner -> RotateSkew -> Size for Rectangle (the only
109 // type with a corner-radius concept); Size -> NodeEdit ->
110 // RotateSkew -> Size for Path (reveals control handles for
111 // every node that has any); Size -> RotateSkew -> Size for
112 // everything else. One unified click-cycle for every shape
113 // type, rather than a separate, less discoverable gesture
114 // (e.g. double-click) for any one shape's extra mode.
116
117 // index conventions, deliberately matched to what already exists
118 // rather than invented fresh:
119 // Resize 0..7, same order as QetGraphicsHandlerUtility::pointsForRect
120 // (this is exactly today's Rectangle/Ellipse handle set --
121 // only the Ctrl/Shift dispatch around it is new)
122 // Rotate 0..3, corners: NW, NE, SE, SW
123 // SkewEdge 0..3, edges: N, E, S, W
124 // CornerRadius 0..1, same order as QetGraphicsHandlerUtility::pointForRadiusRect
125 // ArcEndpoint 0 = start angle, 1 = end angle
126 enum class HandleRole {
127 Resize, // Size mode
128 Rotate, SkewEdge, Pivot, // RotateSkew mode
129 CornerRadius, // Rectangle, always shown alongside Size handles
130 ArcEndpoint, // Ellipse, always shown
131 PathAnchor, PathControlIn, PathControlOut // Polygon/Path, node-edit mode (see setPathNodes())
132 };
133
134 enum { Type = UserType + 1008 };
135
137 QPointF,
138 QPointF = QPointF(0,0),
139 ShapeType = Line,
140 QGraphicsItem *parent = nullptr);
141 ~QetShapeItem() override;
142
143 //Enable the use of qgraphicsitem_cast to safely cast a
144 //QGraphicsItem into a QetShapeItem return the QGraphicsItem type
145 int type() const override { return Type; }
146
148 QPen pen() const {return m_pen;}
149 void setPen(const QPen &pen);
150 QBrush brush() const {return m_brush;}
151 void setBrush(const QBrush &brush);
153
154 virtual bool fromXml (const QDomElement &);
155 virtual QDomElement toXml (QDomDocument &document) const;
156 virtual bool toDXF (const QString &filepath,const QPen &pen);
157
158 void editProperty() override;
159 QString name() const override;
160
161 void setP2 (const QPointF &P2);
162 QLineF line() const{return QLineF(m_P1, m_P2);}
163 bool setLine (const QLineF &line);
164 QRectF rect() const{return QRectF(m_P1, m_P2);}
165 bool setRect (const QRectF &rect);
166 QPolygonF polygon() const {return m_polygon;}
167 bool setPolygon (const QPolygonF &polygon);
168 bool isClosed() const {return m_closed;}
169 void setClosed (bool close);
170 qreal XRadius() const {return m_xRadius;}
171 void setXRadius(qreal X);
172 qreal YRadius() const {return m_yRadius;}
173 void setYRadius(qreal Y);
174
175 //Transform: one accessor pair per ShapeTransform scalar (see
176 //the Q_PROPERTY block above for why they are not grouped into
177 //a single property).
179 qreal rotation() const {return m_transform.rotation;}
180 void setRotation(qreal degrees);
181 qreal skewX() const {return m_transform.skewX;}
182 void setSkewX(qreal degrees);
183 qreal skewY() const {return m_transform.skewY;}
184 void setSkewY(qreal degrees);
185 qreal scaleFactorX() const {return m_transform.scaleX;}
186 void setScaleFactorX(qreal factor);
187 qreal scaleFactorY() const {return m_transform.scaleY;}
188 void setScaleFactorY(qreal factor);
189 QPointF pivot() const {return m_transform.pivot;}
190 void setPivot(const QPointF &pivot); // moves the pivot handle: compensates pos() so the shape does not jump
192 void enableNodeEditMode(); // Path only: switches to NodeEdit mode, so every node's control handles become visible
193
194 //Arc: only meaningful when shapeType() == Ellipse. A full
195 //ellipse is just an arc with span 360 -- there is no separate
196 //Arc shape type.
197 qreal startAngle() const {return m_startAngle;}
198 void setStartAngle(qreal degrees);
199 qreal endAngle() const {return m_endAngle;}
200 void setEndAngle(qreal degrees);
201 qreal spanAngle() const {return m_endAngle - m_startAngle;}
202 bool isFullEllipse() const {return qFuzzyCompare(qAbs(spanAngle()), qreal(360));}
204 void setArcClosure(ArcClosure closure);
205
206 //Path (Bezier): only meaningful when shapeType() == Path.
207 const QVector<PathNode> &pathNodes() const {return m_nodes;}
208 void setPathNodes(const QVector<PathNode> &nodes);
209
210 //Methods available for polygon shape
211 int pointsCount () const;
212 void setNextPoint (QPointF P);
213 void removePoints (int number = 1);
214
215 QRectF boundingRect() const override;
216 QPainterPath shape() const override;
217
218 protected:
219 void paint(
220 QPainter *painter,
221 const QStyleOptionGraphicsItem *option,
222 QWidget *widget) override;
223 void hoverEnterEvent (QGraphicsSceneHoverEvent *event) override;
224 void hoverLeaveEvent (QGraphicsSceneHoverEvent *event) override;
225 void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
226 void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
227 void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override;
228 QVariant itemChange(
229 GraphicsItemChange change,
230 const QVariant &value) override;
231 bool sceneEventFilter(
232 QGraphicsItem *watched,
233 QEvent *event) override;
234 void contextMenuEvent(
235 QGraphicsSceneContextMenuEvent *event) override;
236
237 private:
238 void toggleHandleMode();
239 HandleMode nextHandleMode() const; // what a click would switch to from here -- shared by toggleHandleMode() and the tooltip
240 void updateModeHint(); // keeps the tooltip in sync with nextHandleMode()
241 void refreshInteractionHints(); // updateModeHint(), plus an immediate re-show of tooltip/status bar if currently hovered
242 void showStatusHint(const QString &text) const;
243 void clearStatusHint() const;
244 QString currentModeStatusHint() const; // richer, one-line gesture/modifier reference for the status bar, shown when hovering the shape body
245 QString handleRoleTooltip(HandleRole role, int slot) const; // shown natively by Qt when hovering that specific handle, and pushed to the status bar too
246 static QString handleModeLabel(HandleMode mode);
247 static bool isResizeCornerSlot(int slot); // true for the 4 corner slots (of 8) in QetGraphicsHandlerUtility::pointsForRect's ordering
248 void rebuildHandles(); // (re)creates handler items -- only when the *set* of handles changes
249 void repositionHandles(); // moves existing handler items -- safe to call every frame of a live drag
250 void insertPoint();
251 void removePoint();
252 void convertToPathOrPolygon(); // context-menu action; see promoteRectangleOrEllipseToPolygon() for the separate Alt+drag mechanism
253 static QVector<PathNode> bezierNodesForArc(const QRectF &rect, qreal startAngleDeg, qreal spanAngleDeg);
254 static QVector<PathNode> bezierNodesForRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius);
255 void mirror(bool horizontal); // context-menu action: flips scaleFactorX (horizontal) or scaleFactorY (vertical) around the current pivot
256 void setNodeKind(int nodeIndex, NodeKind kind); // context-menu action on a Path node
257
258 void handlerMousePressEvent(int handlerIndex);
259 void handlerMouseMoveEvent(int handlerIndex, QGraphicsSceneMouseEvent *event);
260 void handlerMouseReleaseEvent(int handlerIndex);
261
262 // One dispatch function per handle role -- called from
263 // handlerMouseMoveEvent() with the mouse position already
264 // mapped to local coordinates and any grid snap applied.
265 // dragResize() covers both the plain and Ctrl/Shift/Alt-modified
266 // interpretations of the whole Size handle set.
267 void dragResize (int index, const QPointF &localPos, Qt::KeyboardModifiers mods);
268 void dragRotateHandle(int cornerIndex, const QPointF &scenePos, Qt::KeyboardModifiers mods);
269 void dragSkewHandle (int edgeIndex, const QPointF &scenePos, Qt::KeyboardModifiers mods);
270 void dragPivotHandle (const QPointF &localPos);
271 void dragArcEndpoint (int which, const QPointF &localPos, Qt::KeyboardModifiers mods);
272 void dragCornerRadius(int which, const QPointF &localPos);
273 void dragPathAnchor (int which, const QPointF &localPos, Qt::KeyboardModifiers mods);
274 void dragPathControlHandle(bool isOutHandle, int nodeIndex, const QPointF &localPos, Qt::KeyboardModifiers mods);
275 void mirrorOppositeHandle(PathNode &node, bool justChangedIsOut); // shared by dragPathControlHandle() and dragCurveSegment()
276 void dragCurveSegment(int segmentIndex, qreal t, const QPointF &localPos); // Inkscape-style "grab the curve itself"
277
278 void promoteRectangleOrEllipseToPolygon(int detachedResizeIndex, const QPointF &newLocalPos);
279 std::pair<int, qreal> nearestPathSegment(const QPointF &localPos) const; // {segmentIndex, t}, -1 if fewer than 2 nodes
280 void insertPathPoint(int segmentIndex, qreal t); // De Casteljau split -- see .cpp for why
281 void removePathPoint(int nodeIndex);
282 QDomElement snapshotXml() const; // helper for PromoteShapeCommand: toXml() into a throwaway document
283
284 QRectF localRect() const;
285 QPainterPath outline() const; // raw, unstroked path for the current type; shared by shape() and paint()
286 QVector<QPointF> currentHandlePositions() const; // in m_handleRoles/m_handleSlot order, local coordinates
287 QPointF handlePositionFor(HandleRole role, int slot) const;
288 QPointF rotateHandleReference(int slot) const; // the point a Rotate handle tracks, before rotation is applied
289 QPointF scaleOnlyOffset(const QPointF &localPoint) const; // (localPoint - pivot), scaled, in the pre-shear frame
290 QPointF scaleAndShearOffset(const QPointF &localPoint) const; // same, with current shear also applied -- the pre-rotation frame
291 static QColor colorForHandleRole(HandleRole role);
292 static QRectF lockAspectRatio(const QRectF &oldRect, QRectF newRect, int resizeIndex, bool mirrored);
293 static QPointF cornerPoint(const QRectF &rect, int cornerIndex); // 0=NW,1=NE,2=SE,3=SW
294 static QPointF edgeMidpoint(const QRectF &rect, int edgeIndex); // 0=N, 1=E, 2=S, 3=W
295
297 private:
299 QPen m_pen;
300 QBrush m_brush;
301 QPointF m_P1,
309 bool m_closed = false,
311 QVector<QetGraphicsHandlerItem *> m_handler_vector;
314 qreal m_xRadius = 0,
320
324 QVector<HandleRole> m_handleRoles; // parallel to m_handler_vector, one role per handle
325 QVector<int> m_handleSlot; // parallel to m_handler_vector, meaning depends on role (see HandleRole)
326 QPointF m_old_pos;
327
328 qreal m_startAngle = 0;
329 qreal m_endAngle = 360;
331 bool m_pivotIsCustom = false; // false: pivot auto-follows the bounding-rect center on every geometry edit
332 bool m_deferHandleReposition = false; // true while setPivot() is applying its two related updates together
333
334 QVector<PathNode> m_nodes;
335 QVector<PathNode> m_old_nodes; // saved at handle press, for undo
336 int m_curveDragSegment = -1; // >=0 while dragging the curve itself (not a handle) between two nodes
337 qreal m_curveDragT = 0; // parameter along that segment where the drag started
338 QPointF m_curveDragOriginalP1, m_curveDragOriginalP2; // absolute control points at drag start, fixed for the whole drag
339 QPointF m_curveDragPressPos; // local position at press, to tell a plain click from a real drag
340 bool m_curveDragEngaged = false; // false until the drag actually exceeds a small threshold
341};
342#endif // QETSHAPEITEM_H
The QetGraphicsHandlerItem class This graphics item represents a point, destined to be used as an han...
Definition qetgraphicshandleritem.h:37
QetGraphicsItem(QGraphicsItem *parent=nullptr)
Definition qetgraphicsitem.cpp:44
virtual QDomElement toXml(QDomDocument &document) const
QetShapeItem::toXml Save this item to xml element.
Definition qetshapeitem.cpp:3016
bool close
Definition qetshapeitem.h:50
QDomElement snapshotXml() const
QetShapeItem::snapshotXml toXml() into a private, throwaway document – used only to hand a self-conta...
Definition qetshapeitem.cpp:1761
qreal m_curveDragT
Definition qetshapeitem.h:337
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
QetShapeItem::paint Paint this item.
Definition qetshapeitem.cpp:624
QPolygonF polygon() const
Definition qetshapeitem.h:166
QBrush m_brush
Definition qetshapeitem.h:300
qreal m_old_startAngle
Definition qetshapeitem.h:318
static QRectF lockAspectRatio(const QRectF &oldRect, QRectF newRect, int resizeIndex, bool mirrored)
QetShapeItem::lockAspectRatio Shift-constrained resize: keep the pre-drag width:height ratio,...
Definition qetshapeitem.cpp:2327
void setEndAngle(qreal degrees)
Definition qetshapeitem.cpp:390
void dragPathAnchor(int which, const QPointF &localPos, Qt::KeyboardModifiers mods)
QetShapeItem::dragPathAnchor Normally just moves the anchor (Polygon vertex, or a Path node's anchor ...
Definition qetshapeitem.cpp:2515
void removePoints(int number=1)
QetShapeItem::removePoints Number of point to remove on the polygon If number is superior to number o...
Definition qetshapeitem.cpp:462
static bool isResizeCornerSlot(int slot)
Definition qetshapeitem.cpp:2353
bool m_modifie_radius_equaly
Definition qetshapeitem.h:310
HandleMode
Definition qetshapeitem.h:115
@ NodeEdit
Definition qetshapeitem.h:115
@ RotateSkew
Definition qetshapeitem.h:115
@ Size
Definition qetshapeitem.h:115
ArcClosure m_arcClosure
Definition qetshapeitem.h:330
void closeChanged()
qreal scaleFactorX
Definition qetshapeitem.h:61
void brushChanged()
@ Type
Definition qetshapeitem.h:134
bool m_curveDragEngaged
Definition qetshapeitem.h:340
QPointF m_curveDragOriginalP1
Definition qetshapeitem.h:338
QString handleRoleTooltip(HandleRole role, int slot) const
QetShapeItem::handleRoleTooltip Set natively on each handle item in rebuildHandles() – Qt shows a han...
Definition qetshapeitem.cpp:1366
void dragResize(int index, const QPointF &localPos, Qt::KeyboardModifiers mods)
Definition qetshapeitem.cpp:2362
qreal rotation() const
Definition qetshapeitem.h:179
void arcChanged()
QPointF m_context_menu_pos
Definition qetshapeitem.h:305
qreal xRadius
Definition qetshapeitem.h:51
void insertPathPoint(int segmentIndex, qreal t)
QetShapeItem::insertPathPoint Splits the cubic Bezier between node segmentIndex and its successor at ...
Definition qetshapeitem.cpp:1867
void removePathPoint(int nodeIndex)
QetShapeItem::removePathPoint Deletes a node outright and lets its two former neighbours connect dire...
Definition qetshapeitem.cpp:1932
QPointF m_P1
Definition qetshapeitem.h:301
QPainterPath outline() const
QetShapeItem::outline The raw, unstroked path for the current type, in local coordinates....
Definition qetshapeitem.cpp:526
QPolygonF m_polygon
Definition qetshapeitem.h:306
const QVector< PathNode > & pathNodes() const
Definition qetshapeitem.h:207
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override
QetShapeItem::hoverEnterEvent Handle hover enter event.
Definition qetshapeitem.cpp:741
int pointsCount() const
QetShapeItem::pointCount.
Definition qetshapeitem.cpp:439
void setYRadius(qreal Y)
Definition qetshapeitem.cpp:233
void editProperty() override
QetShapeItem::editProperty Edit the property of this item.
Definition qetshapeitem.cpp:3209
qreal m_yRadius
Definition qetshapeitem.h:315
QString currentModeStatusHint() const
QetShapeItem::currentModeStatusHint One-line reference for whatever handles are visible right now,...
Definition qetshapeitem.cpp:1293
void handlerMouseReleaseEvent(int handlerIndex)
QetShapeItem::handlerMouseReleaseEvent.
Definition qetshapeitem.cpp:2731
QVector< PathNode > m_old_nodes
Definition qetshapeitem.h:335
QPen pen
Definition qetshapeitem.h:45
void dragSkewHandle(int edgeIndex, const QPointF &scenePos, Qt::KeyboardModifiers mods)
Definition qetshapeitem.cpp:2419
virtual bool fromXml(const QDomElement &)
QetShapeItem::fromXml Build this item from the xml description.
Definition qetshapeitem.cpp:2890
QPointF m_P2
Definition qetshapeitem.h:302
QAction * m_insert_point
Definition qetshapeitem.h:312
void clearStatusHint() const
Definition qetshapeitem.cpp:1275
void XRadiusChanged()
void handlerMouseMoveEvent(int handlerIndex, QGraphicsSceneMouseEvent *event)
QetShapeItem::handlerMouseMoveEvent.
Definition qetshapeitem.cpp:2689
void handlerMousePressEvent(int handlerIndex)
QetShapeItem::handlerMousePressEvent.
Definition qetshapeitem.cpp:2666
void mirrorOppositeHandle(PathNode &node, bool justChangedIsOut)
QetShapeItem::mirrorOppositeHandle Given a node whose one handle (out, if justChangedIsOut; in,...
Definition qetshapeitem.cpp:2589
const ShapeTransform & shapeTransform() const
Definition qetshapeitem.h:178
void YRadiusChanged()
void dragCornerRadius(int which, const QPointF &localPos)
Definition qetshapeitem.cpp:2490
qreal skewX
Definition qetshapeitem.h:59
void setSkewX(qreal degrees)
Definition qetshapeitem.cpp:258
bool m_deferHandleReposition
Definition qetshapeitem.h:332
qreal m_startAngle
Definition qetshapeitem.h:328
void dragRotateHandle(int cornerIndex, const QPointF &scenePos, Qt::KeyboardModifiers mods)
Definition qetshapeitem.cpp:2393
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
QetShapeItem::itemChange.
Definition qetshapeitem.cpp:888
QRectF boundingRect() const override
QetShapeItem::boundingRect.
Definition qetshapeitem.cpp:482
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
QetShapeItem::mouseReleaseEvent If the press in mousePressEvent never turned into a real drag,...
Definition qetshapeitem.cpp:852
QVector< PathNode > m_nodes
Definition qetshapeitem.h:334
void dragArcEndpoint(int which, const QPointF &localPos, Qt::KeyboardModifiers mods)
Definition qetshapeitem.cpp:2469
QPointF scaleAndShearOffset(const QPointF &localPoint) const
Definition qetshapeitem.cpp:1548
static QVector< PathNode > bezierNodesForArc(const QRectF &rect, qreal startAngleDeg, qreal spanAngleDeg)
QetShapeItem::bezierNodesForArc Bezier approximation of an elliptical arc, split into <=90-degree seg...
Definition qetshapeitem.cpp:2065
void setRotation(qreal degrees)
QetShapeItem::setRotation.
Definition qetshapeitem.cpp:249
qreal skewX() const
Definition qetshapeitem.h:181
qreal skewY() const
Definition qetshapeitem.h:183
void geometryChanged()
bool setLine(const QLineF &line)
QetShapeItem::setLine Set item geometry to line (only available for line shape).
Definition qetshapeitem.cpp:153
ShapeType
Definition qetshapeitem.h:79
@ Polygon
Definition qetshapeitem.h:82
@ Ellipse
Definition qetshapeitem.h:81
@ Rectangle
Definition qetshapeitem.h:80
@ Line
Definition qetshapeitem.h:79
@ Path
Definition qetshapeitem.h:83
QAction * m_remove_point
Definition qetshapeitem.h:313
static QColor colorForHandleRole(HandleRole role)
QetShapeItem::colorForHandleRole Purely cosmetic, but consistent with the existing convention of colo...
Definition qetshapeitem.cpp:1422
qreal m_old_endAngle
Definition qetshapeitem.h:319
int m_curveDragSegment
Definition qetshapeitem.h:336
NodeKind
Definition qetshapeitem.h:93
@ Corner
Definition qetshapeitem.h:93
@ Smooth
Definition qetshapeitem.h:93
@ Symmetric
Definition qetshapeitem.h:93
void toggleHandleMode()
Definition qetshapeitem.cpp:1178
void resetPivotToBoundingRectCenter()
Definition qetshapeitem.cpp:337
~QetShapeItem() override
Definition qetshapeitem.cpp:79
QVector< QPointF > currentHandlePositions() const
Definition qetshapeitem.cpp:1521
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override
QetShapeItem::sceneEventFilter.
Definition qetshapeitem.cpp:937
bool setPolygon(const QPolygonF &polygon)
QetShapeItem::setPolygon Set this item geometry to polygon (only available if shape is a polyline).
Definition qetshapeitem.cpp:195
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
QetShapeItem::mouseMoveEvent Only ever does something different from the base class while a curve-seg...
Definition qetshapeitem.cpp:821
qreal yRadius
Definition qetshapeitem.h:52
QPointF scaleOnlyOffset(const QPointF &localPoint) const
QetShapeItem::scaleOnlyOffset / scaleAndShearOffset A local point's offset from the pivot,...
Definition qetshapeitem.cpp:1542
HandleMode m_handleMode
Definition qetshapeitem.h:323
bool m_closed
Definition qetshapeitem.h:309
void setStartAngle(qreal degrees)
Definition qetshapeitem.cpp:380
QVector< int > m_handleSlot
Definition qetshapeitem.h:325
ArcClosure
Definition qetshapeitem.h:86
@ Chord
Definition qetshapeitem.h:86
@ NoClosure
Definition qetshapeitem.h:86
@ Pie
Definition qetshapeitem.h:86
void penChanged()
QPointF pivot() const
Definition qetshapeitem.h:189
void setArcClosure(ArcClosure closure)
Definition qetshapeitem.cpp:400
qreal startAngle() const
Definition qetshapeitem.h:197
void setSkewY(qreal degrees)
Definition qetshapeitem.cpp:267
qreal rotation
Definition qetshapeitem.h:58
void rebuildHandles()
QetShapeItem::rebuildHandles (Re)creates the handler items from scratch, for the current shapeType()/...
Definition qetshapeitem.cpp:1565
void removePoint()
Definition qetshapeitem.cpp:1722
qreal scaleFactorY
Definition qetshapeitem.h:62
static QPointF edgeMidpoint(const QRectF &rect, int edgeIndex)
Definition qetshapeitem.cpp:1461
void enableNodeEditMode()
QetShapeItem::enableNodeEditMode Switches into NodeEdit mode, so every node's control handles (and th...
Definition qetshapeitem.cpp:352
HandleMode nextHandleMode() const
QetShapeItem::toggleHandleMode Cycled by clicking an already-selected shape: Size -> Corner -> Rotate...
Definition qetshapeitem.cpp:1161
QPointF m_old_pos
Definition qetshapeitem.h:326
bool m_hovered
Definition qetshapeitem.h:307
void updateModeHint()
QetShapeItem::updateModeHint Keeps the tooltip in sync with what the next click would do – called on ...
Definition qetshapeitem.cpp:1218
int type() const override
Definition qetshapeitem.h:145
ShapeType shapeType() const
Definition qetshapeitem.h:152
QLineF line
Definition qetshapeitem.h:48
QPolygonF polygon
Definition qetshapeitem.h:49
QString name() const override
QetShapeItem::name.
Definition qetshapeitem.cpp:3221
QPointF m_curveDragPressPos
Definition qetshapeitem.h:339
void repositionHandles()
QetShapeItem::repositionHandles Moves the existing handler items to match current geometry,...
Definition qetshapeitem.cpp:1689
QPen m_pen
Definition qetshapeitem.h:299
void insertPoint()
Definition qetshapeitem.cpp:1706
void setScaleFactorY(qreal factor)
Definition qetshapeitem.cpp:285
void setNextPoint(QPointF P)
QetShapeItem::setNextPoint Add a new point to the current polygon.
Definition qetshapeitem.cpp:449
QPointF m_old_P2
Definition qetshapeitem.h:304
QPointF handlePositionFor(HandleRole role, int slot) const
QetShapeItem::handlePositionFor Local-coordinate position for one (role, slot) pair,...
Definition qetshapeitem.cpp:1480
bool isClosed() const
Definition qetshapeitem.h:168
qreal m_old_yRadius
Definition qetshapeitem.h:317
int m_vector_index
Definition qetshapeitem.h:308
void convertToPathOrPolygon()
QetShapeItem::convertToPathOrPolygon Context-menu action, explicitly requested rather than triggered ...
Definition qetshapeitem.cpp:1970
ArcClosure arcClosure() const
Definition qetshapeitem.h:203
void refreshInteractionHints()
QetShapeItem::refreshInteractionHints Keeps the tooltip text current, and – if the shape is already b...
Definition qetshapeitem.cpp:1237
static QVector< PathNode > bezierNodesForRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius)
QetShapeItem::bezierNodesForRoundedRect Bezier equivalent of QPainterPath::addRoundedRect(): 8 anchor...
Definition qetshapeitem.cpp:2117
QPointF m_old_P1
Definition qetshapeitem.h:303
HandleRole
Definition qetshapeitem.h:126
@ PathAnchor
Definition qetshapeitem.h:131
@ PathControlIn
Definition qetshapeitem.h:131
@ CornerRadius
Definition qetshapeitem.h:129
@ SkewEdge
Definition qetshapeitem.h:128
@ PathControlOut
Definition qetshapeitem.h:131
@ Pivot
Definition qetshapeitem.h:128
@ ArcEndpoint
Definition qetshapeitem.h:130
@ Rotate
Definition qetshapeitem.h:128
@ Resize
Definition qetshapeitem.h:127
void setClosed(bool close)
QetShapeItem::setClosed Close this item – has effect for Polygon and Path only (the two shape types w...
Definition qetshapeitem.cpp:215
void dragCurveSegment(int segmentIndex, qreal t, const QPointF &localPos)
QetShapeItem::dragCurveSegment Inkscape-style "grab the curve itself, not a handle" reshaping: moves ...
Definition qetshapeitem.cpp:2632
QPointF pivot
Definition qetshapeitem.h:63
QRectF rect() const
Definition qetshapeitem.h:164
QRectF rect
Definition qetshapeitem.h:47
QPointF rotateHandleReference(int slot) const
Definition qetshapeitem.cpp:1450
void promoteRectangleOrEllipseToPolygon(int detachedResizeIndex, const QPointF &newLocalPos)
QetShapeItem::promoteRectangleOrEllipseToPolygon Alt+drag on a Resize corner detaches that one vertex...
Definition qetshapeitem.cpp:1780
QBrush brush
Definition qetshapeitem.h:46
void setP2(const QPointF &P2)
QetShapeItem::setP2 Set the second point of this item. If this item is a polyline,...
Definition qetshapeitem.cpp:118
std::pair< int, qreal > nearestPathSegment(const QPointF &localPos) const
QetShapeItem::nearestPathSegment Nearest point on the whole curve to localPos, found by coarse sampli...
Definition qetshapeitem.cpp:1816
qreal startAngle
Definition qetshapeitem.h:65
qreal skewY
Definition qetshapeitem.h:60
ShapeType m_shapeType
ATTRIBUTES.
Definition qetshapeitem.h:298
QLineF line() const
Definition qetshapeitem.h:162
qreal endAngle
Definition qetshapeitem.h:66
qreal scaleFactorX() const
Definition qetshapeitem.h:185
void mirror(bool horizontal)
QetShapeItem::mirror Flips the shape around its own current pivot – horizontal negates scaleFactorX,...
Definition qetshapeitem.cpp:2196
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
QetShapeItem::mousePressEvent A left click on an already selected shape (without having dragged) togg...
Definition qetshapeitem.cpp:768
void setNodeKind(int nodeIndex, NodeKind kind)
QetShapeItem::setNodeKind Change a Path node's kind, via the context menu rather than a drag....
Definition qetshapeitem.cpp:2258
QVector< HandleRole > m_handleRoles
Definition qetshapeitem.h:324
bool isFullEllipse() const
Definition qetshapeitem.h:202
qreal spanAngle() const
Definition qetshapeitem.h:201
qreal endAngle() const
Definition qetshapeitem.h:199
ShapeTransform m_transform
Definition qetshapeitem.h:321
virtual bool toDXF(const QString &filepath, const QPen &pen)
QetShapeItem::toDXF Draw this element to the dxf document.
Definition qetshapeitem.cpp:3133
QPainterPath shape() const override
QetShapeItem::shape.
Definition qetshapeitem.cpp:609
QPointF m_curveDragOriginalP2
Definition qetshapeitem.h:338
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override
QetShapeItem::contextMenuEvent.
Definition qetshapeitem.cpp:994
qreal m_old_xRadius
Definition qetshapeitem.h:316
QRectF localRect() const
QetShapeItem::localRect The rect used for corner/edge handle placement and for arc/radius math....
Definition qetshapeitem.cpp:506
QPen pen() const
METHODS.
Definition qetshapeitem.h:148
qreal YRadius() const
Definition qetshapeitem.h:172
qreal scaleFactorY() const
Definition qetshapeitem.h:187
QPolygonF m_old_polygon
Definition qetshapeitem.h:306
bool setRect(const QRectF &rect)
QetShapeItem::setRect Set this item geometry to rect (only available if shape is a rectangle or an el...
Definition qetshapeitem.cpp:172
bool m_pivotIsCustom
Definition qetshapeitem.h:331
void transformChanged()
void setXRadius(qreal X)
Definition qetshapeitem.cpp:225
void setPen(const QPen &pen)
QetShapeItem::setPen Set the pen to use for draw the shape.
Definition qetshapeitem.cpp:90
QVector< QetGraphicsHandlerItem * > m_handler_vector
Definition qetshapeitem.h:311
void dragPathControlHandle(bool isOutHandle, int nodeIndex, const QPointF &localPos, Qt::KeyboardModifiers mods)
QetShapeItem::dragPathControlHandle Dragging a Bezier control handle. Corner nodes have no linked opp...
Definition qetshapeitem.cpp:2553
void setScaleFactorX(qreal factor)
Definition qetshapeitem.cpp:276
QetShapeItem(QPointF, QPointF=QPointF(0, 0), ShapeType=Line, QGraphicsItem *parent=nullptr)
QetShapeItem::QetShapeItem Constructor of shape item. point 1 and 2 must be in scene coordinate.
Definition qetshapeitem.cpp:52
ShapeTransform m_old_transform
Definition qetshapeitem.h:322
void showStatusHint(const QString &text) const
Definition qetshapeitem.cpp:1267
static QString handleModeLabel(HandleMode mode)
QetShapeItem::handleModeLabel Short, human name for a HandleMode – used to build both the tooltip ("c...
Definition qetshapeitem.cpp:1196
void setPathNodes(const QVector< PathNode > &nodes)
QetShapeItem::setPathNodes Replace the node list of a Path shape. Interactive editing of anchors and ...
Definition qetshapeitem.cpp:416
void dragPivotHandle(const QPointF &localPos)
Definition qetshapeitem.cpp:2460
qreal m_xRadius
Definition qetshapeitem.h:314
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override
QetShapeItem::hoverLeaveEvent Handle hover leave event.
Definition qetshapeitem.cpp:753
static QPointF cornerPoint(const QRectF &rect, int cornerIndex)
Definition qetshapeitem.cpp:1439
qreal XRadius() const
Definition qetshapeitem.h:170
qreal m_endAngle
Definition qetshapeitem.h:329
void setBrush(const QBrush &brush)
QetShapeItem::setBrush Set the brush to use for the fill the shape.
Definition qetshapeitem.cpp:103
void setPivot(const QPointF &pivot)
QetShapeItem::setPivot Move the pivot point. pos() is adjusted at the same time so the shape never vi...
Definition qetshapeitem.cpp:301
QBrush brush() const
Definition qetshapeitem.h:150
Definition qetshapeitem.h:94
bool operator==(const PathNode &other) const
Definition qetshapeitem.h:100
std::optional< QPointF > outHandle
Definition qetshapeitem.h:98
QPointF anchor
Definition qetshapeitem.h:95
NodeKind kind
Definition qetshapeitem.h:96
std::optional< QPointF > inHandle
Definition qetshapeitem.h:97
The ShapeTransform struct Rotation, skew and scale applied to a shape's local geometry around an arbi...
Definition shapetransform.h:50