SILICON
Loading...
Searching...
No Matches
GraphicalText Class Reference

#include <graphicalText.hpp>

Inheritance diagram for GraphicalText:
Collaboration diagram for GraphicalText:

Public Member Functions

 GraphicalText (QGraphicsItem *parent=nullptr)
int type () const override
std::string getTypeName () const override
 Gets the component type name for serialization.
const PropertyMap & getProperties () const override
 Properties exposed by graphical and simulation components alike.
std::optional< std::reference_wrapper< const StringPropertyOptions > > getStringPropertyOptions (std::string_view key) const override
bool isMultilineProperty (std::string_view key) const override
bool participatesInCollisions () const override
 Annotations remain selectable but do not obstruct placement or routing.
std::span< const ResizeHandle > resizeHandles () const override
PropertyMap resizedProperties (QSizeF size, ResizeHandle handle, const PropertyMap &initial) override
void applyProperty (std::string_view key, const PropertyValue &value) override
nlohmann::ordered_json serialize () const override
 Serializes the component to JSON.
void loadSerializedState (const nlohmann::json &json) override
 Loads subclass-specific serialized state.
Public Member Functions inherited from GraphicalComponent
std::optional< PropertyValue > getProperty (std::string_view key) const
bool isPropertyHidden (std::string_view key) const
 Whether a property is omitted from the properties panel.
virtual QRectF resizeBounds () const
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.
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 Attributes

static constexpr std::string_view COMPONENT_TYPE = "Text"

Private Member Functions

void setProperties (PropertyMap next)

Private Attributes

PropertyMap properties

Additional Inherited Members

Static Public Member Functions inherited from GraphicalComponent
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 inherited from GraphicalComponent
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 inherited from GraphicalComponent
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.

Detailed Description

Text annotation supporting bold, italics, and $LaTeX math$.

Definition at line 14 of file graphicalText.hpp.

Constructor & Destructor Documentation

◆ GraphicalText()

GraphicalText ( QGraphicsItem * parent = nullptr)
explicit

Definition at line 317 of file graphicalText.cpp.

Member Function Documentation

◆ applyProperty()

void applyProperty ( std::string_view key,
const PropertyValue & value )
overridevirtual

Reimplemented from GraphicalComponent.

Definition at line 383 of file graphicalText.cpp.

◆ getProperties()

const PropertyMap & getProperties ( ) const
inlinenodiscardoverridevirtual

Properties exposed by graphical and simulation components alike.

Reimplemented from GraphicalComponent.

Definition at line 25 of file graphicalText.hpp.

◆ getStringPropertyOptions()

std::optional< std::reference_wrapper< const StringPropertyOptions > > getStringPropertyOptions ( std::string_view key) const
nodiscardoverridevirtual

Reimplemented from GraphicalComponent.

Definition at line 326 of file graphicalText.cpp.

◆ getTypeName()

std::string getTypeName ( ) const
inlinenodiscardoverridevirtual

Gets the component type name for serialization.

Returns
String representing the component type

Reimplemented from GraphicalComponent.

Definition at line 21 of file graphicalText.hpp.

◆ isMultilineProperty()

bool isMultilineProperty ( std::string_view key) const
inlinenodiscardoverridevirtual

Reimplemented from GraphicalComponent.

Definition at line 28 of file graphicalText.hpp.

◆ loadSerializedState()

void loadSerializedState ( const nlohmann::json & j)
overridevirtual

Loads subclass-specific serialized state.

Parameters
jJSON object previously produced by serialize()

Reimplemented from GraphicalComponent.

Definition at line 405 of file graphicalText.cpp.

◆ participatesInCollisions()

bool participatesInCollisions ( ) const
inlinenodiscardoverridevirtual

Annotations remain selectable but do not obstruct placement or routing.

Reimplemented from GraphicalComponent.

Definition at line 32 of file graphicalText.hpp.

◆ resizedProperties()

PropertyMap resizedProperties ( QSizeF size,
ResizeHandle handle,
const PropertyMap & initial )
nodiscardoverridevirtual

Reimplemented from GraphicalComponent.

Definition at line 365 of file graphicalText.cpp.

◆ resizeHandles()

std::span< const ResizeHandle > resizeHandles ( ) const
inlinenodiscardoverridevirtual

Opt in to shared handles and translate a requested local size into properties.

Reimplemented from GraphicalComponent.

Definition at line 34 of file graphicalText.hpp.

◆ serialize()

nlohmann::ordered_json serialize ( ) const
nodiscardoverridevirtual

Serializes the component to JSON.

Returns
JSON object with position, rotation, and type

Reimplemented from GraphicalComponent.

Definition at line 395 of file graphicalText.cpp.

◆ setProperties()

void setProperties ( PropertyMap next)
private

Definition at line 333 of file graphicalText.cpp.

◆ type()

int type ( ) const
inlinenodiscardoverride

Definition at line 20 of file graphicalText.hpp.

Member Data Documentation

◆ COMPONENT_TYPE

std::string_view COMPONENT_TYPE = "Text"
staticconstexpr

Definition at line 16 of file graphicalText.hpp.

◆ properties

PropertyMap properties
private
Initial value:
{{"text", std::string("Text")},
{"size", 12},
{"font", std::string("Quicksand")},
{"wrapWidth", 0}}

Definition at line 47 of file graphicalText.hpp.


The documentation for this class was generated from the following files: