comparison layer/SpectrumLayer.h @ 193:57c2350a8c40

* Add slice layers (so you can display a slice of a colour 3d plot as if it were a spectrum) * Make spectrum layer a subclass of slice layer
author Chris Cannam
date Fri, 26 Jan 2007 16:59:57 +0000
parents 42118892f428
children 45e995ed84d9
comparison
equal deleted inserted replaced
192:fcc043f75c41 193:57c2350a8c40
15 */ 15 */
16 16
17 #ifndef _SPECTRUM_LAYER_H_ 17 #ifndef _SPECTRUM_LAYER_H_
18 #define _SPECTRUM_LAYER_H_ 18 #define _SPECTRUM_LAYER_H_
19 19
20 #include "Layer.h" 20 #include "SliceLayer.h"
21 21
22 #include "base/Window.h" 22 #include "base/Window.h"
23 23
24 #include "data/model/DenseTimeValueModel.h" 24 #include "data/model/DenseTimeValueModel.h"
25 25
26 #include <QColor> 26 #include <QColor>
27 27
28 class FFTModel; 28 class FFTModel;
29 29
30 class SpectrumLayer : public Layer 30 class SpectrumLayer : public SliceLayer
31 { 31 {
32 Q_OBJECT 32 Q_OBJECT
33 33
34 public: 34 public:
35 SpectrumLayer(); 35 SpectrumLayer();
36 ~SpectrumLayer(); 36 ~SpectrumLayer();
37 37
38 void setModel(DenseTimeValueModel *model); 38 void setModel(DenseTimeValueModel *model);
39 virtual const Model *getModel() const { return m_model; } 39 virtual const Model *getModel() const { return m_originModel; }
40 virtual void paint(View *v, QPainter &paint, QRect rect) const;
41 40
42 virtual PropertyList getProperties() const; 41 virtual PropertyList getProperties() const;
43 virtual QString getPropertyLabel(const PropertyName &) const; 42 virtual QString getPropertyLabel(const PropertyName &) const;
44 virtual PropertyType getPropertyType(const PropertyName &) const; 43 virtual PropertyType getPropertyType(const PropertyName &) const;
45 virtual QString getPropertyGroupName(const PropertyName &) const; 44 virtual QString getPropertyGroupName(const PropertyName &) const;
54 virtual bool getValueExtents(float &min, float &max, 53 virtual bool getValueExtents(float &min, float &max,
55 bool &logarithmic, QString &unit) const; 54 bool &logarithmic, QString &unit) const;
56 55
57 virtual bool isLayerScrollable(const View *v) const { return false; } 56 virtual bool isLayerScrollable(const View *v) const { return false; }
58 57
59 enum ChannelMode { SeparateChannels, MixChannels, OverlayChannels };
60
61 void setChannelMode(ChannelMode);
62 ChannelMode getChannelCount() const { return m_channelMode; }
63
64 void setChannel(int); 58 void setChannel(int);
65 int getChannel() const { return m_channel; } 59 int getChannel() const { return m_channel; }
66
67 enum EnergyScale { LinearScale, MeterScale, dBScale };
68
69 void setBaseColour(QColor);
70 QColor getBaseColour() const { return m_colour; }
71
72 void setEnergyScale(EnergyScale);
73 EnergyScale getEnergyScale() const { return m_energyScale; }
74 60
75 void setWindowSize(size_t); 61 void setWindowSize(size_t);
76 size_t getWindowSize() const { return m_windowSize; } 62 size_t getWindowSize() const { return m_windowSize; }
77 63
78 void setWindowHopLevel(size_t level); 64 void setWindowHopLevel(size_t level);
79 size_t getWindowHopLevel() const { return m_windowHopLevel; } 65 size_t getWindowHopLevel() const { return m_windowHopLevel; }
80 66
81 void setWindowType(WindowType type); 67 void setWindowType(WindowType type);
82 WindowType getWindowType() const { return m_windowType; } 68 WindowType getWindowType() const { return m_windowType; }
83 69
84 void setGain(float gain);
85 float getGain() const;
86
87 void setNormalize(bool n);
88 bool getNormalize() const;
89
90 virtual QString toXmlString(QString indent = "", 70 virtual QString toXmlString(QString indent = "",
91 QString extraAttributes = "") const; 71 QString extraAttributes = "") const;
92 72
93 protected slots: 73 protected slots:
94 void preferenceChanged(PropertyContainer::PropertyName name); 74 void preferenceChanged(PropertyContainer::PropertyName name);
95 75
96 protected: 76 protected:
97 DenseTimeValueModel *m_model; 77 // make this SliceLayer method unavailable to the general public
98 std::vector<FFTModel *> m_fft; 78 // virtual void setModel(DenseThreeDimensionalModel *model) {
99 ChannelMode m_channelMode; 79 // SliceLayer::setModel(model);
80 // }
81
82 DenseTimeValueModel *m_originModel;
100 int m_channel; 83 int m_channel;
101 bool m_channelSet; 84 bool m_channelSet;
102 QColor m_colour;
103 EnergyScale m_energyScale;
104 bool m_normalize;
105 float m_gain;
106 size_t m_windowSize; 85 size_t m_windowSize;
107 WindowType m_windowType; 86 WindowType m_windowType;
108 size_t m_windowHopLevel; 87 size_t m_windowHopLevel;
109 88
110 void setupFFTs(); 89 void setupFFT();
111 90
112 size_t getWindowIncrement() const { 91 size_t getWindowIncrement() const {
113 if (m_windowHopLevel == 0) return m_windowSize; 92 if (m_windowHopLevel == 0) return m_windowSize;
114 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4; 93 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4;
115 else return m_windowSize / (1 << (m_windowHopLevel - 1)); 94 else return m_windowSize / (1 << (m_windowHopLevel - 1));