|
SILICON
|
The visible, selectable polyline wire on the diagram scene. More...
#include <graphicalWire.hpp>
Public Member Functions | |
| GraphicalWireSegment (QPointF firstPoint, QGraphicsItem *parent=nullptr) | |
| Constructs a segment starting at the given point. | |
| int | type () const override |
| Returns the item type identifier. | |
| void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override |
| Paints the wire segment. | |
| QPainterPath | shape () const override |
| Gets the shape for hit testing. | |
| QPainterPath | centerlineShape () const |
| Narrow painted centerline used by component collision checks. | |
| QRectF | boundingRect () const override |
| Gets the bounding rectangle. | |
| QRectF | getCollisionRect () const override |
| Gets the collision rectangle. | |
| bool | isPointOnPath (QPointF point) const |
| Checks if a point is on the wire path. | |
| void | addPoints () |
| Confirms the show points as actual wire points. | |
| void | setShowPoints (const std::vector< QPointF > &newShowPoints) |
| Sets temporary points shown while drawing. | |
| std::vector< QPointF > | getShowPoints () |
| Gets temporary points shown while drawing. | |
| const std::vector< QPointF > & | getPoints () const |
| Gets all points of the segment. | |
| std::vector< QPointF > | getScenePoints () const |
| Gets all points mapped into scene coordinates. | |
| QPointF | lastPoint () const |
| Gets the last point. | |
| QPointF | firstPoint () const |
| Gets the first point. | |
| QPointF | lastShowPoint () const |
| Gets the last show point. | |
| bool | hasShowPoints () const |
| Whether any temporary preview points are being shown. | |
| bool | empty () const |
| Checks if segment has only one point. | |
| void | setPoints (std::vector< QPointF > newPoints) |
| Replaces all points at once. | |
| std::optional< size_t > | pointIndexAt (QPointF localPos) const |
| Gets the index of the point nearest to localPos. | |
| std::optional< size_t > | edgeIndexAt (QPointF localPos) const |
| Finds the first edge within the grab radius of a local position. | |
| bool | isFirstPointJunction () const |
| Checks if first endpoint is a junction. | |
| bool | isLastPointJunction () const |
| Checks if last endpoint is a junction. | |
| void | setFirstPointJunction (bool v) |
| Sets first endpoint junction status. | |
| void | setLastPointJunction (bool v) |
| Sets last endpoint junction status. | |
| GraphicalWire * | getGraphicalWire () const |
| Gets the logical wire. | |
| void | setGraphicalWire (GraphicalWire *newWire) |
| Sets the logical wire, optionally propagating to touching siblings. | |
| void | detachFromWire () |
| Detaches from the logical wire without side effects. | |
| void | updateTopology () override |
| void | modeChanged (InteractionMode mode) override |
| Clears the drag cursor and resets hover highlighting outside normal mode. | |
| ~GraphicalWireSegment () override | |
| bool | isAlignedWith (const GraphicalWireSegment *other) const |
| Checks whether another segment is a straight continuation. | |
| nlohmann::ordered_json | serialize () const |
| Serializes the wire segment to JSON. | |
| Public Member Functions inherited from GraphicalItem | |
| GraphicalItem (ItemCategory category=ItemCategory::GraphicalItem, QGraphicsItem *parent=nullptr) | |
| ~GraphicalItem () override | |
| void | setCollidingStatus (CollidingStatus newStatus) |
| Sets the collision status. | |
| QVariant | itemChange (GraphicsItemChange change, const QVariant &value) override |
| Handles item change events. | |
| int | type () const override |
| Returns the item type identifier. | |
| bool | isColliding () const |
| Checks if the item is colliding. | |
| QPointF | getInitialPosition () const |
| Gets the original position of the item before it started moving. | |
| qreal | getInitialRotation () const |
| uint64_t | getUiId () const |
| void | setInitialPosition () |
| Sets the initialPosition of the item to its current position (should be used when placed). | |
| void | setInitialRotation () |
| void | setUiId (uint64_t newUiId) |
| void | setOwningScene (DiagramScene *scene) |
| void | setGeometryPosition (QPointF position) |
Private Member Functions | |
| void | updatePath () |
| Updates the internal path shapes. | |
| void | mousePressEvent (QGraphicsSceneMouseEvent *event) override |
| Handles mouse press for point dragging. | |
| void | mouseMoveEvent (QGraphicsSceneMouseEvent *event) override |
| Handles mouse move for point dragging. | |
| void | mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override |
| Handles mouse release. | |
| void | hoverMoveEvent (QGraphicsSceneHoverEvent *event) override |
| Handles hover for point highlighting. | |
Private Attributes | |
| QPainterPath | path |
| The main path. | |
| QPainterPath | showPath |
| The temporary path while drawing. | |
| std::vector< QPointF > | points |
| The segment points. | |
| std::vector< QPointF > | showPoints |
| Temporary points while drawing. | |
| GraphicalWire * | graphicalWire = nullptr |
| The logical wire this segment belongs to. | |
| bool | firstJunction = false |
| Junction flag for first endpoint. | |
| bool | lastJunction = false |
| Junction flag for last endpoint. | |
| std::optional< size_t > | hoveredPointIndex = std::nullopt |
| Currently hovered point index. | |
Static Private Attributes | |
| static constexpr int | INTERVAL = 60 |
| Interval for bus size decorations. | |
| static constexpr int | SLASH_LENGTH = 20 |
| Length of slash decorations. | |
| static constexpr int | SLASH_ANGLE = 135 |
| Angle for slash decorations. | |
| static constexpr int | BOX_HEIGHT = 20 |
| Height of bus size label box. | |
| static constexpr int | BOX_WIDTH = INTERVAL * 0.6 |
| Width of bus size label box. | |
| static constexpr double | POINT_RADIUS = 4.0 |
| Radius of draggable points. | |
| static constexpr double | GRAB_RADIUS = 8.0 |
| Grab radius for point selection. | |
Additional Inherited Members | |
| Static Public Member Functions inherited from GraphicalItem | |
| static uint64_t | generateUiId () |
| Protected Member Functions inherited from GraphicalItem | |
| virtual bool | canRotate () const |
| Whether the item can be rotated. | |
| virtual void | onPositionChanged (QPointF offset) |
| Called when the item position changes. | |
| CollidingStatus | getCollidingStatus () const |
| Gets the current collision status. | |
| void | mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override |
| void | mousePressEvent (QGraphicsSceneMouseEvent *event) override |
The visible, selectable polyline wire on the diagram scene.
GraphicalWireSegment is a QGraphicsItem representing a polyline wire drawn on the diagram. It stores and paints orthogonal route geometry and exposes hit-tested bend and edge handles to DiagramScene's interaction state.
Junctions occur where an endpoint meets at least three distinct wire arms. Individual bends can be highlighted while a scene edit previews the route.
Definition at line 216 of file graphicalWire.hpp.
|
explicit |
Constructs a segment starting at the given point.
| firstPoint | The starting point in local coordinates |
| parent | Optional parent graphics item |
Definition at line 158 of file graphicalWire.cpp.
|
override |
Definition at line 599 of file graphicalWire.cpp.
| void addPoints | ( | ) |
Confirms the show points as actual wire points.
Called when the wire drawing is completed, converting the temporary showPoints into permanent points.
Definition at line 223 of file graphicalWire.cpp.
|
nodiscardoverride |
Gets the bounding rectangle.
Definition at line 371 of file graphicalWire.cpp.
|
nodiscard |
Narrow painted centerline used by component collision checks.
Definition at line 386 of file graphicalWire.cpp.
|
inline |
Detaches from the logical wire without side effects.
Used during WireManager teardown to avoid creating new wires or accessing freed memory.
Definition at line 347 of file graphicalWire.hpp.
|
nodiscard |
Finds the first edge within the grab radius of a local position.
| localPos | Position in segment coordinates. |
Definition at line 428 of file graphicalWire.cpp.
|
inlinenodiscard |
Checks if segment has only one point.
Definition at line 295 of file graphicalWire.hpp.
|
inlinenodiscard |
Gets the first point.
Definition at line 283 of file graphicalWire.hpp.
|
inlinenodiscardoverridevirtual |
Gets the collision rectangle.
Implements GraphicalItem.
Definition at line 244 of file graphicalWire.hpp.
|
inline |
Gets the logical wire.
Definition at line 333 of file graphicalWire.hpp.
|
inlinenodiscard |
Gets all points of the segment.
Definition at line 274 of file graphicalWire.hpp.
|
nodiscard |
Gets all points mapped into scene coordinates.
Definition at line 402 of file graphicalWire.cpp.
|
inline |
Gets temporary points shown while drawing.
Definition at line 271 of file graphicalWire.hpp.
|
inlinenodiscard |
Whether any temporary preview points are being shown.
Definition at line 292 of file graphicalWire.hpp.
|
overrideprivate |
Handles hover for point highlighting.
Definition at line 563 of file graphicalWire.cpp.
|
nodiscard |
Checks whether another segment is a straight continuation.
| other | The segment to check |
Definition at line 472 of file graphicalWire.cpp.
|
inlinenodiscard |
Checks if first endpoint is a junction.
Definition at line 321 of file graphicalWire.hpp.
|
inlinenodiscard |
Checks if last endpoint is a junction.
Definition at line 324 of file graphicalWire.hpp.
| bool isPointOnPath | ( | QPointF | point | ) | const |
Checks if a point is on the wire path.
| point | The point to check |
Definition at line 391 of file graphicalWire.cpp.
|
inlinenodiscard |
Gets the last point.
Definition at line 280 of file graphicalWire.hpp.
|
inlinenodiscard |
Gets the last show point.
Definition at line 286 of file graphicalWire.hpp.
|
overridevirtual |
Clears the drag cursor and resets hover highlighting outside normal mode.
Reimplemented from GraphicalItem.
Definition at line 589 of file graphicalWire.cpp.
|
overrideprivate |
Handles mouse move for point dragging.
Definition at line 539 of file graphicalWire.cpp.
|
overrideprivate |
Handles mouse press for point dragging.
Definition at line 522 of file graphicalWire.cpp.
|
overrideprivate |
Handles mouse release.
Definition at line 550 of file graphicalWire.cpp.
|
override |
Paints the wire segment.
Definition at line 272 of file graphicalWire.cpp.
|
nodiscard |
Gets the index of the point nearest to localPos.
| localPos | The position to check |
Definition at line 418 of file graphicalWire.cpp.
|
nodiscard |
Serializes the wire segment to JSON.
Definition at line 616 of file graphicalWire.cpp.
| void setFirstPointJunction | ( | bool | v | ) |
Sets first endpoint junction status.
Definition at line 454 of file graphicalWire.cpp.
| void setGraphicalWire | ( | GraphicalWire * | newWire | ) |
Sets the logical wire, optionally propagating to touching siblings.
| newWire | The wire to set |
Definition at line 180 of file graphicalWire.cpp.
| void setLastPointJunction | ( | bool | v | ) |
Sets last endpoint junction status.
Definition at line 463 of file graphicalWire.cpp.
| void setPoints | ( | std::vector< QPointF > | newPoints | ) |
Replaces all points at once.
Used for route previews, undo/redo, and aligned merge operations.
| newPoints | The new points vector |
Definition at line 409 of file graphicalWire.cpp.
| void setShowPoints | ( | const std::vector< QPointF > & | newShowPoints | ) |
Sets temporary points shown while drawing.
| newShowPoints | The points to show |
Definition at line 212 of file graphicalWire.cpp.
|
nodiscardoverride |
Gets the shape for hit testing.
Definition at line 379 of file graphicalWire.cpp.
|
inlineoverride |
Returns the item type identifier.
Definition at line 226 of file graphicalWire.hpp.
|
private |
Updates the internal path shapes.
Definition at line 246 of file graphicalWire.cpp.
|
overridevirtual |
Reimplemented from GraphicalItem.
Definition at line 173 of file graphicalWire.cpp.
|
staticconstexprprivate |
Height of bus size label box.
Definition at line 420 of file graphicalWire.hpp.
|
staticconstexprprivate |
Width of bus size label box.
Definition at line 423 of file graphicalWire.hpp.
|
private |
Junction flag for first endpoint.
Definition at line 387 of file graphicalWire.hpp.
|
staticconstexprprivate |
Grab radius for point selection.
Definition at line 429 of file graphicalWire.hpp.
|
private |
The logical wire this segment belongs to.
Definition at line 384 of file graphicalWire.hpp.
|
private |
Currently hovered point index.
Definition at line 393 of file graphicalWire.hpp.
|
staticconstexprprivate |
Interval for bus size decorations.
Definition at line 411 of file graphicalWire.hpp.
|
private |
Junction flag for last endpoint.
Definition at line 390 of file graphicalWire.hpp.
|
private |
The main path.
Definition at line 372 of file graphicalWire.hpp.
|
staticconstexprprivate |
Radius of draggable points.
Definition at line 426 of file graphicalWire.hpp.
|
private |
The segment points.
Definition at line 378 of file graphicalWire.hpp.
|
private |
The temporary path while drawing.
Definition at line 375 of file graphicalWire.hpp.
|
private |
Temporary points while drawing.
Definition at line 381 of file graphicalWire.hpp.
|
staticconstexprprivate |
Angle for slash decorations.
Definition at line 417 of file graphicalWire.hpp.
|
staticconstexprprivate |
Length of slash decorations.
Definition at line 414 of file graphicalWire.hpp.