Mercurial > hg > svgui
comparison layer/Colour3DPlotRenderer.cpp @ 1502:62aad7969f8b
Pass the cache pointer through rather than looking it up afresh from the model id for each column
author | Chris Cannam |
---|---|
date | Thu, 12 Sep 2019 11:53:17 +0100 |
parents | ac5a82e57d23 |
children | 084c591622c5 |
comparison
equal
deleted
inserted
replaced
1501:5d179afc0366 | 1502:62aad7969f8b |
---|---|
34 | 34 |
35 #include <utility> | 35 #include <utility> |
36 using namespace std::rel_ops; | 36 using namespace std::rel_ops; |
37 | 37 |
38 //#define DEBUG_COLOUR_PLOT_REPAINT 1 | 38 //#define DEBUG_COLOUR_PLOT_REPAINT 1 |
39 //#define DEBUG_COLOUR_PLOT_CACHE_SELECTION 1 | |
39 | 40 |
40 using namespace std; | 41 using namespace std; |
41 | 42 |
42 Colour3DPlotRenderer::RenderResult | 43 Colour3DPlotRenderer::RenderResult |
43 Colour3DPlotRenderer::render(const LayerGeometryProvider *v, QPainter &paint, QRect rect) | 44 Colour3DPlotRenderer::render(const LayerGeometryProvider *v, QPainter &paint, QRect rect) |
385 } | 386 } |
386 } | 387 } |
387 | 388 |
388 ColumnOp::Column | 389 ColumnOp::Column |
389 Colour3DPlotRenderer::getColumn(int sx, int minbin, int nbins, | 390 Colour3DPlotRenderer::getColumn(int sx, int minbin, int nbins, |
390 int peakCacheIndex) const | 391 shared_ptr<DenseThreeDimensionalModel> source) const |
391 { | 392 { |
392 // order: | 393 // order: |
393 // get column -> scale -> normalise -> record extents -> | 394 // get column -> scale -> normalise -> record extents -> |
394 // peak pick -> distribute/interpolate -> apply display gain | 395 // peak pick -> distribute/interpolate -> apply display gain |
395 | 396 |
398 | 399 |
399 ColumnOp::Column column; | 400 ColumnOp::Column column; |
400 | 401 |
401 if (m_params.showDerivative && sx > 0) { | 402 if (m_params.showDerivative && sx > 0) { |
402 | 403 |
403 auto prev = getColumnRaw(sx - 1, minbin, nbins, peakCacheIndex); | 404 auto prev = getColumnRaw(sx - 1, minbin, nbins, source); |
404 column = getColumnRaw(sx, minbin, nbins, peakCacheIndex); | 405 column = getColumnRaw(sx, minbin, nbins, source); |
405 | 406 |
406 for (int i = 0; i < nbins; ++i) { | 407 for (int i = 0; i < nbins; ++i) { |
407 column[i] -= prev[i]; | 408 column[i] -= prev[i]; |
408 } | 409 } |
409 | 410 |
410 } else { | 411 } else { |
411 column = getColumnRaw(sx, minbin, nbins, peakCacheIndex); | 412 column = getColumnRaw(sx, minbin, nbins, source); |
412 } | 413 } |
413 | 414 |
414 if (m_params.colourScale.getScale() == ColourScaleType::Phase && | 415 if (m_params.colourScale.getScale() == ColourScaleType::Phase && |
415 !m_sources.fft.isNone()) { | 416 !m_sources.fft.isNone()) { |
416 return column; | 417 return column; |
421 } | 422 } |
422 } | 423 } |
423 | 424 |
424 ColumnOp::Column | 425 ColumnOp::Column |
425 Colour3DPlotRenderer::getColumnRaw(int sx, int minbin, int nbins, | 426 Colour3DPlotRenderer::getColumnRaw(int sx, int minbin, int nbins, |
426 int peakCacheIndex) const | 427 shared_ptr<DenseThreeDimensionalModel> source) const |
427 { | 428 { |
428 Profiler profiler("Colour3DPlotRenderer::getColumn"); | 429 Profiler profiler("Colour3DPlotRenderer::getColumn"); |
429 | 430 |
430 ColumnOp::Column column; | 431 ColumnOp::Column column; |
431 ColumnOp::Column fullColumn; | 432 ColumnOp::Column fullColumn; |
436 fullColumn = fftModel->getPhases(sx); | 437 fullColumn = fftModel->getPhases(sx); |
437 } | 438 } |
438 } | 439 } |
439 | 440 |
440 if (fullColumn.empty()) { | 441 if (fullColumn.empty()) { |
441 | 442 fullColumn = source->getColumn(sx); |
442 if (peakCacheIndex >= 0) { | 443 } |
443 auto peakCache = ModelById::getAs<Dense3DModelPeakCache> | 444 |
444 (m_sources.peakCaches[peakCacheIndex]); | |
445 if (!peakCache) { | |
446 return vector<float>(nbins, 0.f); | |
447 } | |
448 fullColumn = peakCache->getColumn(sx); | |
449 } else { | |
450 auto model = ModelById::getAs<DenseThreeDimensionalModel> | |
451 (m_sources.source); | |
452 if (!model) { | |
453 return vector<float>(nbins, 0.f); | |
454 } | |
455 fullColumn = model->getColumn(sx); | |
456 } | |
457 } | |
458 | |
459 column = vector<float>(fullColumn.data() + minbin, | 445 column = vector<float>(fullColumn.data() + minbin, |
460 fullColumn.data() + minbin + nbins); | 446 fullColumn.data() + minbin + nbins); |
461 return column; | 447 return column; |
462 } | 448 } |
463 | 449 |
524 // order: | 510 // order: |
525 // get column -> scale -> normalise -> record extents -> | 511 // get column -> scale -> normalise -> record extents -> |
526 // peak pick -> distribute/interpolate -> apply display gain | 512 // peak pick -> distribute/interpolate -> apply display gain |
527 | 513 |
528 // this does the first three: | 514 // this does the first three: |
529 preparedColumn = getColumn(sx, minbin, nbins, -1); | 515 preparedColumn = getColumn(sx, minbin, nbins, model); |
530 | 516 |
531 magRange.sample(preparedColumn); | 517 magRange.sample(preparedColumn); |
532 | 518 |
533 if (m_params.binDisplay == BinDisplay::PeakBins) { | 519 if (m_params.binDisplay == BinDisplay::PeakBins) { |
534 preparedColumn = ColumnOp::peakPick(preparedColumn); | 520 preparedColumn = ColumnOp::peakPick(preparedColumn); |
643 auto peakCache = ModelById::getAs<Dense3DModelPeakCache> | 629 auto peakCache = ModelById::getAs<Dense3DModelPeakCache> |
644 (m_sources.peakCaches[ix]); | 630 (m_sources.peakCaches[ix]); |
645 if (!peakCache) continue; | 631 if (!peakCache) continue; |
646 int bpp = peakCache->getColumnsPerPeak(); | 632 int bpp = peakCache->getColumnsPerPeak(); |
647 ZoomLevel equivZoom(ZoomLevel::FramesPerPixel, binResolution * bpp); | 633 ZoomLevel equivZoom(ZoomLevel::FramesPerPixel, binResolution * bpp); |
648 #ifdef DEBUG_COLOUR_PLOT_REPAINT | 634 #ifdef DEBUG_COLOUR_PLOT_CACHE_SELECTION |
649 SVDEBUG << "render " << m_sources.source | 635 SVDEBUG << "render " << m_sources.source |
650 << ": getPreferredPeakCache: zoomLevel = " << zoomLevel | 636 << ": getPreferredPeakCache: zoomLevel = " << zoomLevel |
651 << ", cache " << ix << " has bpp = " << bpp | 637 << ", cache " << ix << " has bpp = " << bpp |
652 << " for equivZoom = " << equivZoom << endl; | 638 << " for equivZoom = " << equivZoom << endl; |
653 #endif | 639 #endif |
659 binsPerPeak = bpp; | 645 binsPerPeak = bpp; |
660 } | 646 } |
661 } | 647 } |
662 } | 648 } |
663 | 649 |
664 #ifdef DEBUG_COLOUR_PLOT_REPAINT | 650 #ifdef DEBUG_COLOUR_PLOT_CACHE_SELECTION |
665 SVDEBUG << "render " << m_sources.source | 651 SVDEBUG << "render " << m_sources.source |
666 << ": getPreferredPeakCache: zoomLevel = " << zoomLevel | 652 << ": getPreferredPeakCache: zoomLevel = " << zoomLevel |
667 << ", binResolution " << binResolution | 653 << ", binResolution " << binResolution |
668 << ", peakCaches " << m_sources.peakCaches.size() | 654 << ", peakCaches " << m_sources.peakCaches.size() |
669 << ": preferring peakCacheIndex " << peakCacheIndex | 655 << ": preferring peakCacheIndex " << peakCacheIndex |
1117 // get column -> scale -> normalise -> record extents -> | 1103 // get column -> scale -> normalise -> record extents -> |
1118 // peak pick -> distribute/interpolate -> apply display gain | 1104 // peak pick -> distribute/interpolate -> apply display gain |
1119 | 1105 |
1120 // this does the first three: | 1106 // this does the first three: |
1121 ColumnOp::Column column = getColumn(sx, minbin, nbins, | 1107 ColumnOp::Column column = getColumn(sx, minbin, nbins, |
1122 peakCacheIndex); | 1108 sourceModel); |
1123 | 1109 |
1124 magRange.sample(column); | 1110 magRange.sample(column); |
1125 | 1111 |
1126 if (m_params.binDisplay == BinDisplay::PeakBins) { | 1112 if (m_params.binDisplay == BinDisplay::PeakBins) { |
1127 column = ColumnOp::peakPick(column); | 1113 column = ColumnOp::peakPick(column); |
1282 if (sx < 0 || sx >= modelWidth) { | 1268 if (sx < 0 || sx >= modelWidth) { |
1283 continue; | 1269 continue; |
1284 } | 1270 } |
1285 | 1271 |
1286 if (sx != psx) { | 1272 if (sx != psx) { |
1287 preparedColumn = getColumn(sx, minbin, nbins, -1); | 1273 preparedColumn = getColumn(sx, minbin, nbins, fft); |
1288 magRange.sample(preparedColumn); | 1274 magRange.sample(preparedColumn); |
1289 psx = sx; | 1275 psx = sx; |
1290 } | 1276 } |
1291 | 1277 |
1292 if (sx == sx0) { | 1278 if (sx == sx0) { |