Mercurial > hg > svgui
comparison layer/Colour3DPlotRenderer.cpp @ 1213:34df6ff25472 3.0-integration
Don't start in the middle when repainting the whole width while using a peak cache. It looks funny.
author | Chris Cannam |
---|---|
date | Thu, 05 Jan 2017 14:17:47 +0000 |
parents | a1ee3108d1d3 |
children | be42a33a3db6 |
comparison
equal
deleted
inserted
replaced
1212:a1ee3108d1d3 | 1213:34df6ff25472 |
---|---|
185 int reqx1 = x1; | 185 int reqx1 = x1; |
186 | 186 |
187 if (!m_cache.isValid() && timeConstrained) { | 187 if (!m_cache.isValid() && timeConstrained) { |
188 // When rendering the whole area, in a context where we might | 188 // When rendering the whole area, in a context where we might |
189 // not be able to complete the work, start from somewhere near | 189 // not be able to complete the work, start from somewhere near |
190 // the middle so that the region of interest appears first | 190 // the middle so that the region of interest appears |
191 | 191 // first. But only if we aren't using a peak cache, as |
192 //!!! (perhaps we should avoid doing this if past repaints | 192 // rendering from peak cache is usually (not always) quick and |
193 //!!! have been fast enough to do the whole in one shot) | 193 // looks odd if we make a habit of jumping back after reaching |
194 // the end. | |
194 if (x0 == 0 && x1 == v->getPaintWidth()) { | 195 if (x0 == 0 && x1 == v->getPaintWidth()) { |
195 x0 = int(x1 * 0.3); | 196 int peakCacheIndex = -1, binsPerPeak = -1; |
197 getPreferredPeakCache(v, peakCacheIndex, binsPerPeak); | |
198 if (peakCacheIndex == -1) { // no peak cache | |
199 x0 = int(x1 * 0.3); | |
200 } | |
196 } | 201 } |
197 } | 202 } |
198 | 203 |
199 if (m_cache.isValid()) { | 204 if (m_cache.isValid()) { |
200 | 205 |
482 | 487 |
483 return magRange; | 488 return magRange; |
484 } | 489 } |
485 | 490 |
486 void | 491 void |
487 Colour3DPlotRenderer::renderToCachePixelResolution(const LayerGeometryProvider *v, | 492 Colour3DPlotRenderer::getPreferredPeakCache(const LayerGeometryProvider *v, |
488 int x0, int repaintWidth, | 493 int &peakCacheIndex, |
489 bool rightToLeft, | 494 int &binsPerPeak) const |
490 bool timeConstrained) | 495 { |
491 { | 496 peakCacheIndex = -1; |
492 Profiler profiler("Colour3DPlotRenderer::renderToCachePixelResolution"); | 497 binsPerPeak = -1; |
493 #ifdef DEBUG_COLOUR_PLOT_REPAINT | |
494 cerr << "renderToCachePixelResolution" << endl; | |
495 #endif | |
496 | |
497 // Draw to the draw buffer, and then copy from there. The draw | |
498 // buffer is at the same resolution as the target in the cache, so | |
499 // no extra scaling needed. | |
500 | 498 |
501 const DenseThreeDimensionalModel *model = m_sources.source; | 499 const DenseThreeDimensionalModel *model = m_sources.source; |
502 if (!model || !model->isOK() || !model->isReady()) { | 500 if (!model) return; |
503 throw std::logic_error("no source model provided, or model not ready"); | |
504 } | |
505 | |
506 int h = v->getPaintHeight(); | |
507 | |
508 clearDrawBuffer(repaintWidth, h); | |
509 | |
510 vector<int> binforx(repaintWidth); | |
511 vector<double> binfory(h); | |
512 | 501 |
513 int zoomLevel = v->getZoomLevel(); | 502 int zoomLevel = v->getZoomLevel(); |
514 int binResolution = model->getResolution(); | 503 int binResolution = model->getResolution(); |
515 | 504 |
516 for (int x = 0; x < repaintWidth; ++x) { | 505 for (int ix = 0; in_range_for(m_sources.peakCaches, ix); ++ix) { |
517 sv_frame_t f0 = v->getFrameForX(x0 + x); | 506 int bpp = m_sources.peakCaches[ix]->getColumnsPerPeak(); |
518 double s0 = double(f0 - model->getStartFrame()) / binResolution; | 507 int equivZoom = binResolution * bpp; |
519 binforx[x] = int(s0 + 0.0001); | 508 if (zoomLevel >= equivZoom) { |
520 } | 509 // this peak cache would work, though it might not be best |
521 | 510 if (bpp > binsPerPeak) { |
522 int peakCacheIndex = -1; | 511 // ok, it's better than the best one we've found so far |
523 int binsPerPeak = -1; | 512 peakCacheIndex = ix; |
524 | 513 binsPerPeak = bpp; |
525 if (m_params.colourScale.getScale() != ColourScaleType::Phase) { | 514 } |
526 for (int ix = 0; in_range_for(m_sources.peakCaches, ix); ++ix) { | 515 } |
527 int bpp = m_sources.peakCaches[ix]->getColumnsPerPeak(); | 516 } |
528 int equivZoom = binResolution * bpp; | 517 |
529 if (zoomLevel >= equivZoom) { | 518 SVDEBUG << "getPreferredPeakCache: zoomLevel = " << zoomLevel |
530 // this peak cache would work, though it might not be best | |
531 if (bpp > binsPerPeak) { | |
532 // ok, it's better than the best one we've found so far | |
533 peakCacheIndex = ix; | |
534 binsPerPeak = bpp; | |
535 } | |
536 } | |
537 } | |
538 } | |
539 | |
540 SVDEBUG << "[PIX] zoomLevel = " << zoomLevel | |
541 << ", binResolution " << binResolution | 519 << ", binResolution " << binResolution |
542 << ", binsPerPeak " << binsPerPeak | 520 << ", binsPerPeak " << binsPerPeak |
543 << ", peakCacheIndex " << peakCacheIndex | 521 << ", peakCacheIndex " << peakCacheIndex |
544 << ", peakCaches " << m_sources.peakCaches.size() | 522 << ", peakCaches " << m_sources.peakCaches.size() |
545 << endl; | 523 << endl; |
524 } | |
525 | |
526 void | |
527 Colour3DPlotRenderer::renderToCachePixelResolution(const LayerGeometryProvider *v, | |
528 int x0, int repaintWidth, | |
529 bool rightToLeft, | |
530 bool timeConstrained) | |
531 { | |
532 Profiler profiler("Colour3DPlotRenderer::renderToCachePixelResolution"); | |
533 #ifdef DEBUG_COLOUR_PLOT_REPAINT | |
534 cerr << "renderToCachePixelResolution" << endl; | |
535 #endif | |
536 | |
537 // Draw to the draw buffer, and then copy from there. The draw | |
538 // buffer is at the same resolution as the target in the cache, so | |
539 // no extra scaling needed. | |
540 | |
541 const DenseThreeDimensionalModel *model = m_sources.source; | |
542 if (!model || !model->isOK() || !model->isReady()) { | |
543 throw std::logic_error("no source model provided, or model not ready"); | |
544 } | |
545 | |
546 int h = v->getPaintHeight(); | |
547 | |
548 clearDrawBuffer(repaintWidth, h); | |
549 | |
550 vector<int> binforx(repaintWidth); | |
551 vector<double> binfory(h); | |
552 | |
553 int binResolution = model->getResolution(); | |
554 | |
555 for (int x = 0; x < repaintWidth; ++x) { | |
556 sv_frame_t f0 = v->getFrameForX(x0 + x); | |
557 double s0 = double(f0 - model->getStartFrame()) / binResolution; | |
558 binforx[x] = int(s0 + 0.0001); | |
559 } | |
560 | |
561 int peakCacheIndex = -1; | |
562 int binsPerPeak = -1; | |
563 | |
564 if (m_params.colourScale.getScale() != ColourScaleType::Phase) { | |
565 getPreferredPeakCache(v, peakCacheIndex, binsPerPeak); | |
566 } | |
546 | 567 |
547 for (int y = 0; y < h; ++y) { | 568 for (int y = 0; y < h; ++y) { |
548 binfory[y] = m_sources.verticalBinLayer->getBinForY(v, h - y - 1); | 569 binfory[y] = m_sources.verticalBinLayer->getBinForY(v, h - y - 1); |
549 } | 570 } |
550 | 571 |