|
SILICON
|
Base class for graphical circuit components. More...
#include <graphicalComponent.hpp>
Public Member Functions | |
| virtual const PropertyMap & | getProperties () const |
| Properties exposed by graphical and simulation components alike. | |
| std::optional< PropertyValue > | getProperty (std::string_view key) const |
| virtual std::optional< std::reference_wrapper< const StringPropertyOptions > > | getStringPropertyOptions (std::string_view key) const |
| virtual bool | isMultilineProperty (std::string_view key) const |
| bool | isPropertyHidden (std::string_view key) const |
| Whether a property is omitted from the properties panel. | |
| virtual void | applyProperty (std::string_view key, const PropertyValue &value) |
| virtual bool | participatesInCollisions () const |
| Annotations remain selectable but do not obstruct placement or routing. | |
| virtual std::span< const ResizeHandle > | resizeHandles () const |
| virtual QRectF | resizeBounds () const |
| virtual PropertyMap | resizedProperties (QSizeF size, ResizeHandle handle, const PropertyMap &initial) |
| std::optional< ResizeHandle > | resizeHandleAt (QPointF localPos) const |
| bool | resizeHandlesVisible () const |
| ComponentResizeState | resizeState () const |
| void | applyResizeState (const ComponentResizeState &state) |
| void | modeChanged (InteractionMode mode) override |
| Called when the interaction mode changes. | |
| void | prepareSceneBoundsChange () |
| Prepares a geometry edit and checks its final bounds on the event loop. | |
| QRectF | collisionRectForWires () const |
| Gets the collision rectangle extended for wire connections. | |
| GraphicalComponent (QGraphicsItem *shape, QGraphicsItem *parent=nullptr, bool scanShape=false) | |
| void | rotate () |
| Rotates the component by 90 degrees. | |
| virtual void | setPorts (const std::vector< PortPair > &busToPortInputs, const std::vector< PortPair > &busToPortOutputs) |
| Sets input and output ports. | |
| const std::vector< Port * > & | getInputPorts () const |
| Borrows input ports; copy before replacing the component ports. | |
| const std::vector< Port * > & | getOutputPorts () const |
| Borrows output ports; copy before replacing the component ports. | |
| auto | getPorts () const |
| Borrows every port, inputs first, without copying or deduplicating. | |
| virtual std::string | getTypeName () const |
| Gets the component type name for serialization. | |
| virtual nlohmann::ordered_json | serialize () const |
| Serializes the component to JSON. | |
| virtual void | loadSerializedState (const nlohmann::json &j) |
| Loads subclass-specific serialized state. | |
| 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) |
| virtual void | updateTopology () |
Static Public Member Functions | |
| static std::unique_ptr< GraphicalComponent > | deserialize (const nlohmann::json &j, GUIComponentFactory &factory) |
| Deserializes a component from JSON using the factory. | |
| Static Public Member Functions inherited from GraphicalItem | |
| static uint64_t | generateUiId () |
Protected Member Functions | |
| void | setItemShape (QGraphicsItem *shape) |
| Sets the component shape graphics item. | |
| QGraphicsItem * | getItemShape () const |
| Gets the component shape. | |
| QRectF | boundingRect () const override |
| Gets bounding rectangle with selection margin. | |
| QRectF | boundingRectWithoutMargins () const |
| Gets bounding rectangle without margins. | |
| void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override |
| Paints the component (selection outline). | |
| QRectF | getCollisionRect () const override |
| Gets physical body and port line bounds for drag/drop. | |
| bool | canRotate () const override |
| Components can rotate by default. | |
| QVariant | itemChange (GraphicsItemChange change, const QVariant &value) override |
| void | mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override |
| Handles double-clicks not consumed by a component-specific action. | |
| void | hoverMoveEvent (QGraphicsSceneHoverEvent *event) override |
| void | hoverLeaveEvent (QGraphicsSceneHoverEvent *event) override |
| bool | openDocumentOnDoubleClick (QGraphicsSceneMouseEvent *event, const std::string &path) |
| Queues document navigation for a left double-click in normal mode. | |
| void | setPortLine (Port *port) |
| Creates the connecting line from port to shape. | |
| void | clearPorts () |
| Removes existing input/output ports and their line items. | |
| GraphicalComponent (ItemCategory category, QGraphicsItem *shape, QGraphicsItem *parent=nullptr, bool scanShape=false) | |
| Protected Member Functions inherited from GraphicalItem | |
| 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 |
Protected Attributes | |
| std::unordered_set< std::string, TransparentStringHash, std::equal_to<> > | hiddenProperties |
| Property names hidden from the panel, still accessible and serialized. Add names in subclasses with hiddenProperties.insert("propertyName"). | |
| std::vector< Port * > | inputPorts |
| Input connection ports. | |
| std::vector< Port * > | outputPorts |
| Output connection ports. | |
| bool | boundsUpdatePending = false |
| bool | scanShape = false |
| Whether to scan shape alpha for port placement. | |
| bool | printPortNames = false |
| Whether to print port names. | |
Private Member Functions | |
| void | setPortLine (Port *port, QImage &shapeImage) |
| Reuses a shape image while building a batch of port lines. | |
| QPoint | scanImage (const QImage &image, PortSide side, QPoint initialPoint) const |
| Scans image for first non-transparent pixel. | |
Private Attributes | |
| QGraphicsItem * | itemShape = nullptr |
| The visual shape item. | |
Friends | |
| class | Port |
Base class for graphical circuit components.
GraphicalComponent is the base class for all visually rendered circuit components in the diagram. It manages the component shape, input/output ports, rotation, and property editing.
Ports are positioned relative to the component and can be automatically detected via alpha-scanning the shape image.
Definition at line 154 of file graphicalComponent.hpp.
|
explicitprotected |
Definition at line 209 of file graphicalComponent.cpp.
|
explicit |
Definition at line 165 of file graphicalComponent.cpp.
|
virtual |
Reimplemented in GraphicalLogicComponent, GraphicalROM, GraphicalSubcircuitComponent, and GraphicalText.
Definition at line 203 of file graphicalComponent.cpp.
| void applyResizeState | ( | const ComponentResizeState & | state | ) |
Definition at line 309 of file graphicalComponent.cpp.
|
nodiscardoverrideprotected |
Gets bounding rectangle with selection margin.
Definition at line 263 of file graphicalComponent.cpp.
|
nodiscardprotected |
Gets bounding rectangle without margins.
Definition at line 355 of file graphicalComponent.cpp.
|
inlinenodiscardoverrideprotectedvirtual |
Components can rotate by default.
Reimplemented from GraphicalItem.
Definition at line 226 of file graphicalComponent.hpp.
|
protected |
Removes existing input/output ports and their line items.
Definition at line 482 of file graphicalComponent.cpp.
|
nodiscard |
Gets the collision rectangle extended for wire connections.
Definition at line 383 of file graphicalComponent.cpp.
|
static |
Deserializes a component from JSON using the factory.
| j | JSON object |
| factory | Component factory for creating instances |
Definition at line 825 of file graphicalComponent.cpp.
|
nodiscardoverrideprotectedvirtual |
Gets physical body and port line bounds for drag/drop.
Implements GraphicalItem.
Definition at line 415 of file graphicalComponent.cpp.
|
inlinenodiscard |
Borrows input ports; copy before replacing the component ports.
Definition at line 287 of file graphicalComponent.hpp.
|
inlinenodiscardprotected |
Gets the component shape.
Definition at line 208 of file graphicalComponent.hpp.
|
inlinenodiscard |
Borrows output ports; copy before replacing the component ports.
Definition at line 290 of file graphicalComponent.hpp.
|
inlinenodiscard |
Borrows every port, inputs first, without copying or deduplicating.
Definition at line 296 of file graphicalComponent.hpp.
|
nodiscardvirtual |
Properties exposed by graphical and simulation components alike.
Reimplemented in GraphicalLogicComponent, and GraphicalText.
Definition at line 171 of file graphicalComponent.cpp.
|
nodiscard |
Definition at line 177 of file graphicalComponent.cpp.
|
nodiscardvirtual |
Reimplemented in GraphicalLogicComponent, and GraphicalText.
Definition at line 186 of file graphicalComponent.cpp.
|
nodiscardvirtual |
Gets the component type name for serialization.
Reimplemented in GraphicalBusInput, GraphicalBusOutput, GraphicalInput, GraphicalLogicComponent, GraphicalOutputSingle, and GraphicalText.
Definition at line 811 of file graphicalComponent.cpp.
|
overrideprotected |
Definition at line 342 of file graphicalComponent.cpp.
|
overrideprotected |
Definition at line 318 of file graphicalComponent.cpp.
|
nodiscardvirtual |
Reimplemented in GraphicalText.
Definition at line 192 of file graphicalComponent.cpp.
|
nodiscard |
Whether a property is omitted from the properties panel.
Definition at line 198 of file graphicalComponent.cpp.
|
overrideprotected |
Definition at line 400 of file graphicalComponent.cpp.
|
virtual |
Loads subclass-specific serialized state.
| j | JSON object previously produced by serialize() |
Reimplemented in GraphicalText.
Definition at line 821 of file graphicalComponent.cpp.
|
overridevirtual |
Called when the interaction mode changes.
| mode | The new interaction mode |
Reimplemented from GraphicalItem.
Definition at line 348 of file graphicalComponent.cpp.
|
overrideprotected |
Handles double-clicks not consumed by a component-specific action.
Definition at line 426 of file graphicalComponent.cpp.
|
protected |
Queues document navigation for a left double-click in normal mode.
Definition at line 431 of file graphicalComponent.cpp.
|
overrideprotected |
Paints the component (selection outline).
Definition at line 360 of file graphicalComponent.cpp.
|
inlinenodiscardvirtual |
Annotations remain selectable but do not obstruct placement or routing.
Reimplemented in GraphicalText.
Definition at line 169 of file graphicalComponent.hpp.
| void prepareSceneBoundsChange | ( | ) |
Prepares a geometry edit and checks its final bounds on the event loop.
Definition at line 224 of file graphicalComponent.cpp.
|
inlinenodiscardvirtual |
Definition at line 173 of file graphicalComponent.hpp.
|
nodiscardvirtual |
Reimplemented in GraphicalText.
Definition at line 269 of file graphicalComponent.cpp.
|
nodiscard |
Definition at line 283 of file graphicalComponent.cpp.
|
inlinenodiscardvirtual |
Opt in to shared handles and translate a requested local size into properties.
Reimplemented in GraphicalText.
Definition at line 172 of file graphicalComponent.hpp.
|
nodiscard |
Definition at line 275 of file graphicalComponent.cpp.
|
nodiscard |
Definition at line 304 of file graphicalComponent.cpp.
| void rotate | ( | ) |
Rotates the component by 90 degrees.
Definition at line 394 of file graphicalComponent.cpp.
|
private |
Scans image for first non-transparent pixel.
| image | Image to scan |
| side | |
| initialPoint | Starting point |
Definition at line 500 of file graphicalComponent.cpp.
|
nodiscardvirtual |
Serializes the component to JSON.
Reimplemented in GraphicalText.
Definition at line 814 of file graphicalComponent.cpp.
|
protected |
Sets the component shape graphics item.
| shape | The shape item |
Definition at line 246 of file graphicalComponent.cpp.
|
protected |
Creates the connecting line from port to shape.
| port | The port to connect |
Definition at line 530 of file graphicalComponent.cpp.
|
private |
Reuses a shape image while building a batch of port lines.
Definition at line 536 of file graphicalComponent.cpp.
|
virtual |
Sets input and output ports.
| busToPortInputs | Vector of (name, position) pairs for inputs |
| busToPortOutputs | Vector of (name, position) pairs for outputs |
Reimplemented in GraphicalLogicComponent.
Definition at line 454 of file graphicalComponent.cpp.
|
friend |
Definition at line 156 of file graphicalComponent.hpp.
|
protected |
Definition at line 253 of file graphicalComponent.hpp.
|
protected |
Property names hidden from the panel, still accessible and serialized. Add names in subclasses with hiddenProperties.insert("propertyName").
Definition at line 199 of file graphicalComponent.hpp.
|
protected |
Input connection ports.
Definition at line 242 of file graphicalComponent.hpp.
|
private |
The visual shape item.
Definition at line 345 of file graphicalComponent.hpp.
|
protected |
Output connection ports.
Definition at line 245 of file graphicalComponent.hpp.
|
protected |
Whether to print port names.
Definition at line 259 of file graphicalComponent.hpp.
|
protected |
Whether to scan shape alpha for port placement.
Definition at line 256 of file graphicalComponent.hpp.