Mercurial > hg > svgui
comparison layer/Colour3DPlotRenderer.cpp @ 1469:11a150e65ee1 by-id
Some work on updating layers for ModelId bits
author | Chris Cannam |
---|---|
date | Thu, 27 Jun 2019 13:16:25 +0100 |
parents | f72fb7fac92a |
children | f2525e6cbdf1 |
comparison
equal
deleted
inserted
replaced
1468:de41a11cabc2 | 1469:11a150e65ee1 |
---|---|
332 } | 332 } |
333 | 333 |
334 Colour3DPlotRenderer::RenderType | 334 Colour3DPlotRenderer::RenderType |
335 Colour3DPlotRenderer::decideRenderType(const LayerGeometryProvider *v) const | 335 Colour3DPlotRenderer::decideRenderType(const LayerGeometryProvider *v) const |
336 { | 336 { |
337 const DenseThreeDimensionalModel *model = m_sources.source; | 337 auto model = ModelById::getAs<DenseThreeDimensionalModel>(m_sources.source); |
338 if (!model || !v || !(v->getViewManager())) { | 338 if (!model || !v || !(v->getViewManager())) { |
339 return DrawBufferPixelResolution; // or anything | 339 return DrawBufferPixelResolution; // or anything |
340 } | 340 } |
341 | 341 |
342 int binResolution = model->getResolution(); | 342 int binResolution = model->getResolution(); |
396 } else { | 396 } else { |
397 column = getColumnRaw(sx, minbin, nbins, peakCacheIndex); | 397 column = getColumnRaw(sx, minbin, nbins, peakCacheIndex); |
398 } | 398 } |
399 | 399 |
400 if (m_params.colourScale.getScale() == ColourScaleType::Phase && | 400 if (m_params.colourScale.getScale() == ColourScaleType::Phase && |
401 m_sources.fft) { | 401 !m_sources.fft.isNone()) { |
402 return column; | 402 return column; |
403 } else { | 403 } else { |
404 column = ColumnOp::applyGain(column, m_params.scaleFactor); | 404 column = ColumnOp::applyGain(column, m_params.scaleFactor); |
405 column = ColumnOp::normalize(column, m_params.normalization); | 405 column = ColumnOp::normalize(column, m_params.normalization); |
406 return column; | 406 return column; |
412 int peakCacheIndex) const | 412 int peakCacheIndex) const |
413 { | 413 { |
414 Profiler profiler("Colour3DPlotRenderer::getColumn"); | 414 Profiler profiler("Colour3DPlotRenderer::getColumn"); |
415 | 415 |
416 ColumnOp::Column column; | 416 ColumnOp::Column column; |
417 | 417 ColumnOp::Column fullColumn; |
418 if (m_params.colourScale.getScale() == ColourScaleType::Phase && | 418 |
419 m_sources.fft) { | 419 if (m_params.colourScale.getScale() == ColourScaleType::Phase) { |
420 | 420 auto fftModel = ModelById::getAs<FFTModel>(m_sources.fft); |
421 ColumnOp::Column fullColumn = m_sources.fft->getPhases(sx); | 421 if (fftModel) { |
422 | 422 fullColumn = fftModel->getPhases(sx); |
423 column = vector<float>(fullColumn.data() + minbin, | 423 } |
424 fullColumn.data() + minbin + nbins); | 424 } |
425 | 425 |
426 } else { | 426 if (fullColumn.empty()) { |
427 | 427 |
428 ColumnOp::Column fullColumn = | 428 if (peakCacheIndex >= 0) { |
429 (peakCacheIndex >= 0 ? | 429 fullColumn = m_sources.peakCaches[peakCacheIndex]->getColumn(sx); |
430 m_sources.peakCaches[peakCacheIndex] : | 430 } else { |
431 m_sources.source) | 431 auto model = ModelById::getAs<DenseThreeDimensionalModel> |
432 ->getColumn(sx); | 432 (m_sources.source); |
433 | 433 if (!model) { |
434 column = vector<float>(fullColumn.data() + minbin, | 434 return vector<float>(nbins, 0.f); |
435 fullColumn.data() + minbin + nbins); | 435 } |
436 } | 436 fullColumn = model->getColumn(sx); |
437 | 437 } |
438 } | |
439 | |
440 column = vector<float>(fullColumn.data() + minbin, | |
441 fullColumn.data() + minbin + nbins); | |
438 return column; | 442 return column; |
439 } | 443 } |
440 | 444 |
441 MagnitudeRange | 445 MagnitudeRange |
442 Colour3DPlotRenderer::renderDirectTranslucent(const LayerGeometryProvider *v, | 446 Colour3DPlotRenderer::renderDirectTranslucent(const LayerGeometryProvider *v, |
449 | 453 |
450 QPoint illuminatePos; | 454 QPoint illuminatePos; |
451 bool illuminate = v->shouldIlluminateLocalFeatures | 455 bool illuminate = v->shouldIlluminateLocalFeatures |
452 (m_sources.verticalBinLayer, illuminatePos); | 456 (m_sources.verticalBinLayer, illuminatePos); |
453 | 457 |
454 const DenseThreeDimensionalModel *model = m_sources.source; | 458 auto model = ModelById::getAs<DenseThreeDimensionalModel>(m_sources.source); |
459 if (!model) return magRange; | |
455 | 460 |
456 int x0 = rect.left(); | 461 int x0 = rect.left(); |
457 int x1 = rect.right() + 1; | 462 int x1 = rect.right() + 1; |
458 | 463 |
459 int h = v->getPaintHeight(); | 464 int h = v->getPaintHeight(); |
600 int &binsPerPeak) const | 605 int &binsPerPeak) const |
601 { | 606 { |
602 peakCacheIndex = -1; | 607 peakCacheIndex = -1; |
603 binsPerPeak = -1; | 608 binsPerPeak = -1; |
604 | 609 |
605 const DenseThreeDimensionalModel *model = m_sources.source; | 610 auto model = ModelById::getAs<DenseThreeDimensionalModel>(m_sources.source); |
606 if (!model) return; | 611 if (!model) return; |
607 if (m_params.binDisplay == BinDisplay::PeakFrequencies) return; | 612 if (m_params.binDisplay == BinDisplay::PeakFrequencies) return; |
608 if (m_params.colourScale.getScale() == ColourScaleType::Phase) return; | 613 if (m_params.colourScale.getScale() == ColourScaleType::Phase) return; |
609 | 614 |
610 ZoomLevel zoomLevel = v->getZoomLevel(); | 615 ZoomLevel zoomLevel = v->getZoomLevel(); |
651 | 656 |
652 // Draw to the draw buffer, and then copy from there. The draw | 657 // Draw to the draw buffer, and then copy from there. The draw |
653 // buffer is at the same resolution as the target in the cache, so | 658 // buffer is at the same resolution as the target in the cache, so |
654 // no extra scaling needed. | 659 // no extra scaling needed. |
655 | 660 |
656 const DenseThreeDimensionalModel *model = m_sources.source; | 661 auto model = ModelById::getAs<DenseThreeDimensionalModel>(m_sources.source); |
657 if (!model || !model->isOK() || !model->isReady()) { | 662 if (!model) return; |
658 throw std::logic_error("no source model provided, or model not ready"); | |
659 } | |
660 | 663 |
661 int h = v->getPaintHeight(); | 664 int h = v->getPaintHeight(); |
662 | 665 |
663 clearDrawBuffer(repaintWidth, h); | 666 clearDrawBuffer(repaintWidth, h); |
664 | 667 |
792 | 795 |
793 // Draw to the draw buffer, and then scale-copy from there. Draw | 796 // Draw to the draw buffer, and then scale-copy from there. Draw |
794 // buffer is at bin resolution, i.e. buffer x == source column | 797 // buffer is at bin resolution, i.e. buffer x == source column |
795 // number. We use toolkit smooth scaling for interpolation. | 798 // number. We use toolkit smooth scaling for interpolation. |
796 | 799 |
797 const DenseThreeDimensionalModel *model = m_sources.source; | 800 auto model = ModelById::getAs<DenseThreeDimensionalModel>(m_sources.source); |
798 if (!model || !model->isOK() || !model->isReady()) { | 801 if (!model) return; |
799 throw std::logic_error("no source model provided, or model not ready"); | |
800 } | |
801 | 802 |
802 // The draw buffer will contain a fragment at bin resolution. We | 803 // The draw buffer will contain a fragment at bin resolution. We |
803 // need to ensure that it starts and ends at points where a | 804 // need to ensure that it starts and ends at points where a |
804 // time-bin boundary occurs at an exact pixel boundary, and with a | 805 // time-bin boundary occurs at an exact pixel boundary, and with a |
805 // certain amount of overlap across existing pixels so that we can | 806 // certain amount of overlap across existing pixels so that we can |
948 RenderTimer::NoTimeout); | 949 RenderTimer::NoTimeout); |
949 | 950 |
950 Profiler profiler("Colour3DPlotRenderer::renderDrawBuffer"); | 951 Profiler profiler("Colour3DPlotRenderer::renderDrawBuffer"); |
951 | 952 |
952 int divisor = 1; | 953 int divisor = 1; |
953 const DenseThreeDimensionalModel *sourceModel = m_sources.source; | 954 auto model = ModelById::getAs<DenseThreeDimensionalModel>(m_sources.source); |
955 if (!model) return 0; | |
956 | |
957 const DenseThreeDimensionalModel *sourceModel = model.get(); | |
954 if (peakCacheIndex >= 0) { | 958 if (peakCacheIndex >= 0) { |
955 divisor = m_sources.peakCaches[peakCacheIndex]->getColumnsPerPeak(); | 959 divisor = m_sources.peakCaches[peakCacheIndex]->getColumnsPerPeak(); |
956 sourceModel = m_sources.peakCaches[peakCacheIndex]; | 960 sourceModel = m_sources.peakCaches[peakCacheIndex]; |
957 } | 961 } |
958 | 962 |
1123 | 1127 |
1124 RenderTimer timer(timeConstrained ? | 1128 RenderTimer timer(timeConstrained ? |
1125 RenderTimer::SlowRender : | 1129 RenderTimer::SlowRender : |
1126 RenderTimer::NoTimeout); | 1130 RenderTimer::NoTimeout); |
1127 | 1131 |
1128 const FFTModel *fft = m_sources.fft; | 1132 auto fft = ModelById::getAs<FFTModel>(m_sources.fft); |
1133 if (!fft) return 0; | |
1129 | 1134 |
1130 int sh = fft->getHeight(); | 1135 int sh = fft->getHeight(); |
1131 | 1136 |
1132 int minbin = int(binfory[0] + 0.0001); | 1137 int minbin = int(binfory[0] + 0.0001); |
1133 if (minbin >= sh) minbin = sh - 1; | 1138 if (minbin >= sh) minbin = sh - 1; |