comparison view/Pane.cpp @ 592:a13aa5320221 sonification

Extends the audio feedback of the piano scale to the Spectrum layer (horizontal piano keyboard). Increase of the piano keyboard width (SpectrogramLayer) and height (SpectrumLayer) for layout purposes. A get method should be added to obtain the scale size parameter outside the layer class.
author mathieub <mathieu.barthet@eecs.qmul.ac.uk>
date Wed, 06 Jul 2011 18:05:42 +0100
parents 241929c5d57c
children c080d14ff414
comparison
equal deleted inserted replaced
591:0946feb81b79 592:a13aa5320221
12 License, or (at your option) any later version. See the file 12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information. 13 COPYING included with this distribution for more information.
14 */ 14 */
15 15
16 #include "Pane.h" 16 #include "Pane.h"
17 #include "layer/Layer.h"
18 #include "data/model/Model.h" 17 #include "data/model/Model.h"
19 #include "base/ZoomConstraint.h" 18 #include "base/ZoomConstraint.h"
20 #include "base/RealTime.h" 19 #include "base/RealTime.h"
21 #include "base/Profiler.h" 20 #include "base/Profiler.h"
22 #include "ViewManager.h" 21 #include "ViewManager.h"
1288 1287
1289 m_navigating = false; 1288 m_navigating = false;
1290 m_resizing = false; 1289 m_resizing = false;
1291 m_editing = false; 1290 m_editing = false;
1292 m_releasing = false; 1291 m_releasing = false;
1293 1292
1293 bool scaleclick = false;
1294
1295 Layer *layer = getTopLayer();
1296 if (layer) {
1297 LayerFactory::LayerType type = LayerFactory::getInstance()->getLayerType(layer);
1298
1299 //std::cerr << "hello before switch: " << LayerFactory::getInstance()->getLayerTypeName(type) << std::endl;
1300
1301 switch(type) {
1302
1303 case LayerFactory::Spectrogram:
1304 {
1305 std::cerr << "hello spectrogram ("<< e->x() <<", " << e->y() << ")" << std::endl;
1306 }
1307 case LayerFactory::MelodicRangeSpectrogram:
1308 {
1309 std::cerr << "hello melodic ("<< e->x() <<", " << e->y() << ")" << std::endl;
1310 int sw = getVerticalScaleWidth();
1311 int pkhms = 20; //this value should be retrieved from SpectrogramLayer
1312 int slb = sw - pkhms - 1; //scale left border
1313
1314 //std::cerr << "slb: "<< slb << std::endl;
1315
1316 if ((e->x() < sw)&&(e->x() > slb)) {
1317 scaleclick = true;
1318 }
1319 break;
1320 }
1321 case LayerFactory::Spectrum:
1322 {
1323 std::cerr << "hello spectrum ("<< e->x() <<", " << e->y() << ")" << std::endl;
1324
1325 int h = height();
1326 int pkhs = 20; //this value should be retrieved from SpectrumLayer
1327
1328 int sh = h - pkhs - 1;
1329
1330 //if (e->y() < layer->getHorizontalScaleHeight(this)) {
1331
1332 if (e->y() > sh) {
1333 scaleclick = true;
1334 }
1335 break;
1336 }
1337 }
1338
1339 if (scaleclick) {
1340 // Click occurred over the layer's scale area. Ask the layer
1341 // to do something with it: if it does so (i.e. returns true),
1342 // we've nothing else to do
1343 if (layer->scaleClicked(this, e)) {
1344 m_clickedInRange = false;
1345 emit paneInteractedWith();
1346 return;
1347 }
1348 }
1349 }
1350 /*
1294 if (e->x() < getVerticalScaleWidth()) { 1351 if (e->x() < getVerticalScaleWidth()) {
1295 // Click occurred over the layer's scale area. Ask the layer 1352 // Click occurred over the layer's scale area. Ask the layer
1296 // to do something with it: if it does so (i.e. returns true), 1353 // to do something with it: if it does so (i.e. returns true),
1297 // we've nothing else to do 1354 // we've nothing else to do
1298 Layer *layer = getTopLayer(); 1355 Layer *layer = getTopLayer();
1302 emit paneInteractedWith(); 1359 emit paneInteractedWith();
1303 return; 1360 return;
1304 } 1361 }
1305 } 1362 }
1306 } 1363 }
1364 */
1307 1365
1308 if (mode == ViewManager::NavigateMode || 1366 if (mode == ViewManager::NavigateMode ||
1309 (e->buttons() & Qt::MidButton) || 1367 (e->buttons() & Qt::MidButton) ||
1310 (mode == ViewManager::MeasureMode && 1368 (mode == ViewManager::MeasureMode &&
1311 (e->buttons() & Qt::LeftButton) && m_shiftPressed)) { 1369 (e->buttons() & Qt::LeftButton) && m_shiftPressed)) {