Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 1134:199049012fc6 spectrogram-minor-refactor
Another small tidy
author | Chris Cannam |
---|---|
date | Tue, 02 Aug 2016 18:32:19 +0100 |
parents | ee98d587cd1a |
children | 9ff838a64461 |
comparison
equal
deleted
inserted
replaced
1133:b4b155cfd8b4 | 1134:199049012fc6 |
---|---|
1383 { | 1383 { |
1384 #ifdef DEBUG_SPECTROGRAM | 1384 #ifdef DEBUG_SPECTROGRAM |
1385 cerr << "SpectrogramLayer::invalidateMagnitudes called" << endl; | 1385 cerr << "SpectrogramLayer::invalidateMagnitudes called" << endl; |
1386 #endif | 1386 #endif |
1387 m_viewMags.clear(); | 1387 m_viewMags.clear(); |
1388 /*!!! for (vector<MagnitudeRange>::iterator i = m_columnMags.begin(); | 1388 } |
1389 i != m_columnMags.end(); ++i) { | 1389 |
1390 *i = MagnitudeRange(); | |
1391 } | |
1392 */ | |
1393 } | |
1394 /*!!! | |
1395 bool | |
1396 SpectrogramLayer::updateViewMagnitudes(LayerGeometryProvider *v) const | |
1397 { | |
1398 MagnitudeRange mag; | |
1399 | |
1400 int x0 = 0, x1 = v->getPaintWidth(); | |
1401 double s00 = 0, s01 = 0, s10 = 0, s11 = 0; | |
1402 | |
1403 if (!getXBinRange(v, x0, s00, s01)) { | |
1404 s00 = s01 = double(m_model->getStartFrame()) / getWindowIncrement(); | |
1405 } | |
1406 | |
1407 if (!getXBinRange(v, x1, s10, s11)) { | |
1408 s10 = s11 = double(m_model->getEndFrame()) / getWindowIncrement(); | |
1409 } | |
1410 | |
1411 int s0 = int(min(s00, s10) + 0.0001); | |
1412 int s1 = int(max(s01, s11) + 0.0001); | |
1413 | |
1414 // SVDEBUG << "SpectrogramLayer::updateViewMagnitudes: x0 = " << x0 << ", x1 = " << x1 << ", s00 = " << s00 << ", s11 = " << s11 << " s0 = " << s0 << ", s1 = " << s1 << endl; | |
1415 | |
1416 if (int(m_columnMags.size()) <= s1) { | |
1417 m_columnMags.resize(s1 + 1); | |
1418 } | |
1419 | |
1420 for (int s = s0; s <= s1; ++s) { | |
1421 if (m_columnMags[s].isSet()) { | |
1422 mag.sample(m_columnMags[s]); | |
1423 } | |
1424 } | |
1425 | |
1426 #ifdef DEBUG_SPECTROGRAM_REPAINT | |
1427 cerr << "SpectrogramLayer::updateViewMagnitudes returning from cols " | |
1428 << s0 << " -> " << s1 << " inclusive" << endl; | |
1429 cerr << "SpectrogramLayer::updateViewMagnitudes: for view id " << v->getId() | |
1430 << ": min is " << mag.getMin() << ", max is " << mag.getMax() << endl; | |
1431 #endif | |
1432 | |
1433 if (!mag.isSet()) return false; | |
1434 if (mag == m_viewMags[v->getId()]) return false; | |
1435 m_viewMags[v->getId()] = mag; | |
1436 return true; | |
1437 } | |
1438 */ | |
1439 void | 1390 void |
1440 SpectrogramLayer::setSynchronousPainting(bool synchronous) | 1391 SpectrogramLayer::setSynchronousPainting(bool synchronous) |
1441 { | 1392 { |
1442 m_synchronous = synchronous; | 1393 m_synchronous = synchronous; |
1443 } | 1394 } |
1574 QPoint localPos; | 1525 QPoint localPos; |
1575 if (!v->shouldIlluminateLocalFeatures(this, localPos) || !m_model) { | 1526 if (!v->shouldIlluminateLocalFeatures(this, localPos) || !m_model) { |
1576 return; | 1527 return; |
1577 } | 1528 } |
1578 | 1529 |
1579 // cerr << "SpectrogramLayer: illuminateLocalFeatures(" | 1530 cerr << "SpectrogramLayer: illuminateLocalFeatures(" |
1580 // << localPos.x() << "," << localPos.y() << ")" << endl; | 1531 << localPos.x() << "," << localPos.y() << ")" << endl; |
1581 | 1532 |
1582 double s0, s1; | 1533 double s0, s1; |
1583 double f0, f1; | 1534 double f0, f1; |
1584 | 1535 |
1585 if (getXBinRange(v, localPos.x(), s0, s1) && | 1536 if (getXBinRange(v, localPos.x(), s0, s1) && |
1592 int x1 = v->getXForFrame((s1i + 1) * getWindowIncrement()); | 1543 int x1 = v->getXForFrame((s1i + 1) * getWindowIncrement()); |
1593 | 1544 |
1594 int y1 = int(getYForFrequency(v, f1)); | 1545 int y1 = int(getYForFrequency(v, f1)); |
1595 int y0 = int(getYForFrequency(v, f0)); | 1546 int y0 = int(getYForFrequency(v, f0)); |
1596 | 1547 |
1597 // cerr << "SpectrogramLayer: illuminate " | 1548 cerr << "SpectrogramLayer: illuminate " |
1598 // << x0 << "," << y1 << " -> " << x1 << "," << y0 << endl; | 1549 << x0 << "," << y1 << " -> " << x1 << "," << y0 << endl; |
1599 | 1550 |
1600 paint.setPen(v->getForeground()); | 1551 paint.setPen(v->getForeground()); |
1601 | 1552 |
1602 //!!! should we be using paintCrosshairs for this? | 1553 //!!! should we be using paintCrosshairs for this? |
1603 | 1554 |