Loading...
Searching...
No Matches
EditContext.hpp
1#pragma once
2#include <Process/Dataflow/CableData.hpp>
3#include <Process/TimeValue.hpp>
4
5#include <score/document/DocumentContext.hpp>
6
7#include <ossia-qt/js_utilities.hpp>
8
9#include <QJSValue>
10#include <QList>
11#include <QObject>
12#include <QStringList>
13#include <QVariant>
14
15#include <score_plugin_js_export.h>
16
17#include <memory>
18#include <verdigris>
19namespace score
20{
21struct DocumentContext;
22class Command;
23}
24namespace Scenario::Command
25{
26class Macro;
27}
28namespace JS
29{
30class GlobalDeviceEnumerator;
31class DeviceListener;
32class SCORE_PLUGIN_JS_EXPORT EditJsContext : public QObject
33{
34 W_OBJECT(EditJsContext)
36
37 std::unique_ptr<Macro> m_macro;
38 struct MacroClear
39 {
41 std::unique_ptr<Macro>& macro;
42 bool clearOnDelete{};
43 ~MacroClear();
44 };
45
46 MacroClear macro(const score::DocumentContext& doc);
47
48public:
51
55 const score::DocumentContext* ctx();
56 W_INVOKABLE(ctx);
57
61 QObject* device(QString name);
62 W_SLOT(device)
63
64 QString deviceToJson(QString addr);
65 W_SLOT(deviceToJson)
66
67 QString deviceToOSCQuery(QString addr);
68 W_SLOT(deviceToOSCQuery)
69
70 void createDevice(QString name, QString uuid, QJSValue obj);
71 W_SLOT(createDevice, (QString, QString, QJSValue))
72
73 void createDevice(QString name, QString uuid, QVariant obj);
74 W_SLOT(createDevice, (QString, QString, QVariant))
75
76 void createOSCDevice(QString name, QString host, int in, int out);
77 W_SLOT(createOSCDevice)
78
79 void connectOSCQueryDevice(QString name, QString host);
80 W_SLOT(connectOSCQueryDevice)
81
82 void removeDevice(QString name);
83 W_SLOT(removeDevice)
84
85 void createQMLWebSocketDevice(QString name, QString text);
86 W_SLOT(createQMLWebSocketDevice)
87
88 void createQMLSerialDevice(QString name, QString port, QString text);
89 W_SLOT(createQMLSerialDevice)
90
91 GlobalDeviceEnumerator* enumerateDevices();
92 W_SLOT(enumerateDevices, ())
93
94 GlobalDeviceEnumerator* enumerateDevices(const QString& protocol);
95 W_SLOT(enumerateDevices, (const QString&))
96
97 GlobalDeviceEnumerator* enumerateDevices(const QStringList& protocols);
98 W_SLOT(enumerateDevices, (const QStringList&))
99
100 DeviceListener* listenDevice(const QString& name);
101 W_SLOT(listenDevice, (const QString&))
102
103 void iterateDevice(const QString& name, const QJSValue& op);
104 W_SLOT(iterateDevice, (const QString&, const QJSValue&))
105
106 void setDeviceLearn(const QString& name, bool learn);
107 W_SLOT(setDeviceLearn, (const QString&, bool))
111 void createAddress(QString addr, QString type);
112 W_SLOT(createAddress)
113
114
117 void setUnit(QString addr, QString unit);
118 W_SLOT(setUnit)
119
120 QObject* createProcess(QObject* interval, QString name, QString data);
121 W_SLOT(createProcess)
122
123
124 int processes(QObject* obj);
125 W_SLOT(processes)
126
127
129 QObject* process(QObject* obj, int index);
130 W_SLOT(process)
131
132
135 QObject* parentProcess(QObject* obj);
136 W_SLOT(parentProcess)
137
138
140 QObject* parentInterval(QObject* obj);
141 W_SLOT(parentInterval)
142
143 void loadPreset(QObject* process, QString json);
144 W_SLOT(loadPreset)
145 QString savePreset(QObject* process);
146 W_SLOT(savePreset)
147
148 void setName(QObject* sel, QString new_name);
149 W_SLOT(setName)
150
151 QObject* createBox(QObject* obj, QString startTime, QString duration, double y);
152 W_SLOT(createBox, (QObject*, QString, QString, double))
153
154 QObject*
155 createBox(QObject* obj, double startTimeFlicks, double durationFlicks, double y);
156 W_SLOT(createBox, (QObject*, double, double, double))
157
158 QObject* createState(QObject* ev, double y);
159 W_SLOT(createState)
160
161 QObject* createIntervalAfter(QObject* obj, QString duration, double y);
162 W_SLOT(createIntervalAfter)
163
164 QObject* createIntervalBetween(QObject* startState, QObject* endState);
165 W_SLOT(createIntervalBetween)
166
167 // Triggers and conditions.
168 // A trigger lives on a time sync; intervals (their end), states and events
169 // resolve to theirs. A condition lives on an event; states resolve to theirs.
170 void enableTrigger(QObject* obj);
171 W_SLOT(enableTrigger)
172 void disableTrigger(QObject* obj);
173 W_SLOT(disableTrigger)
174 void enableCondition(QObject* obj);
175 W_SLOT(enableCondition)
176 void disableCondition(QObject* obj);
177 W_SLOT(disableCondition)
181 void setExpression(QObject* obj, QString expression);
182 W_SLOT(setExpression)
183 QString expression(QObject* obj);
184 W_SLOT(expression)
185
186 void setIntervalDuration(QObject* object, TimeVal flicks);
187 W_SLOT(setIntervalDuration)
188 void setIntervalMinDuration(QObject* object, TimeVal flicks);
189 W_SLOT(setIntervalMinDuration)
190 void setIntervalMaxDuration(QObject* object, TimeVal flicks);
191 W_SLOT(setIntervalMaxDuration)
192 void setIntervalMaxInfinite(QObject* object, bool);
193 W_SLOT(setIntervalMaxInfinite)
194 void setIntervalSpeed(QObject* object, double);
195 W_SLOT(setIntervalSpeed)
196
197 void setAutoTrigger(QObject* timeSync, bool);
198 W_SLOT(setAutoTrigger)
199
200 void setProcessLoop(QObject* process, bool);
201 W_SLOT(setProcessLoop)
202
203
205 QObject* port(QObject* obj, QString name);
206 W_SLOT(port)
207
208 QObject* inlet(QObject* obj, int index);
209 W_SLOT(inlet, (QObject*, int))
210
211
212 QObject* inlet(QObject* obj, QString name);
213 W_SLOT(inlet, (QObject*, QString))
214
215 int inlets(QObject* obj);
216 W_SLOT(inlets)
217
218 QObject* outlet(QObject* obj, int index);
219 W_SLOT(outlet, (QObject*, int))
220
221
222 QObject* outlet(QObject* obj, QString name);
223 W_SLOT(outlet, (QObject*, QString))
224
225 int outlets(QObject* obj);
226 W_SLOT(outlets)
227
228 QObject* createCable(QObject* outlet, QObject* inlet);
229 W_SLOT(createCable, (QObject*, QObject*))
230 QObject* createCable(QObject* outlet, QObject* inlet, Process::CableType type);
231 W_SLOT(createCable, (QObject*, QObject*, Process::CableType))
232
233
234 QObject* cable(QObject* port, int index);
235 W_SLOT(cable, (QObject*, int))
236
237
238 int cables(QObject* port);
239 W_SLOT(cables)
240
241
242 QObject* source(QObject* cable);
243 W_SLOT(source)
244
245
246 QObject* sink(QObject* cable);
247 W_SLOT(sink)
248
249
250 QObject* cable(QObject* outlet, QObject* inlet);
251 W_SLOT(cable, (QObject*, QObject*))
252
253 void setAddress(QObject* obj, QString addr);
254 W_SLOT(setAddress)
255
256 void setValue(QObject* obj, double value);
257 W_SLOT(setValue, (QObject*, double))
258
259 void setValue(QObject* obj, QVector2D value);
260 W_SLOT(setValue, (QObject*, QVector2D))
261
262 void setValue(QObject* obj, QVector3D value);
263 W_SLOT(setValue, (QObject*, QVector3D))
264
265 void setValue(QObject* obj, QVector4D value);
266 W_SLOT(setValue, (QObject*, QVector4D))
267
268 void setValue(QObject* obj, QString value);
269 W_SLOT(setValue, (QObject*, QString))
270
271 void setValue(QObject* obj, bool value);
272 W_SLOT(setValue, (QObject*, bool))
273
274 void setValue(QObject* obj, int value);
275 W_SLOT(setValue, (QObject*, int))
276
277 void setValue(QObject* obj, QList<QString> value);
278 W_SLOT(setValue, (QObject*, QList<QString>))
279
280 void setValue(QObject* obj, QList<qreal> value);
281 W_SLOT(setValue, (QObject*, QList<qreal>))
282
283 void setValue(QObject* obj, QList<QVariant> value);
284 W_SLOT(setValue, (QObject*, QList<QVariant>))
285
286 QString portName(QObject* port);
287 W_SLOT(portName)
288 QString valueType(QObject* obj);
289 W_SLOT(valueType)
290
291 double min(QObject* obj);
292 W_SLOT(min)
293
294 double max(QObject* obj);
295 W_SLOT(max)
296
297 QVector<QVariant> enumValues(QObject* obj);
298 W_SLOT(enumValues)
299
300 QObject* metadata(QObject* obj) const noexcept;
301 W_SLOT(metadata)
302
303
306 QObject* documentMetadata() const noexcept;
307 W_SLOT(documentMetadata)
308
309
311 QString documentName() const noexcept;
312 W_SLOT(documentName)
313
314
315 void setDocumentName(QString name);
316 W_SLOT(setDocumentName)
317
318 QObject* startState(QObject* obj);
319 W_SLOT(startState)
320
321 QObject* startEvent(QObject* obj);
322 W_SLOT(startEvent)
323
324 QObject* startSync(QObject* obj);
325 W_SLOT(startSync)
326
327 QObject* endState(QObject* obj);
328 W_SLOT(endState)
329
330 QObject* endEvent(QObject* obj);
331 W_SLOT(endEvent)
332
333 QObject* endSync(QObject* obj);
334 W_SLOT(endSync)
335
336 void remove(QObject* obj);
337 W_SLOT(remove)
338
339 void setCurvePoints(QObject* process, QVector<QVariantList> points);
340 W_SLOT(setCurvePoints)
341
342 void setSteps(QObject* process, QVector<double> points);
343 W_SLOT(setSteps)
344
345 QVariantList messages(QObject* state);
346 W_SLOT(messages)
347
348 void setMessages(QObject* state, QVariantList msgs);
349 W_SLOT(setMessages)
350
351 void replaceAddress(QObjectList objects, QString before, QString after);
352 W_SLOT(replaceAddress)
353
354
356 QVariantList automate(QObject* interval, QString addr);
357 W_SLOT(automate, (QObject*, QString))
358
359
361 QObject* automate(QObject* interval, QObject* port);
362 W_SLOT(automate, (QObject*, QObject*))
363
364
367 void startMacro();
368 W_SLOT(startMacro)
369
370 void endMacro();
371 W_SLOT(endMacro)
372
373 void undo();
374 W_SLOT(undo)
375
376 void redo();
377 W_SLOT(redo)
378
379 void load(QString path);
380 W_SLOT(load)
381
382 void save();
383 W_SLOT(save)
384
385 void saveAs(QString path);
386 W_SLOT(saveAs)
387
388
391 QObject* find(QString p);
392 W_SLOT(find)
393
394 QObject* findByLabel(QString p);
395 W_SLOT(findByLabel)
396 QString path(QObject* obj);
397 W_SLOT(path)
398 QObject* findByPath(QString path);
399 W_SLOT(findByPath)
400
401 QObject* document();
402 W_SLOT(document)
403
404 QObject* rootInterval();
405 W_SLOT(rootInterval)
406
407 QObject* documentPlugin(QString key);
408 W_SLOT(documentPlugin)
409
410
413 void play();
414 W_SLOT(play, ())
415
416 void play(QObject* obj);
417 W_SLOT(play, (QObject*))
418
419 void pause();
420 W_SLOT(pause, ())
421
422 void resume();
423 W_SLOT(resume, ())
424
425 void stop();
426 W_SLOT(stop)
427
428 void reinitialize();
429 W_SLOT(reinitialize)
430
431 void scrub(double z);
432 W_SLOT(scrub)
433
434 QObject* transport();
435 W_INVOKABLE(transport)
436
437
439 QString readFile(QString path);
440 W_SLOT(readFile)
441
442 QString relativizeFilePath(QString path);
443 W_SLOT(relativizeFilePath)
444
445 QString locateFilePath(QString path);
446 W_SLOT(locateFilePath)
447
448
451 QObject* selectedObject();
452 W_SLOT(selectedObject)
453
454 QVariantList selectedObjects();
455 W_SLOT(selectedObjects)
456
457 void select(QObject* obj);
458 W_SLOT(select, (QObject*))
459
460 void select(QVariantList objs);
461 W_SLOT(select, (QVariantList))
462
463 void zoom(double zx, double zy);
464 W_SLOT(zoom, (double, double));
465
466 void scroll(double zx, double zy);
467 W_SLOT(scroll, (double, double));
468
470 QVariant prompt(QVariant v);
471 W_SLOT(prompt)
472
473 bool hasProcessUI(QObject* process);
474 W_SLOT(hasProcessUI)
475
476 void showProcessUI(QObject* process, bool show);
477 W_SLOT(showProcessUI)
478
479 bool hasProcessScriptEditor(QObject* process);
480 W_SLOT(hasProcessScriptEditor)
481
482 void showProcessScriptEditor(QObject* process, bool show);
483 W_SLOT(showProcessScriptEditor)
484
485
486 void setProcessScriptEditorPlacement(QObject* process, QString placement);
487 W_SLOT(setProcessScriptEditorPlacement)
488 void setProcessUIPlacement(QObject* process, QString placement);
489 W_SLOT(setProcessUIPlacement)
490
491
494 QVariantMap availableProcesses() const noexcept;
495 W_SLOT(availableProcesses)
496 QVariant availableProcessesAndPresets() const noexcept;
497 W_SLOT(availableProcessesAndPresets)
498 QVariantList libraryEntries(QString filter) const noexcept;
499 W_SLOT(libraryEntries)
500 QVariant availableProtocols() const noexcept;
501 W_SLOT(availableProtocols)
502
503 QByteArray serializeAsJson() noexcept;
504 W_SLOT(serializeAsJson)
505private:
506 void submit(Macro& m, score::Command* c);
507};
508}
509
510W_REGISTER_ARGTYPE(QVector<QVariantList>)
511W_REGISTER_ARGTYPE(QList<QObject*>)
512W_REGISTER_ARGTYPE(JS::GlobalDeviceEnumerator*)
Definition DeviceEnumerator.hpp:138
Definition EditContext.hpp:33
Definition DeviceEnumerator.hpp:62
Definition CommandAPI.hpp:28
The Command class.
Definition Command.hpp:34
Base toolkit upon which the software is built.
Definition Application.cpp:108
Definition TimeValue.hpp:21
Definition DocumentContext.hpp:18