annotate main/OSCHandler.cpp @ 246:ddbde90773b0 spectrogram-cache-rejig

* Merge from trunk
author Chris Cannam
date Wed, 27 Feb 2008 11:59:42 +0000
parents
children
rev   line source
Chris@246 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@246 2
Chris@246 3 /*
Chris@246 4 Sonic Visualiser
Chris@246 5 An audio file viewer and annotation editor.
Chris@246 6 Centre for Digital Music, Queen Mary, University of London.
Chris@246 7 This file copyright 2006-2007 Chris Cannam and QMUL.
Chris@246 8
Chris@246 9 This program is free software; you can redistribute it and/or
Chris@246 10 modify it under the terms of the GNU General Public License as
Chris@246 11 published by the Free Software Foundation; either version 2 of the
Chris@246 12 License, or (at your option) any later version. See the file
Chris@246 13 COPYING included with this distribution for more information.
Chris@246 14 */
Chris@246 15
Chris@246 16 #include "MainWindow.h"
Chris@246 17 #include "data/osc/OSCQueue.h"
Chris@246 18
Chris@246 19 #include "layer/WaveformLayer.h"
Chris@246 20 #include "view/ViewManager.h"
Chris@246 21 #include "view/Pane.h"
Chris@246 22 #include "view/PaneStack.h"
Chris@246 23 #include "data/model/WaveFileModel.h"
Chris@246 24 #include "base/CommandHistory.h"
Chris@246 25 #include "audioio/AudioCallbackPlaySource.h"
Chris@246 26 #include "audioio/AudioCallbackPlayTarget.h"
Chris@246 27 #include "framework/Document.h"
Chris@246 28 #include "data/fileio/WavFileWriter.h"
Chris@246 29 #include "plugin/transform/TransformFactory.h"
Chris@246 30 #include "widgets/Fader.h"
Chris@246 31 #include "widgets/AudioDial.h"
Chris@246 32
Chris@246 33 #include <QFileInfo>
Chris@246 34
Chris@246 35 void
Chris@246 36 MainWindow::handleOSCMessage(const OSCMessage &message)
Chris@246 37 {
Chris@246 38 std::cerr << "MainWindow::handleOSCMessage: thread id = "
Chris@246 39 << QThread::currentThreadId() << std::endl;
Chris@246 40
Chris@246 41 // This large function should really be abstracted out.
Chris@246 42
Chris@246 43 if (message.getMethod() == "open") {
Chris@246 44
Chris@246 45 if (message.getArgCount() == 1 &&
Chris@246 46 message.getArg(0).canConvert(QVariant::String)) {
Chris@246 47 QString path = message.getArg(0).toString();
Chris@246 48 if (open(path, ReplaceMainModel) != FileOpenSucceeded) {
Chris@246 49 std::cerr << "MainWindow::handleOSCMessage: File open failed for path \""
Chris@246 50 << path.toStdString() << "\"" << std::endl;
Chris@246 51 }
Chris@246 52 //!!! we really need to spin here and not return until the
Chris@246 53 // file has been completely decoded...
Chris@246 54 }
Chris@246 55
Chris@246 56 } else if (message.getMethod() == "openadditional") {
Chris@246 57
Chris@246 58 if (message.getArgCount() == 1 &&
Chris@246 59 message.getArg(0).canConvert(QVariant::String)) {
Chris@246 60 QString path = message.getArg(0).toString();
Chris@246 61 if (open(path, CreateAdditionalModel) != FileOpenSucceeded) {
Chris@246 62 std::cerr << "MainWindow::handleOSCMessage: File open failed for path \""
Chris@246 63 << path.toStdString() << "\"" << std::endl;
Chris@246 64 }
Chris@246 65 }
Chris@246 66
Chris@246 67 } else if (message.getMethod() == "recent" ||
Chris@246 68 message.getMethod() == "last") {
Chris@246 69
Chris@246 70 int n = 0;
Chris@246 71 if (message.getMethod() == "recent" &&
Chris@246 72 message.getArgCount() == 1 &&
Chris@246 73 message.getArg(0).canConvert(QVariant::Int)) {
Chris@246 74 n = message.getArg(0).toInt() - 1;
Chris@246 75 }
Chris@246 76 std::vector<QString> recent = m_recentFiles.getRecent();
Chris@246 77 if (n >= 0 && n < int(recent.size())) {
Chris@246 78 if (open(recent[n], ReplaceMainModel) != FileOpenSucceeded) {
Chris@246 79 std::cerr << "MainWindow::handleOSCMessage: File open failed for path \""
Chris@246 80 << recent[n].toStdString() << "\"" << std::endl;
Chris@246 81 }
Chris@246 82 }
Chris@246 83
Chris@246 84 } else if (message.getMethod() == "save") {
Chris@246 85
Chris@246 86 QString path;
Chris@246 87 if (message.getArgCount() == 1 &&
Chris@246 88 message.getArg(0).canConvert(QVariant::String)) {
Chris@246 89 path = message.getArg(0).toString();
Chris@246 90 if (QFileInfo(path).exists()) {
Chris@246 91 std::cerr << "MainWindow::handleOSCMessage: Refusing to overwrite existing file in save" << std::endl;
Chris@246 92 } else {
Chris@246 93 saveSessionFile(path);
Chris@246 94 }
Chris@246 95 }
Chris@246 96
Chris@246 97 } else if (message.getMethod() == "export") {
Chris@246 98
Chris@246 99 QString path;
Chris@246 100 if (getMainModel()) {
Chris@246 101 if (message.getArgCount() == 1 &&
Chris@246 102 message.getArg(0).canConvert(QVariant::String)) {
Chris@246 103 path = message.getArg(0).toString();
Chris@246 104 if (QFileInfo(path).exists()) {
Chris@246 105 std::cerr << "MainWindow::handleOSCMessage: Refusing to overwrite existing file in export" << std::endl;
Chris@246 106 } else {
Chris@246 107 WavFileWriter writer(path,
Chris@246 108 getMainModel()->getSampleRate(),
Chris@246 109 getMainModel()->getChannelCount());
Chris@246 110 MultiSelection ms = m_viewManager->getSelection();
Chris@246 111 if (!ms.getSelections().empty()) {
Chris@246 112 writer.writeModel(getMainModel(), &ms);
Chris@246 113 } else {
Chris@246 114 writer.writeModel(getMainModel());
Chris@246 115 }
Chris@246 116 }
Chris@246 117 }
Chris@246 118 }
Chris@246 119
Chris@246 120 } else if (message.getMethod() == "jump" ||
Chris@246 121 message.getMethod() == "play") {
Chris@246 122
Chris@246 123 if (getMainModel()) {
Chris@246 124
Chris@246 125 unsigned long frame = m_viewManager->getPlaybackFrame();
Chris@246 126 bool selection = false;
Chris@246 127 bool play = (message.getMethod() == "play");
Chris@246 128
Chris@246 129 if (message.getArgCount() == 1) {
Chris@246 130
Chris@246 131 if (message.getArg(0).canConvert(QVariant::String) &&
Chris@246 132 message.getArg(0).toString() == "selection") {
Chris@246 133
Chris@246 134 selection = true;
Chris@246 135
Chris@246 136 } else if (message.getArg(0).canConvert(QVariant::String) &&
Chris@246 137 message.getArg(0).toString() == "end") {
Chris@246 138
Chris@246 139 frame = getMainModel()->getEndFrame();
Chris@246 140
Chris@246 141 } else if (message.getArg(0).canConvert(QVariant::Double)) {
Chris@246 142
Chris@246 143 double time = message.getArg(0).toDouble();
Chris@246 144 if (time < 0.0) time = 0.0;
Chris@246 145
Chris@246 146 frame = lrint(time * getMainModel()->getSampleRate());
Chris@246 147 }
Chris@246 148 }
Chris@246 149
Chris@246 150 if (frame > getMainModel()->getEndFrame()) {
Chris@246 151 frame = getMainModel()->getEndFrame();
Chris@246 152 }
Chris@246 153
Chris@246 154 if (play) {
Chris@246 155 m_viewManager->setPlaySelectionMode(selection);
Chris@246 156 }
Chris@246 157
Chris@246 158 if (selection) {
Chris@246 159 MultiSelection::SelectionList sl = m_viewManager->getSelections();
Chris@246 160 if (!sl.empty()) {
Chris@246 161 frame = sl.begin()->getStartFrame();
Chris@246 162 }
Chris@246 163 }
Chris@246 164
Chris@246 165 m_viewManager->setPlaybackFrame(frame);
Chris@246 166
Chris@246 167 if (play && !m_playSource->isPlaying()) {
Chris@246 168 m_playSource->play(frame);
Chris@246 169 }
Chris@246 170 }
Chris@246 171
Chris@246 172 } else if (message.getMethod() == "stop") {
Chris@246 173
Chris@246 174 if (m_playSource->isPlaying()) m_playSource->stop();
Chris@246 175
Chris@246 176 } else if (message.getMethod() == "loop") {
Chris@246 177
Chris@246 178 if (message.getArgCount() == 1 &&
Chris@246 179 message.getArg(0).canConvert(QVariant::String)) {
Chris@246 180
Chris@246 181 QString str = message.getArg(0).toString();
Chris@246 182 if (str == "on") {
Chris@246 183 m_viewManager->setPlayLoopMode(true);
Chris@246 184 } else if (str == "off") {
Chris@246 185 m_viewManager->setPlayLoopMode(false);
Chris@246 186 }
Chris@246 187 }
Chris@246 188
Chris@246 189 } else if (message.getMethod() == "solo") {
Chris@246 190
Chris@246 191 if (message.getArgCount() == 1 &&
Chris@246 192 message.getArg(0).canConvert(QVariant::String)) {
Chris@246 193
Chris@246 194 QString str = message.getArg(0).toString();
Chris@246 195 if (str == "on") {
Chris@246 196 m_viewManager->setPlaySoloMode(true);
Chris@246 197 } else if (str == "off") {
Chris@246 198 m_viewManager->setPlaySoloMode(false);
Chris@246 199 }
Chris@246 200 }
Chris@246 201
Chris@246 202 } else if (message.getMethod() == "select" ||
Chris@246 203 message.getMethod() == "addselect") {
Chris@246 204
Chris@246 205 if (getMainModel()) {
Chris@246 206
Chris@246 207 int f0 = getMainModel()->getStartFrame();
Chris@246 208 int f1 = getMainModel()->getEndFrame();
Chris@246 209
Chris@246 210 bool done = false;
Chris@246 211
Chris@246 212 if (message.getArgCount() == 2 &&
Chris@246 213 message.getArg(0).canConvert(QVariant::Double) &&
Chris@246 214 message.getArg(1).canConvert(QVariant::Double)) {
Chris@246 215
Chris@246 216 double t0 = message.getArg(0).toDouble();
Chris@246 217 double t1 = message.getArg(1).toDouble();
Chris@246 218 if (t1 < t0) { double temp = t0; t0 = t1; t1 = temp; }
Chris@246 219 if (t0 < 0.0) t0 = 0.0;
Chris@246 220 if (t1 < 0.0) t1 = 0.0;
Chris@246 221
Chris@246 222 f0 = lrint(t0 * getMainModel()->getSampleRate());
Chris@246 223 f1 = lrint(t1 * getMainModel()->getSampleRate());
Chris@246 224
Chris@246 225 Pane *pane = m_paneStack->getCurrentPane();
Chris@246 226 Layer *layer = 0;
Chris@246 227 if (pane) layer = pane->getSelectedLayer();
Chris@246 228 if (layer) {
Chris@246 229 size_t resolution;
Chris@246 230 layer->snapToFeatureFrame(pane, f0, resolution,
Chris@246 231 Layer::SnapLeft);
Chris@246 232 layer->snapToFeatureFrame(pane, f1, resolution,
Chris@246 233 Layer::SnapRight);
Chris@246 234 }
Chris@246 235
Chris@246 236 } else if (message.getArgCount() == 1 &&
Chris@246 237 message.getArg(0).canConvert(QVariant::String)) {
Chris@246 238
Chris@246 239 QString str = message.getArg(0).toString();
Chris@246 240 if (str == "none") {
Chris@246 241 m_viewManager->clearSelections();
Chris@246 242 done = true;
Chris@246 243 }
Chris@246 244 }
Chris@246 245
Chris@246 246 if (!done) {
Chris@246 247 if (message.getMethod() == "select") {
Chris@246 248 m_viewManager->setSelection(Selection(f0, f1));
Chris@246 249 } else {
Chris@246 250 m_viewManager->addSelection(Selection(f0, f1));
Chris@246 251 }
Chris@246 252 }
Chris@246 253 }
Chris@246 254
Chris@246 255 } else if (message.getMethod() == "add") {
Chris@246 256
Chris@246 257 if (getMainModel()) {
Chris@246 258
Chris@246 259 if (message.getArgCount() >= 1 &&
Chris@246 260 message.getArg(0).canConvert(QVariant::String)) {
Chris@246 261
Chris@246 262 int channel = -1;
Chris@246 263 if (message.getArgCount() == 2 &&
Chris@246 264 message.getArg(0).canConvert(QVariant::Int)) {
Chris@246 265 channel = message.getArg(0).toInt();
Chris@246 266 if (channel < -1 ||
Chris@246 267 channel > int(getMainModel()->getChannelCount())) {
Chris@246 268 std::cerr << "WARNING: MainWindow::handleOSCMessage: channel "
Chris@246 269 << channel << " out of range" << std::endl;
Chris@246 270 channel = -1;
Chris@246 271 }
Chris@246 272 }
Chris@246 273
Chris@246 274 QString str = message.getArg(0).toString();
Chris@246 275
Chris@246 276 LayerFactory::LayerType type =
Chris@246 277 LayerFactory::getInstance()->getLayerTypeForName(str);
Chris@246 278
Chris@246 279 if (type == LayerFactory::UnknownLayer) {
Chris@246 280 std::cerr << "WARNING: MainWindow::handleOSCMessage: unknown layer "
Chris@246 281 << "type " << str.toStdString() << std::endl;
Chris@246 282 } else {
Chris@246 283
Chris@246 284 LayerConfiguration configuration(type,
Chris@246 285 getMainModel(),
Chris@246 286 channel);
Chris@246 287
Chris@246 288 addPane(configuration,
Chris@246 289 tr("Add %1 Pane")
Chris@246 290 .arg(LayerFactory::getInstance()->
Chris@246 291 getLayerPresentationName(type)));
Chris@246 292 }
Chris@246 293 }
Chris@246 294 }
Chris@246 295
Chris@246 296 } else if (message.getMethod() == "undo") {
Chris@246 297
Chris@246 298 CommandHistory::getInstance()->undo();
Chris@246 299
Chris@246 300 } else if (message.getMethod() == "redo") {
Chris@246 301
Chris@246 302 CommandHistory::getInstance()->redo();
Chris@246 303
Chris@246 304 } else if (message.getMethod() == "set") {
Chris@246 305
Chris@246 306 if (message.getArgCount() == 2 &&
Chris@246 307 message.getArg(0).canConvert(QVariant::String) &&
Chris@246 308 message.getArg(1).canConvert(QVariant::Double)) {
Chris@246 309
Chris@246 310 QString property = message.getArg(0).toString();
Chris@246 311 float value = (float)message.getArg(1).toDouble();
Chris@246 312
Chris@246 313 if (property == "gain") {
Chris@246 314 if (value < 0.0) value = 0.0;
Chris@246 315 m_fader->setValue(value);
Chris@246 316 if (m_playTarget) m_playTarget->setOutputGain(value);
Chris@246 317 } else if (property == "speedup") {
Chris@246 318 m_playSpeed->setMappedValue(value);
Chris@246 319 } else if (property == "overlays") {
Chris@246 320 if (value < 0.5) {
Chris@246 321 m_viewManager->setOverlayMode(ViewManager::NoOverlays);
Chris@246 322 } else if (value < 1.5) {
Chris@246 323 m_viewManager->setOverlayMode(ViewManager::MinimalOverlays);
Chris@246 324 } else if (value < 2.5) {
Chris@246 325 m_viewManager->setOverlayMode(ViewManager::StandardOverlays);
Chris@246 326 } else {
Chris@246 327 m_viewManager->setOverlayMode(ViewManager::AllOverlays);
Chris@246 328 }
Chris@246 329 } else if (property == "zoomwheels") {
Chris@246 330 m_viewManager->setZoomWheelsEnabled(value > 0.5);
Chris@246 331 } else if (property == "propertyboxes") {
Chris@246 332 bool toggle = ((value < 0.5) !=
Chris@246 333 (m_paneStack->getLayoutStyle() == PaneStack::NoPropertyStacks));
Chris@246 334 if (toggle) togglePropertyBoxes();
Chris@246 335 }
Chris@246 336
Chris@246 337 } else {
Chris@246 338 PropertyContainer *container = 0;
Chris@246 339 Pane *pane = m_paneStack->getCurrentPane();
Chris@246 340 if (pane &&
Chris@246 341 message.getArgCount() == 3 &&
Chris@246 342 message.getArg(0).canConvert(QVariant::String) &&
Chris@246 343 message.getArg(1).canConvert(QVariant::String) &&
Chris@246 344 message.getArg(2).canConvert(QVariant::String)) {
Chris@246 345 if (message.getArg(0).toString() == "pane") {
Chris@246 346 container = pane->getPropertyContainer(0);
Chris@246 347 } else if (message.getArg(0).toString() == "layer") {
Chris@246 348 container = pane->getSelectedLayer();
Chris@246 349 }
Chris@246 350 }
Chris@246 351 if (container) {
Chris@246 352 QString nameString = message.getArg(1).toString();
Chris@246 353 QString valueString = message.getArg(2).toString();
Chris@246 354 container->setPropertyWithCommand(nameString, valueString);
Chris@246 355 }
Chris@246 356 }
Chris@246 357
Chris@246 358 } else if (message.getMethod() == "setcurrent") {
Chris@246 359
Chris@246 360 int paneIndex = -1, layerIndex = -1;
Chris@246 361 bool wantLayer = false;
Chris@246 362
Chris@246 363 if (message.getArgCount() >= 1 &&
Chris@246 364 message.getArg(0).canConvert(QVariant::Int)) {
Chris@246 365
Chris@246 366 paneIndex = message.getArg(0).toInt() - 1;
Chris@246 367
Chris@246 368 if (message.getArgCount() >= 2 &&
Chris@246 369 message.getArg(1).canConvert(QVariant::Int)) {
Chris@246 370 wantLayer = true;
Chris@246 371 layerIndex = message.getArg(1).toInt() - 1;
Chris@246 372 }
Chris@246 373 }
Chris@246 374
Chris@246 375 if (paneIndex >= 0 && paneIndex < m_paneStack->getPaneCount()) {
Chris@246 376 Pane *pane = m_paneStack->getPane(paneIndex);
Chris@246 377 m_paneStack->setCurrentPane(pane);
Chris@246 378 if (layerIndex >= 0 && layerIndex < pane->getLayerCount()) {
Chris@246 379 Layer *layer = pane->getLayer(layerIndex);
Chris@246 380 m_paneStack->setCurrentLayer(pane, layer);
Chris@246 381 } else if (wantLayer && layerIndex == -1) {
Chris@246 382 m_paneStack->setCurrentLayer(pane, 0);
Chris@246 383 }
Chris@246 384 }
Chris@246 385
Chris@246 386 } else if (message.getMethod() == "delete") {
Chris@246 387
Chris@246 388 if (message.getArgCount() == 1 &&
Chris@246 389 message.getArg(0).canConvert(QVariant::String)) {
Chris@246 390
Chris@246 391 QString target = message.getArg(0).toString();
Chris@246 392
Chris@246 393 if (target == "pane") {
Chris@246 394
Chris@246 395 deleteCurrentPane();
Chris@246 396
Chris@246 397 } else if (target == "layer") {
Chris@246 398
Chris@246 399 deleteCurrentLayer();
Chris@246 400
Chris@246 401 } else {
Chris@246 402
Chris@246 403 std::cerr << "WARNING: MainWindow::handleOSCMessage: Unknown delete target " << target.toStdString() << std::endl;
Chris@246 404 }
Chris@246 405 }
Chris@246 406
Chris@246 407 } else if (message.getMethod() == "zoom") {
Chris@246 408
Chris@246 409 if (message.getArgCount() == 1) {
Chris@246 410 if (message.getArg(0).canConvert(QVariant::String) &&
Chris@246 411 message.getArg(0).toString() == "in") {
Chris@246 412 zoomIn();
Chris@246 413 } else if (message.getArg(0).canConvert(QVariant::String) &&
Chris@246 414 message.getArg(0).toString() == "out") {
Chris@246 415 zoomOut();
Chris@246 416 } else if (message.getArg(0).canConvert(QVariant::String) &&
Chris@246 417 message.getArg(0).toString() == "default") {
Chris@246 418 zoomDefault();
Chris@246 419 } else if (message.getArg(0).canConvert(QVariant::Double)) {
Chris@246 420 double level = message.getArg(0).toDouble();
Chris@246 421 Pane *currentPane = m_paneStack->getCurrentPane();
Chris@246 422 if (level < 1.0) level = 1.0;
Chris@246 423 if (currentPane) currentPane->setZoomLevel(lrint(level));
Chris@246 424 }
Chris@246 425 }
Chris@246 426
Chris@246 427 } else if (message.getMethod() == "zoomvertical") {
Chris@246 428
Chris@246 429 Pane *pane = m_paneStack->getCurrentPane();
Chris@246 430 Layer *layer = 0;
Chris@246 431 if (pane && pane->getLayerCount() > 0) {
Chris@246 432 layer = pane->getLayer(pane->getLayerCount() - 1);
Chris@246 433 }
Chris@246 434 int defaultStep = 0;
Chris@246 435 int steps = 0;
Chris@246 436 if (layer) {
Chris@246 437 steps = layer->getVerticalZoomSteps(defaultStep);
Chris@246 438 if (message.getArgCount() == 1 && steps > 0) {
Chris@246 439 if (message.getArg(0).canConvert(QVariant::String) &&
Chris@246 440 message.getArg(0).toString() == "in") {
Chris@246 441 int step = layer->getCurrentVerticalZoomStep() + 1;
Chris@246 442 if (step < steps) layer->setVerticalZoomStep(step);
Chris@246 443 } else if (message.getArg(0).canConvert(QVariant::String) &&
Chris@246 444 message.getArg(0).toString() == "out") {
Chris@246 445 int step = layer->getCurrentVerticalZoomStep() - 1;
Chris@246 446 if (step >= 0) layer->setVerticalZoomStep(step);
Chris@246 447 } else if (message.getArg(0).canConvert(QVariant::String) &&
Chris@246 448 message.getArg(0).toString() == "default") {
Chris@246 449 layer->setVerticalZoomStep(defaultStep);
Chris@246 450 }
Chris@246 451 } else if (message.getArgCount() == 2) {
Chris@246 452 if (message.getArg(0).canConvert(QVariant::Double) &&
Chris@246 453 message.getArg(1).canConvert(QVariant::Double)) {
Chris@246 454 double min = message.getArg(0).toDouble();
Chris@246 455 double max = message.getArg(1).toDouble();
Chris@246 456 layer->setDisplayExtents(min, max);
Chris@246 457 }
Chris@246 458 }
Chris@246 459 }
Chris@246 460
Chris@246 461 } else if (message.getMethod() == "quit") {
Chris@246 462
Chris@246 463 m_abandoning = true;
Chris@246 464 close();
Chris@246 465
Chris@246 466 } else if (message.getMethod() == "resize") {
Chris@246 467
Chris@246 468 if (message.getArgCount() == 2) {
Chris@246 469
Chris@246 470 int width = 0, height = 0;
Chris@246 471
Chris@246 472 if (message.getArg(1).canConvert(QVariant::Int)) {
Chris@246 473
Chris@246 474 height = message.getArg(1).toInt();
Chris@246 475
Chris@246 476 if (message.getArg(0).canConvert(QVariant::String) &&
Chris@246 477 message.getArg(0).toString() == "pane") {
Chris@246 478
Chris@246 479 Pane *pane = m_paneStack->getCurrentPane();
Chris@246 480 if (pane) pane->resize(pane->width(), height);
Chris@246 481
Chris@246 482 } else if (message.getArg(0).canConvert(QVariant::Int)) {
Chris@246 483
Chris@246 484 width = message.getArg(0).toInt();
Chris@246 485 resize(width, height);
Chris@246 486 }
Chris@246 487 }
Chris@246 488 }
Chris@246 489
Chris@246 490 } else if (message.getMethod() == "transform") {
Chris@246 491
Chris@246 492 Pane *pane = m_paneStack->getCurrentPane();
Chris@246 493
Chris@246 494 if (getMainModel() &&
Chris@246 495 pane &&
Chris@246 496 message.getArgCount() == 1 &&
Chris@246 497 message.getArg(0).canConvert(QVariant::String)) {
Chris@246 498
Chris@246 499 TransformId transformId = message.getArg(0).toString();
Chris@246 500
Chris@246 501 Transform transform = TransformFactory::getInstance()->
Chris@246 502 getDefaultTransformFor(transformId);
Chris@246 503
Chris@246 504 Layer *newLayer = m_document->createDerivedLayer
Chris@246 505 (transform, getMainModel());
Chris@246 506
Chris@246 507 if (newLayer) {
Chris@246 508 m_document->addLayerToView(pane, newLayer);
Chris@246 509 m_recentTransforms.add(transformId);
Chris@246 510 m_paneStack->setCurrentLayer(pane, newLayer);
Chris@246 511 }
Chris@246 512 }
Chris@246 513
Chris@246 514 } else {
Chris@246 515 std::cerr << "WARNING: MainWindow::handleOSCMessage: Unknown or unsupported "
Chris@246 516 << "method \"" << message.getMethod().toStdString()
Chris@246 517 << "\"" << std::endl;
Chris@246 518 }
Chris@246 519
Chris@246 520 }