Maki
Formally verified 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#include "types.h"
8
9class NodeItem;
11
15class TransitionItem : public QGraphicsPathItem
16{
17public:
21 enum class Edge
22 {
23 NONE = 0,
24 FORWARD,
25 BACKWARD,
26 ARC
27 };
28
33 explicit TransitionItem(std::shared_ptr<TransitionSaveInfo> storage);
34
38 virtual ~TransitionItem();
39
44 QString id() const;
45
50 int type() const override;
51
58 void setStart(const QString& id, const QPointF& point, const QPointF& controlShift, const Types::Port& port, const QString& subflow);
59
66 void setEnd(const QString& id, const QPointF& point, const QPointF& controlShift, const Types::Port& port, const QString& subflow);
67
74
79 NodeItem* source() const;
80
85 NodeItem* destination() const;
86
92 void move(const QString& id, QPointF pos);
93
97 void updatePath(QPainterPath painterPath = {});
98
105 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
106
111 QPainterPath shape() const override;
112
117 TransitionSaveInfo saveInfo() const;
118
123 std::shared_ptr<TransitionSaveInfo> storage() const;
124
129 QString getName() const;
130
135 void setName(const QString& name);
136
141 QString getEvent() const;
142
147 void setEvent(const QString& name);
148
153 void setEdge(Edge edge);
154
155 QPointF sourceAnchor() const;
156 QPointF destinationAnchor() const;
157
158 // "signals":
159 std::function<void(TransitionItem* item)> transitionDeleted;
160 std::function<void(TransitionItem* item)> transitionModified;
161
162private:
163 const QString mId;
165
166 Edge mEdge = Edge::NONE;
167
170
171 QGraphicsTextItem* mLabel = nullptr;
172 std::shared_ptr<TransitionSaveInfo> mStorage;
173
174 void updateLabelPosition();
175};
Represents a graphical node item in a flowchart.
Definition node.h:28
Represents a transition between two nodes in a graphical representation.
Definition transition.h:16
void setEvent(const QString &name)
Sets the event associated with this transition.
Definition transition.cpp:254
void move(const QString &id, QPointF pos)
Moves the transition to a new position.
Definition transition.cpp:93
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:164
void updateLabelPosition()
Shared pointer to the storage information.
Definition transition.cpp:222
std::function< void(TransitionItem *item)> transitionModified
Signal emitted when the transition is deleted.
Definition transition.h:160
NodeItem * source() const
Retrieves the source node of this transition.
Definition transition.cpp:83
std::shared_ptr< TransitionSaveInfo > mStorage
Pointer to the label text item.
Definition transition.h:172
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:166
void setName(const QString &name)
Sets the name of this transition.
Definition transition.cpp:217
QString getName() const
Retrieves the name of this transition.
Definition transition.cpp:209
NodeItem * mSource
Type of edge used in the transition.
Definition transition.h:168
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:115
NodeItem * mDestination
Pointer to the source node item.
Definition transition.h:169
const QString mId
Signal emitted when the transition is modified.
Definition transition.h:163
QGraphicsTextItem * mLabel
Pointer to the destination node item.
Definition transition.h:171
void done(NodeItem *source, NodeItem *destination)
Completes the transition by setting source and destination nodes.
Definition transition.cpp:69
void setEdge(Edge edge)
Sets the type of edge for this transition.
Definition transition.cpp:78
Edge
Enumerates the types of edges that can be used for transitions.
Definition transition.h:22
int type() const override
Retrieves the type of this graphics item.
Definition transition.cpp:46
void setStart(const QString &id, const QPointF &point, const QPointF &controlShift, const Types::Port &port, const QString &subflow)
Sets the start point and control shift for the transition.
Definition transition.cpp:51
void setEnd(const QString &id, const QPointF &point, const QPointF &controlShift, const Types::Port &port, const QString &subflow)
Sets the end point and control shift for the transition.
Definition transition.cpp:60
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:249
NodeItem * destination() const
Retrieves the destination node of this transition.
Definition transition.cpp:88
Represents transition save information.
Definition transition_info.h:14