Maki
Formally verfied low-code orchestration
Loading...
Searching...
No Matches
transition.h
1#pragma once
2
3#include <QGraphicsLineItem>
4#include <QGraphicsPathItem>
5
6#include "ids.h"
7
8class NodeItem;
10
14class TransitionItem : public QGraphicsPathItem
15{
16public:
20 enum class Edge
21 {
22 NONE = 0,
23 FORWARD,
24 BACKWARD,
25 ARC
26 };
27
32 TransitionItem(std::shared_ptr<TransitionSaveInfo> storage);
33
37 virtual ~TransitionItem();
38
43 QString id() const;
44
49 int type() const override;
50
57 void setStart(const QString& id, const QPointF& point, const QPointF& controlShift);
58
65 void setEnd(const QString& id, const QPointF& point, const QPointF& controlShift);
66
73
78 NodeItem* source() const;
79
84 NodeItem* destination() const;
85
91 void move(const QString& id, QPointF pos);
92
96 void updatePath(QPainterPath painterPath = {});
97
104 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
105
110 QPainterPath shape() const override;
111
116 TransitionSaveInfo saveInfo() const;
117
122 std::shared_ptr<TransitionSaveInfo> storage() const;
123
128 QString getName() const;
129
134 void setName(const QString& name);
135
140 QString getEvent() const;
141
146 void setEvent(const QString& name);
147
152 void setEdge(Edge edge);
153
154 // "signals":
155 std::function<void(TransitionItem* item)> transitionDeleted;
156 std::function<void(TransitionItem* item)> transitionModified;
157
158private:
159 const QString mId;
161
162 Edge mEdge = Edge::NONE;
163
166
167 QGraphicsTextItem* mLabel = nullptr;
168 std::shared_ptr<TransitionSaveInfo> mStorage;
169
170 void updateLabelPosition();
171};
Represents a graphical node item in a flowchart.
Definition node.h:26
Represents a transition between two nodes in a graphical representation.
Definition transition.h:15
void setEvent(const QString &name)
Sets the event associated with this transition.
Definition transition.cpp:235
void move(const QString &id, QPointF pos)
Moves the transition to a new position.
Definition transition.cpp:91
QPainterPath shape() const override
Retrieves the shape of this graphics item.
Definition transition.cpp:140
bool mComplete
Unique identifier for this transition.
Definition transition.h:160
void updateLabelPosition()
Shared pointer to the storage information.
Definition transition.cpp:202
std::function< void(TransitionItem *item)> transitionModified
Signal emitted when the transition is deleted.
Definition transition.h:156
NodeItem * source() const
Retrieves the source node of this transition.
Definition transition.cpp:81
std::shared_ptr< TransitionSaveInfo > mStorage
Pointer to the label text item.
Definition transition.h:168
void updatePath(QPainterPath painterPath={})
Updates the path of this transition item.
Definition transition.cpp:157
TransitionItem(std::shared_ptr< TransitionSaveInfo > storage)
Constructs a new TransitionItem with the given storage information.
Definition transition.cpp:12
Edge mEdge
Flag indicating if the transition is complete.
Definition transition.h:162
void setName(const QString &name)
Sets the name of this transition.
Definition transition.cpp:197
QString getName() const
Retrieves the name of this transition.
Definition transition.cpp:189
NodeItem * mSource
Type of edge used in the transition.
Definition transition.h:164
QString id() const
Retrieves the unique identifier of this transition item.
Definition transition.cpp:41
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
Paints this graphics item using the given painter.
Definition transition.cpp:112
void setStart(const QString &id, const QPointF &point, const QPointF &controlShift)
Sets the start point and control shift for the transition.
Definition transition.cpp:51
NodeItem * mDestination
Pointer to the source node item.
Definition transition.h:165
const QString mId
Signal emitted when the transition is modified.
Definition transition.h:159
QGraphicsTextItem * mLabel
Pointer to the destination node item.
Definition transition.h:167
void done(NodeItem *source, NodeItem *destination)
Completes the transition by setting source and destination nodes.
Definition transition.cpp:65
void setEdge(Edge edge)
Sets the type of edge for this transition.
Definition transition.cpp:76
Edge
Enumerates the types of edges that can be used for transitions.
Definition transition.h:21
int type() const override
Retrieves the type of this graphics item.
Definition transition.cpp:46
void setEnd(const QString &id, const QPointF &point, const QPointF &controlShift)
Sets the end point and control shift for the transition.
Definition transition.cpp:58
std::shared_ptr< TransitionSaveInfo > storage() const
Retrieves the shared pointer to the storage information.
Definition transition.cpp:147
TransitionSaveInfo saveInfo() const
Retrieves the save information for this transition.
Definition transition.cpp:152
QString getEvent() const
Retrieves the event associated with this transition.
Definition transition.cpp:230
NodeItem * destination() const
Retrieves the destination node of this transition.
Definition transition.cpp:86
Represents transition save information.
Definition transition_info.h:14