Chris@133
|
1
|
Chris@133
|
2 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@133
|
3
|
Chris@133
|
4 /*
|
Chris@133
|
5 Sonic Visualiser
|
Chris@133
|
6 An audio file viewer and annotation editor.
|
Chris@133
|
7 Centre for Digital Music, Queen Mary, University of London.
|
Chris@182
|
8 This file copyright 2006 QMUL.
|
Chris@133
|
9
|
Chris@133
|
10 This program is free software; you can redistribute it and/or
|
Chris@133
|
11 modify it under the terms of the GNU General Public License as
|
Chris@133
|
12 published by the Free Software Foundation; either version 2 of the
|
Chris@133
|
13 License, or (at your option) any later version. See the file
|
Chris@133
|
14 COPYING included with this distribution for more information.
|
Chris@133
|
15 */
|
Chris@133
|
16
|
Chris@193
|
17 #ifndef _SLICE_LAYER_H_
|
Chris@193
|
18 #define _SLICE_LAYER_H_
|
Chris@133
|
19
|
Chris@133
|
20 #include "Layer.h"
|
Chris@133
|
21
|
Chris@153
|
22 #include "base/Window.h"
|
Chris@153
|
23
|
Chris@193
|
24 #include "data/model/DenseThreeDimensionalModel.h"
|
Chris@133
|
25
|
Chris@133
|
26 #include <QColor>
|
Chris@133
|
27
|
Chris@193
|
28 class SliceLayer : public Layer
|
Chris@133
|
29 {
|
Chris@133
|
30 Q_OBJECT
|
Chris@133
|
31
|
Chris@133
|
32 public:
|
Chris@193
|
33 SliceLayer();
|
Chris@193
|
34 ~SliceLayer();
|
Chris@133
|
35
|
Chris@193
|
36 // virtual void setModel(const Model *model);
|
Chris@193
|
37 // virtual const Model *getModel() const { return m_model; }
|
Chris@193
|
38 virtual const Model *getModel() const { return 0; }
|
Chris@193
|
39
|
Chris@193
|
40 void setSliceableModel(const Model *model);
|
Chris@193
|
41
|
Chris@133
|
42 virtual void paint(View *v, QPainter &paint, QRect rect) const;
|
Chris@133
|
43
|
Chris@198
|
44 virtual QString getFeatureDescription(View *v, QPoint &) const;
|
Chris@198
|
45
|
Chris@195
|
46 virtual int getVerticalScaleWidth(View *v, QPainter &) const;
|
Chris@195
|
47 virtual void paintVerticalScale(View *v, QPainter &paint, QRect rect) const;
|
Chris@195
|
48
|
Chris@153
|
49 virtual PropertyList getProperties() const;
|
Chris@153
|
50 virtual QString getPropertyLabel(const PropertyName &) const;
|
Chris@153
|
51 virtual PropertyType getPropertyType(const PropertyName &) const;
|
Chris@153
|
52 virtual QString getPropertyGroupName(const PropertyName &) const;
|
Chris@153
|
53 virtual int getPropertyRangeAndValue(const PropertyName &,
|
Chris@216
|
54 int *min, int *max, int *deflt) const;
|
Chris@153
|
55 virtual QString getPropertyValueLabel(const PropertyName &,
|
Chris@153
|
56 int value) const;
|
Chris@167
|
57 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
|
Chris@153
|
58 virtual void setProperty(const PropertyName &, int value);
|
Chris@133
|
59 virtual void setProperties(const QXmlAttributes &);
|
Chris@133
|
60
|
Chris@133
|
61 virtual bool getValueExtents(float &min, float &max,
|
Chris@133
|
62 bool &logarithmic, QString &unit) const;
|
Chris@133
|
63
|
Chris@217
|
64 virtual bool hasTimeXAxis() const { return false; }
|
Chris@217
|
65
|
Chris@248
|
66 virtual bool isLayerScrollable(const View *) const { return false; }
|
Chris@133
|
67
|
Chris@193
|
68 enum EnergyScale { LinearScale, MeterScale, dBScale };
|
Chris@153
|
69
|
Chris@193
|
70 enum SamplingMode { NearestSample, SampleMean, SamplePeak };
|
Chris@153
|
71
|
Chris@197
|
72 enum PlotStyle { PlotLines, PlotSteps, PlotBlocks, PlotFilledBlocks };
|
Chris@153
|
73
|
Chris@193
|
74 enum BinScale { LinearBins, LogBins, InvertedLogBins };
|
Chris@153
|
75
|
Chris@153
|
76 void setBaseColour(QColor);
|
Chris@153
|
77 QColor getBaseColour() const { return m_colour; }
|
Chris@153
|
78
|
Chris@197
|
79 void setFillColourMap(int);
|
Chris@197
|
80 int getFillColourMap() const { return m_colourMap; }
|
Chris@197
|
81
|
Chris@153
|
82 void setEnergyScale(EnergyScale);
|
Chris@153
|
83 EnergyScale getEnergyScale() const { return m_energyScale; }
|
Chris@153
|
84
|
Chris@193
|
85 void setSamplingMode(SamplingMode);
|
Chris@193
|
86 SamplingMode getSamplingMode() const { return m_samplingMode; }
|
Chris@153
|
87
|
Chris@193
|
88 void setPlotStyle(PlotStyle style);
|
Chris@193
|
89 PlotStyle getPlotStyle() const { return m_plotStyle; }
|
Chris@193
|
90
|
Chris@193
|
91 void setBinScale(BinScale scale);
|
Chris@193
|
92 BinScale getBinScale() const { return m_binScale; }
|
Chris@153
|
93
|
Chris@284
|
94 void setThreshold(float);
|
Chris@284
|
95 int getThreshold() const { return m_threshold; }
|
Chris@284
|
96
|
Chris@153
|
97 void setGain(float gain);
|
Chris@153
|
98 float getGain() const;
|
Chris@153
|
99
|
Chris@153
|
100 void setNormalize(bool n);
|
Chris@153
|
101 bool getNormalize() const;
|
Chris@153
|
102
|
Chris@153
|
103 virtual QString toXmlString(QString indent = "",
|
Chris@153
|
104 QString extraAttributes = "") const;
|
Chris@153
|
105
|
Chris@193
|
106 public slots:
|
Chris@193
|
107 void sliceableModelReplaced(const Model *, const Model *);
|
Chris@193
|
108 void modelAboutToBeDeleted(Model *);
|
Chris@133
|
109
|
Chris@133
|
110 protected:
|
Chris@265
|
111 virtual float getXForBin(int bin, int totalBins, float w) const;
|
Chris@265
|
112 virtual int getBinForX(float x, int totalBins, float w) const;
|
Chris@274
|
113
|
Chris@274
|
114 virtual float getYForValue(float value, const View *v, float &norm) const;
|
Chris@274
|
115 virtual float getValueForY(float y, const View *v) const;
|
Chris@198
|
116
|
Chris@199
|
117 virtual QString getFeatureDescription(View *v, QPoint &,
|
Chris@199
|
118 bool includeBinDescription,
|
Chris@199
|
119 int &minbin, int &maxbin,
|
Chris@199
|
120 int &range) const;
|
Chris@199
|
121
|
Chris@254
|
122 // This curve may, of course, be flat -- the spectrum uses it for
|
Chris@254
|
123 // normalizing the fft results by the fft size (with 1/(fftsize/2)
|
Chris@254
|
124 // in each bin).
|
Chris@254
|
125 typedef std::vector<float> BiasCurve;
|
Chris@254
|
126 virtual void getBiasCurve(BiasCurve &) const { return; }
|
Chris@254
|
127
|
Chris@284
|
128 virtual float getThresholdDb() const;
|
Chris@284
|
129
|
Chris@193
|
130 const DenseThreeDimensionalModel *m_sliceableModel;
|
Chris@193
|
131 QColor m_colour;
|
Chris@197
|
132 int m_colourMap;
|
Chris@193
|
133 EnergyScale m_energyScale;
|
Chris@193
|
134 SamplingMode m_samplingMode;
|
Chris@193
|
135 PlotStyle m_plotStyle;
|
Chris@193
|
136 BinScale m_binScale;
|
Chris@193
|
137 bool m_normalize;
|
Chris@284
|
138 float m_threshold;
|
Chris@284
|
139 float m_initialThreshold;
|
Chris@193
|
140 float m_gain;
|
Chris@195
|
141 mutable std::vector<int> m_scalePoints;
|
Chris@267
|
142 mutable std::map<const View *, int> m_xorigins;
|
Chris@274
|
143 mutable std::map<const View *, int> m_yorigins;
|
Chris@274
|
144 mutable std::map<const View *, int> m_heights;
|
Chris@198
|
145 mutable size_t m_currentf0;
|
Chris@198
|
146 mutable size_t m_currentf1;
|
Chris@198
|
147 mutable std::vector<float> m_values;
|
Chris@133
|
148 };
|
Chris@133
|
149
|
Chris@133
|
150 #endif
|