17 #include "data/osc/OSCQueue.h" 19 #include "layer/WaveformLayer.h" 20 #include "view/ViewManager.h" 21 #include "view/Pane.h" 22 #include "view/PaneStack.h" 23 #include "data/model/WaveFileModel.h" 24 #include "widgets/CommandHistory.h" 25 #include "audio/AudioCallbackPlaySource.h" 26 #include "framework/Document.h" 27 #include "data/fileio/WavFileWriter.h" 28 #include "transform/TransformFactory.h" 29 #include "widgets/LevelPanWidget.h" 30 #include "widgets/LevelPanToolButton.h" 31 #include "widgets/AudioDial.h" 33 #include <bqaudioio/SystemPlaybackTarget.h> 37 #include <QElapsedTimer> 39 #if (QT_VERSION >= 0x050600) 40 #define NOW (QTime::currentTime().toString(Qt::ISODateWithMs)) 42 #define NOW (QTime::currentTime().toString(Qt::ISODate)) 51 SVDEBUG <<
"OSCHandler at " <<
NOW <<
": handling message: " 52 << message.toString() << endl;
54 if (message.getMethod() ==
"open") {
56 if (message.getArgCount() == 1 &&
57 message.getArg(0).canConvert(QVariant::String)) {
58 QString path = message.getArg(0).toString();
59 if (open(path, ReplaceMainModel) == FileOpenSucceeded) {
60 SVDEBUG <<
"OSCHandler: Opened path \"" 61 << path <<
"\"" << endl;
63 SVCERR <<
"OSCHandler: File open failed for path \"" 64 << path <<
"\"" << endl;
69 SVCERR <<
"OSCHandler: Usage: /open <filename>" << endl;
72 }
else if (message.getMethod() ==
"openadditional") {
74 if (message.getArgCount() == 1 &&
75 message.getArg(0).canConvert(QVariant::String)) {
76 QString path = message.getArg(0).toString();
77 if (open(path, CreateAdditionalModel) == FileOpenSucceeded) {
78 SVDEBUG <<
"OSCHandler: Opened additional path \"" 79 << path <<
"\"" << endl;
81 SVCERR <<
"OSCHandler: File open failed for path \"" 82 << path <<
"\"" << endl;
85 SVCERR <<
"OSCHandler: Usage: /openadditional <filename>" << endl;
88 }
else if (message.getMethod() ==
"recent" ||
89 message.getMethod() ==
"last") {
92 if (message.getMethod() ==
"recent" &&
93 message.getArgCount() == 1 &&
94 message.getArg(0).canConvert(QVariant::Int)) {
95 n = message.getArg(0).toInt() - 1;
97 std::vector<QString> recent = m_recentFiles.getRecent();
98 if (n >= 0 && n <
int(recent.size())) {
99 QString path = recent[n];
100 if (open(path, ReplaceMainModel) == FileOpenSucceeded) {
101 SVDEBUG <<
"OSCHandler: Opened recent path \"" 102 << path <<
"\"" << endl;
104 SVCERR <<
"OSCHandler: File open failed for path \"" 105 << path <<
"\"" << endl;
108 SVCERR <<
"OSCHandler: Usage: /recent <n>" << endl;
109 SVCERR <<
" or /last" << endl;
112 }
else if (message.getMethod() ==
"save") {
115 if (message.getArgCount() == 1 &&
116 message.getArg(0).canConvert(QVariant::String)) {
117 path = message.getArg(0).toString();
118 if (QFileInfo(path).exists()) {
119 SVCERR <<
"OSCHandler: Refusing to overwrite existing file in save" << endl;
120 }
else if (saveSessionFile(path)) {
121 SVDEBUG <<
"OSCHandler: Saved session to path \"" 122 << path <<
"\"" << endl;
124 SVCERR <<
"OSCHandler: Save failed to path \"" 125 << path <<
"\"" << endl;
128 SVCERR <<
"OSCHandler: Usage: /save <filename>" << endl;
131 }
else if (message.getMethod() ==
"export") {
134 if (getMainModel()) {
135 if (message.getArgCount() == 1 &&
136 message.getArg(0).canConvert(QVariant::String)) {
137 path = message.getArg(0).toString();
138 if (QFileInfo(path).exists()) {
139 SVCERR <<
"OSCHandler: Refusing to overwrite existing file in export" << endl;
141 WavFileWriter writer(path,
142 getMainModel()->getSampleRate(),
143 getMainModel()->getChannelCount(),
144 WavFileWriter::WriteToTemporary);
145 MultiSelection ms = m_viewManager->getSelection();
146 if (writer.writeModel
147 (getMainModel().
get(),
148 ms.getSelections().empty() ?
nullptr : &ms)) {
149 SVDEBUG <<
"OSCHandler: Exported audio to path \"" 150 << path <<
"\"" << endl;
152 SVCERR <<
"OSCHandler: Export failed to path \"" 153 << path <<
"\"" << endl;
158 SVCERR <<
"OSCHandler: Usage: /export <filename>" << endl;
161 }
else if (message.getMethod() ==
"exportlayer") {
164 if (message.getArgCount() == 1 &&
165 message.getArg(0).canConvert(QVariant::String)) {
166 path = message.getArg(0).toString();
167 if (QFileInfo(path).exists()) {
168 SVCERR <<
"OSCHandler: Refusing to overwrite existing file in layer export" << endl;
170 Pane *currentPane =
nullptr;
171 Layer *currentLayer =
nullptr;
172 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
173 if (currentPane) currentLayer = currentPane->getSelectedLayer();
174 MultiSelection ms = m_viewManager->getSelection();
178 (currentLayer, currentPane,
179 ms.getSelections().empty() ?
nullptr : &ms,
181 SVDEBUG <<
"OSCHandler: Exported layer \"" 182 << currentLayer->getLayerPresentationName()
183 <<
"\" to path \"" << path <<
"\"" << endl;
185 SVCERR <<
"OSCHandler: Export failed to path \"" 186 << path <<
"\"" << endl;
189 SVCERR <<
"OSCHandler: No current layer to export" << endl;
193 SVCERR <<
"OSCHandler: Usage: /exportlayer <filename>" << endl;
196 }
else if (message.getMethod() ==
"exportimage") {
199 if (message.getArgCount() == 1 &&
200 message.getArg(0).canConvert(QVariant::String)) {
201 path = message.getArg(0).toString();
202 if (QFileInfo(path).exists()) {
203 SVCERR <<
"OSCHandler: Refusing to overwrite existing file in image export" << endl;
205 Pane *currentPane =
nullptr;
206 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
207 MultiSelection ms = m_viewManager->getSelection();
209 QImage *image =
nullptr;
210 auto sel = ms.getSelections();
212 sv_frame_t sf0 = sel.begin()->getStartFrame();
213 sv_frame_t sf1 = sel.rbegin()->getEndFrame();
214 image = currentPane->renderPartToNewImage(sf0, sf1);
216 image = currentPane->renderToNewImage();
219 SVCERR <<
"OSCHandler: Failed to create image from pane" 221 }
else if (!image->save(path,
"PNG")) {
222 SVCERR <<
"OSCHandler: Export failed to image file \"" 223 << path <<
"\"" << endl;
225 SVDEBUG <<
"OSCHandler: Exported pane to image file \"" 226 << path <<
"\"" << endl;
230 SVCERR <<
"OSCHandler: No current pane to export" << endl;
234 SVCERR <<
"OSCHandler: Usage: /exportimage <filename>" << endl;
237 }
else if (message.getMethod() ==
"exportsvg") {
240 if (message.getArgCount() == 1 &&
241 message.getArg(0).canConvert(QVariant::String)) {
242 path = message.getArg(0).toString();
243 if (QFileInfo(path).exists()) {
244 SVCERR <<
"OSCHandler: Refusing to overwrite existing file in SVG export" << endl;
246 Pane *currentPane =
nullptr;
247 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
248 MultiSelection ms = m_viewManager->getSelection();
251 auto sel = ms.getSelections();
253 sv_frame_t sf0 = sel.begin()->getStartFrame();
254 sv_frame_t sf1 = sel.rbegin()->getEndFrame();
255 result = currentPane->renderPartToSvgFile(path, sf0, sf1);
257 result = currentPane->renderToSvgFile(path);
260 SVCERR <<
"OSCHandler: Export failed to SVG file \"" 261 << path <<
"\"" << endl;
263 SVDEBUG <<
"OSCHandler: Exported pane to SVG file \"" 264 << path <<
"\"" << endl;
267 SVCERR <<
"OSCHandler: No current pane to export" << endl;
271 SVCERR <<
"OSCHandler: Usage: /exportsvg <filename>" << endl;
274 }
else if (message.getMethod() ==
"jump" ||
275 message.getMethod() ==
"play") {
277 if (getMainModel()) {
279 sv_frame_t frame = m_viewManager->getPlaybackFrame();
280 bool selection =
false;
281 bool play = (message.getMethod() ==
"play");
283 if (message.getArgCount() == 1) {
285 if (message.getArg(0).canConvert(QVariant::String) &&
286 message.getArg(0).toString() ==
"selection") {
290 }
else if (message.getArg(0).canConvert(QVariant::String) &&
291 message.getArg(0).toString() ==
"end") {
293 frame = getMainModel()->getEndFrame();
295 }
else if (message.getArg(0).canConvert(QVariant::Double)) {
297 double time = message.getArg(0).toDouble();
298 if (time < 0.0) time = 0.0;
300 frame = lrint(time * getMainModel()->getSampleRate());
304 if (frame > getMainModel()->getEndFrame()) {
305 frame = getMainModel()->getEndFrame();
309 m_viewManager->setPlaySelectionMode(selection);
313 MultiSelection::SelectionList sl = m_viewManager->getSelections();
315 frame = sl.begin()->getStartFrame();
319 SVDEBUG <<
"OSCHandler: Setting playback frame to " << frame << endl;
321 m_viewManager->setPlaybackFrame(frame);
324 if (!m_playSource->isPlaying()) {
325 SVDEBUG <<
"OSCHandler: Play source is not yet playing, calling play()" << endl;
330 SVDEBUG <<
"OSCHandler: Play source is already playing, not starting it" << endl;
333 SVDEBUG <<
"OSCHandler: Jump only requested, not starting playback" << endl;
337 }
else if (message.getMethod() ==
"ffwd") {
339 if (message.getArgCount() == 1) {
341 if (message.getArg(0).canConvert(QVariant::String) &&
342 message.getArg(0).toString() ==
"similar") {
344 SVDEBUG <<
"OSCHandler: Calling ffwdSimilar" << endl;
349 SVDEBUG <<
"OSCHandler: Calling ffwd" << endl;
353 }
else if (message.getMethod() ==
"rewind") {
355 if (message.getArgCount() == 1) {
357 if (message.getArg(0).canConvert(QVariant::String) &&
358 message.getArg(0).toString() ==
"similar") {
360 SVDEBUG <<
"OSCHandler: Calling rewindSimilar" << endl;
365 SVDEBUG <<
"OSCHandler: Calling rewind" << endl;
369 }
else if (message.getMethod() ==
"stop") {
371 if (m_playSource->isPlaying()) {
375 SVDEBUG <<
"OSCHandler: Calling stop" << endl;
378 SVDEBUG <<
"OSCHandler: Not playing, doing nothing" << endl;
381 }
else if (message.getMethod() ==
"loop") {
383 if (message.getArgCount() == 1 &&
384 message.getArg(0).canConvert(QVariant::String)) {
386 QString str = message.getArg(0).toString();
388 SVDEBUG <<
"OSCHandler: Enabling loop mode" << endl;
389 m_viewManager->setPlayLoopMode(
true);
390 }
else if (str ==
"off") {
391 SVDEBUG <<
"OSCHandler: Disabling loop mode" << endl;
392 m_viewManager->setPlayLoopMode(
false);
396 }
else if (message.getMethod() ==
"solo") {
398 if (message.getArgCount() == 1 &&
399 message.getArg(0).canConvert(QVariant::String)) {
401 QString str = message.getArg(0).toString();
403 SVDEBUG <<
"OSCHandler: Enabling solo mode" << endl;
404 m_viewManager->setPlaySoloMode(
true);
405 }
else if (str ==
"off") {
406 SVDEBUG <<
"OSCHandler: Disabling solo mode" << endl;
407 m_viewManager->setPlaySoloMode(
false);
411 }
else if (message.getMethod() ==
"select" ||
412 message.getMethod() ==
"addselect") {
414 if (getMainModel()) {
416 sv_frame_t f0 = getMainModel()->getStartFrame();
417 sv_frame_t f1 = getMainModel()->getEndFrame();
421 if (message.getArgCount() == 2 &&
422 message.getArg(0).canConvert(QVariant::Double) &&
423 message.getArg(1).canConvert(QVariant::Double)) {
425 double t0 = message.getArg(0).toDouble();
426 double t1 = message.getArg(1).toDouble();
427 if (t1 < t0) {
double temp = t0; t0 = t1; t1 = temp; }
428 if (t0 < 0.0) t0 = 0.0;
429 if (t1 < 0.0) t1 = 0.0;
431 f0 = lrint(t0 * getMainModel()->getSampleRate());
432 f1 = lrint(t1 * getMainModel()->getSampleRate());
434 SVDEBUG <<
"OSCHandler: Converted selection extents to frames " 435 << f0 <<
" and " << f1 << endl;
437 Pane *pane = m_paneStack->getCurrentPane();
438 Layer *layer =
nullptr;
439 if (pane) layer = pane->getSelectedLayer();
442 layer->snapToFeatureFrame(pane, f0, resolution,
443 Layer::SnapLeft, -1);
444 layer->snapToFeatureFrame(pane, f1, resolution,
445 Layer::SnapRight, -1);
447 SVDEBUG <<
"OSCHandler: Snapped selection extents to " 448 << f0 <<
" and " << f1 <<
" for current layer \"" 449 << layer->getLayerPresentationName() <<
"\"" 453 }
else if (message.getArgCount() == 1 &&
454 message.getArg(0).canConvert(QVariant::String)) {
456 QString str = message.getArg(0).toString();
458 SVDEBUG <<
"OSCHandler: Clearing selection" << endl;
459 m_viewManager->clearSelections();
461 }
else if (str ==
"all") {
462 SVDEBUG <<
"OSCHandler: Selecting all" << endl;
463 f0 = getModelsStartFrame();
464 f0 = getModelsEndFrame();
469 if (message.getMethod() ==
"select") {
470 m_viewManager->setSelection(Selection(f0, f1));
472 m_viewManager->addSelection(Selection(f0, f1));
476 SVDEBUG <<
"OSCHandler: Selection now is " 477 << m_viewManager->getSelection().toString() << endl;
480 SVCERR <<
"OSCHandler: No main model, can't modify selection" 484 }
else if (message.getMethod() ==
"add") {
486 if (getMainModel()) {
488 if (message.getArgCount() >= 1 &&
489 message.getArg(0).canConvert(QVariant::String)) {
492 if (message.getArgCount() == 2 &&
493 message.getArg(0).canConvert(QVariant::Int)) {
494 channel = message.getArg(0).toInt();
496 channel >=
int(getMainModel()->getChannelCount())) {
497 SVCERR <<
"OSCHandler: channel " << channel
498 <<
" out of range (0 to " 499 << (getMainModel()->getChannelCount() - 1)
505 QString str = message.getArg(0).toString();
507 LayerFactory::LayerType type =
508 LayerFactory::getInstance()->getLayerTypeForName(str);
510 if (type == LayerFactory::UnknownLayer) {
511 SVCERR <<
"WARNING: OSCHandler: unknown layer " 512 <<
"type " << str << endl;
519 QString pname = LayerFactory::getInstance()->
520 getLayerPresentationName(type);
522 addPane(configuration, tr(
"Add %1 Pane") .arg(pname));
524 SVDEBUG <<
"OSCHandler: Added pane \"" << pname
528 SVCERR <<
"OSCHandler: Usage: /add <layertype> [<channel>]" 533 }
else if (message.getMethod() ==
"undo") {
535 SVDEBUG <<
"OSCHandler: Calling undo" << endl;
536 CommandHistory::getInstance()->undo();
538 }
else if (message.getMethod() ==
"redo") {
540 SVDEBUG <<
"OSCHandler: Calling redo" << endl;
541 CommandHistory::getInstance()->redo();
543 }
else if (message.getMethod() ==
"set") {
545 if (message.getArgCount() == 2 &&
546 message.getArg(0).canConvert(QVariant::String) &&
547 message.getArg(1).canConvert(QVariant::Double)) {
549 QString
property = message.getArg(0).toString();
550 float value = (float)message.getArg(1).toDouble();
552 if (property ==
"gain") {
553 if (value < 0.0) value = 0.0;
555 if (m_playTarget) m_playTarget->setOutputGain(value);
556 }
else if (property ==
"speed") {
558 }
else if (property ==
"speedup") {
574 double percentage = 100.0;
576 percentage = percentage + value;
578 percentage = 10000.0 / (percentage - value);
580 SVDEBUG <<
"OSCHandler: converted speedup(" << value
581 <<
") into speed(" << percentage <<
")" << endl;
585 }
else if (property ==
"overlays") {
587 m_viewManager->setOverlayMode(ViewManager::NoOverlays);
588 }
else if (value < 1.5) {
589 m_viewManager->setOverlayMode(ViewManager::StandardOverlays);
591 m_viewManager->setOverlayMode(ViewManager::AllOverlays);
593 }
else if (property ==
"zoomwheels") {
594 m_viewManager->setZoomWheelsEnabled(value > 0.5);
595 }
else if (property ==
"propertyboxes") {
596 bool toggle = ((value < 0.5) !=
597 (m_paneStack->getLayoutStyle() ==
598 PaneStack::HiddenPropertyStacksLayout));
599 if (toggle) togglePropertyBoxes();
603 PropertyContainer *container =
nullptr;
604 Pane *pane = m_paneStack->getCurrentPane();
606 message.getArgCount() == 3 &&
607 message.getArg(0).canConvert(QVariant::String) &&
608 message.getArg(1).canConvert(QVariant::String) &&
609 message.getArg(2).canConvert(QVariant::String)) {
610 if (message.getArg(0).toString() ==
"pane") {
611 container = pane->getPropertyContainer(0);
612 }
else if (message.getArg(0).toString() ==
"layer") {
613 container = pane->getSelectedLayer();
616 SVCERR <<
"OSCHandler: Usage: /set <control> <value>" << endl
617 <<
" or /set pane <control> <value>" << endl
618 <<
" or /set layer <control> <value>" << endl;
621 QString nameString = message.getArg(1).toString();
622 QString valueString = message.getArg(2).toString();
623 Command *c = container->getSetPropertyCommand
624 (nameString, valueString);
625 if (c) CommandHistory::getInstance()->addCommand(c,
true,
true);
629 }
else if (message.getMethod() ==
"setcurrent") {
631 int paneIndex = -1, layerIndex = -1;
632 bool wantLayer =
false;
634 if (message.getArgCount() >= 1 &&
635 message.getArg(0).canConvert(QVariant::Int)) {
637 paneIndex = message.getArg(0).toInt() - 1;
639 if (message.getArgCount() >= 2 &&
640 message.getArg(1).canConvert(QVariant::Int)) {
642 layerIndex = message.getArg(1).toInt() - 1;
645 SVCERR <<
"OSCHandler: Usage: /setcurrent <pane> [<layer>]" << endl;
648 if (paneIndex >= 0 && paneIndex < m_paneStack->getPaneCount()) {
649 Pane *pane = m_paneStack->getPane(paneIndex);
650 m_paneStack->setCurrentPane(pane);
651 SVDEBUG <<
"OSCHandler: Set current pane to index " 652 << paneIndex <<
" (pane id " << pane->getId()
654 if (layerIndex >= 0 && layerIndex < pane->getLayerCount()) {
655 Layer *layer = pane->getFixedOrderLayer(layerIndex);
656 m_paneStack->setCurrentLayer(pane, layer);
657 SVDEBUG <<
"OSCHandler: Set current layer to index " 658 << layerIndex <<
" (layer \"" 659 << layer->getLayerPresentationName() <<
"\")" << endl;
660 }
else if (wantLayer && layerIndex == -1) {
661 m_paneStack->setCurrentLayer(pane,
nullptr);
662 }
else if (wantLayer) {
663 SVCERR <<
"OSCHandler: Layer index " 664 << layerIndex <<
" out of range for pane" << endl;
668 }
else if (message.getMethod() ==
"delete") {
670 if (message.getArgCount() == 1 &&
671 message.getArg(0).canConvert(QVariant::String)) {
673 QString target = message.getArg(0).toString();
675 if (target ==
"pane") {
677 SVDEBUG <<
"OSCHandler: Calling deleteCurrentPane" << endl;
680 }
else if (target ==
"layer") {
682 SVDEBUG <<
"OSCHandler: Calling deleteCurrentLayer" << endl;
683 deleteCurrentLayer();
687 SVCERR <<
"WARNING: OSCHandler: Unknown delete target \"" 688 << target <<
"\"" << endl;
691 SVCERR <<
"OSCHandler: Usage: /delete pane" << endl
692 <<
" or /delete layer" << endl;
695 }
else if (message.getMethod() ==
"zoom") {
697 if (message.getArgCount() == 1) {
698 if (message.getArg(0).canConvert(QVariant::String) &&
699 message.getArg(0).toString() ==
"in") {
701 }
else if (message.getArg(0).canConvert(QVariant::String) &&
702 message.getArg(0).toString() ==
"out") {
704 }
else if (message.getArg(0).canConvert(QVariant::String) &&
705 message.getArg(0).toString() ==
"default") {
707 }
else if (message.getArg(0).canConvert(QVariant::String) &&
708 message.getArg(0).toString() ==
"fit") {
710 }
else if (message.getArg(0).canConvert(QVariant::Double)) {
711 double level = message.getArg(0).toDouble();
712 Pane *currentPane = m_paneStack->getCurrentPane();
715 zoomLevel = ZoomLevel(ZoomLevel::FramesPerPixel,
718 zoomLevel = ZoomLevel(ZoomLevel::PixelsPerFrame,
719 int(round(1.0 / level)));
722 SVDEBUG <<
"OSCHandler: Setting zoom level to " 723 << zoomLevel << endl;
724 currentPane->setZoomLevel(zoomLevel);
726 SVCERR <<
"OSCHandler: No current pane, can't set zoom" 731 SVCERR <<
"OSCHandler: Usage: /zoom <level>" << endl
732 <<
" or /zoom in" << endl
733 <<
" or /zoom out" << endl
734 <<
" or /zoom fit" << endl
735 <<
" or /zoom default" << endl;
738 }
else if (message.getMethod() ==
"zoomvertical") {
740 Pane *pane = m_paneStack->getCurrentPane();
741 Layer *layer =
nullptr;
742 if (pane && pane->getLayerCount() > 0) {
743 layer = pane->getLayer(pane->getLayerCount() - 1);
748 steps = layer->getVerticalZoomSteps(defaultStep);
749 if (message.getArgCount() == 1 && steps > 0) {
750 if (message.getArg(0).canConvert(QVariant::String) &&
751 message.getArg(0).toString() ==
"in") {
752 int step = layer->getCurrentVerticalZoomStep() + 1;
753 if (step < steps) layer->setVerticalZoomStep(step);
754 }
else if (message.getArg(0).canConvert(QVariant::String) &&
755 message.getArg(0).toString() ==
"out") {
756 int step = layer->getCurrentVerticalZoomStep() - 1;
757 if (step >= 0) layer->setVerticalZoomStep(step);
758 }
else if (message.getArg(0).canConvert(QVariant::String) &&
759 message.getArg(0).toString() ==
"default") {
760 layer->setVerticalZoomStep(defaultStep);
762 }
else if (message.getArgCount() == 2) {
763 if (message.getArg(0).canConvert(QVariant::Double) &&
764 message.getArg(1).canConvert(QVariant::Double)) {
765 double min = message.getArg(0).toDouble();
766 double max = message.getArg(1).toDouble();
767 layer->setDisplayExtents(min, max);
772 }
else if (message.getMethod() ==
"quit") {
774 SVDEBUG <<
"OSCHandler: Exiting abruptly" << endl;
778 while (!m_oscQueue->isEmpty()) {
779 (void)m_oscQueue->readMessage();
783 m_documentModified =
false;
786 }
else if (message.getMethod() ==
"resize") {
788 if (message.getArgCount() == 2) {
790 int width = 0, height = 0;
792 if (message.getArg(1).canConvert(QVariant::Int)) {
794 height = message.getArg(1).toInt();
796 if (message.getArg(0).canConvert(QVariant::String) &&
797 message.getArg(0).toString() ==
"pane") {
799 Pane *pane = m_paneStack->getCurrentPane();
800 if (pane) pane->resize(pane->width(), height);
802 }
else if (message.getArg(0).canConvert(QVariant::Int)) {
804 width = message.getArg(0).toInt();
805 resize(width, height);
810 }
else if (message.getMethod() ==
"transform") {
812 if (message.getArgCount() == 1 &&
813 message.getArg(0).canConvert(QVariant::String)) {
815 Pane *pane = m_paneStack->getCurrentPane();
817 if (getMainModel() && pane) {
819 TransformId transformId = message.getArg(0).toString();
821 Transform transform = TransformFactory::getInstance()->
822 getDefaultTransformFor(transformId);
824 SVDEBUG <<
"OSCHandler: Running transform on main model:" 825 << transform.toXmlString() << endl;
827 Layer *newLayer = m_document->createDerivedLayer
828 (transform, getMainModelId());
831 m_document->addLayerToView(pane, newLayer);
832 m_recentTransforms.add(transformId);
833 m_paneStack->setCurrentLayer(pane, newLayer);
835 SVCERR <<
"OSCHandler: Transform failed to run" << endl;
838 SVCERR <<
"OSCHandler: Lack main model or pane, " 839 <<
"can't run transform" << endl;
844 SVCERR <<
"WARNING: OSCHandler: Unknown or unsupported " 845 <<
"method \"" << message.getMethod()
849 SVDEBUG <<
"OSCHandler at " <<
NOW <<
": finished message: " 850 << message.toString() <<
" in " << timer.elapsed() <<
"ms" << endl;
LevelPanToolButton * m_mainLevelPan
void handleOSCMessage(const OSCMessage &) override