comparison layer/Colour3DPlotRenderer.cpp @ 1163:ab169938832a 3.0-integration

Use peak cache at one zoom level lower (since it exists at that level already -- this is a >= vs > question) + make naming more uniform
author Chris Cannam
date Tue, 08 Nov 2016 14:55:53 +0000
parents 081c7ebf1fea
children f2f43802718b
comparison
equal deleted inserted replaced
1162:081c7ebf1fea 1163:ab169938832a
285 } 285 }
286 } 286 }
287 287
288 ColumnOp::Column 288 ColumnOp::Column
289 Colour3DPlotRenderer::getColumn(int sx, int minbin, int nbins, 289 Colour3DPlotRenderer::getColumn(int sx, int minbin, int nbins,
290 bool usePeaksCache) const 290 bool usePeakCache) const
291 { 291 {
292 // order: 292 // order:
293 // get column -> scale -> normalise -> record extents -> 293 // get column -> scale -> normalise -> record extents ->
294 // peak pick -> distribute/interpolate -> apply display gain 294 // peak pick -> distribute/interpolate -> apply display gain
295 295
307 fullColumn.data() + minbin + nbins); 307 fullColumn.data() + minbin + nbins);
308 308
309 } else { 309 } else {
310 310
311 ColumnOp::Column fullColumn = 311 ColumnOp::Column fullColumn =
312 (usePeaksCache ? m_sources.peaks : m_sources.source)-> 312 (usePeakCache ? m_sources.peakCache : m_sources.source)->
313 getColumn(sx); 313 getColumn(sx);
314 314
315 column = vector<float>(fullColumn.data() + minbin, 315 column = vector<float>(fullColumn.data() + minbin,
316 fullColumn.data() + minbin + nbins); 316 fullColumn.data() + minbin + nbins);
317 317
504 clearDrawBuffer(repaintWidth, h); 504 clearDrawBuffer(repaintWidth, h);
505 505
506 vector<int> binforx(repaintWidth); 506 vector<int> binforx(repaintWidth);
507 vector<double> binfory(h); 507 vector<double> binfory(h);
508 508
509 bool usePeaksCache = false; 509 bool usePeakCache = false;
510 int binsPerPeak = 1; 510 int binsPerPeak = 1;
511 int zoomLevel = v->getZoomLevel(); 511 int zoomLevel = v->getZoomLevel();
512 int binResolution = model->getResolution(); 512 int binResolution = model->getResolution();
513 513
514 for (int x = 0; x < repaintWidth; ++x) { 514 for (int x = 0; x < repaintWidth; ++x) {
515 sv_frame_t f0 = v->getFrameForX(x0 + x); 515 sv_frame_t f0 = v->getFrameForX(x0 + x);
516 double s0 = double(f0 - model->getStartFrame()) / binResolution; 516 double s0 = double(f0 - model->getStartFrame()) / binResolution;
517 binforx[x] = int(s0 + 0.0001); 517 binforx[x] = int(s0 + 0.0001);
518 } 518 }
519 519
520 if (m_sources.peaks) { // peaks cache exists 520 if (m_sources.peakCache) {
521 521 binsPerPeak = m_sources.peakCache->getColumnsPerPeak();
522 binsPerPeak = m_sources.peaks->getColumnsPerPeak(); 522 usePeakCache = (zoomLevel >= binResolution * binsPerPeak);
523 usePeaksCache = (binResolution * binsPerPeak) < zoomLevel;
524
525 if (m_params.colourScale.getScale() == 523 if (m_params.colourScale.getScale() ==
526 ColourScaleType::Phase) { 524 ColourScaleType::Phase) {
527 usePeaksCache = false; 525 usePeakCache = false;
528 } 526 }
529 } 527 }
530 528
531 #ifdef DEBUG_COLOUR_PLOT_REPAINT 529 SVDEBUG << "[PIX] zoomLevel = " << zoomLevel
532 cerr << "[PIX] zoomLevel = " << zoomLevel 530 << ", binResolution " << binResolution
533 << ", binResolution " << binResolution 531 << ", binsPerPeak " << binsPerPeak
534 << ", binsPerPeak " << binsPerPeak 532 << ", peak cache " << m_sources.peakCache
535 << ", peak cache " << m_sources.peaks 533 << ", usePeakCache = " << usePeakCache
536 << ", usePeaksCache = " << usePeaksCache 534 << endl;
537 << endl;
538 #endif
539 535
540 for (int y = 0; y < h; ++y) { 536 for (int y = 0; y < h; ++y) {
541 binfory[y] = m_sources.verticalBinLayer->getBinForY(v, h - y - 1); 537 binfory[y] = m_sources.verticalBinLayer->getBinForY(v, h - y - 1);
542 } 538 }
543 539
555 } else { 551 } else {
556 attainedWidth = renderDrawBuffer(repaintWidth, 552 attainedWidth = renderDrawBuffer(repaintWidth,
557 h, 553 h,
558 binforx, 554 binforx,
559 binfory, 555 binfory,
560 usePeaksCache, 556 usePeakCache,
561 rightToLeft, 557 rightToLeft,
562 timeConstrained); 558 timeConstrained);
563 } 559 }
564 560
565 if (attainedWidth == 0) return; 561 if (attainedWidth == 0) return;
650 646
651 for (int x = 0; x < drawBufferWidth; ++x) { 647 for (int x = 0; x < drawBufferWidth; ++x) {
652 binforx[x] = int(leftBoundaryFrame / binResolution) + x; 648 binforx[x] = int(leftBoundaryFrame / binResolution) + x;
653 } 649 }
654 650
655 #ifdef DEBUG_COLOUR_PLOT_REPAINT 651 SVDEBUG << "[BIN] binResolution " << binResolution
656 cerr << "[BIN] binResolution " << binResolution 652 << endl;
657 << endl;
658 #endif
659 653
660 for (int y = 0; y < h; ++y) { 654 for (int y = 0; y < h; ++y) {
661 binfory[y] = m_sources.verticalBinLayer->getBinForY(v, h - y - 1); 655 binfory[y] = m_sources.verticalBinLayer->getBinForY(v, h - y - 1);
662 } 656 }
663 657
729 723
730 int 724 int
731 Colour3DPlotRenderer::renderDrawBuffer(int w, int h, 725 Colour3DPlotRenderer::renderDrawBuffer(int w, int h,
732 const vector<int> &binforx, 726 const vector<int> &binforx,
733 const vector<double> &binfory, 727 const vector<double> &binfory,
734 bool usePeaksCache, 728 bool usePeakCache,
735 bool rightToLeft, 729 bool rightToLeft,
736 bool timeConstrained) 730 bool timeConstrained)
737 { 731 {
738 // Callers must have checked that the appropriate subset of 732 // Callers must have checked that the appropriate subset of
739 // Sources data members are set for the supplied flags (e.g. that 733 // Sources data members are set for the supplied flags (e.g. that
740 // peaks model exists if usePeaksCache) 734 // peakCache model exists if usePeakCache)
741 735
742 RenderTimer timer(timeConstrained ? 736 RenderTimer timer(timeConstrained ?
743 RenderTimer::FastRender : 737 RenderTimer::FastRender :
744 RenderTimer::NoTimeout); 738 RenderTimer::NoTimeout);
745 739
746 int divisor = 1; 740 int divisor = 1;
747 const DenseThreeDimensionalModel *sourceModel = m_sources.source; 741 const DenseThreeDimensionalModel *sourceModel = m_sources.source;
748 if (usePeaksCache) { 742 if (usePeakCache) {
749 divisor = m_sources.peaks->getColumnsPerPeak(); 743 divisor = m_sources.peakCache->getColumnsPerPeak();
750 sourceModel = m_sources.peaks; 744 sourceModel = m_sources.peakCache;
751 } 745 }
752 746
753 int sh = sourceModel->getHeight(); 747 int sh = sourceModel->getHeight();
754 748
755 int minbin = int(binfory[0] + 0.0001); 749 int minbin = int(binfory[0] + 0.0001);
821 // get column -> scale -> normalise -> record extents -> 815 // get column -> scale -> normalise -> record extents ->
822 // peak pick -> distribute/interpolate -> apply display gain 816 // peak pick -> distribute/interpolate -> apply display gain
823 817
824 // this does the first three: 818 // this does the first three:
825 ColumnOp::Column column = getColumn(sx, minbin, nbins, 819 ColumnOp::Column column = getColumn(sx, minbin, nbins,
826 usePeaksCache); 820 usePeakCache);
827 821
828 magRange.sample(column); 822 magRange.sample(column);
829 823
830 if (m_params.binDisplay == BinDisplay::PeakBins) { 824 if (m_params.binDisplay == BinDisplay::PeakBins) {
831 column = ColumnOp::peakPick(column); 825 column = ColumnOp::peakPick(column);