annotate layer/SliceLayer.h @ 802:584b11df8e4f tonioni

Single-click to move pointer needs to wait for double-click timeout (so it knows you're not starting a double-click)
author Chris Cannam
date Mon, 16 Jun 2014 12:50:27 +0100
parents 5b72899d692b
children 1d526ba11a24
rev   line source
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@193 16 #ifndef _SLICE_LAYER_H_
Chris@193 17 #define _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@193 35 // virtual void setModel(const Model *model);
Chris@193 36 // virtual const Model *getModel() const { return m_model; }
Chris@193 37 virtual const Model *getModel() const { return 0; }
Chris@193 38
Chris@193 39 void setSliceableModel(const Model *model);
Chris@193 40
Chris@133 41 virtual void paint(View *v, QPainter &paint, QRect rect) const;
Chris@133 42
Chris@198 43 virtual QString getFeatureDescription(View *v, QPoint &) const;
Chris@198 44
Chris@607 45 virtual int getVerticalScaleWidth(View *v, bool, QPainter &) const;
Chris@607 46 virtual void paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const;
Chris@195 47
Chris@287 48 virtual ColourSignificance getLayerColourSignificance() const {
Chris@287 49 return ColourAndBackgroundSignificant;
Chris@287 50 }
Chris@287 51
Chris@153 52 virtual PropertyList getProperties() const;
Chris@153 53 virtual QString getPropertyLabel(const PropertyName &) const;
Chris@335 54 virtual QString getPropertyIconName(const PropertyName &) const;
Chris@153 55 virtual PropertyType getPropertyType(const PropertyName &) const;
Chris@153 56 virtual QString getPropertyGroupName(const PropertyName &) const;
Chris@153 57 virtual int getPropertyRangeAndValue(const PropertyName &,
Chris@216 58 int *min, int *max, int *deflt) const;
Chris@153 59 virtual QString getPropertyValueLabel(const PropertyName &,
Chris@153 60 int value) const;
Chris@167 61 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
Chris@153 62 virtual void setProperty(const PropertyName &, int value);
Chris@133 63 virtual void setProperties(const QXmlAttributes &);
Chris@133 64
Chris@133 65 virtual bool getValueExtents(float &min, float &max,
Chris@133 66 bool &logarithmic, QString &unit) const;
Chris@133 67
Chris@217 68 virtual bool hasTimeXAxis() const { return false; }
Chris@217 69
Chris@248 70 virtual bool isLayerScrollable(const View *) const { return false; }
Chris@133 71
Chris@538 72 enum EnergyScale { LinearScale, MeterScale, dBScale, AbsoluteScale };
Chris@153 73
Chris@193 74 enum SamplingMode { NearestSample, SampleMean, SamplePeak };
Chris@153 75
Chris@197 76 enum PlotStyle { PlotLines, PlotSteps, PlotBlocks, PlotFilledBlocks };
Chris@153 77
Chris@193 78 enum BinScale { LinearBins, LogBins, InvertedLogBins };
Chris@153 79
Chris@197 80 void setFillColourMap(int);
Chris@197 81 int getFillColourMap() const { return m_colourMap; }
Chris@197 82
Chris@153 83 void setEnergyScale(EnergyScale);
Chris@153 84 EnergyScale getEnergyScale() const { return m_energyScale; }
Chris@153 85
Chris@193 86 void setSamplingMode(SamplingMode);
Chris@193 87 SamplingMode getSamplingMode() const { return m_samplingMode; }
Chris@153 88
Chris@193 89 void setPlotStyle(PlotStyle style);
Chris@193 90 PlotStyle getPlotStyle() const { return m_plotStyle; }
Chris@193 91
Chris@193 92 void setBinScale(BinScale scale);
Chris@193 93 BinScale getBinScale() const { return m_binScale; }
Chris@153 94
Chris@284 95 void setThreshold(float);
Chris@284 96 int getThreshold() const { return m_threshold; }
Chris@284 97
Chris@153 98 void setGain(float gain);
Chris@153 99 float getGain() const;
Chris@153 100
Chris@153 101 void setNormalize(bool n);
Chris@153 102 bool getNormalize() const;
Chris@153 103
Chris@316 104 virtual void toXml(QTextStream &stream, QString indent = "",
Chris@316 105 QString extraAttributes = "") const;
Chris@153 106
Chris@193 107 public slots:
Chris@193 108 void sliceableModelReplaced(const Model *, const Model *);
Chris@193 109 void modelAboutToBeDeleted(Model *);
Chris@133 110
Chris@133 111 protected:
Chris@265 112 virtual float getXForBin(int bin, int totalBins, float w) const;
Chris@265 113 virtual int getBinForX(float x, int totalBins, float w) const;
Chris@274 114
Chris@274 115 virtual float getYForValue(float value, const View *v, float &norm) const;
Chris@274 116 virtual float getValueForY(float y, const View *v) const;
Chris@198 117
Chris@199 118 virtual QString getFeatureDescription(View *v, QPoint &,
Chris@199 119 bool includeBinDescription,
Chris@199 120 int &minbin, int &maxbin,
Chris@199 121 int &range) const;
Chris@199 122
Chris@254 123 // This curve may, of course, be flat -- the spectrum uses it for
Chris@254 124 // normalizing the fft results by the fft size (with 1/(fftsize/2)
Chris@254 125 // in each bin).
Chris@254 126 typedef std::vector<float> BiasCurve;
Chris@254 127 virtual void getBiasCurve(BiasCurve &) const { return; }
Chris@254 128
Chris@284 129 virtual float getThresholdDb() const;
Chris@284 130
Chris@287 131 virtual int getDefaultColourHint(bool dark, bool &impose);
Chris@287 132
Chris@193 133 const DenseThreeDimensionalModel *m_sliceableModel;
Chris@197 134 int m_colourMap;
Chris@193 135 EnergyScale m_energyScale;
Chris@193 136 SamplingMode m_samplingMode;
Chris@193 137 PlotStyle m_plotStyle;
Chris@193 138 BinScale m_binScale;
Chris@193 139 bool m_normalize;
Chris@284 140 float m_threshold;
Chris@284 141 float m_initialThreshold;
Chris@193 142 float m_gain;
Chris@195 143 mutable std::vector<int> m_scalePoints;
Chris@267 144 mutable std::map<const View *, int> m_xorigins;
Chris@274 145 mutable std::map<const View *, int> m_yorigins;
Chris@274 146 mutable std::map<const View *, int> m_heights;
Chris@198 147 mutable size_t m_currentf0;
Chris@198 148 mutable size_t m_currentf1;
Chris@198 149 mutable std::vector<float> m_values;
Chris@133 150 };
Chris@133 151
Chris@133 152 #endif