Chris@545
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@545
|
2
|
Chris@545
|
3 /*
|
Chris@545
|
4 Sonic Visualiser
|
Chris@545
|
5 An audio file viewer and annotation editor.
|
Chris@545
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@545
|
7 This file copyright 2009 QMUL.
|
Chris@545
|
8
|
Chris@545
|
9 This program is free software; you can redistribute it and/or
|
Chris@545
|
10 modify it under the terms of the GNU General Public License as
|
Chris@545
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@545
|
12 License, or (at your option) any later version. See the file
|
Chris@545
|
13 COPYING included with this distribution for more information.
|
Chris@545
|
14 */
|
Chris@545
|
15
|
Chris@545
|
16 #ifndef _DENSE_3D_MODEL_PEAK_CACHE_H_
|
Chris@545
|
17 #define _DENSE_3D_MODEL_PEAK_CACHE_H_
|
Chris@545
|
18
|
Chris@545
|
19 #include "DenseThreeDimensionalModel.h"
|
Chris@545
|
20 #include "EditableDenseThreeDimensionalModel.h"
|
Chris@545
|
21 #include "base/ResizeableBitset.h"
|
Chris@545
|
22
|
Chris@545
|
23 class Dense3DModelPeakCache : public DenseThreeDimensionalModel
|
Chris@545
|
24 {
|
Chris@546
|
25 Q_OBJECT
|
Chris@546
|
26
|
Chris@545
|
27 public:
|
Chris@545
|
28 Dense3DModelPeakCache(DenseThreeDimensionalModel *source,
|
Chris@929
|
29 int columnsPerPeak);
|
Chris@545
|
30 ~Dense3DModelPeakCache();
|
Chris@545
|
31
|
Chris@546
|
32 virtual bool isOK() const {
|
Chris@546
|
33 return m_source && m_source->isOK();
|
Chris@546
|
34 }
|
Chris@546
|
35
|
Chris@929
|
36 virtual int getSampleRate() const {
|
Chris@546
|
37 return m_source->getSampleRate();
|
Chris@546
|
38 }
|
Chris@546
|
39
|
Chris@929
|
40 virtual int getStartFrame() const {
|
Chris@546
|
41 return m_source->getStartFrame();
|
Chris@546
|
42 }
|
Chris@546
|
43
|
Chris@929
|
44 virtual int getEndFrame() const {
|
Chris@546
|
45 return m_source->getEndFrame();
|
Chris@546
|
46 }
|
Chris@546
|
47
|
Chris@546
|
48 virtual Model *clone() const {
|
Chris@546
|
49 return new Dense3DModelPeakCache(m_source, m_resolution);
|
Chris@546
|
50 }
|
Chris@546
|
51
|
Chris@929
|
52 virtual int getResolution() const {
|
Chris@545
|
53 return m_source->getResolution() * m_resolution;
|
Chris@545
|
54 }
|
Chris@545
|
55
|
Chris@929
|
56 virtual int getWidth() const {
|
Chris@545
|
57 return m_source->getWidth() / m_resolution + 1;
|
Chris@545
|
58 }
|
Chris@545
|
59
|
Chris@929
|
60 virtual int getHeight() const {
|
Chris@545
|
61 return m_source->getHeight();
|
Chris@545
|
62 }
|
Chris@545
|
63
|
Chris@545
|
64 virtual float getMinimumLevel() const {
|
Chris@545
|
65 return m_source->getMinimumLevel();
|
Chris@545
|
66 }
|
Chris@545
|
67
|
Chris@545
|
68 virtual float getMaximumLevel() const {
|
Chris@545
|
69 return m_source->getMaximumLevel();
|
Chris@545
|
70 }
|
Chris@545
|
71
|
Chris@929
|
72 virtual bool isColumnAvailable(int column) const;
|
Chris@545
|
73
|
Chris@929
|
74 virtual Column getColumn(int column) const;
|
Chris@545
|
75
|
Chris@929
|
76 virtual float getValueAt(int column, int n) const;
|
Chris@545
|
77
|
Chris@929
|
78 virtual QString getBinName(int n) const {
|
Chris@545
|
79 return m_source->getBinName(n);
|
Chris@545
|
80 }
|
Chris@545
|
81
|
Chris@545
|
82 virtual bool shouldUseLogValueScale() const {
|
Chris@545
|
83 return m_source->shouldUseLogValueScale();
|
Chris@545
|
84 }
|
Chris@545
|
85
|
Chris@545
|
86 QString getTypeName() const { return tr("Dense 3-D Peak Cache"); }
|
Chris@545
|
87
|
Chris@545
|
88 virtual int getCompletion() const {
|
Chris@545
|
89 return m_source->getCompletion();
|
Chris@545
|
90 }
|
Chris@545
|
91
|
Chris@545
|
92 protected slots:
|
Chris@545
|
93 void sourceModelChanged();
|
Chris@545
|
94 void sourceModelAboutToBeDeleted();
|
Chris@545
|
95
|
Chris@545
|
96 private:
|
Chris@545
|
97 DenseThreeDimensionalModel *m_source;
|
Chris@545
|
98 mutable EditableDenseThreeDimensionalModel *m_cache;
|
Chris@545
|
99 mutable ResizeableBitset m_coverage;
|
Chris@929
|
100 int m_resolution;
|
Chris@545
|
101
|
Chris@929
|
102 bool haveColumn(int column) const;
|
Chris@929
|
103 void fillColumn(int column) const;
|
Chris@545
|
104 };
|
Chris@545
|
105
|
Chris@545
|
106
|
Chris@545
|
107 #endif
|