# HG changeset patch # User Chris Cannam # Date 1542122208 0 # Node ID c39f2d439d59eccd00295b6196d9203c5683fa56 # Parent 3c99083a4d839e57c0fb6f6f34b161f9a9d43079 Toward highlighting peaks on spectrum diff -r 3c99083a4d83 -r c39f2d439d59 layer/FlexiNoteLayer.cpp --- a/layer/FlexiNoteLayer.cpp Tue Nov 13 14:48:42 2018 +0000 +++ b/layer/FlexiNoteLayer.cpp Tue Nov 13 15:16:48 2018 +0000 @@ -439,7 +439,7 @@ } if (!usePoints.empty()) { - int fuzz = 2; + int fuzz = ViewManager::scalePixelSize(2); int px = v->getXForFrame(usePoints.begin()->frame); if ((px > x && px - x > fuzz) || (px < x && x - px > fuzz + 1)) { diff -r 3c99083a4d83 -r c39f2d439d59 layer/Layer.h --- a/layer/Layer.h Tue Nov 13 14:48:42 2018 +0000 +++ b/layer/Layer.h Tue Nov 13 15:16:48 2018 +0000 @@ -414,6 +414,12 @@ virtual PlayParameters *getPlayParameters(); + /** + * True if this layer will need to place text labels when it is + * painted. The view will take into account how many layers are + * requesting this, and will provide a distinct y-coord to each + * layer on request via View::getTextLabelHeight(). + */ virtual bool needsTextLabelHeight() const { return false; } /** diff -r 3c99083a4d83 -r c39f2d439d59 layer/NoteLayer.cpp --- a/layer/NoteLayer.cpp Tue Nov 13 14:48:42 2018 +0000 +++ b/layer/NoteLayer.cpp Tue Nov 13 15:16:48 2018 +0000 @@ -421,7 +421,7 @@ } if (!usePoints.empty()) { - int fuzz = 2; + int fuzz = ViewManager::scalePixelSize(2); int px = v->getXForFrame(usePoints.begin()->frame); if ((px > x && px - x > fuzz) || (px < x && x - px > fuzz + 1)) { diff -r 3c99083a4d83 -r c39f2d439d59 layer/RegionLayer.cpp --- a/layer/RegionLayer.cpp Tue Nov 13 14:48:42 2018 +0000 +++ b/layer/RegionLayer.cpp Tue Nov 13 15:16:48 2018 +0000 @@ -335,7 +335,7 @@ } if (!usePoints.empty()) { - int fuzz = 2; + int fuzz = ViewManager::scalePixelSize(2); int px = v->getXForFrame(usePoints.begin()->frame); if ((px > x && px - x > fuzz) || (px < x && x - px > fuzz + 1)) { diff -r 3c99083a4d83 -r c39f2d439d59 layer/SpectrumLayer.cpp --- a/layer/SpectrumLayer.cpp Tue Nov 13 14:48:42 2018 +0000 +++ b/layer/SpectrumLayer.cpp Tue Nov 13 15:16:48 2018 +0000 @@ -709,6 +709,11 @@ int xorigin = getVerticalScaleWidth(v, false, paint) + 1; int scaleHeight = getHorizontalScaleHeight(v, paint); + QPoint localPos; + bool shouldIlluminate = v->shouldIlluminateLocalFeatures(this, localPos); + + cerr << "shouldIlluminate = " << shouldIlluminate << ", localPos = " << localPos.x() << "," << localPos.y() << endl; + if (fft && m_showPeaks) { // draw peak lines @@ -738,6 +743,8 @@ int px = -1; + int fuzz = ViewManager::scalePixelSize(2); + for (FFTModel::PeakSet::iterator i = peaks.begin(); i != peaks.end(); ++i) { @@ -746,7 +753,7 @@ if (x == px) { continue; } - + int bin = i->first; // cerr << "bin = " << bin << ", thresh = " << thresh << ", value = " << fft->getMagnitudeAt(col, bin) << endl; @@ -754,6 +761,12 @@ double value = fft->getValueAt(col, bin); if (value < thresh) continue; if (bin < cs) value *= curve[bin]; + + bool highlightThis = false; + if (std::abs(localPos.x() - x) <= fuzz) { + highlightThis = true; + cerr << "should highlight this one (at " << x << ")" << endl; + } double norm = 0.f; // don't need return value, need norm: diff -r 3c99083a4d83 -r c39f2d439d59 layer/TimeInstantLayer.cpp --- a/layer/TimeInstantLayer.cpp Tue Nov 13 14:48:42 2018 +0000 +++ b/layer/TimeInstantLayer.cpp Tue Nov 13 15:16:48 2018 +0000 @@ -191,7 +191,7 @@ } if (!usePoints.empty()) { - int fuzz = 2; + int fuzz = ViewManager::scalePixelSize(2); int px = v->getXForFrame(usePoints.begin()->frame); if ((px > x && px - x > fuzz) || (px < x && x - px > fuzz + 1)) { diff -r 3c99083a4d83 -r c39f2d439d59 layer/TimeRulerLayer.cpp --- a/layer/TimeRulerLayer.cpp Tue Nov 13 14:48:42 2018 +0000 +++ b/layer/TimeRulerLayer.cpp Tue Nov 13 15:16:48 2018 +0000 @@ -113,7 +113,7 @@ dr = abs(v->getXForFrame(right) - x); } - int fuzz = 2; + int fuzz = ViewManager::scalePixelSize(2); if (dl >= 0 && dr >= 0) { if (dl < dr) { diff -r 3c99083a4d83 -r c39f2d439d59 layer/TimeValueLayer.cpp --- a/layer/TimeValueLayer.cpp Tue Nov 13 14:48:42 2018 +0000 +++ b/layer/TimeValueLayer.cpp Tue Nov 13 15:16:48 2018 +0000 @@ -565,7 +565,7 @@ } if (!usePoints.empty()) { - int fuzz = 2; + int fuzz = ViewManager::scalePixelSize(2); int px = v->getXForFrame(usePoints.begin()->frame); if ((px > x && px - x > fuzz) || (px < x && x - px > fuzz + 3)) { diff -r 3c99083a4d83 -r c39f2d439d59 view/Pane.cpp --- a/view/Pane.cpp Tue Nov 13 14:48:42 2018 +0000 +++ b/view/Pane.cpp Tue Nov 13 15:16:48 2018 +0000 @@ -300,8 +300,8 @@ bool Pane::shouldIlluminateLocalSelection(QPoint &pos, - bool &closeToLeft, - bool &closeToRight) const + bool &closeToLeft, + bool &closeToRight) const { if (m_identifyFeatures && m_manager &&