Loading...
Searching...
No Matches
EventModel.hpp
1#pragma once
2#include <State/Expression.hpp>
3
4#include <Process/TimeValue.hpp>
5
6#include <Scenario/Document/Event/ExecutionStatus.hpp>
7#include <Scenario/Document/Metatypes.hpp>
8
9#include <score/model/Component.hpp>
10#include <score/model/EntityImpl.hpp>
11#include <score/model/IdentifiedObject.hpp>
12#include <score/model/Identifier.hpp>
13#include <score/selection/Selectable.hpp>
14#include <score/tools/Metadata.hpp>
15#include <score/tools/std/Optional.hpp>
16
17#include <score_plugin_scenario_export.h>
18
19#include <verdigris>
20class DataStream;
21class JSONObject;
22class QObject;
23
24namespace Process
25{
26struct Style;
27}
28
29namespace Scenario
30{
31class StateModel;
32class ScenarioInterface;
33class TimeSyncModel;
34
35class SCORE_PLUGIN_SCENARIO_EXPORT EventModel final : public score::Entity<EventModel>
36{
37 W_OBJECT(EventModel)
38
39 SCORE_SERIALIZE_FRIENDS
40
41public:
43 Selectable selection{this};
44
47 const Id<EventModel>&, const Id<TimeSyncModel>& timesync, const TimeVal& date,
48 QObject* parent);
49
50 template <typename DeserializerVisitor>
51 EventModel(DeserializerVisitor&& vis, QObject* parent)
52 : Entity{vis, parent}
53 {
54 vis.writeTo(*this);
55 }
56
57 // Timenode
58 void changeTimeSync(const Id<TimeSyncModel>& elt);
59 const Id<TimeSyncModel>& timeSync() const noexcept { return m_timeSync; }
60
61 // States
62 void addState(const Id<StateModel>& ds);
63 void removeState(const Id<StateModel>& ds);
64 void clearStates();
65 using StateIdVec = ossia::small_vector<Id<StateModel>, 2>;
66 const StateIdVec& states() const noexcept;
67
68 // Other properties
69 const State::Expression& condition() const noexcept;
70 OffsetBehavior offsetBehavior() const noexcept;
71 const TimeVal& date() const noexcept;
73 double dateInFlicks() const noexcept { return date().impl; }
74 void translate(const TimeVal& deltaTime);
75 ExecutionStatus status() const noexcept;
76
77 bool active() const noexcept;
78
80 bool scriptable() const noexcept { return m_scriptable; }
81 void setScriptable(bool b);
82
83 void setCondition(const State::Expression& arg);
84 void setDate(const TimeVal& date);
85 void setStatus(Scenario::ExecutionStatus status, const Scenario::ScenarioInterface&);
86 void setOffsetBehavior(Scenario::OffsetBehavior);
87
88 const QBrush& color(const Process::Style&) const noexcept;
89
90public:
91 void dateChanged(const TimeVal& arg_1)
92 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, dateChanged, arg_1)
93 void conditionChanged(const State::Expression& arg_1)
94 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, conditionChanged, arg_1)
95 void statesChanged() E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, statesChanged)
96 void statusChanged(Scenario::ExecutionStatus status)
97 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, statusChanged, status)
98 void offsetBehaviorChanged(OffsetBehavior arg_1)
99 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, offsetBehaviorChanged, arg_1)
100 void scriptableChanged(bool b)
101 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, scriptableChanged, b)
102 void
103 timeSyncChanged(Id<Scenario::TimeSyncModel> oldt, Id<Scenario::TimeSyncModel> newt)
104 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, timeSyncChanged, oldt, newt)
105
106 PROPERTY(bool, scriptable READ scriptable WRITE setScriptable NOTIFY scriptableChanged)
107
108private:
109 Id<TimeSyncModel> m_timeSync;
110 StateIdVec m_states;
111 State::Expression m_condition;
112 TimeVal m_date{TimeVal::zero()};
113
114 ExecutionStatusProperty m_status{};
115 OffsetBehavior m_offset{};
116 bool m_scriptable{};
117
118 PROPERTY(double, date READ dateInFlicks NOTIFY dateChanged)
119
120 W_PROPERTY(
121 Scenario::OffsetBehavior,
122 offsetBehavior READ offsetBehavior WRITE setOffsetBehavior NOTIFY
123 offsetBehaviorChanged,
124 W_Final)
125};
126}
127
128DEFAULT_MODEL_METADATA(Scenario::EventModel, "Event")
129TR_TEXT_METADATA(, Scenario::EventModel, PrettyName_k, "Event")
Definition VisitorInterface.hpp:53
Definition VisitorInterface.hpp:61
Metadata to get the name that will be shown in the user interface.
Definition EventModel.hpp:36
Definition ScenarioInterface.hpp:20
Definition TimeSyncModel.hpp:34
The Selectable class.
Definition Selectable.hpp:14
The id_base_t class.
Definition Identifier.hpp:59
Base for complex model objects.
Definition EntityBase.hpp:24
Base classes and tools to implement processes and layers.
Definition JSONVisitor.hpp:1115
Main plug-in of score.
Definition ConnectionsList.hpp:22
Utilities for OSSIA data structures.
Definition DeviceInterface.hpp:35
Definition ScenarioStyle.hpp:13
Definition TimeValue.hpp:21