Maki
Formally verfied low-code orchestration
Loading...
Searching...
No Matches
BehaviourCanvas Class Reference

A specialized canvas for managing and displaying behavior-related nodes. More...

#include <behaviour_canvas.h>

Inheritance diagram for BehaviourCanvas:
Canvas PipelineCanvas

Public Member Functions

 BehaviourCanvas (Flow *flow, std::shared_ptr< ConfigurationTable > configTable, std::shared_ptr< EdgeRouter > router, QObject *parent=nullptr)
 Constructs a BehaviourCanvas object.
virtual Types::LibraryTypes type () const override
 Retrieves the type of library associated with this canvas.
bool canAddTransition (NodeItem *node) const override
 Checkes whether it is possible to add a new trasition to a node.
TransitionConfig nextTransition (NodeItem *node) const override
 Gets the next transition configuration for a given node.
QVector< QGraphicsItem * > cleanTransitionsOfNode (const QString &nodeId) override
 Remove all transitions to and from a node with id nodeId.
void addTransition (TransitionItem *transition) override
 Add the TransitionItem to the Flow managed by this Canvas.
void removeTransition (TransitionItem *transition) override
 Removed the TransitionItem from the Flow managed by this Canvas.
void onNodeMoved (const NodeItem *node) override
 Callback triggered whenever a node moves significantly.
void setupInitialNodes ()
 Used to create the start and end nodes of a flow.
Public Member Functions inherited from Canvas
 Canvas (const QString &canvasId, std::shared_ptr< ConfigurationTable > configTable, std::shared_ptr< EdgeRouter > router, QObject *parent=nullptr)
 Constructs a new Canvas object.
QString id () const
 Returns the unique identifier for this canvas.
void pasteCopiedItems ()
 Pastes copied items onto the canvas.
void copySelectedItems (NodeItem *node)
 Copies selected items to the clipboard.
void deleteSelectedItems ()
 Deletes selected items from the canvas.
qreal getScale () const
 Returns the current scale of the canvas.
QPointF getCenter () const
 Returns the center position of the canvas.
VoidResult loadFromSave (const SaveInfo &info)
 Loads the canvas from save information.
QList< NodeItem * > availableNodes ()
 Returns a list of available node items.
QUndoStack * undoStack () const
 Returns a pointer to the undo stack associated with this canvas.
void nodeClicked (NodeItem *node)
 Handles node click events.
void populate (const FlowSaveInfo &flow)
 Populates the canvas with a given flow.
void themeChanged ()
 Handles theme change events.
void createNode (const NodeSaveInfo &info, NodeCreation creation)
 Creates a node based on save information.
void removeNode (const NodeSaveInfo &info)
 Removes a node based on save information.
void moveNodeTo (const QString &nodeId, const QPointF &position)
 Moves a node to a new position.
void setNodeSize (const QString &nodeId, const QSizeF &size)
 Sets the size of a node.
void createTransition (const TransitionSaveInfo &info)
 Creates a transition based on save information.
void removeTransition (const TransitionSaveInfo &info)
 Removes a transition based on save information.
void requestAlignNodes (const QList< Types::AlignmentNode > &items, Types::AlignmentMode mode, Types::AlignmentDirection direction)
 Requests alignment of nodes.
void alignNodes (const QList< Types::AlignmentNode > &items, Types::AlignmentMode mode, Types::AlignmentDirection direction, bool useGiven)
 Aligns nodes based on the given parameters.

Protected Member Functions

void cleanFlow ()
 Deletes the Flow managed by this Canvas. This should not be called if the Flow is created by a NodeItem.
Protected Member Functions inherited from Canvas
void dragEnterEvent (QGraphicsSceneDragDropEvent *event) override
 Handles drag enter events.
void dragMoveEvent (QGraphicsSceneDragDropEvent *event) override
 Handles drag move events.
void dropEvent (QGraphicsSceneDragDropEvent *event) override
 Handles drop events.
void mousePressEvent (QGraphicsSceneMouseEvent *event) override
 Handles mouse press events.
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override
 Handles mouse move events.
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override
 Handles mouse release events.
void contextMenuEvent (QGraphicsSceneContextMenuEvent *event) override
 Handles context menu events.
std::shared_ptr< NodeConfig > getNodeConfig (const QString &key) const
 Pointer to the undo stack.
