Maki
Formally verified low-code orchestration
Loading...
Searching...
No Matches

Represents a graphical node item in a flowchart. More...

#include <node.h>

Inheritance diagram for NodeItem:
NodeBase BehaviourNode CapabilityNode TaskNode CapabilityCallNode ContinueNode FailureNode FlowCallNode JoinNode LinkInNode LinkOutNode RepeatNode StartNode SuccessNode TerminateNode WithinNode

Classes

struct  PortKey
 Current size of the node. More...

Public Member Functions

 NodeItem (const QString &id, std::shared_ptr< NodeSaveInfo > info, const QPointF &initialPosition, std::shared_ptr< NodeConfig > nodeConfig, QGraphicsItem *parent=nullptr)
 Constructs a new NodeItem with the given parameters.
virtual ~NodeItem ()
 Destructor for the NodeItem.
int type () const override
 Returns the type of this item.
virtual VoidResult start ()
 Starts the node.
virtual QRectF nodeRect () const override
 Returns the bounding rectangle for this item.
virtual QPainterPath shape () const override
 Returns the shape of this item.
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *style, QWidget *widget) override
 Paints the item using the given painter.
HelpConfig help () const
 Returns help configuration for this node.
QString nodeName () const
 Returns the name of the node.
QString nodeType () const
 Returns the type of the node.
QString behaviour () const
 Returns the behavior of the node.
QVector< ControlsConfig > controls () const
 Returns the controls configuration for this node.
QVector< std::shared_ptr< IParameter > > properties () const
 Returns the properties of the node.
QVector< PropertyConfig > configurationProperties () const
 Returns the configuration properties of the node.
Types::LibraryTypes function () const
 Returns the library type associated with this node's function.
const PropertyInfo * getProperty (const QString &key) const
 Gets a property by key.
virtual void setProperty (const QString &key, const maki::Value &value)
 Sets a property with a given key and value.
void renameNode ()
 Renames the node to a new name.
NodeItem * parentNode () const
 Returns the parent node of this item.
QVector< NodeItem * > children (const QString &subflow=Constants::MAIN_SUB_FLOW) const
 Returns a list of child nodes.
QPointF edgePointToward (const QPointF &targetScenePos) const
 Calculates an edge point toward a target scene position.
QVector< std::shared_ptr< IParameter > > fields () const
 Returns a list of fields associated with this node.
PropertyInfo getField (const QString &key) const
 Gets a property info by key.
VoidResult setField (const QString &key, const QJsonObject &property)
 Sets a field with a given key and JSON object.
VoidResult setField (const QString &key, std::shared_ptr< PropertyInfo > property)
 Sets a field with a given key and PropertyInfo object.
void removeField (const QString &key)
 Removes a field by key.
void setEvent (int index, const FlowConfig &event)
 Sets an event at the given index with the provided FlowConfig.
QVector< std::shared_ptr< IFlow > > flowConfigs () const
 Returns a list of events associated with this node.
virtual void addParent (NodeItem *node, const QString &subflow)
 Adds a parent node to this item.
virtual void addChild (NodeItem *node, std::shared_ptr< NodeSaveInfo > info)
 Adds a child node with the given save information.
virtual void childRemoved (NodeItem *child)
 Handles when a child is removed from this item.
std::vector< std::shared_ptr< Flow > > flows () const
 Returns a list of flows associated with this node.
PFlow createFlow (std::shared_ptr< FlowSaveInfo > info)
 Creates a new flow with the given name and save information.
PFlow getFlow (const QString &flowId) const
 Gets a flow by its ID.
void deleteFlow (const QString &flowId)
 Deletes a flow by its ID.
qreal baseScale () const
 Returns the base scale for this node.
QVector< TransitionConfig > configTransitions () const
 Returns a list of configured transitions.
virtual void applySize (const QSizeF &size)
 Applies a new size to the node.
