comparison layer/SpectrogramLayer.h @ 1324:13d9b422f7fe zoom

Merge from default branch
author Chris Cannam
date Mon, 17 Sep 2018 13:51:31 +0100
parents a34a2a25907c
children d79e21855aef
comparison
equal deleted inserted replaced
1183:57d192e26331 1324:13d9b422f7fe
47 * SpectrogramLayer represents waveform data (obtained from a 47 * SpectrogramLayer represents waveform data (obtained from a
48 * DenseTimeValueModel) in spectrogram form. 48 * DenseTimeValueModel) in spectrogram form.
49 */ 49 */
50 50
51 class SpectrogramLayer : public VerticalBinLayer, 51 class SpectrogramLayer : public VerticalBinLayer,
52 public PowerOfSqrtTwoZoomConstraint 52 public PowerOfSqrtTwoZoomConstraint
53 { 53 {
54 Q_OBJECT 54 Q_OBJECT
55 55
56 public: 56 public:
57 enum Configuration { FullRangeDb, MelodicRange, MelodicPeaks }; 57 enum Configuration { FullRangeDb, MelodicRange, MelodicPeaks };
72 virtual void paintCrosshairs(LayerGeometryProvider *, QPainter &, QPoint) const; 72 virtual void paintCrosshairs(LayerGeometryProvider *, QPainter &, QPoint) const;
73 73
74 virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const; 74 virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const;
75 75
76 virtual bool snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, 76 virtual bool snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame,
77 int &resolution, 77 int &resolution,
78 SnapType snap) const; 78 SnapType snap) const;
79 79
80 virtual void measureDoubleClick(LayerGeometryProvider *, QMouseEvent *); 80 virtual void measureDoubleClick(LayerGeometryProvider *, QMouseEvent *);
81 81
82 virtual bool hasLightBackground() const; 82 virtual bool hasLightBackground() const;
83 83
89 virtual PropertyType getPropertyType(const PropertyName &) const; 89 virtual PropertyType getPropertyType(const PropertyName &) const;
90 virtual QString getPropertyGroupName(const PropertyName &) const; 90 virtual QString getPropertyGroupName(const PropertyName &) const;
91 virtual int getPropertyRangeAndValue(const PropertyName &, 91 virtual int getPropertyRangeAndValue(const PropertyName &,
92 int *min, int *max, int *deflt) const; 92 int *min, int *max, int *deflt) const;
93 virtual QString getPropertyValueLabel(const PropertyName &, 93 virtual QString getPropertyValueLabel(const PropertyName &,
94 int value) const; 94 int value) const;
95 virtual QString getPropertyValueIconName(const PropertyName &, 95 virtual QString getPropertyValueIconName(const PropertyName &,
96 int value) const; 96 int value) const;
97 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const; 97 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
98 virtual void setProperty(const PropertyName &, int value); 98 virtual void setProperty(const PropertyName &, int value);
99 99
187 */ 187 */
188 void setColourRotation(int); 188 void setColourRotation(int);
189 int getColourRotation() const; 189 int getColourRotation() const;
190 190
191 virtual VerticalPosition getPreferredFrameCountPosition() const { 191 virtual VerticalPosition getPreferredFrameCountPosition() const {
192 return PositionTop; 192 return PositionTop;
193 } 193 }
194 194
195 virtual bool isLayerOpaque() const { return true; } 195 virtual bool isLayerOpaque() const { return true; }
196 196
197 virtual ColourSignificance getLayerColourSignificance() const { 197 virtual ColourSignificance getLayerColourSignificance() const {
222 222
223 void setProperties(const QXmlAttributes &attributes); 223 void setProperties(const QXmlAttributes &attributes);
224 224
225 virtual void setLayerDormant(const LayerGeometryProvider *v, bool dormant); 225 virtual void setLayerDormant(const LayerGeometryProvider *v, bool dormant);
226 226
227 virtual bool isLayerScrollable(const LayerGeometryProvider *) const { return false; } 227 virtual bool isLayerScrollable(const LayerGeometryProvider *) const;
228 228
229 virtual int getVerticalZoomSteps(int &defaultStep) const; 229 virtual int getVerticalZoomSteps(int &defaultStep) const;
230 virtual int getCurrentVerticalZoomStep() const; 230 virtual int getCurrentVerticalZoomStep() const;
231 virtual void setVerticalZoomStep(int); 231 virtual void setVerticalZoomStep(int);
232 virtual RangeMapper *getNewVerticalZoomRangeMapper() const; 232 virtual RangeMapper *getNewVerticalZoomRangeMapper() const;
256 int m_maxFrequency; 256 int m_maxFrequency;
257 int m_initialMaxFrequency; 257 int m_initialMaxFrequency;
258 ColourScaleType m_colourScale; 258 ColourScaleType m_colourScale;
259 double m_colourScaleMultiple; 259 double m_colourScaleMultiple;
260 int m_colourMap; 260 int m_colourMap;
261 QColor m_crosshairColour; 261 mutable QColor m_crosshairColour;
262 BinScale m_binScale; 262 BinScale m_binScale;
263 BinDisplay m_binDisplay; 263 BinDisplay m_binDisplay;
264 ColumnNormalization m_normalization; // of individual columns 264 ColumnNormalization m_normalization; // of individual columns
265 bool m_normalizeVisibleArea; 265 bool m_normalizeVisibleArea;
266 int m_lastEmittedZoomStep; 266 int m_lastEmittedZoomStep;
285 bool getXBinRange(LayerGeometryProvider *v, int x, double &windowMin, double &windowMax) const; 285 bool getXBinRange(LayerGeometryProvider *v, int x, double &windowMin, double &windowMax) const;
286 bool getYBinRange(LayerGeometryProvider *v, int y, double &freqBinMin, double &freqBinMax) const; 286 bool getYBinRange(LayerGeometryProvider *v, int y, double &freqBinMin, double &freqBinMax) const;
287 287
288 bool getYBinSourceRange(LayerGeometryProvider *v, int y, double &freqMin, double &freqMax) const; 288 bool getYBinSourceRange(LayerGeometryProvider *v, int y, double &freqMin, double &freqMax) const;
289 bool getAdjustedYBinSourceRange(LayerGeometryProvider *v, int x, int y, 289 bool getAdjustedYBinSourceRange(LayerGeometryProvider *v, int x, int y,
290 double &freqMin, double &freqMax, 290 double &freqMin, double &freqMax,
291 double &adjFreqMin, double &adjFreqMax) const; 291 double &adjFreqMin, double &adjFreqMax) const;
292 bool getXBinSourceRange(LayerGeometryProvider *v, int x, RealTime &timeMin, RealTime &timeMax) const; 292 bool getXBinSourceRange(LayerGeometryProvider *v, int x, RealTime &timeMin, RealTime &timeMax) const;
293 bool getXYBinSourceRange(LayerGeometryProvider *v, int x, int y, double &min, double &max, 293 bool getXYBinSourceRange(LayerGeometryProvider *v, int x, int y, double &min, double &max,
294 double &phaseMin, double &phaseMax) const; 294 double &phaseMin, double &phaseMax) const;
295 295
296 int getWindowIncrement() const { 296 int getWindowIncrement() const {
297 if (m_windowHopLevel == 0) return m_windowSize; 297 if (m_windowHopLevel == 0) return m_windowSize;
298 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4; 298 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4;
299 else return m_windowSize / (1 << (m_windowHopLevel - 1)); 299 else return m_windowSize / (1 << (m_windowHopLevel - 1));
300 } 300 }
301 301
302 int getFFTOversampling() const; 302 int getFFTOversampling() const;
303 int getFFTSize() const; // m_windowSize * getFFTOversampling() 303 int getFFTSize() const; // m_windowSize * getFFTOversampling()
304 304
305 mutable FFTModel *m_fftModel; //!!! should not be mutable, see getFFTModel()? 305 FFTModel *m_fftModel;
306 mutable Dense3DModelPeakCache *m_peakCache; 306 FFTModel *getFFTModel() const { return m_fftModel; }
307 Dense3DModelPeakCache *m_wholeCache;
308 Dense3DModelPeakCache *m_peakCache;
309 Dense3DModelPeakCache *getPeakCache() const { return m_peakCache; }
307 const int m_peakCacheDivisor; 310 const int m_peakCacheDivisor;
311 bool canStoreWholeCache() const;
312 void recreateFFTModel();
308 313
309 typedef std::map<int, MagnitudeRange> ViewMagMap; // key is view id 314 typedef std::map<int, MagnitudeRange> ViewMagMap; // key is view id
310 mutable ViewMagMap m_viewMags; 315 mutable ViewMagMap m_viewMags;
311 mutable ViewMagMap m_lastRenderedMags; // when in normalizeVisibleArea mode 316 mutable ViewMagMap m_lastRenderedMags; // when in normalizeVisibleArea mode
312 void invalidateMagnitudes(); 317 void invalidateMagnitudes();
313 318
314 typedef std::map<int, Colour3DPlotRenderer *> ViewRendererMap; // key is view id 319 typedef std::map<int, Colour3DPlotRenderer *> ViewRendererMap; // key is view id
315 mutable ViewRendererMap m_renderers; 320 mutable ViewRendererMap m_renderers;
316 Colour3DPlotRenderer *getRenderer(LayerGeometryProvider *) const; 321 Colour3DPlotRenderer *getRenderer(LayerGeometryProvider *) const;
317 void invalidateRenderers(); 322 void invalidateRenderers();
318 323
319 FFTModel *getFFTModel() const; 324 void deleteDerivedModels();
320 Dense3DModelPeakCache *getPeakCache() const; 325
321 void invalidateFFTModel();
322
323 void paintWithRenderer(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; 326 void paintWithRenderer(LayerGeometryProvider *v, QPainter &paint, QRect rect) const;
324 327
325 void paintDetailedScale(LayerGeometryProvider *v, 328 void paintDetailedScale(LayerGeometryProvider *v,
326 QPainter &paint, QRect rect) const; 329 QPainter &paint, QRect rect) const;
327 void paintDetailedScalePhase(LayerGeometryProvider *v, 330 void paintDetailedScalePhase(LayerGeometryProvider *v,