Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 1089:c8683d94442a spectrogram-minor-refactor
Start to introduce renderer objects
author | Chris Cannam |
---|---|
date | Tue, 05 Jul 2016 12:20:56 +0100 |
parents | c520f90bbf2e |
children | c8c747783110 |
comparison
equal
deleted
inserted
replaced
1088:c520f90bbf2e | 1089:c8683d94442a |
---|---|
29 | 29 |
30 #include "ColourMapper.h" | 30 #include "ColourMapper.h" |
31 #include "ImageRegionFinder.h" | 31 #include "ImageRegionFinder.h" |
32 #include "PianoScale.h" | 32 #include "PianoScale.h" |
33 #include "PaintAssistant.h" | 33 #include "PaintAssistant.h" |
34 #include "Colour3DPlotRenderer.h" | |
34 | 35 |
35 #include <QPainter> | 36 #include <QPainter> |
36 #include <QImage> | 37 #include <QImage> |
37 #include <QPixmap> | 38 #include <QPixmap> |
38 #include <QRect> | 39 #include <QRect> |
572 #endif | 573 #endif |
573 for (ViewImageCache::iterator i = m_imageCaches.begin(); | 574 for (ViewImageCache::iterator i = m_imageCaches.begin(); |
574 i != m_imageCaches.end(); ++i) { | 575 i != m_imageCaches.end(); ++i) { |
575 i->second.invalidate(); | 576 i->second.invalidate(); |
576 } | 577 } |
578 | |
579 //!!! | |
580 for (ViewRendererMap::iterator i = m_renderers.begin(); | |
581 i != m_renderers.end(); ++i) { | |
582 delete i->second; | |
583 } | |
584 m_renderers.clear(); | |
577 } | 585 } |
578 | 586 |
579 void | 587 void |
580 SpectrogramLayer::preferenceChanged(PropertyContainer::PropertyName name) | 588 SpectrogramLayer::preferenceChanged(PropertyContainer::PropertyName name) |
581 { | 589 { |
1521 } | 1529 } |
1522 return m_imageCaches.at(view->getId()); | 1530 return m_imageCaches.at(view->getId()); |
1523 } | 1531 } |
1524 | 1532 |
1525 void | 1533 void |
1534 SpectrogramLayer::paintAlternative(LayerGeometryProvider *v, QPainter &paint, QRect rect) const | |
1535 { | |
1536 Colour3DPlotRenderer *renderer = getRenderer(v); | |
1537 | |
1538 | |
1539 } | |
1540 | |
1541 Colour3DPlotRenderer * | |
1542 SpectrogramLayer::getRenderer(LayerGeometryProvider *v) const | |
1543 { | |
1544 if (m_renderers.find(v->getId()) == m_renderers.end()) { | |
1545 | |
1546 Colour3DPlotRenderer::Sources sources; | |
1547 sources.geometryProvider = v; | |
1548 sources.verticalBinLayer = this; | |
1549 sources.source = m_fftModel; | |
1550 sources.peaks = m_peakCache; | |
1551 sources.fft = m_fftModel; | |
1552 | |
1553 ::ColourScale::Parameters cparams; | |
1554 //!!! todo | |
1555 | |
1556 Colour3DPlotRenderer::Parameters params; | |
1557 params.colourScale = ::ColourScale(cparams); | |
1558 params.normalization = m_normalization; | |
1559 //!!! map properly: | |
1560 params.binDisplay = (Colour3DPlotRenderer::BinDisplay)(int)m_binDisplay; | |
1561 params.binScale = (Colour3DPlotRenderer::BinScale)(int)m_frequencyScale; | |
1562 //!!! and the rest | |
1563 | |
1564 m_renderers[v->getId()] = new Colour3DPlotRenderer(sources, params); | |
1565 } | |
1566 | |
1567 return m_renderers[v->getId()]; | |
1568 } | |
1569 | |
1570 void | |
1526 SpectrogramLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const | 1571 SpectrogramLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const |
1527 { | 1572 { |
1528 Profiler profiler("SpectrogramLayer::paint", false); | 1573 Profiler profiler("SpectrogramLayer::paint", false); |
1529 | 1574 |
1530 #ifdef DEBUG_SPECTROGRAM_REPAINT | 1575 #ifdef DEBUG_SPECTROGRAM_REPAINT |
1541 | 1586 |
1542 if (isLayerDormant(v)) { | 1587 if (isLayerDormant(v)) { |
1543 SVDEBUG << "SpectrogramLayer::paint(): Layer is dormant, making it undormant again" << endl; | 1588 SVDEBUG << "SpectrogramLayer::paint(): Layer is dormant, making it undormant again" << endl; |
1544 } | 1589 } |
1545 | 1590 |
1591 // paintAlternative(v, paint, rect); | |
1592 // return; | |
1593 | |
1594 //!!! | |
1595 | |
1546 // Need to do this even if !isLayerDormant, as that could mean v | 1596 // Need to do this even if !isLayerDormant, as that could mean v |
1547 // is not in the dormancy map at all -- we need it to be present | 1597 // is not in the dormancy map at all -- we need it to be present |
1548 // and accountable for when determining whether we need the cache | 1598 // and accountable for when determining whether we need the cache |
1549 // in the cache-fill thread above. | 1599 // in the cache-fill thread above. |
1550 //!!! no inter use cache-fill thread | 1600 //!!! no inter use cache-fill thread |