|
Maki
Formally verfied low-code orchestration
|
The Canvas class represents the main drawing area for nodes and transitions. More...
#include <canvas.h>
Classes | |
| struct | CopiedNode |
Public Slots | |
| 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 | |
| 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. | |
Public Member Functions | |
| 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. | |
| virtual Types::LibraryTypes | type () const |
| Returns the type of library this canvas belongs to. | |
| 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 | 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. | |
| virtual void | updateParent (NodeItem *node, std::shared_ptr< NodeSaveInfo > storage, bool adding) |
| Updates the parent of a node. | |
| 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. | |
Protected Attributes | |
| std::shared_ptr< EdgeRouter > | mRouter |
| Pointer to the configuration table. | |
| QUndoStack * | mUndoStack = nullptr |
| Pointer to the system edge router. | |
Private Member Functions | |
| void | clearCanvas () |
| Clears all items from the canvas. | |
| void | selectNode (NodeItem *node, bool select) |
| Selects a node and updates its selection state. | |
| NodeItem * | findNodeWithId (const QString &id) const |
| Finds a node by its ID. | |
| QList< NodeItem * > | selectedNodes () const |
| Returns a list of currently selected nodes. | |
| void | alignNodesHorizontally (const QList< Types::AlignmentNode > &items, Types::AlignmentDirection direction) |
| Aligns nodes horizontally based on the given parameters. | |
| void | alignNodesVertically (const QList< Types::AlignmentNode > &items, Types::AlignmentDirection direction) |
| Aligns nodes vertically based on the given parameters. | |
| QVector< QGraphicsItem * > | removeNode (NodeItem *node) |
| Creates a context menu for alignment options. | |
| void | clearSelectedNodes () |
| Removes a node and its associated connections. | |
| bool | isModifierSet (QGraphicsSceneMouseEvent *event, Qt::KeyboardModifier modifier) |
| Clears all selected nodes. | |
| bool | nodeClickHandler (QGraphicsSceneMouseEvent *event, QGraphicsItem *item) |
| Checks if a specific keyboard modifier is set. | |
| bool | transitionClickHandler (QGraphicsSceneMouseEvent *event, QGraphicsItem *item) |
| Handles node click events. | |
| void | createNodeContextMenu (QMenu *menu, NodeItem *node, const QList< NodeItem * > &items) |
| Handles transition click events. | |
| void | createTransitionContextMenu (QMenu *menu, const QList< NodeItem * > &items) |
| Creates a context menu for nodes. | |
| bool | isParentSelected (NodeItem *node) |
| Creates a context menu for transitions. | |
| void | pasteCopiedItems (const QPointF &mousePosition, NodeItem *parentNode, QList< CopiedNode > nodes, bool relative) |
| Checks if the parent of a node is selected. | |
| VoidResult | loadFromSave (const QVector< std::shared_ptr< INode > > &nodes, NodeItem *parent) |
| Pastes copied items at a specified position. | |
| void | onSelectionChanged () |
| Loads nodes and their children from save information. | |
Private Attributes | |
| TransitionItem * | mTransition = nullptr |
| Pointer to the hovered node. | |
| NodeItem * | mNode = nullptr |
| Pointer to the current transition being created. | |
| QPointF | mStartDragPosition |
| Pointer to the currently clicked node. | |
| bool | mDragging = false |
| The starting position of a drag operation. | |
| bool | mMouseDown = false |
| Whether a drag operation is in progress. | |
| QPointF | mSelectionStart |
| Whether the mouse button is pressed. | |
| QList< CopiedNode > | mCopiedNodes |
| Unique identifier for this canvas. | |
| QList< NodeItem * > | mSelectedNodes |
| List of copied nodes. | |
| NodeItem * | mSuggestionSourceNode = nullptr |
| List of currently selected nodes. | |
The Canvas class represents the main drawing area for nodes and transitions.
| Canvas::Canvas | ( | const QString & | canvasId, |
| std::shared_ptr< ConfigurationTable > | configTable, | ||
| std::shared_ptr< EdgeRouter > | router, | ||
| QObject * | parent = nullptr ) |
Constructs a new Canvas object.
| canvasId | The unique identifier for this canvas. |
| storage | Shared pointer to the save information. |
| configTable | Shared pointer to the configuration table. |
| parent | Pointer to the parent object. |
| void Canvas::alignNodes | ( | const QList< Types::AlignmentNode > & | items, |
| Types::AlignmentMode | mode, | ||
| Types::AlignmentDirection | direction, | ||
| bool | useGiven ) |
Aligns nodes based on the given parameters.
| items | List of alignment nodes. |
| mode | The alignment mode. |
| direction | The alignment direction. |
| useGiven | Whether to use the given positions for alignment. |
|
private |
Aligns nodes horizontally based on the given parameters.
| items | List of alignment nodes. |
| direction | The alignment direction. |
|
private |
Aligns nodes vertically based on the given parameters.
| items | List of alignment nodes. |
| direction | The alignment direction. |
| QList< NodeItem * > Canvas::availableNodes | ( | ) |
Returns a list of available node items.
|
overrideprotected |
Handles context menu events.
| event | Pointer to the QGraphicsSceneContextMenuEvent. |
| void Canvas::copySelectedItems | ( | NodeItem * | node | ) |
Copies selected items to the clipboard.
| node | Pointer to the clicked node, if any. |
|
signal |
Emitted when an event is created.
| node | Pointer to the node where the event is created. |
| void Canvas::createNode | ( | const NodeSaveInfo & | info, |
| NodeCreation | creation ) |
Creates a node based on save information.
| info | The save information for the node. |
|
protected |
Creates a new node based on save information and other parameters.
| creation | The type of node creation (e.g., dropping, pasting). |
| info | Shared pointer to the save information for the node. |
| position | The initial position of the node. |
| parent | Pointer to the parent node. |
| void Canvas::createTransition | ( | const TransitionSaveInfo & | info | ) |
Creates a transition based on save information.
| info | The save information for the transition. |
|
overrideprotected |
Handles drag enter events.
| event | Pointer to the QGraphicsSceneDragDropEvent. |
|
overrideprotected |
Handles drag move events.
| event | Pointer to the QGraphicsSceneDragDropEvent. |
|
overrideprotected |
Handles drop events.
| event | Pointer to the QGraphicsSceneDragDropEvent. |
|
private |
Finds a node by its ID.
| id | The ID of the node to find. |
Emitted when a flow is added.
| flow | Pointer to the added flow. |
| node | Pointer to the node associated with the flow. |
|
signal |
Emitted when a flow is removed.
| flowId | The ID of the removed flow. |
| nodeId | The ID of the node associated with the flow. |
| QPointF Canvas::getCenter | ( | ) | const |
Returns the center position of the canvas.
| qreal Canvas::getScale | ( | ) | const |
Returns the current scale of the canvas.
| QString Canvas::id | ( | ) | const |
Returns the unique identifier for this canvas.
| VoidResult Canvas::loadFromSave | ( | const SaveInfo & | info | ) |
Loads the canvas from save information.
| info | The save information to load. |
|
overrideprotected |
Handles mouse move events.
| event | Pointer to the QGraphicsSceneMouseEvent. |
|
overrideprotected |
Handles mouse press events.
| event | Pointer to the QGraphicsSceneMouseEvent. |
|
overrideprotected |
Handles mouse release events.
| event | Pointer to the QGraphicsSceneMouseEvent. |
| void Canvas::moveNodeTo | ( | const QString & | nodeId, |
| const QPointF & | position ) |
Moves a node to a new position.
| nodeId | The ID of the node to move. |
| position | The new position for the node. |
|
signal |
Emitted when a node is added.
| node | Pointer to the added node. |
| void Canvas::nodeClicked | ( | NodeItem * | node | ) |
Handles node click events.
| node | Pointer to the clicked node. |
|
signal |
Emitted when a node is modified.
| node | Pointer to the modified node. |
|
signal |
Emitted when a node is removed.
| nodeId | The ID of the removed node. |
| parentId | The ID of the parent node. |
|
signal |
Emitted when a node is selected.
| node | Pointer to the selected node. |
| selected | Whether the node is selected or not. |
|
slot |
Handles removal of a flow.
| flowId | The ID of the removed flow. |
| nodeId | The ID of the node associated with the flow. |
|
slot |
Handles selection of a flow.
| flowId | The ID of the selected flow. |
| nodeId | The ID of the node associated with the flow. |
|
slot |
Handles focus on a node.
| flowId | The ID of the flow that contains the given node. |
| nodeId | The ID of the focused node. |
|
slot |
Handles removal of a node.
| nodeId | The ID of the node to remove. |
|
signal |
Emitted when a flow is opened.
| flow | Pointer to the opened flow. |
| node | Pointer to the node associated with the flow. |
|
protected |
Returns the parent view of this canvas.
| void Canvas::populate | ( | const FlowSaveInfo & | flow | ) |
Populates the canvas with a given flow.
| flow | Pointer to the flow to populate. |
| void Canvas::removeNode | ( | const NodeSaveInfo & | info | ) |
Removes a node based on save information.
| info | The save information for the node. |
| void Canvas::removeTransition | ( | const TransitionSaveInfo & | info | ) |
Removes a transition based on save information.
| info | The save information for the transition. |
| void Canvas::requestAlignNodes | ( | const QList< Types::AlignmentNode > & | items, |
| Types::AlignmentMode | mode, | ||
| Types::AlignmentDirection | direction ) |
Requests alignment of nodes.
| items | List of alignment nodes. |
| mode | The alignment mode. |
| direction | The alignment direction. |
|
private |
Returns a list of currently selected nodes.
|
private |
Selects a node and updates its selection state.
| node | Pointer to the node to select. |
| select | Whether to select or deselect the node. |
| void Canvas::setNodeSize | ( | const QString & | nodeId, |
| const QSizeF & | size ) |
Sets the size of a node.
| nodeId | The ID of the node to resize. |
| size | The new size for the node. |
|
signal |
Emitted when a transition is selected.
| transtion | Pointer to the selected transition. |
|
virtual |
Returns the type of library this canvas belongs to.
Reimplemented in BehaviourCanvas, PipelineCanvas, and StructureCanvas.
| QUndoStack * Canvas::undoStack | ( | ) | const |
Returns a pointer to the undo stack associated with this canvas.
|
protectedvirtual |
Updates the parent of a node.
| node | Pointer to the node. |
| storage | Shared pointer to the save information. |
| adding | Whether this is an addition or removal. |
Reimplemented in BehaviourCanvas, and StructureCanvas.