Mercurial > hg > svgui
comparison layer/Colour3DPlotRenderer.cpp @ 1325:bc2cb82050a0 zoom
Gradual ZoomLevel updates
| author | Chris Cannam |
|---|---|
| date | Wed, 19 Sep 2018 15:42:22 +0100 |
| parents | a34a2a25907c |
| children | 344f29e46258 |
comparison
equal
deleted
inserted
replaced
| 1324:13d9b422f7fe | 1325:bc2cb82050a0 |
|---|---|
| 30 | 30 |
| 31 #include "view/ViewManager.h" // for main model sample rate. Pity | 31 #include "view/ViewManager.h" // for main model sample rate. Pity |
| 32 | 32 |
| 33 #include <vector> | 33 #include <vector> |
| 34 | 34 |
| 35 //#define DEBUG_COLOUR_PLOT_REPAINT 1 | 35 #include <utility> |
| 36 using namespace std::rel_ops; | |
| 37 | |
| 38 #define DEBUG_COLOUR_PLOT_REPAINT 1 | |
| 36 | 39 |
| 37 using namespace std; | 40 using namespace std; |
| 38 | 41 |
| 39 Colour3DPlotRenderer::RenderResult | 42 Colour3DPlotRenderer::RenderResult |
| 40 Colour3DPlotRenderer::render(const LayerGeometryProvider *v, QPainter &paint, QRect rect) | 43 Colour3DPlotRenderer::render(const LayerGeometryProvider *v, QPainter &paint, QRect rect) |
| 313 if (!model || !v || !(v->getViewManager())) { | 316 if (!model || !v || !(v->getViewManager())) { |
| 314 return DrawBufferPixelResolution; // or anything | 317 return DrawBufferPixelResolution; // or anything |
| 315 } | 318 } |
| 316 | 319 |
| 317 int binResolution = model->getResolution(); | 320 int binResolution = model->getResolution(); |
| 318 int zoomLevel = v->getZoomLevel(); | 321 ZoomLevel zoomLevel = v->getZoomLevel(); |
| 319 sv_samplerate_t modelRate = model->getSampleRate(); | 322 sv_samplerate_t modelRate = model->getSampleRate(); |
| 320 | 323 |
| 321 double rateRatio = v->getViewManager()->getMainModelSampleRate() / modelRate; | 324 double rateRatio = v->getViewManager()->getMainModelSampleRate() / modelRate; |
| 322 double relativeBinResolution = binResolution * rateRatio; | 325 double relativeBinResolution = binResolution * rateRatio; |
| 323 | 326 |
| 330 | 333 |
| 331 // consider translucent option -- only if not smoothing & not | 334 // consider translucent option -- only if not smoothing & not |
| 332 // explicitly requested opaque & sufficiently zoomed-in | 335 // explicitly requested opaque & sufficiently zoomed-in |
| 333 | 336 |
| 334 if (model->getHeight() * 3 < v->getPaintHeight() && | 337 if (model->getHeight() * 3 < v->getPaintHeight() && |
| 335 relativeBinResolution >= 3 * zoomLevel) { | 338 zoomLevel < ZoomLevel(ZoomLevel::FramesPerPixel, |
| 339 int(round(relativeBinResolution / 3)))) { | |
| 336 return DirectTranslucent; | 340 return DirectTranslucent; |
| 337 } | 341 } |
| 338 } | 342 } |
| 339 | 343 |
| 340 if (relativeBinResolution > zoomLevel) { | 344 if (ZoomLevel(ZoomLevel::FramesPerPixel, |
| 345 int(round(relativeBinResolution))) > zoomLevel) { | |
| 341 return DrawBufferBinResolution; | 346 return DrawBufferBinResolution; |
| 342 } else { | 347 } else { |
| 343 return DrawBufferPixelResolution; | 348 return DrawBufferPixelResolution; |
| 344 } | 349 } |
| 345 } | 350 } |
| 553 const DenseThreeDimensionalModel *model = m_sources.source; | 558 const DenseThreeDimensionalModel *model = m_sources.source; |
| 554 if (!model) return; | 559 if (!model) return; |
| 555 if (m_params.binDisplay == BinDisplay::PeakFrequencies) return; | 560 if (m_params.binDisplay == BinDisplay::PeakFrequencies) return; |
| 556 if (m_params.colourScale.getScale() == ColourScaleType::Phase) return; | 561 if (m_params.colourScale.getScale() == ColourScaleType::Phase) return; |
| 557 | 562 |
| 558 int zoomLevel = v->getZoomLevel(); | 563 ZoomLevel zoomLevel = v->getZoomLevel(); |
| 559 int binResolution = model->getResolution(); | 564 int binResolution = model->getResolution(); |
| 560 | 565 |
| 561 for (int ix = 0; in_range_for(m_sources.peakCaches, ix); ++ix) { | 566 for (int ix = 0; in_range_for(m_sources.peakCaches, ix); ++ix) { |
| 562 int bpp = m_sources.peakCaches[ix]->getColumnsPerPeak(); | 567 int bpp = m_sources.peakCaches[ix]->getColumnsPerPeak(); |
| 563 int equivZoom = binResolution * bpp; | 568 ZoomLevel equivZoom(ZoomLevel::FramesPerPixel, binResolution * bpp); |
| 564 if (zoomLevel >= equivZoom) { | 569 if (zoomLevel >= equivZoom) { |
| 565 // this peak cache would work, though it might not be best | 570 // this peak cache would work, though it might not be best |
| 566 if (bpp > binsPerPeak) { | 571 if (bpp > binsPerPeak) { |
| 567 // ok, it's better than the best one we've found so far | 572 // ok, it's better than the best one we've found so far |
| 568 peakCacheIndex = ix; | 573 peakCacheIndex = ix; |
