Mercurial > hg > svgui
comparison layer/WaveformLayer.cpp @ 709:def489f5ce92 tonioni
Adjustable middle-line height for waveform. Not 100% supported (only really for basic waveform rendering)
author | Chris Cannam |
---|---|
date | Wed, 08 Jan 2014 17:47:34 +0000 |
parents | 1a0dfcbffaf1 |
children | 1d526ba11a24 |
comparison
equal
deleted
inserted
replaced
708:1c4bbf8952bc | 709:def489f5ce92 |
---|---|
41 m_showMeans(true), | 41 m_showMeans(true), |
42 m_greyscale(true), | 42 m_greyscale(true), |
43 m_channelMode(SeparateChannels), | 43 m_channelMode(SeparateChannels), |
44 m_channel(-1), | 44 m_channel(-1), |
45 m_scale(LinearScale), | 45 m_scale(LinearScale), |
46 m_middleLineHeight(0.5), | |
46 m_aggressive(false), | 47 m_aggressive(false), |
47 m_cache(0), | 48 m_cache(0), |
48 m_cacheValid(false) | 49 m_cacheValid(false) |
49 { | 50 { |
50 | 51 |
304 m_cacheValid = false; | 305 m_cacheValid = false; |
305 emit layerParametersChanged(); | 306 emit layerParametersChanged(); |
306 } | 307 } |
307 | 308 |
308 void | 309 void |
310 WaveformLayer::setMiddleLineHeight(float height) | |
311 { | |
312 if (m_middleLineHeight == height) return; | |
313 m_middleLineHeight = height; | |
314 m_cacheValid = false; | |
315 emit layerParametersChanged(); | |
316 } | |
317 | |
318 void | |
309 WaveformLayer::setAggressiveCacheing(bool aggressive) | 319 WaveformLayer::setAggressiveCacheing(bool aggressive) |
310 { | 320 { |
311 if (m_aggressive == aggressive) return; | 321 if (m_aggressive == aggressive) return; |
312 m_aggressive = aggressive; | 322 m_aggressive = aggressive; |
313 m_cacheValid = false; | 323 m_cacheValid = false; |
529 } else { | 539 } else { |
530 paint = &viewPainter; | 540 paint = &viewPainter; |
531 } | 541 } |
532 | 542 |
533 paint->setRenderHint(QPainter::Antialiasing, false); | 543 paint->setRenderHint(QPainter::Antialiasing, false); |
544 | |
545 if (m_middleLineHeight != 0.5) { | |
546 paint->save(); | |
547 float space = m_middleLineHeight * 2; | |
548 if (space > 1.0) space = 2.0 - space; | |
549 float yt = h * (m_middleLineHeight - space/2); | |
550 paint->translate(QPointF(0, yt)); | |
551 paint->scale(1.0, space); | |
552 } | |
534 | 553 |
535 int x0 = 0, x1 = w - 1; | 554 int x0 = 0, x1 = w - 1; |
536 int y0 = 0, y1 = h - 1; | 555 int y0 = 0, y1 = h - 1; |
537 | 556 |
538 x0 = rect.left(); | 557 x0 = rect.left(); |
913 prevRangeBottom = rangeBottom; | 932 prevRangeBottom = rangeBottom; |
914 prevRangeTop = rangeTop; | 933 prevRangeTop = rangeTop; |
915 } | 934 } |
916 } | 935 } |
917 | 936 |
937 if (m_middleLineHeight != 0.5) { | |
938 paint->restore(); | |
939 } | |
940 | |
918 if (m_aggressive) { | 941 if (m_aggressive) { |
919 | 942 |
920 if (ready && rect == v->rect()) { | 943 if (ready && rect == v->rect()) { |
921 m_cacheValid = true; | 944 m_cacheValid = true; |
922 m_cacheZoomLevel = zoomLevel; | 945 m_cacheZoomLevel = zoomLevel; |
1312 "showMeans=\"%2\" " | 1335 "showMeans=\"%2\" " |
1313 "greyscale=\"%3\" " | 1336 "greyscale=\"%3\" " |
1314 "channelMode=\"%4\" " | 1337 "channelMode=\"%4\" " |
1315 "channel=\"%5\" " | 1338 "channel=\"%5\" " |
1316 "scale=\"%6\" " | 1339 "scale=\"%6\" " |
1317 "aggressive=\"%7\" " | 1340 "middleLineHeight=\"%7\" " |
1318 "autoNormalize=\"%8\"") | 1341 "aggressive=\"%8\" " |
1342 "autoNormalize=\"%9\"") | |
1319 .arg(m_gain) | 1343 .arg(m_gain) |
1320 .arg(m_showMeans) | 1344 .arg(m_showMeans) |
1321 .arg(m_greyscale) | 1345 .arg(m_greyscale) |
1322 .arg(m_channelMode) | 1346 .arg(m_channelMode) |
1323 .arg(m_channel) | 1347 .arg(m_channel) |
1324 .arg(m_scale) | 1348 .arg(m_scale) |
1349 .arg(m_middleLineHeight) | |
1325 .arg(m_aggressive) | 1350 .arg(m_aggressive) |
1326 .arg(m_autoNormalize); | 1351 .arg(m_autoNormalize); |
1327 | 1352 |
1328 SingleColourLayer::toXml(stream, indent, extraAttributes + " " + s); | 1353 SingleColourLayer::toXml(stream, indent, extraAttributes + " " + s); |
1329 } | 1354 } |
1351 if (ok) setChannelMode(channelMode); | 1376 if (ok) setChannelMode(channelMode); |
1352 | 1377 |
1353 int channel = attributes.value("channel").toInt(&ok); | 1378 int channel = attributes.value("channel").toInt(&ok); |
1354 if (ok) setChannel(channel); | 1379 if (ok) setChannel(channel); |
1355 | 1380 |
1356 Scale scale = (Scale) | 1381 Scale scale = (Scale)attributes.value("scale").toInt(&ok); |
1357 attributes.value("scale").toInt(&ok); | |
1358 if (ok) setScale(scale); | 1382 if (ok) setScale(scale); |
1383 | |
1384 float middleLineHeight = attributes.value("middleLineHeight").toFloat(&ok); | |
1385 if (ok) setMiddleLineHeight(middleLineHeight); | |
1359 | 1386 |
1360 bool aggressive = (attributes.value("aggressive") == "1" || | 1387 bool aggressive = (attributes.value("aggressive") == "1" || |
1361 attributes.value("aggressive") == "true"); | 1388 attributes.value("aggressive") == "true"); |
1362 setUseGreyscale(aggressive); | 1389 setUseGreyscale(aggressive); |
1363 | 1390 |