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
59 QJSValue controls() const noexcept;
60 W_PROPERTY(QJSValue, Controls READ controls)
61 QJSValue triggers() const noexcept;
62 W_PROPERTY(QJSValue, Triggers READ triggers)
63 QJSValue conditions() const noexcept;
64 W_PROPERTY(QJSValue, Conditions READ conditions)
66 void setNamespaces(QJSValue ns);
67
71 QObject* device(QString name);
72 W_SLOT(device)
73
74
77 QVariant deviceSettings(QString name);
78 W_SLOT(deviceSettings)
79
80 QString deviceToJson(QString addr);
81 W_SLOT(deviceToJson)
82
83 QString deviceToOSCQuery(QString addr);
84 W_SLOT(deviceToOSCQuery)
85
86 void createDevice(QString name, QString uuid, QJSValue obj);
87 W_SLOT(createDevice, (QString, QString, QJSValue))
88
89 void createDevice(QString name, QString uuid, QVariant obj);
90 W_SLOT(createDevice, (QString, QString, QVariant))
91
92 void createOSCDevice(QString name, QString host, int in, int out);
93 W_SLOT(createOSCDevice)
94
95 void connectOSCQueryDevice(QString name, QString host);
96 W_SLOT(connectOSCQueryDevice)
97
98 void removeDevice(QString name);
99 W_SLOT(removeDevice)
100
101
103 void disconnectDevice(QString name);
104 W_SLOT(disconnectDevice)
105 void reconnectDevice(QString name);
106 W_SLOT(reconnectDevice)
107
108 void createQMLWebSocketDevice(QString name, QString text);
109 W_SLOT(createQMLWebSocketDevice)
110
111 void createQMLSerialDevice(QString name, QString port, QString text);
112 W_SLOT(createQMLSerialDevice)
113
114 GlobalDeviceEnumerator* enumerateDevices();
115 W_SLOT(enumerateDevices, ())
116
117 GlobalDeviceEnumerator* enumerateDevices(const QString& protocol);
118 W_SLOT(enumerateDevices, (const QString&))
119
120 GlobalDeviceEnumerator* enumerateDevices(const QStringList& protocols);
121 W_SLOT(enumerateDevices, (const QStringList&))
122
123 DeviceListener* listenDevice(const QString& name);
124 W_SLOT(listenDevice, (const QString&))
125
126 void iterateDevice(const QString& name, const QJSValue& op);
127 W_SLOT(iterateDevice, (const QString&, const QJSValue&))
128
129 void setDeviceLearn(const QString& name, bool learn);
130 W_SLOT(setDeviceLearn, (const QString&, bool))
134 void createAddress(QString addr, QString type);
135 W_SLOT(createAddress)
136
137
140 void setUnit(QString addr, QString unit);
141 W_SLOT(setUnit)
142
143 QObject* createProcess(QObject* interval, QString name, QString data);
144 W_SLOT(createProcess)
145
146
147 int processes(QObject* obj);
148 W_SLOT(processes)
149
150
152 QObject* process(QObject* obj, int index);
153 W_SLOT(process)
154
155
158 QObject* parentProcess(QObject* obj);
159 W_SLOT(parentProcess)
160
161
163 QObject* parentInterval(QObject* obj);
164 W_SLOT(parentInterval)
165
166 void loadPreset(QObject* process, QString json);
167 W_SLOT(loadPreset)
168 QString savePreset(QObject* process);
169 W_SLOT(savePreset)
172 QStringList builtinPresets(QObject* process);
173 W_SLOT(builtinPresets)
174
175 void setName(QObject* sel, QString new_name);
176 W_SLOT(setName)
177
178
180 void autoLayout(QObject* interval, QVariantList processes);
181 W_SLOT(autoLayout, (QObject*, QVariantList))
182 void autoLayout(QObject* interval);
183 W_SLOT(autoLayout, (QObject*))
184
185
186 void setFolded(QObject* process, bool folded);
187 W_SLOT(setFolded)
188
189
190 void setComment(QObject* sel, QString comment);
191 W_SLOT(setComment)
192
193 QObject* createBox(QObject* obj, QString startTime, QString duration, double y);
194 W_SLOT(createBox, (QObject*, QString, QString, double))
195
196 QObject*
197 createBox(QObject* obj, double startTimeFlicks, double durationFlicks, double y);
198 W_SLOT(createBox, (QObject*, double, double, double))
199
200 QObject* createState(QObject* ev, double y);
201 W_SLOT(createState)
202
203 QObject* createIntervalAfter(QObject* obj, QString duration, double y);
204 W_SLOT(createIntervalAfter)
205
206 QObject* createIntervalBetween(QObject* startState, QObject* endState);
207 W_SLOT(createIntervalBetween)
208
209 // Triggers and conditions.
210 // A trigger lives on a time sync; intervals (their end), states and events
211 // resolve to theirs. A condition lives on an event; states resolve to theirs.
212 void enableTrigger(QObject* obj);
213 W_SLOT(enableTrigger)
214 void disableTrigger(QObject* obj);
215 W_SLOT(disableTrigger)
216 void enableCondition(QObject* obj);
217 W_SLOT(enableCondition)
218 void disableCondition(QObject* obj);
219 W_SLOT(disableCondition)
223 void setExpression(QObject* obj, QString expression);
224 W_SLOT(setExpression)
225 QString expression(QObject* obj);
226 W_SLOT(expression)
227
228
229 void setScriptable(QObject* obj, bool scriptable);
230 W_SLOT(setScriptable)
231 QString scriptableAddress(QObject* obj);
232 W_SLOT(scriptableAddress)
233 void trigger(QObject* obj);
234 W_SLOT(trigger)
235
236 void setIntervalDuration(QObject* object, TimeVal flicks);
237 W_SLOT(setIntervalDuration)
238 void setIntervalMinDuration(QObject* object, TimeVal flicks);
239 W_SLOT(setIntervalMinDuration)
240 void setIntervalMaxDuration(QObject* object, TimeVal flicks);
241 W_SLOT(setIntervalMaxDuration)
242 void setIntervalMaxInfinite(QObject* object, bool);
243 W_SLOT(setIntervalMaxInfinite)
244 void setIntervalSpeed(QObject* object, double);
245 W_SLOT(setIntervalSpeed)
248 void setIntervalQuantization(QObject* object, double bars);
249 W_SLOT(setIntervalQuantization)
250
251 void setAutoTrigger(QObject* timeSync, bool);
252 W_SLOT(setAutoTrigger)
253
254 void setProcessLoop(QObject* process, bool);
255 W_SLOT(setProcessLoop)
256
257
259 QObject* port(QObject* obj, QString name);
260 W_SLOT(port)
261
262 QObject* inlet(QObject* obj, int index);
263 W_SLOT(inlet, (QObject*, int))
264
265
266 QObject* inlet(QObject* obj, QString name);
267 W_SLOT(inlet, (QObject*, QString))
268
269 int inlets(QObject* obj);
270 W_SLOT(inlets)
271
272 QObject* outlet(QObject* obj, int index);
273 W_SLOT(outlet, (QObject*, int))
274
275
276 QObject* outlet(QObject* obj, QString name);
277 W_SLOT(outlet, (QObject*, QString))
278
279 int outlets(QObject* obj);
280 W_SLOT(outlets)
281
282 QObject* createCable(QObject* outlet, QObject* inlet);
283 W_SLOT(createCable, (QObject*, QObject*))
284 QObject* createCable(QObject* outlet, QObject* inlet, Process::CableType type);
285 W_SLOT(createCable, (QObject*, QObject*, Process::CableType))
286
287
288 QObject* cable(QObject* port, int index);
289 W_SLOT(cable, (QObject*, int))
290
291
292 int cables(QObject* port);
293 W_SLOT(cables)
294
295
296 QObject* source(QObject* cable);
297 W_SLOT(source)
298
299
300 QObject* sink(QObject* cable);
301 W_SLOT(sink)
302
303
304 QObject* cable(QObject* outlet, QObject* inlet);
305 W_SLOT(cable, (QObject*, QObject*))
306
307 void setAddress(QObject* obj, QString addr);
308 W_SLOT(setAddress)
309
310
312 void setPropagate(QObject* obj, bool propagate);
313 W_SLOT(setPropagate)
314
315 void setValue(QObject* obj, double value);
316 W_SLOT(setValue, (QObject*, double))
317
318 void setValue(QObject* obj, QVector2D value);
319 W_SLOT(setValue, (QObject*, QVector2D))
320
321 void setValue(QObject* obj, QVector3D value);
322 W_SLOT(setValue, (QObject*, QVector3D))
323
324 void setValue(QObject* obj, QVector4D value);
325 W_SLOT(setValue, (QObject*, QVector4D))
326
327 void setValue(QObject* obj, QString value);
328 W_SLOT(setValue, (QObject*, QString))
329
330 void setValue(QObject* obj, bool value);
331 W_SLOT(setValue, (QObject*, bool))
332
333 void setValue(QObject* obj, int value);
334 W_SLOT(setValue, (QObject*, int))
335
336 void setValue(QObject* obj, QList<QString> value);
337 W_SLOT(setValue, (QObject*, QList<QString>))
338
339 void setValue(QObject* obj, QList<qreal> value);
340 W_SLOT(setValue, (QObject*, QList<qreal>))
341
342 void setValue(QObject* obj, QList<QVariant> value);
343 W_SLOT(setValue, (QObject*, QList<QVariant>))
344
345
352 void editValue(QObject* obj, QVariant value);
353 W_SLOT(editValue)
354
355
356 void commitEdit();
357 W_SLOT(commitEdit)
358
359 bool pushExecutionValue(QObject* port, QVariant value);
360 W_SLOT(pushExecutionValue)
361
362 QString portName(QObject* port);
363 W_SLOT(portName)
364 QString valueType(QObject* obj);
365 W_SLOT(valueType)
366
367 double min(QObject* obj);
368 W_SLOT(min)
369
370 double max(QObject* obj);
371 W_SLOT(max)
372
373 QVector<QVariant> enumValues(QObject* obj);
374 W_SLOT(enumValues)
375
376 QObject* metadata(QObject* obj) const noexcept;
377 W_SLOT(metadata)
378
379
382 QObject* documentMetadata() const noexcept;
383 W_SLOT(documentMetadata)
384
385
387 QString documentName() const noexcept;
388 W_SLOT(documentName)
389
390
391 void setDocumentName(QString name);
392 W_SLOT(setDocumentName)
393
394 QObject* startState(QObject* obj);
395 W_SLOT(startState)
396
397 QObject* startEvent(QObject* obj);
398 W_SLOT(startEvent)
399
400 QObject* startSync(QObject* obj);
401 W_SLOT(startSync)
402
403 QObject* endState(QObject* obj);
404 W_SLOT(endState)
405
406 QObject* endEvent(QObject* obj);
407 W_SLOT(endEvent)
408
409 QObject* endSync(QObject* obj);
410 W_SLOT(endSync)
411
412 void remove(QObject* obj);
413 W_SLOT(remove)
414
415 void setCurvePoints(QObject* process, QVector<QVariantList> points);
416 W_SLOT(setCurvePoints)
417
418 void setSteps(QObject* process, QVector<double> points);
419 W_SLOT(setSteps)
420
421 QVariantList messages(QObject* state);
422 W_SLOT(messages)
423
424 void setMessages(QObject* state, QVariantList msgs);
425 W_SLOT(setMessages)
426
427 void replaceAddress(QObjectList objects, QString before, QString after);
428 W_SLOT(replaceAddress)
429
430
432 QVariantList automate(QObject* interval, QString addr);
433 W_SLOT(automate, (QObject*, QString))
434
435
437 QObject* automate(QObject* interval, QObject* port);
438 W_SLOT(automate, (QObject*, QObject*))
439
440
443 void startMacro();
444 W_SLOT(startMacro)
445
446
450 void withMacro(QJSValue fn);
451 W_SLOT(withMacro)
452
453 void endMacro();
454 W_SLOT(endMacro)
455
456
458 void registerCommandHandler(QString name, QJSValue fn);
459 W_SLOT(registerCommandHandler)
460
461
467 void pushCommand(QString name, QJSValue undoPayload, QJSValue redoPayload);
468 W_SLOT(pushCommand)
469
470 void undo();
471 W_SLOT(undo)
472
473 void redo();
474 W_SLOT(redo)
475
476
478 bool canUndo();
479 W_SLOT(canUndo)
480
481 bool canRedo();
482 W_SLOT(canRedo)
483
484
485 int undoIndex();
486 W_SLOT(undoIndex)
487
488
489 int undoCount();
490 W_SLOT(undoCount)
491
492
493 QString undoText();
494 W_SLOT(undoText)
495
496 QString redoText();
497 W_SLOT(redoText)
498
499 void load(QString path);
500 W_SLOT(load)
501
502 void save();
503 W_SLOT(save)
504
505 void saveAs(QString path);
506 W_SLOT(saveAs)
507
508
511 QVariantList consolidate(bool collectLibraryFiles);
512 W_SLOT(consolidate)
513
514
516 QString archive(QString zipPath, bool collectLibraryFiles);
517 W_SLOT(archive)
518
519
522 QObject* find(QString p);
523 W_SLOT(find)
524
525 QObject* findByLabel(QString p);
526 W_SLOT(findByLabel)
527
528
529 QObjectList references(QObject* obj);
530 W_SLOT(references)
532 QObjectList targets(QObject* obj);
533 W_SLOT(targets)
535 void rebind(QObject* obj, QString from, QString to);
536 W_SLOT(rebind)
537 QString path(QObject* obj);
538 W_SLOT(path)
539 QObject* findByPath(QString path);
540 W_SLOT(findByPath)
541
542 QObject* document();
543 W_SLOT(document)
544
545 QObject* rootInterval();
546 W_SLOT(rootInterval)
547
548 QObject* documentPlugin(QString key);
549 W_SLOT(documentPlugin)
550
551
554 void play();
555 W_SLOT(play, ())
556
557 void play(QObject* obj);
558 W_SLOT(play, (QObject*))
559
560
562 void playFromHere(double ms);
563 W_SLOT(playFromHere)
564
565
567 void playIntervalFromHere(QObject* interval, double ms);
568 W_SLOT(playIntervalFromHere)
569
570 void pause();
571 W_SLOT(pause, ())
572
573 void resume();
574 W_SLOT(resume, ())
575
576 void stop();
577 W_SLOT(stop, ())
578
579
580 void stop(QObject* obj);
581 W_SLOT(stop, (QObject*))
582
583 void reinitialize();
584 W_SLOT(reinitialize)
585
586 void scrub(double z);
587 W_SLOT(scrub)
588
589 QObject* transport();
590 W_INVOKABLE(transport)
591
592
594 QString readFile(QString path);
595 W_SLOT(readFile)
596
597 QString relativizeFilePath(QString path);
598 W_SLOT(relativizeFilePath)
599
600 QString locateFilePath(QString path);
601 W_SLOT(locateFilePath)
602
603
606 QObject* selectedObject();
607 W_SLOT(selectedObject)
608
609 QVariantList selectedObjects();
610 W_SLOT(selectedObjects)
611
612 void select(QObject* obj);
613 W_SLOT(select, (QObject*))
614
615 void select(QVariantList objs);
616 W_SLOT(select, (QVariantList))
617
618 void zoom(double zx, double zy);
619 W_SLOT(zoom, (double, double));
620
621 void scroll(double zx, double zy);
622 W_SLOT(scroll, (double, double));
623
625 QVariant prompt(QVariant v);
626 W_SLOT(prompt)
627
628 bool hasProcessUI(QObject* process);
629 W_SLOT(hasProcessUI)
630
631 void showProcessUI(QObject* process, bool show);
632 W_SLOT(showProcessUI)
633
634 bool hasProcessScriptEditor(QObject* process);
635 W_SLOT(hasProcessScriptEditor)
636
637 void showProcessScriptEditor(QObject* process, bool show);
638 W_SLOT(showProcessScriptEditor)
639
640
641 void setProcessScriptEditorPlacement(QObject* process, QString placement);
642 W_SLOT(setProcessScriptEditorPlacement)
643 void setProcessUIPlacement(QObject* process, QString placement);
644 W_SLOT(setProcessUIPlacement)
645
646
649 QVariantMap availableProcesses() const noexcept;
650 W_SLOT(availableProcesses)
651 QVariant availableProcessesAndPresets() const noexcept;
652 W_SLOT(availableProcessesAndPresets)
653 QVariantList libraryEntries(QString filter) const noexcept;
654 W_SLOT(libraryEntries)
655 QVariant availableProtocols() const noexcept;
656 W_SLOT(availableProtocols)
657
658 QByteArray serializeAsJson() noexcept;
659 W_SLOT(serializeAsJson)
660private:
661 void submit(Macro& m, score::Command* c);
662 QJSValue m_namespaces;
663
664 void setControlValue(QObject* obj, ossia::value value);
665};
666}
667
668W_REGISTER_ARGTYPE(QVector<QVariantList>)
669W_REGISTER_ARGTYPE(QList<QObject*>)
670W_REGISTER_ARGTYPE(JS::GlobalDeviceEnumerator*)
Definition DeviceEnumerator.hpp:157
Definition EditContext.hpp:33
Definition DeviceEnumerator.hpp:71
Definition CommandAPI.hpp:28
The Command class.
Definition Command.hpp:34
Base toolkit upon which the software is built.
Definition Application.cpp:85
Definition TimeValue.hpp:21
Definition DocumentContext.hpp:18