void updatePosition (const QPointF &position, Config::NodeMove reason=Config::NodeMove::User)
 Updates the position of the node.
NodeSaveInfo saveInfo () const
 Returns the savable information for this node.
virtual void childPositionUpdated (NodeItem *node)
 Called to tell the parent that the position of this node was updated.
Public Member Functions inherited from NodeBase
 NodeBase (const QString &id, const QString &nodeId, std::shared_ptr< NodeConfig > config, QGraphicsItem *parent)
 Constructs a new NodeBase instance.
virtual ~NodeBase ()
 Destructor.
QString id () const
 Retrieves the unique identifier of the node.
virtual QString nodeId () const
 Retrieves the identifier of the node within its type.
std::shared_ptr< NodeConfig > config () const
 Retrieves the configuration settings for the node.
virtual QRectF boundingRect () const override
 Returns the bounding rectangle of the node.
virtual QRectF labelBoundingRect () const
 Returns the bounding rectangle of the label.
virtual QRectF scaledRect () const
 Returns the scaled rectangle of the node.
virtual QRectF drawingRect (const QRectF &input) const
 Returns the drawing rectangle based on the input rectangle.
virtual QPainterPath nodeShape (const QRectF &bounds) const
 Returns the node shape as a QPainterPath.
void paintNode (const QRectF &bounds, const QColor &background, const QPen &text, QPainter *painter)
 Paints the node using the provided painter.
virtual QPixmap nodePixmap () const
 Retrieves the pixmap of the node.
virtual QString nodeIcon () const
 Retrieves the icon path of the node.
virtual void toggleLabelVisibility (bool forceVisible=false)
 Toggles the visibility of the label.
virtual void settingsChanged (const AppearanceSettings &appearance)
 Update the node on setting change.

Protected Member Functions

void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override
 Handles mouse move events for this item.
void mousePressEvent (QGraphicsSceneMouseEvent *event) override
 Handles mouse press events for this item.
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override
 Handles mouse release events for this item.
virtual QVariant itemChange (GraphicsItemChange change, const QVariant &value) override
 Handles changes to the item's properties.
virtual void updateExtrasPosition (Config::NodeMove reason)
 Updates extra positions related to this node.
Protected Member Functions inherited from NodeBase
virtual void setIcon (const QString &path, const QColor &iconColor)
 Sets the icon for the node.
virtual void setLabel (const QString &name, qreal fontSize)
 Sets the label text and font size.
virtual void setLabelName (const QString &name)
 Sets the label text.
virtual void setLabelSize (qreal fontSize, const QSizeF &boundingSize)
 Sets the font size and bounding size for the label.
virtual void paintLabel (QPainter *painter, const QRectF &area, const QPen &pen, bool elide=false) const
 Paints the label using the provided painter.
virtual void initializeNodeSize ()
 Called by children after setup to fix size.

Protected Attributes

QSizeF mSize {0, 0}
 Save information for the node.
Protected Attributes inherited from NodeBase
QString mIconPath = ""
 Configuration settings for the node.
QGraphicsSvgItem * mIconItem = nullptr
 Path to the icon image.
QSvgRenderer * mRenderer
 Pointer to the SVG icon item.

Private Member Functions

QSizeF clampSize (qreal width, qreal height) const
 Size of the node when resizing started.
QPointF clampPosInside (const QRectF &inner, const QRectF &childSceneRect) const
 Clamps a position inside an inner rectangle.
void fitInsideParent (qreal padding)
 Fits this node inside its parent with optional padding.
QRectF parentInnerSceneRect (qreal padding) const
 Returns the inner scene rectangle of the parent, optionally padded.

Private Attributes

NodeItem * mParentNode
 List of flows associated with this node.
QVector< NodeItem * > mChildrenNodes
 Parent node of this item, if any.
CanvasMessage * mHighlightMessage = nullptr
 List of child nodes.
QPointF mDragStartPos {0, 0}
 Base scale for the node.
