Loading...
Searching...
No Matches
TimeSyncModel.hpp
1#pragma once
2#include <State/Expression.hpp>
3
4#include <Process/Dataflow/TimeSignature.hpp>
5#include <Process/TimeValue.hpp>
6
7#include <Scenario/Document/Event/ExecutionStatus.hpp>
8#include <Scenario/Document/Metatypes.hpp>
9#include <Scenario/Document/VerticalExtent.hpp>
10
11#include <score/model/Component.hpp>
12#include <score/model/EntityImpl.hpp>
13#include <score/model/IdentifiedObject.hpp>
14#include <score/model/Identifier.hpp>
15#include <score/selection/Selectable.hpp>
16#include <score/tools/Metadata.hpp>
17#include <score/tools/std/Optional.hpp>
18
19#include <QObject>
20
21#include <score_plugin_scenario_export.h>
22
23#include <verdigris>
24class DataStream;
25class JSONObject;
26
27namespace Scenario
28{
29class EventModel;
30class ScenarioInterface;
31
32class SCORE_PLUGIN_SCENARIO_EXPORT TimeSyncModel final
33 : public score::Entity<TimeSyncModel>
34{
35 W_OBJECT(TimeSyncModel)
36
37 SCORE_SERIALIZE_FRIENDS
38
39public:
41 Selectable selection{this};
42
44 TimeSyncModel(const Id<TimeSyncModel>& id, const TimeVal& date, QObject* parent);
45
46 template <typename DeserializerVisitor>
47 TimeSyncModel(DeserializerVisitor&& vis, QObject* parent)
48 : Entity{vis, parent}
49 {
50 vis.writeTo(*this);
51 }
52
53 // Data of the TimeSync
54 const TimeVal& date() const noexcept;
57 double dateInFlicks() const noexcept { return date().impl; }
58 void setDate(const TimeVal&);
59
60 void addEvent(const Id<EventModel>&);
61 bool removeEvent(const Id<EventModel>&);
62 void clearEvents();
63
64 using EventIdVec = ossia::small_vector<Id<EventModel>, 2>;
65 const EventIdVec& events() const noexcept;
66 void setEvents(const TimeSyncModel::EventIdVec& events);
67
68 State::Expression expression() const noexcept { return m_expression; }
69 void setExpression(const State::Expression& expression);
70
71 bool active() const noexcept;
72 void setActive(bool active);
73
74 bool autotrigger() const noexcept;
75 void setAutotrigger(bool t);
76
77 bool isStartPoint() const noexcept;
78 void setStartPoint(bool t);
79
80 ossia::musical_sync musicalSync() const noexcept;
81 void setMusicalSync(ossia::musical_sync sig);
82
83 void setWaiting(bool);
84 bool waiting() const noexcept;
85
87 bool scriptable() const noexcept { return m_scriptable; }
88 void setScriptable(bool b);
89
90public:
91 void dateChanged(const TimeVal& arg_1)
92 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, dateChanged, arg_1)
93
94 void newEvent(const Id<Scenario::EventModel>& eventId)
95 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, newEvent, eventId)
96 void eventRemoved(const Id<Scenario::EventModel>& eventId)
97 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, eventRemoved, eventId)
98
99 void triggerChanged(const State::Expression& arg_1)
100 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, triggerChanged, arg_1)
101 void activeChanged() E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, activeChanged)
102
103 void autotriggerChanged(bool b)
104 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, autotriggerChanged, b)
105 void startPointChanged(bool b)
106 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, startPointChanged, b)
107 void scriptableChanged(bool b)
108 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, scriptableChanged, b)
109
110 void triggeredByGui() const E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, triggeredByGui)
111
112 void waitingChanged(bool b) const
113 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, waitingChanged, b)
114
115 double musicalSyncChanged(ossia::musical_sync sync)
116 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, musicalSyncChanged, sync)
117
118 PROPERTY(
119 ossia::musical_sync,
120 musicalSync READ musicalSync WRITE setMusicalSync NOTIFY musicalSyncChanged)
121 PROPERTY(double, date READ dateInFlicks NOTIFY dateChanged)
122 PROPERTY(bool, active READ active WRITE setActive NOTIFY activeChanged)
123 PROPERTY(
124 bool, autotrigger READ autotrigger WRITE setAutotrigger NOTIFY autotriggerChanged)
125 PROPERTY(
126 bool, startPoint READ isStartPoint WRITE setStartPoint NOTIFY startPointChanged)
127 PROPERTY(bool, scriptable READ scriptable WRITE setScriptable NOTIFY scriptableChanged)
128 PROPERTY(
129 State::Expression,
130 expression READ expression WRITE setExpression NOTIFY triggerChanged)
131
132private:
133 TimeVal m_date{};
134 State::Expression m_expression;
135
136 EventIdVec m_events;
137 ossia::musical_sync m_musicalSync{-1.};
138 bool m_active{false};
139 bool m_autotrigger{false};
140 bool m_startPoint{false};
141 bool m_scriptable{false};
142 bool m_waiting{false};
143};
144}
145
146DEFAULT_MODEL_METADATA(Scenario::TimeSyncModel, "Sync")
147TR_TEXT_METADATA(, Scenario::TimeSyncModel, PrettyName_k, "Sync")
Definition VisitorInterface.hpp:53
Definition VisitorInterface.hpp:61
Metadata to get the name that will be shown in the user interface.
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
Main plug-in of score.
Definition ConnectionsList.hpp:22
Utilities for OSSIA data structures.
Definition DeviceInterface.hpp:35
Definition TimeValue.hpp:21