Mercurial > hg > svgui
comparison layer/SpectrogramLayer.h @ 1216:dc2af6616c83
Merge from branch 3.0-integration
author | Chris Cannam |
---|---|
date | Fri, 13 Jan 2017 10:29:50 +0000 |
parents | a1ee3108d1d3 |
children | de1792daae07 |
comparison
equal
deleted
inserted
replaced
1048:e8102ff5573b | 1216:dc2af6616c83 |
---|---|
11 published by the Free Software Foundation; either version 2 of the | 11 published by the Free Software Foundation; either version 2 of the |
12 License, or (at your option) any later version. See the file | 12 License, or (at your option) any later version. See the file |
13 COPYING included with this distribution for more information. | 13 COPYING included with this distribution for more information. |
14 */ | 14 */ |
15 | 15 |
16 #ifndef _SPECTROGRAM_LAYER_H_ | 16 #ifndef SPECTROGRAM_LAYER_H |
17 #define _SPECTROGRAM_LAYER_H_ | 17 #define SPECTROGRAM_LAYER_H |
18 | 18 |
19 #include "SliceableLayer.h" | 19 #include "SliceableLayer.h" |
20 #include "base/Window.h" | 20 #include "base/Window.h" |
21 #include "base/MagnitudeRange.h" | |
21 #include "base/RealTime.h" | 22 #include "base/RealTime.h" |
22 #include "base/Thread.h" | 23 #include "base/Thread.h" |
23 #include "base/PropertyContainer.h" | 24 #include "base/PropertyContainer.h" |
24 #include "data/model/PowerOfSqrtTwoZoomConstraint.h" | 25 #include "data/model/PowerOfSqrtTwoZoomConstraint.h" |
25 #include "data/model/DenseTimeValueModel.h" | 26 #include "data/model/DenseTimeValueModel.h" |
26 #include "data/model/FFTModel.h" | 27 #include "data/model/FFTModel.h" |
28 | |
29 #include "VerticalBinLayer.h" | |
30 #include "ColourScale.h" | |
31 #include "Colour3DPlotRenderer.h" | |
27 | 32 |
28 #include <QMutex> | 33 #include <QMutex> |
29 #include <QWaitCondition> | 34 #include <QWaitCondition> |
30 #include <QImage> | 35 #include <QImage> |
31 #include <QPixmap> | 36 #include <QPixmap> |
36 class QPixmap; | 41 class QPixmap; |
37 class QTimer; | 42 class QTimer; |
38 class FFTModel; | 43 class FFTModel; |
39 class Dense3DModelPeakCache; | 44 class Dense3DModelPeakCache; |
40 | 45 |
41 | |
42 /** | 46 /** |
43 * SpectrogramLayer represents waveform data (obtained from a | 47 * SpectrogramLayer represents waveform data (obtained from a |
44 * DenseTimeValueModel) in spectrogram form. | 48 * DenseTimeValueModel) in spectrogram form. |
45 */ | 49 */ |
46 | 50 |
47 class SpectrogramLayer : public SliceableLayer, | 51 class SpectrogramLayer : public VerticalBinLayer, |
48 public PowerOfSqrtTwoZoomConstraint | 52 public PowerOfSqrtTwoZoomConstraint |
49 { | 53 { |
50 Q_OBJECT | 54 Q_OBJECT |
51 | 55 |
52 public: | 56 public: |
55 SpectrogramLayer(Configuration = FullRangeDb); | 59 SpectrogramLayer(Configuration = FullRangeDb); |
56 ~SpectrogramLayer(); | 60 ~SpectrogramLayer(); |
57 | 61 |
58 virtual const ZoomConstraint *getZoomConstraint() const { return this; } | 62 virtual const ZoomConstraint *getZoomConstraint() const { return this; } |
59 virtual const Model *getModel() const { return m_model; } | 63 virtual const Model *getModel() const { return m_model; } |
60 virtual void paint(View *v, QPainter &paint, QRect rect) const; | 64 virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; |
61 virtual void setSynchronousPainting(bool synchronous); | 65 virtual void setSynchronousPainting(bool synchronous); |
62 | 66 |
63 virtual int getVerticalScaleWidth(View *v, bool detailed, QPainter &) const; | 67 virtual int getVerticalScaleWidth(LayerGeometryProvider *v, bool detailed, QPainter &) const; |
64 virtual void paintVerticalScale(View *v, bool detailed, QPainter &paint, QRect rect) const; | 68 virtual void paintVerticalScale(LayerGeometryProvider *v, bool detailed, QPainter &paint, QRect rect) const; |
65 | 69 |
66 virtual bool getCrosshairExtents(View *, QPainter &, QPoint cursorPos, | 70 virtual bool getCrosshairExtents(LayerGeometryProvider *, QPainter &, QPoint cursorPos, |
67 std::vector<QRect> &extents) const; | 71 std::vector<QRect> &extents) const; |
68 virtual void paintCrosshairs(View *, QPainter &, QPoint) const; | 72 virtual void paintCrosshairs(LayerGeometryProvider *, QPainter &, QPoint) const; |
69 | 73 |
70 virtual QString getFeatureDescription(View *v, QPoint &) const; | 74 virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const; |
71 | 75 |
72 virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame, | 76 virtual bool snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, |
73 int &resolution, | 77 int &resolution, |
74 SnapType snap) const; | 78 SnapType snap) const; |
75 | 79 |
76 virtual void measureDoubleClick(View *, QMouseEvent *); | 80 virtual void measureDoubleClick(LayerGeometryProvider *, QMouseEvent *); |
77 | 81 |
78 virtual bool hasLightBackground() const; | 82 virtual bool hasLightBackground() const; |
79 | 83 |
80 void setModel(const DenseTimeValueModel *model); | 84 void setModel(const DenseTimeValueModel *model); |
81 | 85 |
86 virtual QString getPropertyGroupName(const PropertyName &) const; | 90 virtual QString getPropertyGroupName(const PropertyName &) const; |
87 virtual int getPropertyRangeAndValue(const PropertyName &, | 91 virtual int getPropertyRangeAndValue(const PropertyName &, |
88 int *min, int *max, int *deflt) const; | 92 int *min, int *max, int *deflt) const; |
89 virtual QString getPropertyValueLabel(const PropertyName &, | 93 virtual QString getPropertyValueLabel(const PropertyName &, |
90 int value) const; | 94 int value) const; |
95 virtual QString getPropertyValueIconName(const PropertyName &, | |
96 int value) const; | |
91 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const; | 97 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const; |
92 virtual void setProperty(const PropertyName &, int value); | 98 virtual void setProperty(const PropertyName &, int value); |
93 | 99 |
94 /** | 100 /** |
95 * Specify the channel to use from the source model. | 101 * Specify the channel to use from the source model. |
106 int getWindowHopLevel() const; | 112 int getWindowHopLevel() const; |
107 | 113 |
108 void setWindowType(WindowType type); | 114 void setWindowType(WindowType type); |
109 WindowType getWindowType() const; | 115 WindowType getWindowType() const; |
110 | 116 |
111 void setZeroPadLevel(int level); | |
112 int getZeroPadLevel() const; | |
113 | |
114 /** | 117 /** |
115 * Set the gain multiplier for sample values in this view. | 118 * Set the gain multiplier for sample values in this view. |
116 * The default is 1.0. | 119 * The default is 1.0. |
117 */ | 120 */ |
118 void setGain(float gain); | 121 void setGain(float gain); |
120 | 123 |
121 /** | 124 /** |
122 * Set the threshold for sample values to qualify for being shown | 125 * Set the threshold for sample values to qualify for being shown |
123 * in the FFT, in voltage units. | 126 * in the FFT, in voltage units. |
124 * | 127 * |
125 * The default is 0.0. | 128 * The default is 10^-8 (-80dB). |
126 */ | 129 */ |
127 void setThreshold(float threshold); | 130 void setThreshold(float threshold); |
128 float getThreshold() const; | 131 float getThreshold() const; |
129 | 132 |
130 void setMinFrequency(int); | 133 void setMinFrequency(int); |
131 int getMinFrequency() const; | 134 int getMinFrequency() const; |
132 | 135 |
133 void setMaxFrequency(int); // 0 -> no maximum | 136 void setMaxFrequency(int); // 0 -> no maximum |
134 int getMaxFrequency() const; | 137 int getMaxFrequency() const; |
135 | 138 |
136 enum ColourScale { | 139 /** |
137 LinearColourScale, | 140 * Specify the scale for sample levels. See ColourScale and |
138 MeterColourScale, | 141 * WaveformLayer for comparison and details of meter and dB |
139 dBSquaredColourScale, | 142 * scaling. The default is LogColourScale. |
140 dBColourScale, | 143 */ |
141 PhaseColourScale | 144 void setColourScale(ColourScaleType); |
142 }; | 145 ColourScaleType getColourScale() const; |
143 | 146 |
144 /** | 147 /** |
145 * Specify the scale for sample levels. See WaveformLayer for | 148 * Specify multiple factor for colour scale. This is 2.0 for |
146 * details of meter and dB scaling. The default is dBColourScale. | 149 * log-power spectrogram and 1.0 otherwise. |
147 */ | 150 */ |
148 void setColourScale(ColourScale); | 151 void setColourScaleMultiple(double); |
149 ColourScale getColourScale() const; | 152 double getColourScaleMultiple() const; |
150 | |
151 enum FrequencyScale { | |
152 LinearFrequencyScale, | |
153 LogFrequencyScale | |
154 }; | |
155 | 153 |
156 /** | 154 /** |
157 * Specify the scale for the y axis. | 155 * Specify the scale for the y axis. |
158 */ | 156 */ |
159 void setFrequencyScale(FrequencyScale); | 157 void setBinScale(BinScale); |
160 FrequencyScale getFrequencyScale() const; | 158 BinScale getBinScale() const; |
161 | 159 |
162 enum BinDisplay { | |
163 AllBins, | |
164 PeakBins, | |
165 PeakFrequencies | |
166 }; | |
167 | |
168 /** | 160 /** |
169 * Specify the processing of frequency bins for the y axis. | 161 * Specify the processing of frequency bins for the y axis. |
170 */ | 162 */ |
171 void setBinDisplay(BinDisplay); | 163 void setBinDisplay(BinDisplay); |
172 BinDisplay getBinDisplay() const; | 164 BinDisplay getBinDisplay() const; |
173 | 165 |
174 /** | 166 /** |
175 * Normalize each column to its maximum value, independent of its | 167 * Specify the normalization mode for individual columns. |
176 * neighbours. | 168 */ |
177 */ | 169 void setNormalization(ColumnNormalization); |
178 void setNormalizeColumns(bool n); | 170 ColumnNormalization getNormalization() const; |
179 bool getNormalizeColumns() const; | 171 |
180 | 172 /** |
181 /** | 173 * Specify whether to normalize the visible area. |
182 * Normalize each value against the maximum in the visible region. | 174 */ |
183 */ | 175 void setNormalizeVisibleArea(bool); |
184 void setNormalizeVisibleArea(bool n); | |
185 bool getNormalizeVisibleArea() const; | 176 bool getNormalizeVisibleArea() const; |
186 | 177 |
187 /** | 178 /** |
188 * Normalize each column to its maximum value, and then scale by | 179 * Specify the colour map. See ColourMapper for the colour map |
189 * the log of the (absolute) maximum value. | 180 * values. |
190 */ | 181 */ |
191 void setNormalizeHybrid(bool n); | |
192 bool getNormalizeHybrid() const; | |
193 | |
194 void setColourMap(int map); | 182 void setColourMap(int map); |
195 int getColourMap() const; | 183 int getColourMap() const; |
196 | 184 |
197 /** | 185 /** |
198 * Specify the colourmap rotation for the colour scale. | 186 * Specify the colourmap rotation for the colour scale. |
208 | 196 |
209 virtual ColourSignificance getLayerColourSignificance() const { | 197 virtual ColourSignificance getLayerColourSignificance() const { |
210 return ColourHasMeaningfulValue; | 198 return ColourHasMeaningfulValue; |
211 } | 199 } |
212 | 200 |
213 double getYForFrequency(const View *v, double frequency) const; | 201 double getYForFrequency(const LayerGeometryProvider *v, double frequency) const; |
214 double getFrequencyForY(const View *v, int y) const; | 202 double getFrequencyForY(const LayerGeometryProvider *v, int y) const; |
215 | 203 |
216 virtual int getCompletion(View *v) const; | 204 //!!! VerticalBinLayer methods. Note overlap with get*BinRange() |
217 virtual QString getError(View *v) const; | 205 double getYForBin(const LayerGeometryProvider *, double bin) const; |
206 double getBinForY(const LayerGeometryProvider *, double y) const; | |
207 | |
208 virtual int getCompletion(LayerGeometryProvider *v) const; | |
209 virtual QString getError(LayerGeometryProvider *v) const; | |
218 | 210 |
219 virtual bool getValueExtents(double &min, double &max, | 211 virtual bool getValueExtents(double &min, double &max, |
220 bool &logarithmic, QString &unit) const; | 212 bool &logarithmic, QString &unit) const; |
221 | 213 |
222 virtual bool getDisplayExtents(double &min, double &max) const; | 214 virtual bool getDisplayExtents(double &min, double &max) const; |
223 | 215 |
224 virtual bool setDisplayExtents(double min, double max); | 216 virtual bool setDisplayExtents(double min, double max); |
225 | 217 |
226 virtual bool getYScaleValue(const View *, int, double &, QString &) const; | 218 virtual bool getYScaleValue(const LayerGeometryProvider *, int, double &, QString &) const; |
227 | 219 |
228 virtual void toXml(QTextStream &stream, QString indent = "", | 220 virtual void toXml(QTextStream &stream, QString indent = "", |
229 QString extraAttributes = "") const; | 221 QString extraAttributes = "") const; |
230 | 222 |
231 void setProperties(const QXmlAttributes &attributes); | 223 void setProperties(const QXmlAttributes &attributes); |
232 | 224 |
233 virtual void setLayerDormant(const View *v, bool dormant); | 225 virtual void setLayerDormant(const LayerGeometryProvider *v, bool dormant); |
234 | 226 |
235 virtual bool isLayerScrollable(const View *) const { return false; } | 227 virtual bool isLayerScrollable(const LayerGeometryProvider *) const { return false; } |
236 | 228 |
237 virtual int getVerticalZoomSteps(int &defaultStep) const; | 229 virtual int getVerticalZoomSteps(int &defaultStep) const; |
238 virtual int getCurrentVerticalZoomStep() const; | 230 virtual int getCurrentVerticalZoomStep() const; |
239 virtual void setVerticalZoomStep(int); | 231 virtual void setVerticalZoomStep(int); |
240 virtual RangeMapper *getNewVerticalZoomRangeMapper() const; | 232 virtual RangeMapper *getNewVerticalZoomRangeMapper() const; |
245 void cacheInvalid(); | 237 void cacheInvalid(); |
246 void cacheInvalid(sv_frame_t startFrame, sv_frame_t endFrame); | 238 void cacheInvalid(sv_frame_t startFrame, sv_frame_t endFrame); |
247 | 239 |
248 void preferenceChanged(PropertyContainer::PropertyName name); | 240 void preferenceChanged(PropertyContainer::PropertyName name); |
249 | 241 |
250 void fillTimerTimedOut(); | |
251 | |
252 protected: | 242 protected: |
253 const DenseTimeValueModel *m_model; // I do not own this | 243 const DenseTimeValueModel *m_model; // I do not own this |
254 | 244 |
255 int m_channel; | 245 int m_channel; |
256 int m_windowSize; | 246 int m_windowSize; |
257 WindowType m_windowType; | 247 WindowType m_windowType; |
258 int m_windowHopLevel; | 248 int m_windowHopLevel; |
259 int m_zeroPadLevel; | |
260 int m_fftSize; | |
261 float m_gain; | 249 float m_gain; |
262 float m_initialGain; | 250 float m_initialGain; |
263 float m_threshold; | 251 float m_threshold; |
264 float m_initialThreshold; | 252 float m_initialThreshold; |
265 int m_colourRotation; | 253 int m_colourRotation; |
266 int m_initialRotation; | 254 int m_initialRotation; |
267 int m_minFrequency; | 255 int m_minFrequency; |
268 int m_maxFrequency; | 256 int m_maxFrequency; |
269 int m_initialMaxFrequency; | 257 int m_initialMaxFrequency; |
270 ColourScale m_colourScale; | 258 ColourScaleType m_colourScale; |
259 double m_colourScaleMultiple; | |
271 int m_colourMap; | 260 int m_colourMap; |
272 QColor m_crosshairColour; | 261 QColor m_crosshairColour; |
273 FrequencyScale m_frequencyScale; | 262 BinScale m_binScale; |
274 BinDisplay m_binDisplay; | 263 BinDisplay m_binDisplay; |
275 bool m_normalizeColumns; | 264 ColumnNormalization m_normalization; // of individual columns |
276 bool m_normalizeVisibleArea; | 265 bool m_normalizeVisibleArea; |
277 bool m_normalizeHybrid; | |
278 int m_lastEmittedZoomStep; | 266 int m_lastEmittedZoomStep; |
279 bool m_synchronous; | 267 bool m_synchronous; |
280 | 268 |
281 mutable bool m_haveDetailedScale; | 269 mutable bool m_haveDetailedScale; |
282 mutable int m_lastPaintBlockWidth; | 270 |
283 mutable RealTime m_lastPaintTime; | 271 static std::pair<ColourScaleType, double> convertToColourScale(int value); |
284 | 272 static int convertFromColourScale(ColourScaleType type, double multiple); |
285 enum { NO_VALUE = 0 }; // colour index for unused pixels | 273 static std::pair<ColumnNormalization, bool> convertToColumnNorm(int value); |
286 | 274 static int convertFromColumnNorm(ColumnNormalization norm, bool visible); |
287 class Palette | 275 |
288 { | |
289 public: | |
290 QColor getColour(unsigned char index) const { | |
291 return m_colours[index]; | |
292 } | |
293 | |
294 void setColour(unsigned char index, QColor colour) { | |
295 m_colours[index] = colour; | |
296 } | |
297 | |
298 private: | |
299 QColor m_colours[256]; | |
300 }; | |
301 | |
302 Palette m_palette; | |
303 | |
304 /** | |
305 * ImageCache covers the area of the view, at view resolution. | |
306 * Not all of it is necessarily valid at once (it is refreshed | |
307 * in parts when scrolling, for example). | |
308 */ | |
309 struct ImageCache | |
310 { | |
311 QImage image; | |
312 QRect validArea; | |
313 sv_frame_t startFrame; | |
314 int zoomLevel; | |
315 }; | |
316 typedef std::map<const View *, ImageCache> ViewImageCache; | |
317 void invalidateImageCaches(); | |
318 void invalidateImageCaches(sv_frame_t startFrame, sv_frame_t endFrame); | |
319 mutable ViewImageCache m_imageCaches; | |
320 | |
321 /** | |
322 * When painting, we draw directly onto the draw buffer and then | |
323 * copy this to the part of the image cache that needed refreshing | |
324 * before copying the image cache onto the window. (Remind me why | |
325 * we don't draw directly onto the cache?) | |
326 */ | |
327 mutable QImage m_drawBuffer; | |
328 | |
329 mutable QTimer *m_updateTimer; | |
330 | |
331 mutable sv_frame_t m_candidateFillStartFrame; | |
332 bool m_exiting; | 276 bool m_exiting; |
333 | 277 |
334 void initialisePalette(); | |
335 void rotatePalette(int distance); | |
336 | |
337 unsigned char getDisplayValue(View *v, double input) const; | |
338 | |
339 int getColourScaleWidth(QPainter &) const; | 278 int getColourScaleWidth(QPainter &) const; |
340 | 279 |
341 void illuminateLocalFeatures(View *v, QPainter &painter) const; | 280 void illuminateLocalFeatures(LayerGeometryProvider *v, QPainter &painter) const; |
342 | 281 |
343 double getEffectiveMinFrequency() const; | 282 double getEffectiveMinFrequency() const; |
344 double getEffectiveMaxFrequency() const; | 283 double getEffectiveMaxFrequency() const; |
345 | 284 |
346 // Note that the getYBin... methods return the nominal bin in the | 285 bool getXBinRange(LayerGeometryProvider *v, int x, double &windowMin, double &windowMax) const; |
347 // un-smoothed spectrogram. This is not necessarily the same bin | 286 bool getYBinRange(LayerGeometryProvider *v, int y, double &freqBinMin, double &freqBinMax) const; |
348 // as is pulled from the spectrogram and drawn at the given | 287 |
349 // position, if the spectrogram has oversampling smoothing. Use | 288 bool getYBinSourceRange(LayerGeometryProvider *v, int y, double &freqMin, double &freqMax) const; |
350 // getSmoothedYBinRange to obtain that. | 289 bool getAdjustedYBinSourceRange(LayerGeometryProvider *v, int x, int y, |
351 | |
352 bool getXBinRange(View *v, int x, double &windowMin, double &windowMax) const; | |
353 bool getYBinRange(View *v, int y, double &freqBinMin, double &freqBinMax) const; | |
354 bool getSmoothedYBinRange(View *v, int y, double &freqBinMin, double &freqBinMax) const; | |
355 | |
356 bool getYBinSourceRange(View *v, int y, double &freqMin, double &freqMax) const; | |
357 bool getAdjustedYBinSourceRange(View *v, int x, int y, | |
358 double &freqMin, double &freqMax, | 290 double &freqMin, double &freqMax, |
359 double &adjFreqMin, double &adjFreqMax) const; | 291 double &adjFreqMin, double &adjFreqMax) const; |
360 bool getXBinSourceRange(View *v, int x, RealTime &timeMin, RealTime &timeMax) const; | 292 bool getXBinSourceRange(LayerGeometryProvider *v, int x, RealTime &timeMin, RealTime &timeMax) const; |
361 bool getXYBinSourceRange(View *v, int x, int y, double &min, double &max, | 293 bool getXYBinSourceRange(LayerGeometryProvider *v, int x, int y, double &min, double &max, |
362 double &phaseMin, double &phaseMax) const; | 294 double &phaseMin, double &phaseMax) const; |
363 | 295 |
364 int getWindowIncrement() const { | 296 int getWindowIncrement() const { |
365 if (m_windowHopLevel == 0) return m_windowSize; | 297 if (m_windowHopLevel == 0) return m_windowSize; |
366 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4; | 298 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4; |
367 else return m_windowSize / (1 << (m_windowHopLevel - 1)); | 299 else return m_windowSize / (1 << (m_windowHopLevel - 1)); |
368 } | 300 } |
369 | 301 |
370 int getZeroPadLevel(const View *v) const; | 302 int getFFTOversampling() const; |
371 int getFFTSize(const View *v) const; | 303 int getFFTSize() const; // m_windowSize * getFFTOversampling() |
372 FFTModel *getFFTModel(const View *v) const; | 304 |
373 Dense3DModelPeakCache *getPeakCache(const View *v) const; | 305 FFTModel *m_fftModel; |
374 void invalidateFFTModels(); | 306 FFTModel *getFFTModel() const { return m_fftModel; } |
375 | 307 Dense3DModelPeakCache *m_wholeCache; |
376 typedef std::pair<FFTModel *, sv_frame_t> FFTFillPair; // model, last fill | 308 Dense3DModelPeakCache *m_peakCache; |
377 typedef std::map<const View *, FFTFillPair> ViewFFTMap; | 309 Dense3DModelPeakCache *getPeakCache() const { return m_peakCache; } |
378 typedef std::map<const View *, Dense3DModelPeakCache *> PeakCacheMap; | 310 const int m_peakCacheDivisor; |
379 mutable ViewFFTMap m_fftModels; | 311 bool canStoreWholeCache() const; |
380 mutable PeakCacheMap m_peakCaches; | 312 void recreateFFTModel(); |
381 mutable Model *m_sliceableModel; | 313 |
382 | 314 typedef std::map<int, MagnitudeRange> ViewMagMap; // key is view id |
383 class MagnitudeRange { | |
384 public: | |
385 MagnitudeRange() : m_min(0), m_max(0) { } | |
386 bool operator==(const MagnitudeRange &r) { | |
387 return r.m_min == m_min && r.m_max == m_max; | |
388 } | |
389 bool isSet() const { return (m_min != 0.f || m_max != 0.f); } | |
390 void set(float min, float max) { | |
391 m_min = min; | |
392 m_max = max; | |
393 if (m_max < m_min) m_max = m_min; | |
394 } | |
395 bool sample(float f) { | |
396 bool changed = false; | |
397 if (isSet()) { | |
398 if (f < m_min) { m_min = f; changed = true; } | |
399 if (f > m_max) { m_max = f; changed = true; } | |
400 } else { | |
401 m_max = m_min = f; | |
402 changed = true; | |
403 } | |
404 return changed; | |
405 } | |
406 bool sample(const MagnitudeRange &r) { | |
407 bool changed = false; | |
408 if (isSet()) { | |
409 if (r.m_min < m_min) { m_min = r.m_min; changed = true; } | |
410 if (r.m_max > m_max) { m_max = r.m_max; changed = true; } | |
411 } else { | |
412 m_min = r.m_min; | |
413 m_max = r.m_max; | |
414 changed = true; | |
415 } | |
416 return changed; | |
417 } | |
418 float getMin() const { return m_min; } | |
419 float getMax() const { return m_max; } | |
420 private: | |
421 float m_min; | |
422 float m_max; | |
423 }; | |
424 | |
425 typedef std::map<const View *, MagnitudeRange> ViewMagMap; | |
426 mutable ViewMagMap m_viewMags; | 315 mutable ViewMagMap m_viewMags; |
427 mutable std::vector<MagnitudeRange> m_columnMags; | 316 mutable ViewMagMap m_lastRenderedMags; // when in normalizeVisibleArea mode |
428 void invalidateMagnitudes(); | 317 void invalidateMagnitudes(); |
429 bool updateViewMagnitudes(View *v) const; | 318 |
430 bool paintDrawBuffer(View *v, int w, int h, | 319 typedef std::map<int, Colour3DPlotRenderer *> ViewRendererMap; // key is view id |
431 const std::vector<int> &binforx, | 320 mutable ViewRendererMap m_renderers; |
432 const std::vector<double> &binfory, | 321 Colour3DPlotRenderer *getRenderer(LayerGeometryProvider *) const; |
433 bool usePeaksCache, | 322 void invalidateRenderers(); |
434 MagnitudeRange &overallMag, | 323 |
435 bool &overallMagChanged) const; | 324 void paintWithRenderer(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; |
436 bool paintDrawBufferPeakFrequencies(View *v, int w, int h, | 325 |
437 const std::vector<int> &binforx, | 326 void paintDetailedScale(LayerGeometryProvider *v, |
438 int minbin, | 327 QPainter &paint, QRect rect) const; |
439 int maxbin, | 328 void paintDetailedScalePhase(LayerGeometryProvider *v, |
440 double displayMinFreq, | 329 QPainter &paint, QRect rect) const; |
441 double displayMaxFreq, | 330 |
442 bool logarithmic, | 331 virtual void updateMeasureRectYCoords(LayerGeometryProvider *v, |
443 MagnitudeRange &overallMag, | 332 const MeasureRect &r) const; |
444 bool &overallMagChanged) const; | 333 virtual void setMeasureRectYCoord(LayerGeometryProvider *v, |
445 | 334 MeasureRect &r, bool start, int y) const; |
446 virtual void updateMeasureRectYCoords(View *v, const MeasureRect &r) const; | |
447 virtual void setMeasureRectYCoord(View *v, MeasureRect &r, bool start, int y) const; | |
448 }; | 335 }; |
449 | 336 |
450 #endif | 337 #endif |