QPointF mLastPosition {0, 0}
 Position where dragging started.
bool mIsResizing {false}
 Last known position of the node.
QPointF mResizeStartMousePos {0, 0}
 Flag indicating if the node is being resized.
QSizeF mResizeStartSize {0, 0}
 Mouse position when resizing started.

Friends

QDataStream & operator<< (QDataStream &out, const NodeItem &config)
 Saves the state of this NodeItem to a QDataStream.
QDataStream & operator>> (QDataStream &in, NodeItem &config)
 Loads the state of a NodeItem from a QDataStream.

Detailed Description

Represents a graphical node item in a flowchart.

Constructor & Destructor Documentation

◆ NodeItem()

NodeItem::NodeItem ( const QString & id,
std::shared_ptr< NodeSaveInfo > info,
const QPointF & initialPosition,
std::shared_ptr< NodeConfig > nodeConfig,
QGraphicsItem * parent = nullptr )
explicit

Constructs a new NodeItem with the given parameters.

Parameters
idThe unique identifier for the node.
infoThe save information for the node.
initialPositionThe initial position of the node in scene coordinates.
nodeConfigThe configuration for the node.
parentThe parent graphics item, if any.

Member Function Documentation

◆ addChild()

void NodeItem::addChild ( NodeItem * node,
std::shared_ptr< NodeSaveInfo > info )
virtual

Adds a child node with the given save information.

Parameters
nodeThe NodeItem to add as a child.
infoThe save information for the child node.

Reimplemented in RepeatNode, TaskNode, and WithinNode.

◆ addParent()

void NodeItem::addParent ( NodeItem * node,
const QString & subflow )
virtual

Adds a parent node to this item.

Parameters
nodeThe NodeItem to add as a parent.

Reimplemented in CapabilityNode.

◆ applySize()

void NodeItem::applySize ( const QSizeF & size)
virtual

Applies a new size to the node.

Parameters
sizeThe new QSizeF for the node.

◆ baseScale()

qreal NodeItem::baseScale ( ) const

Returns the base scale for this node.

Returns
The base scale value.

◆ behaviour()

QString NodeItem::behaviour ( ) const

Returns the behavior of the node.

Returns
The behavior string.

◆ childRemoved()

void NodeItem::childRemoved ( NodeItem * child)
virtual

Handles when a child is removed from this item.

Parameters
childThe NodeItem that was removed.

Reimplemented in RepeatNode, TaskNode, and WithinNode.

◆ children()

QVector< NodeItem * > NodeItem::children ( const QString & subflow = Constants::MAIN_SUB_FLOW) const

Returns a list of child nodes.

Returns
The QVector of child NodeItems.

◆ clampPosInside()

QPointF NodeItem::clampPosInside ( const QRectF & inner,
const QRectF & childSceneRect ) const
private

Clamps a position inside an inner rectangle.

Parameters
innerThe inner QRectF.
childSceneRectThe scene rectangle of the child item.
Returns
The clamped QPointF value.

◆ clampSize()

QSizeF NodeItem::clampSize ( qreal width,
qreal height ) const
private

Size of the node when resizing started.

Clamps a size within valid limits.

Parameters
widthThe width to clamp.
heightThe height to clamp.
Returns
The clamped QSizeF value.

◆ configTransitions()

QVector< TransitionConfig > NodeItem::configTransitions ( ) const

Returns a list of configured transitions.

Returns
The QVector of TransitionConfig objects.

◆ configurationProperties()

QVector< PropertyConfig > NodeItem::configurationProperties ( ) const

Returns the configuration properties of the node.

Returns
The QVector of PropertyConfig objects.

◆ controls()

QVector< ControlsConfig > NodeItem::controls ( ) const

Returns the controls configuration for this node.

Returns
The QVector of ControlsConfig objects.

◆ createFlow()

