Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 28:202d1dca67d2
* Rationalise the local feature identification API in Layer subclasses
* Add segmentation mode to TimeInstantLayer
author | Chris Cannam |
---|---|
date | Mon, 06 Feb 2006 17:24:52 +0000 |
parents | dcdb21b62dbb |
children | 9f55af9676b4 |
comparison
equal
deleted
inserted
replaced
27:38fe0ea9e46e | 28:202d1dca67d2 |
---|---|
1481 size_t completion = m_fillThread->getFillCompletion(); | 1481 size_t completion = m_fillThread->getFillCompletion(); |
1482 // std::cerr << "SpectrogramLayer::getCompletion: completion = " << completion << std::endl; | 1482 // std::cerr << "SpectrogramLayer::getCompletion: completion = " << completion << std::endl; |
1483 return completion; | 1483 return completion; |
1484 } | 1484 } |
1485 | 1485 |
1486 int | 1486 bool |
1487 SpectrogramLayer::getNearestFeatureFrame(int frame, | 1487 SpectrogramLayer::snapToFeatureFrame(int &frame, |
1488 size_t &resolution, | 1488 size_t &resolution, |
1489 bool snapRight) const | 1489 SnapType snap) const |
1490 { | 1490 { |
1491 resolution = getWindowIncrement(); | 1491 resolution = getWindowIncrement(); |
1492 int snapFrame = (frame / resolution) * resolution; | 1492 int left = (frame / resolution) * resolution; |
1493 if (snapRight) snapFrame += resolution; | 1493 int right = left + resolution; |
1494 return snapFrame; | 1494 |
1495 } | 1495 switch (snap) { |
1496 case SnapLeft: frame = left; break; | |
1497 case SnapRight: frame = right; break; | |
1498 case SnapNearest: | |
1499 case SnapNeighbouring: | |
1500 if (frame - left > right - frame) frame = right; | |
1501 else frame = left; | |
1502 break; | |
1503 } | |
1504 | |
1505 return true; | |
1506 } | |
1496 | 1507 |
1497 QString | 1508 QString |
1498 SpectrogramLayer::getFeatureDescription(QPoint &pos) const | 1509 SpectrogramLayer::getFeatureDescription(QPoint &pos) const |
1499 { | 1510 { |
1500 int x = pos.x(); | 1511 int x = pos.x(); |