Mercurial > hg > svgui
diff layer/SpectrogramLayer.cpp @ 389:2ed4e572d0d4
* Attempt fix for #1914752 export image has holes (1.0 and 1.2)
author | Chris Cannam |
---|---|
date | Tue, 20 May 2008 10:40:20 +0000 |
parents | b35184d0dfe5 |
children | 0384cf63e91c |
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp Tue May 20 08:37:46 2008 +0000 +++ b/layer/SpectrogramLayer.cpp Tue May 20 10:40:20 2008 +0000 @@ -68,6 +68,7 @@ m_normalizeColumns(false), m_normalizeVisibleArea(false), m_lastEmittedZoomStep(-1), + m_synchronous(true), //!!! m_lastPaintBlockWidth(0), m_updateTimer(0), m_candidateFillStartFrame(0), @@ -1672,6 +1673,12 @@ } void +SpectrogramLayer::setSynchronousPainting(bool synchronous) +{ + m_synchronous = synchronous; +} + +void SpectrogramLayer::paint(View *v, QPainter &paint, QRect rect) const { // What a lovely, old-fashioned function this is. @@ -1883,24 +1890,31 @@ int paintBlockWidth = m_lastPaintBlockWidth; - if (paintBlockWidth == 0) { - paintBlockWidth = (300000 / zoomLevel); + if (m_synchronous) { + if (paintBlockWidth < x1 - x0) { + // always paint full width + paintBlockWidth = x1 - x0; + } } else { - RealTime lastTime = m_lastPaintTime; - while (lastTime > RealTime::fromMilliseconds(200) && - paintBlockWidth > 50) { - paintBlockWidth /= 2; - lastTime = lastTime / 2; + if (paintBlockWidth == 0) { + paintBlockWidth = (300000 / zoomLevel); + } else { + RealTime lastTime = m_lastPaintTime; + while (lastTime > RealTime::fromMilliseconds(200) && + paintBlockWidth > 50) { + paintBlockWidth /= 2; + lastTime = lastTime / 2; + } + while (lastTime < RealTime::fromMilliseconds(90) && + paintBlockWidth < 1500) { + paintBlockWidth *= 2; + lastTime = lastTime * 2; + } } - while (lastTime < RealTime::fromMilliseconds(90) && - paintBlockWidth < 1500) { - paintBlockWidth *= 2; - lastTime = lastTime * 2; - } + + if (paintBlockWidth < 20) paintBlockWidth = 20; } - if (paintBlockWidth < 20) paintBlockWidth = 20; - #ifdef DEBUG_SPECTROGRAM_REPAINT std::cerr << "[" << this << "]: last paint width: " << m_lastPaintBlockWidth << ", last paint time: " << m_lastPaintTime << ", new paint width: " << paintBlockWidth << std::endl; #endif @@ -2128,13 +2142,14 @@ for (int s = s0i; s <= s1i; ++s) { - if (!fft->isColumnAvailable(s)) { + if (!m_synchronous) { + if (!fft->isColumnAvailable(s)) { #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "Met unavailable column at col " << s << std::endl; + std::cerr << "Met unavailable column at col " << s << std::endl; #endif -// continue; - runOutOfData = true; - break; + runOutOfData = true; + break; + } } if (!fftSuspended) { @@ -2379,37 +2394,40 @@ cache.startFrame = startFrame; cache.zoomLevel = zoomLevel; - if (!m_normalizeVisibleArea || !overallMagChanged) { + if (!m_synchronous) { + + if (!m_normalizeVisibleArea || !overallMagChanged) { - if (cache.validArea.x() > 0) { + if (cache.validArea.x() > 0) { #ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::paint() updating left (0, " - << cache.validArea.x() << ")" << std::endl; + std::cerr << "SpectrogramLayer::paint() updating left (0, " + << cache.validArea.x() << ")" << std::endl; #endif - v->update(0, 0, cache.validArea.x(), h); + v->update(0, 0, cache.validArea.x(), h); + } + + if (cache.validArea.x() + cache.validArea.width() < + cache.pixmap.width()) { +#ifdef DEBUG_SPECTROGRAM_REPAINT + std::cerr << "SpectrogramLayer::paint() updating right (" + << cache.validArea.x() + cache.validArea.width() + << ", " + << cache.pixmap.width() - (cache.validArea.x() + + cache.validArea.width()) + << ")" << std::endl; +#endif + v->update(cache.validArea.x() + cache.validArea.width(), + 0, + cache.pixmap.width() - (cache.validArea.x() + + cache.validArea.width()), + h); + } + } else { + // overallMagChanged + std::cerr << "\noverallMagChanged - updating all\n" << std::endl; + cache.validArea = QRect(); + v->update(); } - - if (cache.validArea.x() + cache.validArea.width() < - cache.pixmap.width()) { -#ifdef DEBUG_SPECTROGRAM_REPAINT - std::cerr << "SpectrogramLayer::paint() updating right (" - << cache.validArea.x() + cache.validArea.width() - << ", " - << cache.pixmap.width() - (cache.validArea.x() + - cache.validArea.width()) - << ")" << std::endl; -#endif - v->update(cache.validArea.x() + cache.validArea.width(), - 0, - cache.pixmap.width() - (cache.validArea.x() + - cache.validArea.width()), - h); - } - } else { - // overallMagChanged - std::cerr << "\noverallMagChanged - updating all\n" << std::endl; - cache.validArea = QRect(); - v->update(); } illuminateLocalFeatures(v, paint); @@ -2418,9 +2436,11 @@ std::cerr << "SpectrogramLayer::paint() returning" << std::endl; #endif - m_lastPaintBlockWidth = paintBlockWidth; - (void)gettimeofday(&tv, 0); - m_lastPaintTime = RealTime::fromTimeval(tv) - mainPaintStart; + if (!m_synchronous) { + m_lastPaintBlockWidth = paintBlockWidth; + (void)gettimeofday(&tv, 0); + m_lastPaintTime = RealTime::fromTimeval(tv) - mainPaintStart; + } if (fftSuspended) fft->resume(); }