NodeItem * createNode (NodeCreation creation, std::shared_ptr< NodeSaveInfo > info, const QPointF &position, NodeItem *parent)
 Creates a new node based on save information and other parameters.
CanvasView * parentView () const
 Returns the parent view of this canvas.

Private Member Functions

void updateParent (NodeItem *node, std::shared_ptr< NodeSaveInfo > storage, bool adding) override
 Updates the parent node of a given node item.

Private Attributes

Flow * mFlow
 A pointer to the Flow object associated with this canvas.

Additional Inherited Members

Public Slots inherited from Canvas
void onFocusNode (const QString &flowId, const QString &nodeId, const maki::FocusProperties &properties)
 Handles focus on a node.
void onRemoveNode (const QString &flowId, const QString &nodeId)
 Handles removal of a node.
void onFlowSelected (const QString &flowId, const QString &nodeId)
 Handles selection of a flow.
void onFlowRemoved (const QString &flowId, const QString &nodeId)
 Handles removal of a flow.
Signals inherited from Canvas
void nodeSelected (NodeItem *node, bool selected)
 Emitted when a node is selected.
void nodeAdded (NodeItem *node)
 Emitted when a node is added.
void nodeRemoved (const QString &nodeId, const QString &parentId)
 Emitted when a node is removed.
void nodeModified (NodeItem *node)
 Emitted when a node is modified.
void transitionSelected (TransitionItem *transtion)
 Emitted when a transition is selected.
void createEvent (NodeItem *node)
 Emitted when an event is created.
void openFlow (Flow *flow, const QString &nodeId, const maki::FocusProperties &properties)
 Emitted when a flow is opened.
void flowAdded (Flow *flow, NodeItem *node)
 Emitted when a flow is added.
void flowRemoved (const QString &flowId, NodeItem *node)
 Emitted when a flow is removed.
Protected Attributes inherited from Canvas
std::shared_ptr< EdgeRouter > mRouter
 Pointer to the configuration table.
QUndoStack * mUndoStack = nullptr
 Pointer to the system edge router.

Detailed Description

A specialized canvas for managing and displaying behavior-related nodes.

This class extends the Canvas class and provides functionality specific to handling behavior-related nodes in the system. It interacts with a single Flow object and utilizes storage and configuration data.

Constructor & Destructor Documentation

◆ BehaviourCanvas()

BehaviourCanvas::BehaviourCanvas ( Flow * flow,
std::shared_ptr< ConfigurationTable > configTable,
std::shared_ptr< EdgeRouter > router,
QObject * parent = nullptr )

Constructs a BehaviourCanvas object.

Parameters
flowA pointer to the Flow object associated with this canvas.
storageA shared pointer to the SaveInfo object for managing storage.
configTableA shared pointer to the ConfigurationTable for configuration data.
parentAn optional QObject parent for this canvas.

Member Function Documentation

◆ canAddTransition()

bool BehaviourCanvas::canAddTransition ( NodeItem * node) const
overridevirtual

Checkes whether it is possible to add a new trasition to a node.

Parameters
nodeA pointer to the node of interest
Returns
True if the node allows more transitions, and false otherwise.

Reimplemented from Canvas.

◆ nextTransition()

TransitionConfig BehaviourCanvas::nextTransition ( NodeItem * node) const
overridevirtual

Gets the next transition configuration for a given node.

This method assumes the caller already called canAddTransition

Parameters
nodeA pointer to the node of interest
Returns
The TransitionConfig object of the next allowed transition

Reimplemented from Canvas.

◆ type()

Types::LibraryTypes BehaviourCanvas::type ( ) const
overridevirtual

Retrieves the type of library associated with this canvas.

Returns
The library type as a value of Types::LibraryTypes.

Reimplemented from Canvas.

Reimplemented in PipelineCanvas.

◆ updateParent()

void BehaviourCanvas::updateParent ( NodeItem * node,
std::shared_ptr< NodeSaveInfo > storage,
bool adding )
overrideprivatevirtual

Updates the parent node of a given node item.

This method is used to update the parent-child relationship of nodes in the canvas.

Parameters
nodeA pointer to the NodeItem whose parent is being updated.
storageA shared pointer to the NodeSaveInfo object for managing node storage.
addingA boolean indicating whether the node is being added or removed.

Reimplemented from Canvas.


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