Mercurial > hg > svcore
comparison data/model/Dense3DModelPeakCache.h @ 1365:3382d914e110
Merge from branch 3.0-integration
author | Chris Cannam |
---|---|
date | Fri, 13 Jan 2017 10:29:44 +0000 |
parents | df59bf0b4236 |
children | c01cbe41aeb5 |
comparison
equal
deleted
inserted
replaced
1272:6a7ea3bd0e10 | 1365:3382d914e110 |
---|---|
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 } |
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 | 75 |
68 virtual bool isColumnAvailable(int column) const; | 76 /** |
77 * Retrieve the peaks column at peak-cache column number col. This | |
78 * will consist of the peak values in the underlying model from | |
79 * columns (col * getColumnsPerPeak()) to ((col+1) * | |
80 * getColumnsPerPeak() - 1) inclusive. | |
81 */ | |
82 virtual Column getColumn(int col) const; | |
69 | 83 |
70 virtual Column getColumn(int column) const; | 84 virtual float getValueAt(int col, int n) const; |
71 | |
72 virtual float getValueAt(int column, int n) const; | |
73 | 85 |
74 virtual QString getBinName(int n) const { | 86 virtual QString getBinName(int n) const { |
75 return m_source->getBinName(n); | 87 return m_source->getBinName(n); |
76 } | 88 } |
77 | 89 |
88 protected slots: | 100 protected slots: |
89 void sourceModelChanged(); | 101 void sourceModelChanged(); |
90 void sourceModelAboutToBeDeleted(); | 102 void sourceModelAboutToBeDeleted(); |
91 | 103 |
92 private: | 104 private: |
93 DenseThreeDimensionalModel *m_source; | 105 const DenseThreeDimensionalModel *m_source; |
94 mutable EditableDenseThreeDimensionalModel *m_cache; | 106 mutable EditableDenseThreeDimensionalModel *m_cache; |
95 mutable ResizeableBitset m_coverage; | 107 mutable std::vector<bool> m_coverage; // must be bool, for space efficiency |
96 int m_resolution; | 108 // (vector of bool uses 1-bit elements) |
109 int m_columnsPerPeak; | |
97 | 110 |
98 bool haveColumn(int column) const; | 111 bool haveColumn(int column) const; |
99 void fillColumn(int column) const; | 112 void fillColumn(int column) const; |
100 }; | 113 }; |
101 | 114 |