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

Merge from default branch
author Chris Cannam
date Mon, 17 Sep 2018 13:51:31 +0100
parents fc9d9f1103fa
children d79e21855aef
comparison
equal deleted inserted replaced
1183:57d192e26331 1324:13d9b422f7fe
12 published by the Free Software Foundation; either version 2 of the 12 published by the Free Software Foundation; either version 2 of the
13 License, or (at your option) any later version. See the file 13 License, or (at your option) any later version. See the file
14 COPYING included with this distribution for more information. 14 COPYING included with this distribution for more information.
15 */ 15 */
16 16
17 #ifndef _SPECTRUM_LAYER_H_ 17 #ifndef SV_SPECTRUM_LAYER_H
18 #define _SPECTRUM_LAYER_H_ 18 #define SV_SPECTRUM_LAYER_H
19 19
20 #include "SliceLayer.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 "HorizontalScaleProvider.h"
27
26 #include <QColor> 28 #include <QColor>
27 #include <QMutex> 29 #include <QMutex>
28 30
29 class FFTModel; 31 class FFTModel;
30 32
31 class SpectrumLayer : public SliceLayer 33 class SpectrumLayer : public SliceLayer,
34 public HorizontalScaleProvider
32 { 35 {
33 Q_OBJECT 36 Q_OBJECT
34 37
35 public: 38 public:
36 SpectrumLayer(); 39 SpectrumLayer();
37 ~SpectrumLayer(); 40 ~SpectrumLayer();
38 41
39 void setModel(DenseTimeValueModel *model); 42 void setModel(DenseTimeValueModel *model);
40 virtual const Model *getModel() const { return m_originModel; } 43 virtual const Model *getModel() const override { return m_originModel; }
41 44
42 virtual bool getCrosshairExtents(LayerGeometryProvider *, QPainter &, QPoint cursorPos, 45 virtual bool getCrosshairExtents(LayerGeometryProvider *, QPainter &, QPoint cursorPos,
43 std::vector<QRect> &extents) const; 46 std::vector<QRect> &extents) const override;
44 virtual void paintCrosshairs(LayerGeometryProvider *, QPainter &, QPoint) const; 47 virtual void paintCrosshairs(LayerGeometryProvider *, QPainter &, QPoint) const override;
45 48
46 virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const; 49 virtual int getHorizontalScaleHeight(LayerGeometryProvider *, QPainter &) const;
50 virtual void paintHorizontalScale(LayerGeometryProvider *, QPainter &, int xorigin) const;
51
52 virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const override;
47 53
48 virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; 54 virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const override;
49 55
50 virtual VerticalPosition getPreferredFrameCountPosition() const { 56 virtual VerticalPosition getPreferredFrameCountPosition() const override {
51 return PositionTop; 57 return PositionTop;
52 } 58 }
53 59
54 virtual PropertyList getProperties() const; 60 virtual PropertyList getProperties() const override;
55 virtual QString getPropertyLabel(const PropertyName &) const; 61 virtual QString getPropertyLabel(const PropertyName &) const override;
56 virtual QString getPropertyIconName(const PropertyName &) const; 62 virtual QString getPropertyIconName(const PropertyName &) const override;
57 virtual PropertyType getPropertyType(const PropertyName &) const; 63 virtual PropertyType getPropertyType(const PropertyName &) const override;
58 virtual QString getPropertyGroupName(const PropertyName &) const; 64 virtual QString getPropertyGroupName(const PropertyName &) const override;
59 virtual int getPropertyRangeAndValue(const PropertyName &, 65 virtual int getPropertyRangeAndValue(const PropertyName &,
60 int *min, int *max, int *deflt) const; 66 int *min, int *max, int *deflt) const override;
61 virtual QString getPropertyValueLabel(const PropertyName &, 67 virtual QString getPropertyValueLabel(const PropertyName &,
62 int value) const; 68 int value) const override;
63 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const; 69 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const override;
64 virtual void setProperty(const PropertyName &, int value); 70 virtual void setProperty(const PropertyName &, int value) override;
65 virtual void setProperties(const QXmlAttributes &); 71 virtual void setProperties(const QXmlAttributes &) override;
66
67 virtual bool getValueExtents(double &min, double &max,
68 bool &logarithmic, QString &unit) const;
69 72
70 virtual bool getXScaleValue(const LayerGeometryProvider *v, int x, 73 virtual bool getXScaleValue(const LayerGeometryProvider *v, int x,
71 double &value, QString &unit) const; 74 double &value, QString &unit) const override;
72 75
73 virtual bool getYScaleValue(const LayerGeometryProvider *, int y, 76 virtual bool getYScaleValue(const LayerGeometryProvider *, int y,
74 double &value, QString &unit) const; 77 double &value, QString &unit) const override;
75 78
76 virtual bool getYScaleDifference(const LayerGeometryProvider *, int y0, int y1, 79 virtual bool getYScaleDifference(const LayerGeometryProvider *, int y0, int y1,
77 double &diff, QString &unit) const; 80 double &diff, QString &unit) const override;
78 81
79 virtual bool isLayerScrollable(const LayerGeometryProvider *) const { return false; } 82 virtual bool isLayerScrollable(const LayerGeometryProvider *) const override { return false; }
80 83
81 void setChannel(int); 84 void setChannel(int);
82 int getChannel() const { return m_channel; } 85 int getChannel() const { return m_channel; }
83 86
84 void setWindowSize(int); 87 void setWindowSize(int);
91 WindowType getWindowType() const { return m_windowType; } 94 WindowType getWindowType() const { return m_windowType; }
92 95
93 void setShowPeaks(bool); 96 void setShowPeaks(bool);
94 bool getShowPeaks() const { return m_showPeaks; } 97 bool getShowPeaks() const { return m_showPeaks; }
95 98
96 virtual int getVerticalScaleWidth(LayerGeometryProvider *, bool, QPainter &) const { return 0; } 99 virtual void toXml(QTextStream &stream, QString indent = "",
100 QString extraAttributes = "") const override;
97 101
98 virtual void toXml(QTextStream &stream, QString indent = "", 102 virtual double getFrequencyForX(const LayerGeometryProvider *, double x)
99 QString extraAttributes = "") const; 103 const override;
104 virtual double getXForFrequency(const LayerGeometryProvider *, double freq)
105 const override;
100 106
101 protected slots: 107 protected slots:
102 void preferenceChanged(PropertyContainer::PropertyName name); 108 void preferenceChanged(PropertyContainer::PropertyName name);
103 109
104 protected: 110 protected:
105 // make this SliceLayer method unavailable to the general public
106 // virtual void setModel(DenseThreeDimensionalModel *model) {
107 // SliceLayer::setModel(model);
108 // }
109
110 DenseTimeValueModel *m_originModel; 111 DenseTimeValueModel *m_originModel;
111 int m_channel; 112 int m_channel;
112 bool m_channelSet; 113 bool m_channelSet;
113 int m_windowSize; 114 int m_windowSize;
114 WindowType m_windowType; 115 WindowType m_windowType;
118 119
119 mutable QMutex m_fftMutex; 120 mutable QMutex m_fftMutex;
120 121
121 void setupFFT(); 122 void setupFFT();
122 123
123 virtual void getBiasCurve(BiasCurve &) const; 124 virtual void getBiasCurve(BiasCurve &) const override;
124 BiasCurve m_biasCurve; 125 BiasCurve m_biasCurve;
125
126 virtual double getXForBin(int bin, int totalBins, double w) const;
127 virtual int getBinForX(double x, int totalBins, double w) const;
128
129 double getFrequencyForX(double x, double w) const;
130 double getXForFrequency(double freq, double w) const;
131 126
132 int getWindowIncrement() const { 127 int getWindowIncrement() const {
133 if (m_windowHopLevel == 0) return m_windowSize; 128 if (m_windowHopLevel == 0) return m_windowSize;
134 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4; 129 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4;
135 else return m_windowSize / (1 << (m_windowHopLevel - 1)); 130 else return m_windowSize / (1 << (m_windowHopLevel - 1));