Chris@133
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@133
|
2
|
Chris@133
|
3 /*
|
Chris@133
|
4 Sonic Visualiser
|
Chris@133
|
5 An audio file viewer and annotation editor.
|
Chris@133
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@182
|
7 This file copyright 2006 QMUL.
|
Chris@133
|
8
|
Chris@133
|
9 This program is free software; you can redistribute it and/or
|
Chris@133
|
10 modify it under the terms of the GNU General Public License as
|
Chris@133
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@133
|
12 License, or (at your option) any later version. See the file
|
Chris@133
|
13 COPYING included with this distribution for more information.
|
Chris@133
|
14 */
|
Chris@133
|
15
|
Chris@1284
|
16 #ifndef SV_SLICE_LAYER_H
|
Chris@1284
|
17 #define SV_SLICE_LAYER_H
|
Chris@133
|
18
|
Chris@287
|
19 #include "SingleColourLayer.h"
|
Chris@133
|
20
|
Chris@153
|
21 #include "base/Window.h"
|
Chris@153
|
22
|
Chris@193
|
23 #include "data/model/DenseThreeDimensionalModel.h"
|
Chris@133
|
24
|
Chris@133
|
25 #include <QColor>
|
Chris@133
|
26
|
Chris@287
|
27 class SliceLayer : public SingleColourLayer
|
Chris@133
|
28 {
|
Chris@133
|
29 Q_OBJECT
|
Chris@133
|
30
|
Chris@133
|
31 public:
|
Chris@193
|
32 SliceLayer();
|
Chris@193
|
33 ~SliceLayer();
|
Chris@133
|
34
|
Chris@1406
|
35 const Model *getModel() const override { return 0; }
|
Chris@193
|
36
|
Chris@193
|
37 void setSliceableModel(const Model *model);
|
Chris@193
|
38
|
Chris@1406
|
39 void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const override;
|
Chris@133
|
40
|
Chris@1406
|
41 QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const override;
|
Chris@198
|
42
|
Chris@1406
|
43 int getVerticalScaleWidth(LayerGeometryProvider *v, bool, QPainter &) const override;
|
Chris@1406
|
44 void paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect rect) const override;
|
Chris@195
|
45
|
Chris@1406
|
46 ColourSignificance getLayerColourSignificance() const override {
|
Chris@287
|
47 return ColourAndBackgroundSignificant;
|
Chris@287
|
48 }
|
Chris@287
|
49
|
Chris@1406
|
50 bool hasLightBackground() const override;
|
Chris@1281
|
51
|
Chris@1406
|
52 PropertyList getProperties() const override;
|
Chris@1406
|
53 QString getPropertyLabel(const PropertyName &) const override;
|
Chris@1406
|
54 QString getPropertyIconName(const PropertyName &) const override;
|
Chris@1406
|
55 PropertyType getPropertyType(const PropertyName &) const override;
|
Chris@1406
|
56 QString getPropertyGroupName(const PropertyName &) const override;
|
Chris@1406
|
57 int getPropertyRangeAndValue(const PropertyName &,
|
Chris@1406
|
58 int *min, int *max, int *deflt) const override;
|
Chris@1406
|
59 QString getPropertyValueLabel(const PropertyName &,
|
Chris@1406
|
60 int value) const override;
|
Chris@1406
|
61 RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const override;
|
Chris@1406
|
62 void setProperty(const PropertyName &, int value) override;
|
Chris@1406
|
63 void setProperties(const QXmlAttributes &) override;
|
Chris@133
|
64
|
Chris@1406
|
65 bool getValueExtents(double &min, double &max,
|
Chris@1406
|
66 bool &logarithmic, QString &unit) const override;
|
Chris@133
|
67
|
Chris@1406
|
68 bool getDisplayExtents(double &min, double &max) const override;
|
Chris@1406
|
69 bool setDisplayExtents(double min, double max) override;
|
Chris@1238
|
70
|
Chris@1406
|
71 int getVerticalZoomSteps(int &defaultStep) const override;
|
Chris@1406
|
72 int getCurrentVerticalZoomStep() const override;
|
Chris@1406
|
73 void setVerticalZoomStep(int) override;
|
Chris@1406
|
74 RangeMapper *getNewVerticalZoomRangeMapper() const override;
|
Chris@1238
|
75
|
Chris@1389
|
76 virtual bool hasTimeXAxis() const override { return false; }
|
Chris@1389
|
77
|
Chris@1389
|
78 virtual void zoomToRegion(const LayerGeometryProvider *, QRect) override;
|
Chris@217
|
79
|
Chris@1406
|
80 bool isLayerScrollable(const LayerGeometryProvider *) const override { return false; }
|
Chris@133
|
81
|
Chris@538
|
82 enum EnergyScale { LinearScale, MeterScale, dBScale, AbsoluteScale };
|
Chris@153
|
83
|
Chris@193
|
84 enum SamplingMode { NearestSample, SampleMean, SamplePeak };
|
Chris@153
|
85
|
Chris@197
|
86 enum PlotStyle { PlotLines, PlotSteps, PlotBlocks, PlotFilledBlocks };
|
Chris@153
|
87
|
Chris@193
|
88 enum BinScale { LinearBins, LogBins, InvertedLogBins };
|
Chris@153
|
89
|
Chris@1281
|
90 bool usesSolidColour() const { return m_plotStyle == PlotFilledBlocks; }
|
Chris@1281
|
91
|
Chris@197
|
92 void setFillColourMap(int);
|
Chris@197
|
93 int getFillColourMap() const { return m_colourMap; }
|
Chris@197
|
94
|
Chris@153
|
95 void setEnergyScale(EnergyScale);
|
Chris@153
|
96 EnergyScale getEnergyScale() const { return m_energyScale; }
|
Chris@153
|
97
|
Chris@193
|
98 void setSamplingMode(SamplingMode);
|
Chris@193
|
99 SamplingMode getSamplingMode() const { return m_samplingMode; }
|
Chris@153
|
100
|
Chris@193
|
101 void setPlotStyle(PlotStyle style);
|
Chris@193
|
102 PlotStyle getPlotStyle() const { return m_plotStyle; }
|
Chris@193
|
103
|
Chris@193
|
104 void setBinScale(BinScale scale);
|
Chris@193
|
105 BinScale getBinScale() const { return m_binScale; }
|
Chris@153
|
106
|
Chris@284
|
107 void setThreshold(float);
|
Chris@905
|
108 float getThreshold() const { return m_threshold; }
|
Chris@284
|
109
|
Chris@153
|
110 void setGain(float gain);
|
Chris@153
|
111 float getGain() const;
|
Chris@153
|
112
|
Chris@153
|
113 void setNormalize(bool n);
|
Chris@153
|
114 bool getNormalize() const;
|
Chris@153
|
115
|
Chris@1406
|
116 void toXml(QTextStream &stream, QString indent = "",
|
Chris@1406
|
117 QString extraAttributes = "") const override;
|
Chris@153
|
118
|
Chris@193
|
119 public slots:
|
Chris@193
|
120 void sliceableModelReplaced(const Model *, const Model *);
|
Chris@193
|
121 void modelAboutToBeDeleted(Model *);
|
Chris@133
|
122
|
Chris@133
|
123 protected:
|
Chris@1386
|
124 /// Convert a (possibly non-integral) bin into x-coord. May be overridden
|
Chris@1238
|
125 virtual double getXForBin(const LayerGeometryProvider *, double bin) const;
|
Chris@1386
|
126
|
Chris@1386
|
127 /// Convert an x-coord into (possibly non-integral) bin. May be overridden
|
Chris@1238
|
128 virtual double getBinForX(const LayerGeometryProvider *, double x) const;
|
Chris@274
|
129
|
Chris@1386
|
130 /// Convert a point such as a bin number into x-coord, given max &
|
Chris@1386
|
131 /// min. For use by getXForBin etc
|
Chris@1386
|
132 double getXForScalePoint(const LayerGeometryProvider *,
|
Chris@1386
|
133 double p, double pmin, double pmax) const;
|
Chris@1386
|
134
|
Chris@1386
|
135 /// Convert an x-coord into a point such as a bin number, given
|
Chris@1386
|
136 /// max & min. For use by getBinForX etc
|
Chris@1386
|
137 double getScalePointForX(const LayerGeometryProvider *,
|
Chris@1386
|
138 double x, double pmin, double pmax) const;
|
Chris@1386
|
139
|
Chris@1238
|
140 virtual double getYForValue(const LayerGeometryProvider *v, double value, double &norm) const;
|
Chris@1238
|
141 virtual double getValueForY(const LayerGeometryProvider *v, double y) const;
|
Chris@198
|
142
|
Chris@918
|
143 virtual QString getFeatureDescriptionAux(LayerGeometryProvider *v, QPoint &,
|
Chris@805
|
144 bool includeBinDescription,
|
Chris@805
|
145 int &minbin, int &maxbin,
|
Chris@805
|
146 int &range) const;
|
Chris@199
|
147
|
Chris@254
|
148 // This curve may, of course, be flat -- the spectrum uses it for
|
Chris@254
|
149 // normalizing the fft results by the fft size (with 1/(fftsize/2)
|
Chris@254
|
150 // in each bin).
|
Chris@254
|
151 typedef std::vector<float> BiasCurve;
|
Chris@254
|
152 virtual void getBiasCurve(BiasCurve &) const { return; }
|
Chris@254
|
153
|
Chris@284
|
154 virtual float getThresholdDb() const;
|
Chris@284
|
155
|
Chris@1406
|
156 int getDefaultColourHint(bool dark, bool &impose) override;
|
Chris@287
|
157
|
Chris@1400
|
158 // Determine how the bins are lined up
|
Chris@1400
|
159 // horizontally. BinsCentredOnScalePoint means we operate like a
|
Chris@1400
|
160 // spectrum, where a bin maps to a specific frequency, and so the
|
Chris@1400
|
161 // bin should be visually centred on the scale point that
|
Chris@1400
|
162 // corresponds to that frequency. BinsSpanScalePoints means we
|
Chris@1400
|
163 // have numbered or labelled bins that are not mapped to a
|
Chris@1400
|
164 // continuous scale, like a typical chromagram output, and so bin
|
Chris@1400
|
165 // N spans from scale point N to N+1. This is a fundamental
|
Chris@1400
|
166 // quality of the class or input data, not a user-configurable
|
Chris@1400
|
167 // property.
|
Chris@1400
|
168 //
|
Chris@1400
|
169 enum BinAlignment {
|
Chris@1400
|
170 BinsCentredOnScalePoints,
|
Chris@1400
|
171 BinsSpanScalePoints
|
Chris@1400
|
172 };
|
Chris@1400
|
173
|
Chris@193
|
174 const DenseThreeDimensionalModel *m_sliceableModel;
|
Chris@1400
|
175 BinAlignment m_binAlignment;
|
Chris@197
|
176 int m_colourMap;
|
Chris@1362
|
177 bool m_colourInverted;
|
Chris@193
|
178 EnergyScale m_energyScale;
|
Chris@193
|
179 SamplingMode m_samplingMode;
|
Chris@193
|
180 PlotStyle m_plotStyle;
|
Chris@193
|
181 BinScale m_binScale;
|
Chris@193
|
182 bool m_normalize;
|
Chris@284
|
183 float m_threshold;
|
Chris@284
|
184 float m_initialThreshold;
|
Chris@193
|
185 float m_gain;
|
Chris@1238
|
186 int m_minbin;
|
Chris@1238
|
187 int m_maxbin;
|
Chris@195
|
188 mutable std::vector<int> m_scalePoints;
|
Chris@1284
|
189 mutable int m_scalePaintHeight;
|
Chris@1238
|
190 mutable std::map<int, int> m_xorigins; // LayerGeometryProvider id -> x
|
Chris@1238
|
191 mutable std::map<int, int> m_yorigins; // LayerGeometryProvider id -> y
|
Chris@1238
|
192 mutable std::map<int, int> m_heights; // LayerGeometryProvider id -> h
|
Chris@906
|
193 mutable sv_frame_t m_currentf0;
|
Chris@906
|
194 mutable sv_frame_t m_currentf1;
|
Chris@198
|
195 mutable std::vector<float> m_values;
|
Chris@133
|
196 };
|
Chris@133
|
197
|
Chris@133
|
198 #endif
|