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
79 void setCondition(const State::Expression& arg);
80 void setDate(const TimeVal& date);
81 void setStatus(Scenario::ExecutionStatus status, const Scenario::ScenarioInterface&);
82 void setOffsetBehavior(Scenario::OffsetBehavior);
83
84 const QBrush& color(const Process::Style&) const noexcept;
85
86public:
87 void dateChanged(const TimeVal& arg_1)
88 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, dateChanged, arg_1)
89 void conditionChanged(const State::Expression& arg_1)
90 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, conditionChanged, arg_1)
91 void statesChanged() E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, statesChanged)
92 void statusChanged(Scenario::ExecutionStatus status)
93 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, statusChanged, status)
94 void offsetBehaviorChanged(OffsetBehavior arg_1)
95 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, offsetBehaviorChanged, arg_1)
96 void
97 timeSyncChanged(Id<Scenario::TimeSyncModel> oldt, Id<Scenario::TimeSyncModel> newt)
98 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, timeSyncChanged, oldt, newt)
99
100private:
101 Id<TimeSyncModel> m_timeSync;
102 StateIdVec m_states;
103 State::Expression m_condition;
104 TimeVal m_date{TimeVal::zero()};
105
106 ExecutionStatusProperty m_status{};
107 OffsetBehavior m_offset{};
108
109 PROPERTY(double, date READ dateInFlicks NOTIFY dateChanged)
110
111 W_PROPERTY(
112 Scenario::OffsetBehavior,
113 offsetBehavior READ offsetBehavior WRITE setOffsetBehavior NOTIFY
114 offsetBehaviorChanged,
115 W_Final)
116};
117}
118
119DEFAULT_MODEL_METADATA(Scenario::EventModel, "Event")
120TR_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 score-plugin-dataflow/Dataflow/PortItem.hpp:13
Utilities for OSSIA data structures.
Definition DeviceInterface.hpp:35
Definition TimeValue.hpp:21