Mercurial > hg > svcore
comparison data/model/Dense3DModelPeakCache.h @ 1206:659372323b45 tony-2.0-integration
Merge latest SV 3.0 branch code
author | Chris Cannam |
---|---|
date | Fri, 19 Aug 2016 15:58:57 +0100 |
parents | 9884efa1f88a |
children | df59bf0b4236 |
comparison
equal
deleted
inserted
replaced
1136:e94719f941ba | 1206:659372323b45 |
---|---|
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 #include "base/ResizeableBitset.h" | |
22 | 21 |
23 class Dense3DModelPeakCache : public DenseThreeDimensionalModel | 22 class Dense3DModelPeakCache : public DenseThreeDimensionalModel |
24 { | 23 { |
25 Q_OBJECT | 24 Q_OBJECT |
26 | 25 |
27 public: | 26 public: |
28 Dense3DModelPeakCache(DenseThreeDimensionalModel *source, | 27 Dense3DModelPeakCache(const DenseThreeDimensionalModel *source, |
29 int columnsPerPeak); | 28 int columnsPerPeak); |
30 ~Dense3DModelPeakCache(); | 29 ~Dense3DModelPeakCache(); |
31 | 30 |
32 virtual bool isOK() const { | 31 virtual bool isOK() const { |
33 return m_source && m_source->isOK(); | 32 return m_source && m_source->isOK(); |
44 virtual sv_frame_t getEndFrame() const { | 43 virtual sv_frame_t getEndFrame() const { |
45 return m_source->getEndFrame(); | 44 return m_source->getEndFrame(); |
46 } | 45 } |
47 | 46 |
48 virtual int getResolution() const { | 47 virtual int getResolution() const { |
49 return m_source->getResolution() * m_resolution; | 48 return m_source->getResolution() * m_columnsPerPeak; |
50 } | 49 } |
51 | 50 |
51 virtual int getColumnsPerPeak() const { | |
52 return m_columnsPerPeak; | |
53 } | |
54 | |
52 virtual int getWidth() const { | 55 virtual int getWidth() const { |
53 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 } | |
54 } | 62 } |
55 | 63 |
56 virtual int getHeight() const { | 64 virtual int getHeight() const { |
57 return m_source->getHeight(); | 65 return m_source->getHeight(); |
58 } | 66 } |
62 } | 70 } |
63 | 71 |
64 virtual float getMaximumLevel() const { | 72 virtual float getMaximumLevel() const { |
65 return m_source->getMaximumLevel(); | 73 return m_source->getMaximumLevel(); |
66 } | 74 } |
67 | |
68 virtual bool isColumnAvailable(int column) const; | |
69 | 75 |
70 virtual Column getColumn(int column) const; | 76 virtual Column getColumn(int column) const; |
71 | 77 |
72 virtual float getValueAt(int column, int n) const; | 78 virtual float getValueAt(int column, int n) const; |
73 | 79 |
88 protected slots: | 94 protected slots: |
89 void sourceModelChanged(); | 95 void sourceModelChanged(); |
90 void sourceModelAboutToBeDeleted(); | 96 void sourceModelAboutToBeDeleted(); |
91 | 97 |
92 private: | 98 private: |
93 DenseThreeDimensionalModel *m_source; | 99 const DenseThreeDimensionalModel *m_source; |
94 mutable EditableDenseThreeDimensionalModel *m_cache; | 100 mutable EditableDenseThreeDimensionalModel *m_cache; |
95 mutable ResizeableBitset m_coverage; | 101 mutable std::vector<bool> m_coverage; // must be bool, for space efficiency |
96 int m_resolution; | 102 // (vector of bool uses 1-bit elements) |
103 int m_columnsPerPeak; | |
97 | 104 |
98 bool haveColumn(int column) const; | 105 bool haveColumn(int column) const; |
99 void fillColumn(int column) const; | 106 void fillColumn(int column) const; |
100 }; | 107 }; |
101 | 108 |