annotate layer/SpectrumLayer.h @ 918:4fe7a09be0fe osx-retina

Many fixes for the previous stuff
author Chris Cannam
date Tue, 17 Mar 2015 16:56:03 +0000
parents 94e4952a6774
children 366ffdf719cd
rev   line source
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@133 17 #ifndef _SPECTRUM_LAYER_H_
Chris@133 18 #define _SPECTRUM_LAYER_H_
Chris@133 19
Chris@193 20 #include "SliceLayer.h"
Chris@133 21
Chris@153 22 #include "base/Window.h"
Chris@153 23
Chris@133 24 #include "data/model/DenseTimeValueModel.h"
Chris@133 25
Chris@133 26 #include <QColor>
Chris@349 27 #include <QMutex>
Chris@133 28
Chris@133 29 class FFTModel;
Chris@133 30
Chris@193 31 class SpectrumLayer : public SliceLayer
Chris@133 32 {
Chris@133 33 Q_OBJECT
Chris@133 34
Chris@133 35 public:
Chris@133 36 SpectrumLayer();
Chris@133 37 ~SpectrumLayer();
Chris@133 38
Chris@133 39 void setModel(DenseTimeValueModel *model);
Chris@193 40 virtual const Model *getModel() const { return m_originModel; }
Chris@133 41
Chris@918 42 virtual bool getCrosshairExtents(LayerGeometryProvider *, QPainter &, QPoint cursorPos,
Chris@254 43 std::vector<QRect> &extents) const;
Chris@918 44 virtual void paintCrosshairs(LayerGeometryProvider *, QPainter &, QPoint) const;
Chris@254 45
Chris@918 46 virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const;
Chris@199 47
Chris@916 48 virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const;
Chris@275 49
Chris@277 50 virtual VerticalPosition getPreferredFrameCountPosition() const {
Chris@277 51 return PositionTop;
Chris@277 52 }
Chris@277 53
Chris@153 54 virtual PropertyList getProperties() const;
Chris@153 55 virtual QString getPropertyLabel(const PropertyName &) const;
Chris@335 56 virtual QString getPropertyIconName(const PropertyName &) const;
Chris@153 57 virtual PropertyType getPropertyType(const PropertyName &) const;
Chris@153 58 virtual QString getPropertyGroupName(const PropertyName &) const;
Chris@153 59 virtual int getPropertyRangeAndValue(const PropertyName &,
Chris@216 60 int *min, int *max, int *deflt) const;
Chris@153 61 virtual QString getPropertyValueLabel(const PropertyName &,
Chris@153 62 int value) const;
Chris@167 63 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
Chris@153 64 virtual void setProperty(const PropertyName &, int value);
Chris@133 65 virtual void setProperties(const QXmlAttributes &);
Chris@133 66
Chris@905 67 virtual bool getValueExtents(double &min, double &max,
Chris@133 68 bool &logarithmic, QString &unit) const;
Chris@133 69
Chris@918 70 virtual bool getXScaleValue(const LayerGeometryProvider *v, int x,
Chris@905 71 double &value, QString &unit) const;
Chris@260 72
Chris@918 73 virtual bool getYScaleValue(const LayerGeometryProvider *, int y,
Chris@905 74 double &value, QString &unit) const;
Chris@274 75
Chris@918 76 virtual bool getYScaleDifference(const LayerGeometryProvider *, int y0, int y1,
Chris@905 77 double &diff, QString &unit) const;
Chris@274 78
Chris@918 79 virtual bool isLayerScrollable(const LayerGeometryProvider *) const { return false; }
Chris@133 80
Chris@153 81 void setChannel(int);
Chris@153 82 int getChannel() const { return m_channel; }
Chris@153 83
Chris@805 84 void setWindowSize(int);
Chris@805 85 int getWindowSize() const { return m_windowSize; }
Chris@153 86
Chris@805 87 void setWindowHopLevel(int level);
Chris@805 88 int getWindowHopLevel() const { return m_windowHopLevel; }
Chris@153 89
Chris@153 90 void setWindowType(WindowType type);
Chris@153 91 WindowType getWindowType() const { return m_windowType; }
Chris@153 92
Chris@284 93 void setShowPeaks(bool);
Chris@284 94 bool getShowPeaks() const { return m_showPeaks; }
Chris@284 95
Chris@918 96 virtual int getVerticalScaleWidth(LayerGeometryProvider *, bool, QPainter &) const { return 0; }
Chris@607 97
Chris@316 98 virtual void toXml(QTextStream &stream, QString indent = "",
Chris@316 99 QString extraAttributes = "") const;
Chris@153 100
Chris@153 101 protected slots:
Chris@153 102 void preferenceChanged(PropertyContainer::PropertyName name);
Chris@133 103
Chris@133 104 protected:
Chris@193 105 // make this SliceLayer method unavailable to the general public
Chris@193 106 // virtual void setModel(DenseThreeDimensionalModel *model) {
Chris@193 107 // SliceLayer::setModel(model);
Chris@193 108 // }
Chris@193 109
Chris@193 110 DenseTimeValueModel *m_originModel;
Chris@153 111 int m_channel;
Chris@153 112 bool m_channelSet;
Chris@805 113 int m_windowSize;
Chris@153 114 WindowType m_windowType;
Chris@805 115 int m_windowHopLevel;
Chris@284 116 bool m_showPeaks;
Chris@275 117 mutable bool m_newFFTNeeded;
Chris@153 118
Chris@349 119 mutable QMutex m_fftMutex;
Chris@349 120
Chris@193 121 void setupFFT();
Chris@153 122
Chris@254 123 virtual void getBiasCurve(BiasCurve &) const;
Chris@254 124 BiasCurve m_biasCurve;
Chris@254 125
Chris@905 126 virtual double getXForBin(int bin, int totalBins, double w) const;
Chris@905 127 virtual int getBinForX(double x, int totalBins, double w) const;
Chris@265 128
Chris@905 129 double getFrequencyForX(double x, double w) const;
Chris@905 130 double getXForFrequency(double freq, double w) const;
Chris@254 131
Chris@805 132 int getWindowIncrement() const {
Chris@153 133 if (m_windowHopLevel == 0) return m_windowSize;
Chris@153 134 else if (m_windowHopLevel == 1) return (m_windowSize * 3) / 4;
Chris@153 135 else return m_windowSize / (1 << (m_windowHopLevel - 1));
Chris@153 136 }
Chris@133 137 };
Chris@133 138
Chris@133 139 #endif