PFlow NodeItem::createFlow ( std::shared_ptr< FlowSaveInfo > info)

Creates a new flow with the given name and save information.

Parameters
flowNameThe name of the flow.
infoThe save information for the flow.
Returns
The created Flow object, if successful.

◆ deleteFlow()

void NodeItem::deleteFlow ( const QString & flowId)

Deletes a flow by its ID.

Parameters
flowIdThe ID of the flow to delete.

◆ edgePointToward()

QPointF NodeItem::edgePointToward ( const QPointF & targetScenePos) const

Calculates an edge point toward a target scene position.

Parameters
targetScenePosThe target scene position.
Returns
The QPointF representing the edge point.

◆ fields()

QVector< std::shared_ptr< IParameter > > NodeItem::fields ( ) const

Returns a list of fields associated with this node.

Returns
The QVector of IParameter pointers.

◆ fitInsideParent()

void NodeItem::fitInsideParent ( qreal padding)
private

Fits this node inside its parent with optional padding.

Parameters
paddingThe padding to apply when fitting.

◆ flowConfigs()

QVector< std::shared_ptr< IFlow > > NodeItem::flowConfigs ( ) const

Returns a list of events associated with this node.

Returns
The QVector of IFlow pointers.

◆ flows()

std::vector< std::shared_ptr< Flow > > NodeItem::flows ( ) const

Returns a list of flows associated with this node.

Returns
The QVector of Flow pointers.

◆ function()

Types::LibraryTypes NodeItem::function ( ) const

Returns the library type associated with this node's function.

Returns
The Types::LibraryTypes enum value.

◆ getField()

PropertyInfo NodeItem::getField ( const QString & key) const

Gets a property info by key.

Parameters
keyThe property key.
Returns
The PropertyInfo object for the given key.

◆ getFlow()

PFlow NodeItem::getFlow ( const QString & flowId) const

Gets a flow by its ID.

Parameters
flowIdThe ID of the flow to retrieve.
Returns
The Flow object, if found.

◆ getProperty()

const PropertyInfo * NodeItem::getProperty ( const QString & key) const

Gets a property by key.

Parameters
keyThe property key.
Returns
The QVariant value of the property.

◆ help()

HelpConfig NodeItem::help ( ) const

Returns help configuration for this node.

Returns
The HelpConfig object.

◆ itemChange()

QVariant NodeItem::itemChange ( GraphicsItemChange change,
const QVariant & value )
overrideprotectedvirtual

Handles changes to the item's properties.

Parameters
changeThe GraphicsItemChange enum value.
valueThe new value for the property.
Returns
The modified QVariant value.

Reimplemented in RepeatNode, and WithinNode.

◆ mouseMoveEvent()

void NodeItem::mouseMoveEvent ( QGraphicsSceneMouseEvent * event)
overrideprotected

Handles mouse move events for this item.

Parameters
eventThe QGraphicsSceneMouseEvent object.

◆ mousePressEvent()

void NodeItem::mousePressEvent ( QGraphicsSceneMouseEvent * event)
overrideprotected

Handles mouse press events for this item.

Parameters
eventThe QGraphicsSceneMouseEvent object.

◆ mouseReleaseEvent()

void NodeItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event)
overrideprotected

Handles mouse release events for this item.

Parameters
eventThe QGraphicsSceneMouseEvent object.

◆ nodeName()

QString NodeItem::nodeName ( ) const

Returns the name of the node.

Returns
The node name.

◆ nodeRect()

QRectF NodeItem::nodeRect ( ) const
overridevirtual

Returns the bounding rectangle for this item.

Returns
The bounding rectangle.

Reimplemented from NodeBase.

Reimplemented in RepeatNode, and WithinNode.

◆ nodeType()

QString NodeItem::nodeType ( ) const

Returns the type of the node.

Returns
The node type.

◆ paint()

void NodeItem::paint ( QPainter * painter,
const QStyleOptionGraphicsItem * style,
QWidget * widget )
overridevirtual

