Chris@224
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@224
|
2
|
Chris@224
|
3 /*
|
Chris@224
|
4 Sonic Visualiser
|
Chris@224
|
5 An audio file viewer and annotation editor.
|
Chris@224
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@224
|
7 This file copyright 2006-2007 Chris Cannam and QMUL.
|
Chris@224
|
8
|
Chris@224
|
9 This program is free software; you can redistribute it and/or
|
Chris@224
|
10 modify it under the terms of the GNU General Public License as
|
Chris@224
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@224
|
12 License, or (at your option) any later version. See the file
|
Chris@224
|
13 COPYING included with this distribution for more information.
|
Chris@224
|
14 */
|
Chris@216
|
15
|
Chris@216
|
16 #include "MainWindow.h"
|
Chris@216
|
17 #include "data/osc/OSCQueue.h"
|
Chris@216
|
18
|
Chris@216
|
19 #include "layer/WaveformLayer.h"
|
Chris@216
|
20 #include "view/ViewManager.h"
|
Chris@216
|
21 #include "view/Pane.h"
|
Chris@216
|
22 #include "view/PaneStack.h"
|
Chris@216
|
23 #include "data/model/WaveFileModel.h"
|
Chris@248
|
24 #include "widgets/CommandHistory.h"
|
Chris@1035
|
25 #include "audio/AudioCallbackPlaySource.h"
|
Chris@216
|
26 #include "framework/Document.h"
|
Chris@216
|
27 #include "data/fileio/WavFileWriter.h"
|
Chris@249
|
28 #include "transform/TransformFactory.h"
|
Chris@1386
|
29 #include "widgets/LevelPanWidget.h"
|
Chris@1431
|
30 #include "widgets/LevelPanToolButton.h"
|
Chris@216
|
31 #include "widgets/AudioDial.h"
|
Chris@216
|
32
|
Chris@1035
|
33 #include <bqaudioio/SystemPlaybackTarget.h>
|
Chris@1035
|
34
|
Chris@216
|
35 #include <QFileInfo>
|
Chris@2441
|
36 #include <QTime>
|
Chris@2441
|
37 #include <QElapsedTimer>
|
Chris@2441
|
38
|
Chris@2441
|
39 #define NOW (QTime::currentTime().toString(Qt::ISODateWithMs))
|
Chris@216
|
40
|
Chris@216
|
41 void
|
Chris@216
|
42 MainWindow::handleOSCMessage(const OSCMessage &message)
|
Chris@216
|
43 {
|
Chris@2441
|
44 QElapsedTimer timer;
|
Chris@2441
|
45 timer.start();
|
Chris@2441
|
46
|
Chris@2441
|
47 SVDEBUG << "OSCHandler at " << NOW << ": handling message: "
|
Chris@2441
|
48 << message.toString() << endl;
|
Chris@216
|
49
|
Chris@216
|
50 if (message.getMethod() == "open") {
|
Chris@216
|
51
|
Chris@216
|
52 if (message.getArgCount() == 1 &&
|
Chris@216
|
53 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@216
|
54 QString path = message.getArg(0).toString();
|
Chris@2441
|
55 if (open(path, ReplaceMainModel) == FileOpenSucceeded) {
|
Chris@2441
|
56 SVDEBUG << "OSCHandler: Opened path \""
|
Chris@2441
|
57 << path << "\"" << endl;
|
Chris@2441
|
58 } else {
|
Chris@2441
|
59 SVCERR << "OSCHandler: File open failed for path \""
|
Chris@2441
|
60 << path << "\"" << endl;
|
Chris@216
|
61 }
|
Chris@216
|
62 //!!! we really need to spin here and not return until the
|
Chris@216
|
63 // file has been completely decoded...
|
Chris@2519
|
64 } else {
|
Chris@2519
|
65 SVCERR << "OSCHandler: Usage: /open <filename>" << endl;
|
Chris@216
|
66 }
|
Chris@216
|
67
|
Chris@216
|
68 } else if (message.getMethod() == "openadditional") {
|
Chris@216
|
69
|
Chris@216
|
70 if (message.getArgCount() == 1 &&
|
Chris@216
|
71 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@216
|
72 QString path = message.getArg(0).toString();
|
Chris@2441
|
73 if (open(path, CreateAdditionalModel) == FileOpenSucceeded) {
|
Chris@2441
|
74 SVDEBUG << "OSCHandler: Opened additional path \""
|
Chris@2441
|
75 << path << "\"" << endl;
|
Chris@2441
|
76 } else {
|
Chris@2441
|
77 SVCERR << "OSCHandler: File open failed for path \""
|
Chris@665
|
78 << path << "\"" << endl;
|
Chris@216
|
79 }
|
Chris@2519
|
80 } else {
|
Chris@2519
|
81 SVCERR << "OSCHandler: Usage: /openadditional <filename>" << endl;
|
Chris@216
|
82 }
|
Chris@216
|
83
|
Chris@216
|
84 } else if (message.getMethod() == "recent" ||
|
Chris@216
|
85 message.getMethod() == "last") {
|
Chris@216
|
86
|
Chris@216
|
87 int n = 0;
|
Chris@216
|
88 if (message.getMethod() == "recent" &&
|
Chris@216
|
89 message.getArgCount() == 1 &&
|
Chris@216
|
90 message.getArg(0).canConvert(QVariant::Int)) {
|
Chris@216
|
91 n = message.getArg(0).toInt() - 1;
|
Chris@216
|
92 }
|
Chris@216
|
93 std::vector<QString> recent = m_recentFiles.getRecent();
|
Chris@216
|
94 if (n >= 0 && n < int(recent.size())) {
|
Chris@2441
|
95 QString path = recent[n];
|
Chris@2441
|
96 if (open(path, ReplaceMainModel) == FileOpenSucceeded) {
|
Chris@2441
|
97 SVDEBUG << "OSCHandler: Opened recent path \""
|
Chris@2441
|
98 << path << "\"" << endl;
|
Chris@2441
|
99 } else {
|
Chris@2441
|
100 SVCERR << "OSCHandler: File open failed for path \""
|
Chris@2441
|
101 << path << "\"" << endl;
|
Chris@216
|
102 }
|
Chris@2519
|
103 } else {
|
Chris@2519
|
104 SVCERR << "OSCHandler: Usage: /recent <n>" << endl;
|
Chris@2519
|
105 SVCERR << " or /last" << endl;
|
Chris@216
|
106 }
|
Chris@216
|
107
|
Chris@216
|
108 } else if (message.getMethod() == "save") {
|
Chris@216
|
109
|
Chris@216
|
110 QString path;
|
Chris@216
|
111 if (message.getArgCount() == 1 &&
|
Chris@216
|
112 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@216
|
113 path = message.getArg(0).toString();
|
Chris@216
|
114 if (QFileInfo(path).exists()) {
|
Chris@2441
|
115 SVCERR << "OSCHandler: Refusing to overwrite existing file in save" << endl;
|
Chris@2441
|
116 } else if (saveSessionFile(path)) {
|
Chris@2441
|
117 SVDEBUG << "OSCHandler: Saved session to path \""
|
Chris@2441
|
118 << path << "\"" << endl;
|
Chris@216
|
119 } else {
|
Chris@2441
|
120 SVCERR << "OSCHandler: Save failed to path \""
|
Chris@2441
|
121 << path << "\"" << endl;
|
Chris@216
|
122 }
|
Chris@2519
|
123 } else {
|
Chris@2519
|
124 SVCERR << "OSCHandler: Usage: /save <filename>" << endl;
|
Chris@216
|
125 }
|
Chris@216
|
126
|
Chris@216
|
127 } else if (message.getMethod() == "export") {
|
Chris@216
|
128
|
Chris@216
|
129 QString path;
|
Chris@216
|
130 if (getMainModel()) {
|
Chris@216
|
131 if (message.getArgCount() == 1 &&
|
Chris@216
|
132 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@216
|
133 path = message.getArg(0).toString();
|
Chris@216
|
134 if (QFileInfo(path).exists()) {
|
Chris@2441
|
135 SVCERR << "OSCHandler: Refusing to overwrite existing file in export" << endl;
|
Chris@216
|
136 } else {
|
Chris@216
|
137 WavFileWriter writer(path,
|
Chris@216
|
138 getMainModel()->getSampleRate(),
|
Chris@428
|
139 getMainModel()->getChannelCount(),
|
Chris@428
|
140 WavFileWriter::WriteToTemporary);
|
Chris@216
|
141 MultiSelection ms = m_viewManager->getSelection();
|
Chris@2441
|
142 if (writer.writeModel
|
Chris@2441
|
143 (getMainModel().get(),
|
Chris@2441
|
144 ms.getSelections().empty() ? nullptr : &ms)) {
|
Chris@2441
|
145 SVDEBUG << "OSCHandler: Exported audio to path \""
|
Chris@2441
|
146 << path << "\"" << endl;
|
Chris@216
|
147 } else {
|
Chris@2441
|
148 SVCERR << "OSCHandler: Export failed to path \""
|
Chris@2441
|
149 << path << "\"" << endl;
|
Chris@216
|
150 }
|
Chris@216
|
151 }
|
Chris@216
|
152 }
|
Chris@2519
|
153 } else {
|
Chris@2519
|
154 SVCERR << "OSCHandler: Usage: /export <filename>" << endl;
|
Chris@216
|
155 }
|
Chris@216
|
156
|
Chris@2242
|
157 } else if (message.getMethod() == "exportlayer") {
|
Chris@2242
|
158
|
Chris@2242
|
159 QString path;
|
Chris@2242
|
160 if (message.getArgCount() == 1 &&
|
Chris@2242
|
161 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@2242
|
162 path = message.getArg(0).toString();
|
Chris@2242
|
163 if (QFileInfo(path).exists()) {
|
Chris@2519
|
164 SVCERR << "OSCHandler: Refusing to overwrite existing file in layer export" << endl;
|
Chris@2242
|
165 } else {
|
Chris@2242
|
166 Pane *currentPane = nullptr;
|
Chris@2242
|
167 Layer *currentLayer = nullptr;
|
Chris@2242
|
168 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
|
Chris@2242
|
169 if (currentPane) currentLayer = currentPane->getSelectedLayer();
|
Chris@2442
|
170 MultiSelection ms = m_viewManager->getSelection();
|
Chris@2242
|
171 if (currentLayer) {
|
Chris@2242
|
172 QString error;
|
Chris@2442
|
173 if (exportLayerTo
|
Chris@2442
|
174 (currentLayer, currentPane,
|
Chris@2442
|
175 ms.getSelections().empty() ? nullptr : &ms,
|
Chris@2442
|
176 path, error)) {
|
Chris@2442
|
177 SVDEBUG << "OSCHandler: Exported layer \""
|
Chris@2442
|
178 << currentLayer->getLayerPresentationName()
|
Chris@2442
|
179 << "\" to path \"" << path << "\"" << endl;
|
Chris@2442
|
180 } else {
|
Chris@2442
|
181 SVCERR << "OSCHandler: Export failed to path \""
|
Chris@2442
|
182 << path << "\"" << endl;
|
Chris@2242
|
183 }
|
Chris@2242
|
184 } else {
|
Chris@2242
|
185 SVCERR << "OSCHandler: No current layer to export" << endl;
|
Chris@2242
|
186 }
|
Chris@2242
|
187 }
|
Chris@2519
|
188 } else {
|
Chris@2519
|
189 SVCERR << "OSCHandler: Usage: /exportlayer <filename>" << endl;
|
Chris@2519
|
190 }
|
Chris@2519
|
191
|
Chris@2519
|
192 } else if (message.getMethod() == "exportimage") {
|
Chris@2519
|
193
|
Chris@2519
|
194 QString path;
|
Chris@2519
|
195 if (message.getArgCount() == 1 &&
|
Chris@2519
|
196 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@2519
|
197 path = message.getArg(0).toString();
|
Chris@2519
|
198 if (QFileInfo(path).exists()) {
|
Chris@2519
|
199 SVCERR << "OSCHandler: Refusing to overwrite existing file in image export" << endl;
|
Chris@2519
|
200 } else {
|
Chris@2519
|
201 Pane *currentPane = nullptr;
|
Chris@2519
|
202 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
|
Chris@2519
|
203 MultiSelection ms = m_viewManager->getSelection();
|
Chris@2519
|
204 if (currentPane) {
|
Chris@2519
|
205 QImage *image = nullptr;
|
Chris@2519
|
206 auto sel = ms.getSelections();
|
Chris@2519
|
207 if (!sel.empty()) {
|
Chris@2519
|
208 sv_frame_t sf0 = sel.begin()->getStartFrame();
|
Chris@2519
|
209 sv_frame_t sf1 = sel.rbegin()->getEndFrame();
|
Chris@2519
|
210 image = currentPane->renderPartToNewImage(sf0, sf1);
|
Chris@2519
|
211 } else {
|
Chris@2519
|
212 image = currentPane->renderToNewImage();
|
Chris@2519
|
213 }
|
Chris@2519
|
214 if (!image) {
|
Chris@2519
|
215 SVCERR << "OSCHandler: Failed to create image from pane"
|
Chris@2519
|
216 << endl;
|
Chris@2519
|
217 } else if (!image->save(path, "PNG")) {
|
Chris@2519
|
218 SVCERR << "OSCHandler: Export failed to image file \""
|
Chris@2519
|
219 << path << "\"" << endl;
|
Chris@2519
|
220 } else {
|
Chris@2519
|
221 SVDEBUG << "OSCHandler: Exported pane to image file \""
|
Chris@2519
|
222 << path << "\"" << endl;
|
Chris@2519
|
223 }
|
Chris@2519
|
224 delete image;
|
Chris@2519
|
225 } else {
|
Chris@2519
|
226 SVCERR << "OSCHandler: No current pane to export" << endl;
|
Chris@2519
|
227 }
|
Chris@2519
|
228 }
|
Chris@2519
|
229 } else {
|
Chris@2519
|
230 SVCERR << "OSCHandler: Usage: /exportimage <filename>" << endl;
|
Chris@2519
|
231 }
|
Chris@2519
|
232
|
Chris@2519
|
233 } else if (message.getMethod() == "exportsvg") {
|
Chris@2519
|
234
|
Chris@2519
|
235 QString path;
|
Chris@2519
|
236 if (message.getArgCount() == 1 &&
|
Chris@2519
|
237 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@2519
|
238 path = message.getArg(0).toString();
|
Chris@2519
|
239 if (QFileInfo(path).exists()) {
|
Chris@2519
|
240 SVCERR << "OSCHandler: Refusing to overwrite existing file in SVG export" << endl;
|
Chris@2519
|
241 } else {
|
Chris@2519
|
242 Pane *currentPane = nullptr;
|
Chris@2519
|
243 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
|
Chris@2519
|
244 MultiSelection ms = m_viewManager->getSelection();
|
Chris@2519
|
245 if (currentPane) {
|
Chris@2519
|
246 bool result = false;
|
Chris@2519
|
247 auto sel = ms.getSelections();
|
Chris@2519
|
248 if (!sel.empty()) {
|
Chris@2519
|
249 sv_frame_t sf0 = sel.begin()->getStartFrame();
|
Chris@2519
|
250 sv_frame_t sf1 = sel.rbegin()->getEndFrame();
|
Chris@2519
|
251 result = currentPane->renderPartToSvgFile(path, sf0, sf1);
|
Chris@2519
|
252 } else {
|
Chris@2519
|
253 result = currentPane->renderToSvgFile(path);
|
Chris@2519
|
254 }
|
Chris@2519
|
255 if (!result) {
|
Chris@2519
|
256 SVCERR << "OSCHandler: Export failed to SVG file \""
|
Chris@2519
|
257 << path << "\"" << endl;
|
Chris@2519
|
258 } else {
|
Chris@2519
|
259 SVDEBUG << "OSCHandler: Exported pane to SVG file \""
|
Chris@2519
|
260 << path << "\"" << endl;
|
Chris@2519
|
261 }
|
Chris@2519
|
262 } else {
|
Chris@2519
|
263 SVCERR << "OSCHandler: No current pane to export" << endl;
|
Chris@2519
|
264 }
|
Chris@2519
|
265 }
|
Chris@2519
|
266 } else {
|
Chris@2519
|
267 SVCERR << "OSCHandler: Usage: /exportsvg <filename>" << endl;
|
Chris@2242
|
268 }
|
Chris@2242
|
269
|
Chris@216
|
270 } else if (message.getMethod() == "jump" ||
|
Chris@216
|
271 message.getMethod() == "play") {
|
Chris@216
|
272
|
Chris@216
|
273 if (getMainModel()) {
|
Chris@216
|
274
|
Chris@922
|
275 sv_frame_t frame = m_viewManager->getPlaybackFrame();
|
Chris@216
|
276 bool selection = false;
|
Chris@216
|
277 bool play = (message.getMethod() == "play");
|
Chris@216
|
278
|
Chris@216
|
279 if (message.getArgCount() == 1) {
|
Chris@216
|
280
|
Chris@216
|
281 if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@216
|
282 message.getArg(0).toString() == "selection") {
|
Chris@216
|
283
|
Chris@216
|
284 selection = true;
|
Chris@216
|
285
|
Chris@216
|
286 } else if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@216
|
287 message.getArg(0).toString() == "end") {
|
Chris@216
|
288
|
Chris@216
|
289 frame = getMainModel()->getEndFrame();
|
Chris@216
|
290
|
Chris@216
|
291 } else if (message.getArg(0).canConvert(QVariant::Double)) {
|
Chris@216
|
292
|
Chris@216
|
293 double time = message.getArg(0).toDouble();
|
Chris@216
|
294 if (time < 0.0) time = 0.0;
|
Chris@216
|
295
|
Chris@216
|
296 frame = lrint(time * getMainModel()->getSampleRate());
|
Chris@216
|
297 }
|
Chris@216
|
298 }
|
Chris@216
|
299
|
Chris@216
|
300 if (frame > getMainModel()->getEndFrame()) {
|
Chris@216
|
301 frame = getMainModel()->getEndFrame();
|
Chris@216
|
302 }
|
Chris@216
|
303
|
Chris@216
|
304 if (play) {
|
Chris@216
|
305 m_viewManager->setPlaySelectionMode(selection);
|
Chris@216
|
306 }
|
Chris@216
|
307
|
Chris@216
|
308 if (selection) {
|
Chris@216
|
309 MultiSelection::SelectionList sl = m_viewManager->getSelections();
|
Chris@216
|
310 if (!sl.empty()) {
|
Chris@216
|
311 frame = sl.begin()->getStartFrame();
|
Chris@216
|
312 }
|
Chris@216
|
313 }
|
Chris@216
|
314
|
Chris@1617
|
315 SVDEBUG << "OSCHandler: Setting playback frame to " << frame << endl;
|
Chris@1617
|
316
|
Chris@216
|
317 m_viewManager->setPlaybackFrame(frame);
|
Chris@216
|
318
|
Chris@1617
|
319 if (play) {
|
Chris@1617
|
320 if (!m_playSource->isPlaying()) {
|
Chris@1617
|
321 SVDEBUG << "OSCHandler: Play source is not yet playing, calling play()" << endl;
|
Chris@1617
|
322 // handles audio device suspend/resume etc, as
|
Chris@1617
|
323 // well as calling m_playSource->play(frame)
|
Chris@1617
|
324 MainWindow::play();
|
Chris@1617
|
325 } else {
|
Chris@1617
|
326 SVDEBUG << "OSCHandler: Play source is already playing, not starting it" << endl;
|
Chris@1617
|
327 }
|
Chris@1617
|
328 } else {
|
Chris@1617
|
329 SVDEBUG << "OSCHandler: Jump only requested, not starting playback" << endl;
|
Chris@216
|
330 }
|
Chris@216
|
331 }
|
Chris@216
|
332
|
Chris@313
|
333 } else if (message.getMethod() == "ffwd") {
|
Chris@313
|
334
|
Chris@313
|
335 if (message.getArgCount() == 1) {
|
Chris@313
|
336
|
Chris@313
|
337 if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@313
|
338 message.getArg(0).toString() == "similar") {
|
Chris@313
|
339
|
Chris@2441
|
340 SVDEBUG << "OSCHandler: Calling ffwdSimilar" << endl;
|
Chris@313
|
341 ffwdSimilar();
|
Chris@313
|
342 }
|
Chris@313
|
343 } else {
|
Chris@313
|
344
|
Chris@2441
|
345 SVDEBUG << "OSCHandler: Calling ffwd" << endl;
|
Chris@313
|
346 ffwd();
|
Chris@313
|
347 }
|
Chris@313
|
348
|
Chris@313
|
349 } else if (message.getMethod() == "rewind") {
|
Chris@313
|
350
|
Chris@313
|
351 if (message.getArgCount() == 1) {
|
Chris@313
|
352
|
Chris@313
|
353 if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@313
|
354 message.getArg(0).toString() == "similar") {
|
Chris@313
|
355
|
Chris@2441
|
356 SVDEBUG << "OSCHandler: Calling rewindSimilar" << endl;
|
Chris@313
|
357 rewindSimilar();
|
Chris@313
|
358 }
|
Chris@313
|
359 } else {
|
Chris@313
|
360
|
Chris@2441
|
361 SVDEBUG << "OSCHandler: Calling rewind" << endl;
|
Chris@313
|
362 rewind();
|
Chris@313
|
363 }
|
Chris@313
|
364
|
Chris@216
|
365 } else if (message.getMethod() == "stop") {
|
Chris@216
|
366
|
Chris@2441
|
367 if (m_playSource->isPlaying()) {
|
Chris@2441
|
368 // As with play, we want to use the MainWindow function
|
Chris@2441
|
369 // rather than call m_playSource directly because that way
|
Chris@2441
|
370 // the audio driver suspend/resume etc is handled properly
|
Chris@2441
|
371 SVDEBUG << "OSCHandler: Calling stop" << endl;
|
Chris@2441
|
372 MainWindow::stop();
|
Chris@2441
|
373 } else {
|
Chris@2441
|
374 SVDEBUG << "OSCHandler: Not playing, doing nothing" << endl;
|
Chris@2441
|
375 }
|
Chris@216
|
376
|
Chris@216
|
377 } else if (message.getMethod() == "loop") {
|
Chris@216
|
378
|
Chris@216
|
379 if (message.getArgCount() == 1 &&
|
Chris@216
|
380 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@216
|
381
|
Chris@216
|
382 QString str = message.getArg(0).toString();
|
Chris@216
|
383 if (str == "on") {
|
Chris@2441
|
384 SVDEBUG << "OSCHandler: Enabling loop mode" << endl;
|
Chris@216
|
385 m_viewManager->setPlayLoopMode(true);
|
Chris@216
|
386 } else if (str == "off") {
|
Chris@2441
|
387 SVDEBUG << "OSCHandler: Disabling loop mode" << endl;
|
Chris@216
|
388 m_viewManager->setPlayLoopMode(false);
|
Chris@216
|
389 }
|
Chris@216
|
390 }
|
Chris@216
|
391
|
Chris@216
|
392 } else if (message.getMethod() == "solo") {
|
Chris@216
|
393
|
Chris@216
|
394 if (message.getArgCount() == 1 &&
|
Chris@216
|
395 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@216
|
396
|
Chris@216
|
397 QString str = message.getArg(0).toString();
|
Chris@216
|
398 if (str == "on") {
|
Chris@2441
|
399 SVDEBUG << "OSCHandler: Enabling solo mode" << endl;
|
Chris@216
|
400 m_viewManager->setPlaySoloMode(true);
|
Chris@216
|
401 } else if (str == "off") {
|
Chris@2441
|
402 SVDEBUG << "OSCHandler: Disabling solo mode" << endl;
|
Chris@216
|
403 m_viewManager->setPlaySoloMode(false);
|
Chris@216
|
404 }
|
Chris@216
|
405 }
|
Chris@216
|
406
|
Chris@216
|
407 } else if (message.getMethod() == "select" ||
|
Chris@216
|
408 message.getMethod() == "addselect") {
|
Chris@216
|
409
|
Chris@216
|
410 if (getMainModel()) {
|
Chris@216
|
411
|
Chris@920
|
412 sv_frame_t f0 = getMainModel()->getStartFrame();
|
Chris@920
|
413 sv_frame_t f1 = getMainModel()->getEndFrame();
|
Chris@216
|
414
|
Chris@216
|
415 bool done = false;
|
Chris@216
|
416
|
Chris@216
|
417 if (message.getArgCount() == 2 &&
|
Chris@216
|
418 message.getArg(0).canConvert(QVariant::Double) &&
|
Chris@216
|
419 message.getArg(1).canConvert(QVariant::Double)) {
|
Chris@216
|
420
|
Chris@216
|
421 double t0 = message.getArg(0).toDouble();
|
Chris@216
|
422 double t1 = message.getArg(1).toDouble();
|
Chris@216
|
423 if (t1 < t0) { double temp = t0; t0 = t1; t1 = temp; }
|
Chris@216
|
424 if (t0 < 0.0) t0 = 0.0;
|
Chris@216
|
425 if (t1 < 0.0) t1 = 0.0;
|
Chris@216
|
426
|
Chris@216
|
427 f0 = lrint(t0 * getMainModel()->getSampleRate());
|
Chris@216
|
428 f1 = lrint(t1 * getMainModel()->getSampleRate());
|
Chris@2441
|
429
|
Chris@2441
|
430 SVDEBUG << "OSCHandler: Converted selection extents to frames "
|
Chris@2441
|
431 << f0 << " and " << f1 << endl;
|
Chris@216
|
432
|
Chris@216
|
433 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@2126
|
434 Layer *layer = nullptr;
|
Chris@216
|
435 if (pane) layer = pane->getSelectedLayer();
|
Chris@216
|
436 if (layer) {
|
Chris@730
|
437 int resolution;
|
Chris@216
|
438 layer->snapToFeatureFrame(pane, f0, resolution,
|
Chris@2380
|
439 Layer::SnapLeft, -1);
|
Chris@216
|
440 layer->snapToFeatureFrame(pane, f1, resolution,
|
Chris@2380
|
441 Layer::SnapRight, -1);
|
Chris@2441
|
442
|
Chris@2441
|
443 SVDEBUG << "OSCHandler: Snapped selection extents to "
|
Chris@2441
|
444 << f0 << " and " << f1 << " for current layer \""
|
Chris@2441
|
445 << layer->getLayerPresentationName() << "\""
|
Chris@2441
|
446 << endl;
|
Chris@216
|
447 }
|
Chris@216
|
448
|
Chris@216
|
449 } else if (message.getArgCount() == 1 &&
|
Chris@216
|
450 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@2519
|
451
|
Chris@216
|
452 QString str = message.getArg(0).toString();
|
Chris@216
|
453 if (str == "none") {
|
Chris@2441
|
454 SVDEBUG << "OSCHandler: Clearing selection" << endl;
|
Chris@216
|
455 m_viewManager->clearSelections();
|
Chris@216
|
456 done = true;
|
Chris@2441
|
457 } else if (str == "all") {
|
Chris@2441
|
458 SVDEBUG << "OSCHandler: Selecting all" << endl;
|
Chris@2441
|
459 f0 = getModelsStartFrame();
|
Chris@2441
|
460 f0 = getModelsEndFrame();
|
Chris@216
|
461 }
|
Chris@216
|
462 }
|
Chris@216
|
463
|
Chris@216
|
464 if (!done) {
|
Chris@216
|
465 if (message.getMethod() == "select") {
|
Chris@216
|
466 m_viewManager->setSelection(Selection(f0, f1));
|
Chris@216
|
467 } else {
|
Chris@216
|
468 m_viewManager->addSelection(Selection(f0, f1));
|
Chris@216
|
469 }
|
Chris@216
|
470 }
|
Chris@2441
|
471
|
Chris@2441
|
472 SVDEBUG << "OSCHandler: Selection now is "
|
Chris@2441
|
473 << m_viewManager->getSelection().toString() << endl;
|
Chris@2441
|
474
|
Chris@2441
|
475 } else {
|
Chris@2441
|
476 SVCERR << "OSCHandler: No main model, can't modify selection"
|
Chris@2441
|
477 << endl;
|
Chris@216
|
478 }
|
Chris@216
|
479
|
Chris@216
|
480 } else if (message.getMethod() == "add") {
|
Chris@216
|
481
|
Chris@216
|
482 if (getMainModel()) {
|
Chris@216
|
483
|
Chris@216
|
484 if (message.getArgCount() >= 1 &&
|
Chris@216
|
485 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@216
|
486
|
Chris@216
|
487 int channel = -1;
|
Chris@216
|
488 if (message.getArgCount() == 2 &&
|
Chris@216
|
489 message.getArg(0).canConvert(QVariant::Int)) {
|
Chris@216
|
490 channel = message.getArg(0).toInt();
|
Chris@216
|
491 if (channel < -1 ||
|
Chris@2519
|
492 channel >= int(getMainModel()->getChannelCount())) {
|
Chris@2519
|
493 SVCERR << "OSCHandler: channel " << channel
|
Chris@2519
|
494 << " out of range (0 to "
|
Chris@2519
|
495 << (getMainModel()->getChannelCount() - 1)
|
Chris@2519
|
496 << ")" << endl;
|
Chris@216
|
497 channel = -1;
|
Chris@216
|
498 }
|
Chris@216
|
499 }
|
Chris@216
|
500
|
Chris@216
|
501 QString str = message.getArg(0).toString();
|
Chris@216
|
502
|
Chris@216
|
503 LayerFactory::LayerType type =
|
Chris@216
|
504 LayerFactory::getInstance()->getLayerTypeForName(str);
|
Chris@216
|
505
|
Chris@216
|
506 if (type == LayerFactory::UnknownLayer) {
|
Chris@2441
|
507 SVCERR << "WARNING: OSCHandler: unknown layer "
|
Chris@2441
|
508 << "type " << str << endl;
|
Chris@216
|
509 } else {
|
Chris@216
|
510
|
Chris@232
|
511 LayerConfiguration configuration(type,
|
Chris@2300
|
512 getMainModelId(),
|
Chris@232
|
513 channel);
|
Chris@2441
|
514
|
Chris@2441
|
515 QString pname = LayerFactory::getInstance()->
|
Chris@2441
|
516 getLayerPresentationName(type);
|
Chris@216
|
517
|
Chris@2441
|
518 addPane(configuration, tr("Add %1 Pane") .arg(pname));
|
Chris@2441
|
519
|
Chris@2441
|
520 SVDEBUG << "OSCHandler: Added pane \"" << pname
|
Chris@2441
|
521 << "\"" << endl;
|
Chris@216
|
522 }
|
Chris@2519
|
523 } else {
|
Chris@2519
|
524 SVCERR << "OSCHandler: Usage: /add <layertype> [<channel>]"
|
Chris@2519
|
525 << endl;
|
Chris@216
|
526 }
|
Chris@216
|
527 }
|
Chris@216
|
528
|
Chris@216
|
529 } else if (message.getMethod() == "undo") {
|
Chris@216
|
530
|
Chris@2441
|
531 SVDEBUG << "OSCHandler: Calling undo" << endl;
|
Chris@216
|
532 CommandHistory::getInstance()->undo();
|
Chris@216
|
533
|
Chris@216
|
534 } else if (message.getMethod() == "redo") {
|
Chris@216
|
535
|
Chris@2441
|
536 SVDEBUG << "OSCHandler: Calling redo" << endl;
|
Chris@216
|
537 CommandHistory::getInstance()->redo();
|
Chris@216
|
538
|
Chris@216
|
539 } else if (message.getMethod() == "set") {
|
Chris@216
|
540
|
Chris@216
|
541 if (message.getArgCount() == 2 &&
|
Chris@216
|
542 message.getArg(0).canConvert(QVariant::String) &&
|
Chris@216
|
543 message.getArg(1).canConvert(QVariant::Double)) {
|
Chris@216
|
544
|
Chris@216
|
545 QString property = message.getArg(0).toString();
|
Chris@216
|
546 float value = (float)message.getArg(1).toDouble();
|
Chris@216
|
547
|
Chris@216
|
548 if (property == "gain") {
|
Chris@216
|
549 if (value < 0.0) value = 0.0;
|
Chris@1386
|
550 m_mainLevelPan->setLevel(value);
|
Chris@216
|
551 if (m_playTarget) m_playTarget->setOutputGain(value);
|
Chris@1617
|
552 } else if (property == "speed") {
|
Chris@1617
|
553 m_playSpeed->setMappedValue(value);
|
Chris@216
|
554 } else if (property == "speedup") {
|
Chris@1617
|
555
|
Chris@1617
|
556 // The speedup method existed before the speed method
|
Chris@1617
|
557 // and is a bit weirder.
|
Chris@1617
|
558 //
|
Chris@1617
|
559 // For speed(x), x is a percentage of normal speed, so
|
Chris@1617
|
560 // x=100 means play at the normal speed, x=50 means
|
Chris@1617
|
561 // half speed, x=200 double speed etc.
|
Chris@1617
|
562 //
|
Chris@1617
|
563 // For speedup(x), x was some sort of modifier of
|
Chris@1617
|
564 // percentage thing, so x=0 meant play at the normal
|
Chris@1617
|
565 // speed, x=50 meant play at 150% of normal speed,
|
Chris@1617
|
566 // x=100 meant play at double speed, and x=-100 rather
|
Chris@1617
|
567 // bizarrely meant play at half speed. We handle this
|
Chris@1617
|
568 // now by converting to speed percentage as follows:
|
Chris@1617
|
569
|
Chris@1617
|
570 double percentage = 100.0;
|
Chris@1617
|
571 if (value > 0.f) {
|
Chris@1617
|
572 percentage = percentage + value;
|
Chris@1617
|
573 } else {
|
Chris@1617
|
574 percentage = 10000.0 / (percentage - value);
|
Chris@1617
|
575 }
|
Chris@1617
|
576 SVDEBUG << "OSCHandler: converted speedup(" << value
|
Chris@1617
|
577 << ") into speed(" << percentage << ")" << endl;
|
Chris@1617
|
578
|
Chris@1617
|
579 m_playSpeed->setMappedValue(percentage);
|
Chris@1617
|
580
|
Chris@216
|
581 } else if (property == "overlays") {
|
Chris@216
|
582 if (value < 0.5) {
|
Chris@216
|
583 m_viewManager->setOverlayMode(ViewManager::NoOverlays);
|
Chris@216
|
584 } else if (value < 1.5) {
|
Chris@701
|
585 m_viewManager->setOverlayMode(ViewManager::StandardOverlays);
|
Chris@216
|
586 } else {
|
Chris@216
|
587 m_viewManager->setOverlayMode(ViewManager::AllOverlays);
|
Chris@216
|
588 }
|
Chris@216
|
589 } else if (property == "zoomwheels") {
|
Chris@216
|
590 m_viewManager->setZoomWheelsEnabled(value > 0.5);
|
Chris@216
|
591 } else if (property == "propertyboxes") {
|
Chris@216
|
592 bool toggle = ((value < 0.5) !=
|
Chris@2339
|
593 (m_paneStack->getLayoutStyle() ==
|
Chris@2339
|
594 PaneStack::HiddenPropertyStacksLayout));
|
Chris@216
|
595 if (toggle) togglePropertyBoxes();
|
Chris@216
|
596 }
|
Chris@216
|
597
|
Chris@216
|
598 } else {
|
Chris@2126
|
599 PropertyContainer *container = nullptr;
|
Chris@216
|
600 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@216
|
601 if (pane &&
|
Chris@216
|
602 message.getArgCount() == 3 &&
|
Chris@216
|
603 message.getArg(0).canConvert(QVariant::String) &&
|
Chris@216
|
604 message.getArg(1).canConvert(QVariant::String) &&
|
Chris@216
|
605 message.getArg(2).canConvert(QVariant::String)) {
|
Chris@216
|
606 if (message.getArg(0).toString() == "pane") {
|
Chris@216
|
607 container = pane->getPropertyContainer(0);
|
Chris@216
|
608 } else if (message.getArg(0).toString() == "layer") {
|
Chris@216
|
609 container = pane->getSelectedLayer();
|
Chris@216
|
610 }
|
Chris@2519
|
611 } else {
|
Chris@2519
|
612 SVCERR << "OSCHandler: Usage: /set <control> <value>" << endl
|
Chris@2519
|
613 << " or /set pane <control> <value>" << endl
|
Chris@2519
|
614 << " or /set layer <control> <value>" << endl;
|
Chris@216
|
615 }
|
Chris@216
|
616 if (container) {
|
Chris@216
|
617 QString nameString = message.getArg(1).toString();
|
Chris@216
|
618 QString valueString = message.getArg(2).toString();
|
Chris@248
|
619 Command *c = container->getSetPropertyCommand
|
Chris@248
|
620 (nameString, valueString);
|
Chris@248
|
621 if (c) CommandHistory::getInstance()->addCommand(c, true, true);
|
Chris@216
|
622 }
|
Chris@216
|
623 }
|
Chris@216
|
624
|
Chris@216
|
625 } else if (message.getMethod() == "setcurrent") {
|
Chris@216
|
626
|
Chris@216
|
627 int paneIndex = -1, layerIndex = -1;
|
Chris@216
|
628 bool wantLayer = false;
|
Chris@216
|
629
|
Chris@216
|
630 if (message.getArgCount() >= 1 &&
|
Chris@216
|
631 message.getArg(0).canConvert(QVariant::Int)) {
|
Chris@216
|
632
|
Chris@216
|
633 paneIndex = message.getArg(0).toInt() - 1;
|
Chris@216
|
634
|
Chris@216
|
635 if (message.getArgCount() >= 2 &&
|
Chris@216
|
636 message.getArg(1).canConvert(QVariant::Int)) {
|
Chris@216
|
637 wantLayer = true;
|
Chris@216
|
638 layerIndex = message.getArg(1).toInt() - 1;
|
Chris@216
|
639 }
|
Chris@2519
|
640 } else {
|
Chris@2519
|
641 SVCERR << "OSCHandler: Usage: /setcurrent <pane> [<layer>]" << endl;
|
Chris@216
|
642 }
|
Chris@216
|
643
|
Chris@216
|
644 if (paneIndex >= 0 && paneIndex < m_paneStack->getPaneCount()) {
|
Chris@216
|
645 Pane *pane = m_paneStack->getPane(paneIndex);
|
Chris@216
|
646 m_paneStack->setCurrentPane(pane);
|
Chris@2441
|
647 SVDEBUG << "OSCHandler: Set current pane to index "
|
Chris@2441
|
648 << paneIndex << " (pane id " << pane->getId()
|
Chris@2441
|
649 << ")" << endl;
|
Chris@216
|
650 if (layerIndex >= 0 && layerIndex < pane->getLayerCount()) {
|
Chris@2437
|
651 Layer *layer = pane->getFixedOrderLayer(layerIndex);
|
Chris@216
|
652 m_paneStack->setCurrentLayer(pane, layer);
|
Chris@2441
|
653 SVDEBUG << "OSCHandler: Set current layer to index "
|
Chris@2441
|
654 << layerIndex << " (layer \""
|
Chris@2441
|
655 << layer->getLayerPresentationName() << "\")" << endl;
|
Chris@216
|
656 } else if (wantLayer && layerIndex == -1) {
|
Chris@2126
|
657 m_paneStack->setCurrentLayer(pane, nullptr);
|
Chris@2441
|
658 } else if (wantLayer) {
|
Chris@2441
|
659 SVCERR << "OSCHandler: Layer index "
|
Chris@2441
|
660 << layerIndex << " out of range for pane" << endl;
|
Chris@2441
|
661 }
|
Chris@216
|
662 }
|
Chris@216
|
663
|
Chris@216
|
664 } else if (message.getMethod() == "delete") {
|
Chris@216
|
665
|
Chris@216
|
666 if (message.getArgCount() == 1 &&
|
Chris@216
|
667 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@216
|
668
|
Chris@216
|
669 QString target = message.getArg(0).toString();
|
Chris@216
|
670
|
Chris@216
|
671 if (target == "pane") {
|
Chris@216
|
672
|
Chris@2441
|
673 SVDEBUG << "OSCHandler: Calling deleteCurrentPane" << endl;
|
Chris@216
|
674 deleteCurrentPane();
|
Chris@216
|
675
|
Chris@216
|
676 } else if (target == "layer") {
|
Chris@216
|
677
|
Chris@2441
|
678 SVDEBUG << "OSCHandler: Calling deleteCurrentLayer" << endl;
|
Chris@216
|
679 deleteCurrentLayer();
|
Chris@216
|
680
|
Chris@216
|
681 } else {
|
Chris@216
|
682
|
Chris@2441
|
683 SVCERR << "WARNING: OSCHandler: Unknown delete target \""
|
Chris@2441
|
684 << target << "\"" << endl;
|
Chris@216
|
685 }
|
Chris@2519
|
686 } else {
|
Chris@2519
|
687 SVCERR << "OSCHandler: Usage: /delete pane" << endl
|
Chris@2519
|
688 << " or /delete layer" << endl;
|
Chris@216
|
689 }
|
Chris@216
|
690
|
Chris@216
|
691 } else if (message.getMethod() == "zoom") {
|
Chris@216
|
692
|
Chris@216
|
693 if (message.getArgCount() == 1) {
|
Chris@216
|
694 if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@216
|
695 message.getArg(0).toString() == "in") {
|
Chris@216
|
696 zoomIn();
|
Chris@216
|
697 } else if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@216
|
698 message.getArg(0).toString() == "out") {
|
Chris@216
|
699 zoomOut();
|
Chris@216
|
700 } else if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@216
|
701 message.getArg(0).toString() == "default") {
|
Chris@216
|
702 zoomDefault();
|
Chris@312
|
703 } else if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@312
|
704 message.getArg(0).toString() == "fit") {
|
Chris@312
|
705 zoomToFit();
|
Chris@216
|
706 } else if (message.getArg(0).canConvert(QVariant::Double)) {
|
Chris@216
|
707 double level = message.getArg(0).toDouble();
|
Chris@216
|
708 Pane *currentPane = m_paneStack->getCurrentPane();
|
Chris@2011
|
709 ZoomLevel zoomLevel;
|
Chris@2011
|
710 if (level >= 0.66) {
|
Chris@2011
|
711 zoomLevel = ZoomLevel(ZoomLevel::FramesPerPixel,
|
Chris@2011
|
712 int(round(level)));
|
Chris@2011
|
713 } else {
|
Chris@2011
|
714 zoomLevel = ZoomLevel(ZoomLevel::PixelsPerFrame,
|
Chris@2011
|
715 int(round(1.0 / level)));
|
Chris@2011
|
716 }
|
Chris@2011
|
717 if (currentPane) {
|
Chris@2441
|
718 SVDEBUG << "OSCHandler: Setting zoom level to "
|
Chris@2441
|
719 << zoomLevel << endl;
|
Chris@2011
|
720 currentPane->setZoomLevel(zoomLevel);
|
Chris@2441
|
721 } else {
|
Chris@2441
|
722 SVCERR << "OSCHandler: No current pane, can't set zoom"
|
Chris@2441
|
723 << endl;
|
Chris@2011
|
724 }
|
Chris@216
|
725 }
|
Chris@2519
|
726 } else {
|
Chris@2519
|
727 SVCERR << "OSCHandler: Usage: /zoom <level>" << endl
|
Chris@2519
|
728 << " or /zoom in" << endl
|
Chris@2519
|
729 << " or /zoom out" << endl
|
Chris@2519
|
730 << " or /zoom fit" << endl
|
Chris@2519
|
731 << " or /zoom default" << endl;
|
Chris@216
|
732 }
|
Chris@216
|
733
|
Chris@216
|
734 } else if (message.getMethod() == "zoomvertical") {
|
Chris@216
|
735
|
Chris@216
|
736 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@2126
|
737 Layer *layer = nullptr;
|
Chris@216
|
738 if (pane && pane->getLayerCount() > 0) {
|
Chris@216
|
739 layer = pane->getLayer(pane->getLayerCount() - 1);
|
Chris@216
|
740 }
|
Chris@216
|
741 int defaultStep = 0;
|
Chris@216
|
742 int steps = 0;
|
Chris@216
|
743 if (layer) {
|
Chris@216
|
744 steps = layer->getVerticalZoomSteps(defaultStep);
|
Chris@216
|
745 if (message.getArgCount() == 1 && steps > 0) {
|
Chris@216
|
746 if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@216
|
747 message.getArg(0).toString() == "in") {
|
Chris@216
|
748 int step = layer->getCurrentVerticalZoomStep() + 1;
|
Chris@216
|
749 if (step < steps) layer->setVerticalZoomStep(step);
|
Chris@216
|
750 } else if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@216
|
751 message.getArg(0).toString() == "out") {
|
Chris@216
|
752 int step = layer->getCurrentVerticalZoomStep() - 1;
|
Chris@216
|
753 if (step >= 0) layer->setVerticalZoomStep(step);
|
Chris@216
|
754 } else if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@216
|
755 message.getArg(0).toString() == "default") {
|
Chris@216
|
756 layer->setVerticalZoomStep(defaultStep);
|
Chris@216
|
757 }
|
Chris@216
|
758 } else if (message.getArgCount() == 2) {
|
Chris@216
|
759 if (message.getArg(0).canConvert(QVariant::Double) &&
|
Chris@216
|
760 message.getArg(1).canConvert(QVariant::Double)) {
|
Chris@216
|
761 double min = message.getArg(0).toDouble();
|
Chris@216
|
762 double max = message.getArg(1).toDouble();
|
Chris@216
|
763 layer->setDisplayExtents(min, max);
|
Chris@216
|
764 }
|
Chris@216
|
765 }
|
Chris@216
|
766 }
|
Chris@216
|
767
|
Chris@216
|
768 } else if (message.getMethod() == "quit") {
|
Chris@2440
|
769
|
Chris@2440
|
770 SVDEBUG << "OSCHandler: Exiting abruptly" << endl;
|
Chris@2440
|
771 m_documentModified = false; // so we don't ask to save
|
Chris@216
|
772 close();
|
Chris@216
|
773
|
Chris@216
|
774 } else if (message.getMethod() == "resize") {
|
Chris@216
|
775
|
Chris@216
|
776 if (message.getArgCount() == 2) {
|
Chris@216
|
777
|
Chris@216
|
778 int width = 0, height = 0;
|
Chris@216
|
779
|
Chris@216
|
780 if (message.getArg(1).canConvert(QVariant::Int)) {
|
Chris@216
|
781
|
Chris@216
|
782 height = message.getArg(1).toInt();
|
Chris@216
|
783
|
Chris@216
|
784 if (message.getArg(0).canConvert(QVariant::String) &&
|
Chris@216
|
785 message.getArg(0).toString() == "pane") {
|
Chris@216
|
786
|
Chris@216
|
787 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@216
|
788 if (pane) pane->resize(pane->width(), height);
|
Chris@216
|
789
|
Chris@216
|
790 } else if (message.getArg(0).canConvert(QVariant::Int)) {
|
Chris@216
|
791
|
Chris@216
|
792 width = message.getArg(0).toInt();
|
Chris@216
|
793 resize(width, height);
|
Chris@216
|
794 }
|
Chris@216
|
795 }
|
Chris@216
|
796 }
|
Chris@216
|
797
|
Chris@216
|
798 } else if (message.getMethod() == "transform") {
|
Chris@216
|
799
|
Chris@2441
|
800 if (message.getArgCount() == 1 &&
|
Chris@216
|
801 message.getArg(0).canConvert(QVariant::String)) {
|
Chris@216
|
802
|
Chris@2441
|
803 Pane *pane = m_paneStack->getCurrentPane();
|
Chris@2441
|
804
|
Chris@2441
|
805 if (getMainModel() && pane) {
|
Chris@216
|
806
|
Chris@2441
|
807 TransformId transformId = message.getArg(0).toString();
|
Chris@2441
|
808
|
Chris@2441
|
809 Transform transform = TransformFactory::getInstance()->
|
Chris@2441
|
810 getDefaultTransformFor(transformId);
|
Chris@2441
|
811
|
Chris@2441
|
812 SVDEBUG << "OSCHandler: Running transform on main model:"
|
Chris@2441
|
813 << transform.toXmlString() << endl;
|
Chris@1770
|
814
|
Chris@2441
|
815 Layer *newLayer = m_document->createDerivedLayer
|
Chris@2441
|
816 (transform, getMainModelId());
|
Chris@2441
|
817
|
Chris@2441
|
818 if (newLayer) {
|
Chris@2441
|
819 m_document->addLayerToView(pane, newLayer);
|
Chris@2441
|
820 m_recentTransforms.add(transformId);
|
Chris@2441
|
821 m_paneStack->setCurrentLayer(pane, newLayer);
|
Chris@2441
|
822 } else {
|
Chris@2441
|
823 SVCERR << "OSCHandler: Transform failed to run" << endl;
|
Chris@2441
|
824 }
|
Chris@2441
|
825 } else {
|
Chris@2441
|
826 SVCERR << "OSCHandler: Lack main model or pane, "
|
Chris@2441
|
827 << "can't run transform" << endl;
|
Chris@216
|
828 }
|
Chris@2441
|
829 }
|
Chris@216
|
830
|
Chris@216
|
831 } else {
|
Chris@2441
|
832 SVCERR << "WARNING: OSCHandler: Unknown or unsupported "
|
Chris@665
|
833 << "method \"" << message.getMethod()
|
Chris@665
|
834 << "\"" << endl;
|
Chris@216
|
835 }
|
Chris@2441
|
836
|
Chris@2441
|
837 SVDEBUG << "OSCHandler at " << NOW << ": finished message: "
|
Chris@2441
|
838 << message.toString() << " in " << timer.elapsed() << "ms" << endl;
|
Chris@216
|
839 }
|