Mercurial > hg > svgui
diff 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 |
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp Fri Feb 03 17:30:47 2006 +0000 +++ b/layer/SpectrogramLayer.cpp Mon Feb 06 17:24:52 2006 +0000 @@ -1483,16 +1483,27 @@ return completion; } -int -SpectrogramLayer::getNearestFeatureFrame(int frame, - size_t &resolution, - bool snapRight) const +bool +SpectrogramLayer::snapToFeatureFrame(int &frame, + size_t &resolution, + SnapType snap) const { resolution = getWindowIncrement(); - int snapFrame = (frame / resolution) * resolution; - if (snapRight) snapFrame += resolution; - return snapFrame; -} + int left = (frame / resolution) * resolution; + int right = left + resolution; + + switch (snap) { + case SnapLeft: frame = left; break; + case SnapRight: frame = right; break; + case SnapNearest: + case SnapNeighbouring: + if (frame - left > right - frame) frame = right; + else frame = left; + break; + } + + return true; +} QString SpectrogramLayer::getFeatureDescription(QPoint &pos) const