CommandAPI.hpp
1 #pragma once
2 #include <Process/ProcessMimeSerialization.hpp>
3 
4 #include <Scenario/Palette/ScenarioPoint.hpp>
5 #include <Scenario/Process/ScenarioModel.hpp>
6 
7 #include <Dataflow/Commands/CableHelpers.hpp>
8 
9 #include <score/command/AggregateCommand.hpp>
10 #include <score/command/Dispatchers/MacroCommandDispatcher.hpp>
11 #include <score/command/PropertyCommand.hpp>
12 #include <score/document/DocumentContext.hpp>
13 
14 #include <ossia/detail/span.hpp>
15 
16 #include <memory>
17 
18 namespace Curve
19 {
20 struct CurveDomain;
21 }
22 namespace Scenario
23 {
24 class ScenarioDocumentModel;
25 namespace Command
26 {
27 class SCORE_PLUGIN_SCENARIO_EXPORT Macro
28 {
30 
31 public:
33  ~Macro();
34 
35  StateModel&
36  createState(const Scenario::ProcessModel& scenar, const Id<EventModel>& ev, double y);
37 
38  std::tuple<TimeSyncModel&, EventModel&, StateModel&>
39  createDot(const Scenario::ProcessModel& scenar, Scenario::Point pt);
40 
42  createBox(const Scenario::ProcessModel& scenar, TimeVal start, TimeVal end, double y);
43 
44  IntervalModel& createIntervalAfter(
45  const Scenario::ProcessModel& scenar, const Id<Scenario::StateModel>& state,
46  Scenario::Point pt);
47 
48  IntervalModel& createInterval(
49  const Scenario::ProcessModel& scenar, const Id<Scenario::StateModel>& start,
50  const Id<Scenario::StateModel>& end);
51 
52  Process::ProcessModel* createProcess(
54  const QString& data);
55 
56  Process::ProcessModel* createProcess(
57  const Scenario::IntervalModel& interval, const UuidKey<Process::ProcessModel>& key,
58  const QString& data, const QPointF& pos);
59 
60  Process::ProcessModel* createProcess(
61  const Scenario::IntervalModel& interval, const Process::ProcessData& data,
62  const QPointF& pos);
63 
64  template <typename T>
65  T& createProcess(
66  const Scenario::IntervalModel& interval, const QString& data, const QPointF& pos)
67  {
68  return *safe_cast<T*>(
69  this->createProcess(interval, Metadata<ConcreteKey_k, T>::get(), data, pos));
70  }
71 
72  Process::ProcessModel* createProcessInNewSlot(
73  const Scenario::IntervalModel& interval, const UuidKey<Process::ProcessModel>& key,
74  const QString& data);
75 
76  Process::ProcessModel* createProcessInNewSlot(
77  const Scenario::IntervalModel& interval, const UuidKey<Process::ProcessModel>& key,
78  const QString& data, const QPointF& pos);
79 
80  Process::ProcessModel* createProcessInNewSlot(
81  const Scenario::IntervalModel& interval, const Process::ProcessData& data);
82  Process::ProcessModel* createProcessInNewSlot(
83  const Scenario::IntervalModel& interval, const Process::ProcessData& data,
84  const QPointF& pos);
85 
86  template <typename T>
87  T& createProcessInNewSlot(const Scenario::IntervalModel& interval, const QString& data)
88  {
89  return *safe_cast<T*>(
90  this->createProcessInNewSlot(interval, Metadata<ConcreteKey_k, T>::get(), data));
91  }
92 
94  loadProcess(const Scenario::IntervalModel& interval, const rapidjson::Value& procdata);
95  Process::ProcessModel* loadProcessInSlot(
96  const Scenario::IntervalModel& interval, const rapidjson::Value& procdata);
97  Process::ProcessModel* loadProcessFromPreset(
98  const IntervalModel& interval, const Process::Preset& preset,
99  QPointF pos = QPointF{});
100 
101  void createViewForNewProcess(
102  const IntervalModel& interval, const Process::ProcessModel& proc);
103 
104  void clearInterval(const Scenario::IntervalModel&);
105 
106  void resizeInterval(const IntervalModel& itv, const TimeVal& dur);
107 
108  void setIntervalMin(const IntervalModel& itv, const TimeVal& dur, bool noMin);
109 
110  void setIntervalMax(const IntervalModel& itv, const TimeVal& dur, bool infinite);
111 
112  void createSlot(const Scenario::IntervalModel& interval);
113 
114  void addLayer(
115  const Scenario::IntervalModel& interval, int slot_index,
116  const Process::ProcessModel& proc);
117 
118  void addLayerToLastSlot(
119  const Scenario::IntervalModel& interval, const Process::ProcessModel& proc);
120 
121  void addLayerInNewSlot(
122  const Scenario::IntervalModel& interval, const Process::ProcessModel& proc);
123 
124  void addLayer(const Scenario::SlotPath& slotpath, const Process::ProcessModel& proc);
125 
126  void showRack(const Scenario::IntervalModel& interval);
127 
128  void resizeSlot(
129  const Scenario::IntervalModel& interval, const SlotPath& slotPath, double newSize);
130 
131  void resizeSlot(
132  const Scenario::IntervalModel& interval, SlotPath&& slotPath, double newSize);
133 
135  duplicate(const Scenario::ProcessModel& scenario, const Scenario::IntervalModel& itv);
136 
137  Process::ProcessModel& duplicateProcess(
138  const Scenario::IntervalModel& itv, const Process::ProcessModel& process);
139 
140  void pasteElements(
141  const Scenario::ProcessModel& scenario, const rapidjson::Value& objs,
142  Scenario::Point pos);
143 
144  void pasteElementsAfter(
145  const ProcessModel& scenario, const TimeSyncModel& sync,
146  const rapidjson::Value& objs, double scale);
147 
148  void mergeTimeSyncs(
149  const Scenario::ProcessModel& scenario, const Id<TimeSyncModel>& a,
150  const Id<TimeSyncModel>& b);
151 
152  void moveProcess(
153  const Scenario::IntervalModel& old_interval,
154  const Scenario::IntervalModel& new_interval,
155  const Id<Process::ProcessModel>& proc);
156 
157  void moveSlot(
158  const IntervalModel& old_interval, const IntervalModel& new_interval,
159  int slot_idx);
160 
161  void removeProcess(
162  const Scenario::IntervalModel& interval, const Id<Process::ProcessModel>& proc);
163 
164  Process::Cable& createCable(
165  const Scenario::ScenarioDocumentModel& dp, const Process::Port& source,
166  const Process::Port& sink);
167 
168  void
169  removeCable(const Scenario::ScenarioDocumentModel& dp, const Process::Cable& theCable);
170 
171  void loadCables(const ObjectPath& parent, const Dataflow::SerializedCables& c);
172  void removeElements(const Scenario::ProcessModel& scenario, const Selection& sel);
173 
174  void addMessages(const Scenario::StateModel& state, State::MessageList msgs);
175 
176  void findAndReplace(
177  tcb::span<QObject*> sel, const State::Address& oldRoot,
178  const State::Address& newRoot);
179 
180  std::vector<Process::ProcessModel*>
181  automate(const Scenario::IntervalModel& scenar, const QString& addr);
182 
184  automate(const Scenario::IntervalModel& parent, const Process::Inlet& port);
185 
186  Process::ProcessModel& automate(
187  const IntervalModel& interval, const std::vector<SlotPath>& slotList,
189  const Curve::CurveDomain& dom, bool tween);
190 
191  template <typename Property, typename T, typename U>
192  void setProperty(const T& object, U&& value)
193  {
194  auto cmd
195  = new typename score::PropertyCommand_T<Property>::template command<void>::type{
196  object, std::forward<U>(value)};
197  m.submit(cmd);
198  }
199 
200  void submit(score::Command* cmd);
201  void commit();
202 };
203 }
204 }
The MacroCommandDispatcher class.
Definition: MacroCommandDispatcher.hpp:18
The ObjectPath class.
Definition: ObjectPath.hpp:37
Definition: Cable.hpp:38
Definition: Port.hpp:177
Definition: Port.hpp:102
The Process class.
Definition: score-lib-process/Process/Process.hpp:61
Definition: CommandAPI.hpp:28
Definition: IntervalModel.hpp:50
The core hierarchical and temporal process of score.
Definition: ScenarioModel.hpp:37
Definition: ScenarioDocumentModel.hpp:29
Definition: StateModel.hpp:63
Definition: TimeSyncModel.hpp:34
Definition: Selection.hpp:12
The id_base_t class.
Definition: Identifier.hpp:57
Allows for grouping of multiple commands in a single one.
Definition: AggregateCommand.hpp:15
The Command class.
Definition: Command.hpp:34
Definition: PropertyCommand.hpp:58
Utilities and base classes for 1D curves.
Definition: FocusDispatcher.hpp:12
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Definition: CurveModel.hpp:104
Static metadata implementation.
Definition: lib/score/tools/Metadata.hpp:36
Definition: Preset.hpp:32
Definition: ProcessMimeSerialization.hpp:38
Definition: ScenarioPoint.hpp:13
Definition: Slot.hpp:54
Definition: Address.hpp:108
The Address struct.
Definition: Address.hpp:58
Definition: TimeValue.hpp:21
Definition: DocumentContext.hpp:18