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
86public:
87 void dateChanged(const TimeVal& arg_1)
88 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, dateChanged, arg_1)
89
90 void newEvent(const Id<Scenario::EventModel>& eventId)
91 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, newEvent, eventId)
92 void eventRemoved(const Id<Scenario::EventModel>& eventId)
93 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, eventRemoved, eventId)
94
95 void triggerChanged(const State::Expression& arg_1)
96 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, triggerChanged, arg_1)
97 void activeChanged() E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, activeChanged)
98
99 void autotriggerChanged(bool b)
100 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, autotriggerChanged, b)
101 void startPointChanged(bool b)
102 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, startPointChanged, b)
103
104 void triggeredByGui() const E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, triggeredByGui)
105
106 void waitingChanged(bool b) const
107 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, waitingChanged, b)
108
109 double musicalSyncChanged(ossia::musical_sync sync)
110 E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, musicalSyncChanged, sync)
111
112 PROPERTY(
113 ossia::musical_sync,
114 musicalSync READ musicalSync WRITE setMusicalSync NOTIFY musicalSyncChanged)
115 PROPERTY(double, date READ dateInFlicks NOTIFY dateChanged)
116 PROPERTY(bool, active READ active WRITE setActive NOTIFY activeChanged)
117 PROPERTY(
118 bool, autotrigger READ autotrigger WRITE setAutotrigger NOTIFY autotriggerChanged)
119 PROPERTY(
120 bool, startPoint READ isStartPoint WRITE setStartPoint NOTIFY startPointChanged)
121 PROPERTY(
122 State::Expression,
123 expression READ expression WRITE setExpression NOTIFY triggerChanged)
124
125private:
126 TimeVal m_date{};
127 State::Expression m_expression;
128
129 EventIdVec m_events;
130 ossia::musical_sync m_musicalSync{-1.};
131 bool m_active{false};
132 bool m_autotrigger{false};
133 bool m_startPoint{false};
134 bool m_waiting{false};
135};
136}
137
138DEFAULT_MODEL_METADATA(Scenario::TimeSyncModel, "Sync")
139TR_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 score-plugin-dataflow/Dataflow/PortItem.hpp:13
Utilities for OSSIA data structures.
Definition DeviceInterface.hpp:35
Definition TimeValue.hpp:21