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