comparison data/model/Dense3DModelPeakCache.h @ 1202:3b84f9bd0048 3.0-integration

Merge work on unified spectrogram and colour 3d plot caching renderer
author Chris Cannam
date Fri, 05 Aug 2016 15:05:02 +0100
parents 9884efa1f88a
children df59bf0b4236
comparison
equal deleted inserted replaced
1185:69c84a66727b 1202:3b84f9bd0048
11 published by the Free Software Foundation; either version 2 of the 11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file 12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information. 13 COPYING included with this distribution for more information.
14 */ 14 */
15 15
16 #ifndef _DENSE_3D_MODEL_PEAK_CACHE_H_ 16 #ifndef DENSE_3D_MODEL_PEAK_CACHE_H
17 #define _DENSE_3D_MODEL_PEAK_CACHE_H_ 17 #define DENSE_3D_MODEL_PEAK_CACHE_H
18 18
19 #include "DenseThreeDimensionalModel.h" 19 #include "DenseThreeDimensionalModel.h"
20 #include "EditableDenseThreeDimensionalModel.h" 20 #include "EditableDenseThreeDimensionalModel.h"
21 21
22 class Dense3DModelPeakCache : public DenseThreeDimensionalModel 22 class Dense3DModelPeakCache : public DenseThreeDimensionalModel
23 { 23 {
24 Q_OBJECT 24 Q_OBJECT
25 25
26 public: 26 public:
27 Dense3DModelPeakCache(DenseThreeDimensionalModel *source, 27 Dense3DModelPeakCache(const DenseThreeDimensionalModel *source,
28 int columnsPerPeak); 28 int columnsPerPeak);
29 ~Dense3DModelPeakCache(); 29 ~Dense3DModelPeakCache();
30 30
31 virtual bool isOK() const { 31 virtual bool isOK() const {
32 return m_source && m_source->isOK(); 32 return m_source && m_source->isOK();
43 virtual sv_frame_t getEndFrame() const { 43 virtual sv_frame_t getEndFrame() const {
44 return m_source->getEndFrame(); 44 return m_source->getEndFrame();
45 } 45 }
46 46
47 virtual int getResolution() const { 47 virtual int getResolution() const {
48 return m_source->getResolution() * m_resolution; 48 return m_source->getResolution() * m_columnsPerPeak;
49 } 49 }
50 50
51 virtual int getColumnsPerPeak() const {
52 return m_columnsPerPeak;
53 }
54
51 virtual int getWidth() const { 55 virtual int getWidth() const {
52 return m_source->getWidth() / m_resolution + 1; 56 int sourceWidth = m_source->getWidth();
57 if ((sourceWidth % m_columnsPerPeak) == 0) {
58 return sourceWidth / m_columnsPerPeak;
59 } else {
60 return sourceWidth / m_columnsPerPeak + 1;
61 }
53 } 62 }
54 63
55 virtual int getHeight() const { 64 virtual int getHeight() const {
56 return m_source->getHeight(); 65 return m_source->getHeight();
57 } 66 }
85 protected slots: 94 protected slots:
86 void sourceModelChanged(); 95 void sourceModelChanged();
87 void sourceModelAboutToBeDeleted(); 96 void sourceModelAboutToBeDeleted();
88 97
89 private: 98 private:
90 DenseThreeDimensionalModel *m_source; 99 const DenseThreeDimensionalModel *m_source;
91 mutable EditableDenseThreeDimensionalModel *m_cache; 100 mutable EditableDenseThreeDimensionalModel *m_cache;
92 mutable std::vector<bool> m_coverage; // must be bool, for space efficiency 101 mutable std::vector<bool> m_coverage; // must be bool, for space efficiency
93 // (vector of bool uses 1-bit elements) 102 // (vector of bool uses 1-bit elements)
94 int m_resolution; 103 int m_columnsPerPeak;
95 104
96 bool haveColumn(int column) const; 105 bool haveColumn(int column) const;
97 void fillColumn(int column) const; 106 void fillColumn(int column) const;
98 }; 107 };
99 108