Paints the item using the given painter.

Parameters
painterThe painter to use for drawing.
styleThe style option for the graphics item.
widgetThe parent widget, if any.

Reimplemented in BehaviourNode, CapabilityCallNode, CapabilityNode, RepeatNode, TaskNode, and WithinNode.

◆ parentInnerSceneRect()

QRectF NodeItem::parentInnerSceneRect ( qreal padding) const
private

Returns the inner scene rectangle of the parent, optionally padded.

Parameters
paddingThe padding to apply.
Returns
The QRectF representing the inner scene rectangle.

◆ parentNode()

NodeItem * NodeItem::parentNode ( ) const

Returns the parent node of this item.

Returns
The parent NodeItem, if any.

◆ properties()

QVector< std::shared_ptr< IParameter > > NodeItem::properties ( ) const

Returns the properties of the node.

Returns
The QMap of property keys to QVariant values.

◆ removeField()

void NodeItem::removeField ( const QString & key)

Removes a field by key.

Parameters
keyThe property key to remove.

◆ saveInfo()

NodeSaveInfo NodeItem::saveInfo ( ) const

Returns the savable information for this node.

Returns
A NodeSaveInfo class populated with the information from this node

◆ setEvent()

void NodeItem::setEvent ( int index,
const FlowConfig & event )

Sets an event at the given index with the provided FlowConfig.

Parameters
indexThe index of the event.
eventThe FlowConfig object for the event.

◆ setField() [1/2]

VoidResult NodeItem::setField ( const QString & key,
const QJsonObject & property )

Sets a field with a given key and JSON object.

Parameters
keyThe property key.
propertyThe QJsonObject representing the property.
Returns
VoidResult indicating success or failure.

◆ setField() [2/2]

VoidResult NodeItem::setField ( const QString & key,
std::shared_ptr< PropertyInfo > property )

Sets a field with a given key and PropertyInfo object.

Parameters
keyThe property key.
propertyThe PropertyInfo object to set.
Returns
VoidResult indicating success or failure.

◆ setProperty()

void NodeItem::setProperty ( const QString & key,
const maki::Value & value )
virtual

Sets a property with a given key and value.

Parameters
keyThe property key.
valueThe new value for the property.

Reimplemented in CapabilityCallNode, RepeatNode, and WithinNode.

◆ shape()

QPainterPath NodeItem::shape ( ) const
overridevirtual

Returns the shape of this item.

Returns
The QPainterPath representing the shape.

Reimplemented in CapabilityNode, RepeatNode, and WithinNode.

◆ start()

VoidResult NodeItem::start ( )
virtual

Starts the node.

Returns
VoidResult indicating success or failure.

Reimplemented in CapabilityCallNode, RepeatNode, TaskNode, and WithinNode.

◆ type()

int NodeItem::type ( ) const
overridevirtual

Returns the type of this item.

Returns
The type of the item.

Reimplemented from NodeBase.

◆ updatePosition()

void NodeItem::updatePosition ( const QPointF & position,
Config::NodeMove reason = Config::NodeMove::User )

Updates the position of the node.

Parameters
positionThe new QPointF for the node's position.

◆ operator<<

QDataStream & operator<< ( QDataStream & out,
const NodeItem & config )
friend

Saves the state of this NodeItem to a QDataStream.

Parameters
outThe QDataStream to save to.
configThe NodeItem to save.
Returns
The modified QDataStream.

◆ operator>>

QDataStream & operator>> ( QDataStream & in,
NodeItem & config )
friend

Loads the state of a NodeItem from a QDataStream.

Parameters
inThe QDataStream to load from.
configThe NodeItem to load into.
Returns
The modified QDataStream.

The documentation for this class was generated from the following files:
  • /__w/maki/maki/app/elements/node.h
  • /__w/maki/maki/app/elements/node.cpp