comparison data/model/Dense3DModelPeakCache.h @ 545:c603d9439b37

* Add peak cache type for 3d models
author Chris Cannam
date Wed, 04 Feb 2009 13:33:50 +0000
parents
children 95391b480e17
comparison
equal deleted inserted replaced
544:65d955c4d671 545:c603d9439b37
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2009 QMUL.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #ifndef _DENSE_3D_MODEL_PEAK_CACHE_H_
17 #define _DENSE_3D_MODEL_PEAK_CACHE_H_
18
19 #include "DenseThreeDimensionalModel.h"
20 #include "EditableDenseThreeDimensionalModel.h"
21 #include "base/ResizeableBitset.h"
22
23 class Dense3DModelPeakCache : public DenseThreeDimensionalModel
24 {
25 public:
26 Dense3DModelPeakCache(DenseThreeDimensionalModel *source,
27 size_t columnsPerPeak);
28 ~Dense3DModelPeakCache();
29
30 virtual size_t getResolution() const {
31 return m_source->getResolution() * m_resolution;
32 }
33
34 virtual size_t getWidth() const {
35 return m_source->getWidth() / m_resolution + 1;
36 }
37
38 virtual size_t getHeight() const {
39 return m_source->getHeight();
40 }
41
42 virtual float getMinimumLevel() const {
43 return m_source->getMinimumLevel();
44 }
45
46 virtual float getMaximumLevel() const {
47 return m_source->getMaximumLevel();
48 }
49
50 virtual bool isColumnAvailable(size_t column) const;
51
52 virtual Column getColumn(size_t column) const;
53
54 virtual float getValueAt(size_t column, size_t n) const;
55
56 virtual QString getBinName(size_t n) const {
57 return m_source->getBinName(n);
58 }
59
60 virtual bool shouldUseLogValueScale() const {
61 return m_source->shouldUseLogValueScale();
62 }
63
64 QString getTypeName() const { return tr("Dense 3-D Peak Cache"); }
65
66 virtual int getCompletion() const {
67 return m_source->getCompletion();
68 }
69
70 protected slots:
71 void sourceModelChanged();
72 void sourceModelAboutToBeDeleted();
73
74 private:
75 DenseThreeDimensionalModel *m_source;
76 mutable EditableDenseThreeDimensionalModel *m_cache;
77 mutable ResizeableBitset m_coverage;
78 size_t m_resolution;
79
80 bool haveColumn(size_t column) const;
81 void fillColumn(size_t column) const;
82 };
83
84
85 #endif