svgui
1.9
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Sonic Visualiser 00005 An audio file viewer and annotation editor. 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file copyright 2006 QMUL. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #ifndef _SLICE_LAYER_H_ 00017 #define _SLICE_LAYER_H_ 00018 00019 #include "SingleColourLayer.h" 00020 00021 #include "base/Window.h" 00022 00023 #include "data/model/DenseThreeDimensionalModel.h" 00024 00025 #include <QColor> 00026 00027 class SliceLayer : public SingleColourLayer 00028 { 00029 Q_OBJECT 00030 00031 public: 00032 SliceLayer(); 00033 ~SliceLayer(); 00034 00035 // virtual void setModel(const Model *model); 00036 // virtual const Model *getModel() const { return m_model; } 00037 virtual const Model *getModel() const { return 0; } 00038 00039 void setSliceableModel(const Model *model); 00040 00041 virtual void paint(View *v, QPainter &paint, QRect rect) const; 00042 00043 virtual QString getFeatureDescription(View *v, QPoint &) const; 00044 00045 virtual int getVerticalScaleWidth(View *v, bool, QPainter &) const; 00046 virtual void paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const; 00047 00048 virtual ColourSignificance getLayerColourSignificance() const { 00049 return ColourAndBackgroundSignificant; 00050 } 00051 00052 virtual PropertyList getProperties() const; 00053 virtual QString getPropertyLabel(const PropertyName &) const; 00054 virtual QString getPropertyIconName(const PropertyName &) const; 00055 virtual PropertyType getPropertyType(const PropertyName &) const; 00056 virtual QString getPropertyGroupName(const PropertyName &) const; 00057 virtual int getPropertyRangeAndValue(const PropertyName &, 00058 int *min, int *max, int *deflt) const; 00059 virtual QString getPropertyValueLabel(const PropertyName &, 00060 int value) const; 00061 virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const; 00062 virtual void setProperty(const PropertyName &, int value); 00063 virtual void setProperties(const QXmlAttributes &); 00064 00065 virtual bool getValueExtents(float &min, float &max, 00066 bool &logarithmic, QString &unit) const; 00067 00068 virtual bool hasTimeXAxis() const { return false; } 00069 00070 virtual bool isLayerScrollable(const View *) const { return false; } 00071 00072 enum EnergyScale { LinearScale, MeterScale, dBScale, AbsoluteScale }; 00073 00074 enum SamplingMode { NearestSample, SampleMean, SamplePeak }; 00075 00076 enum PlotStyle { PlotLines, PlotSteps, PlotBlocks, PlotFilledBlocks }; 00077 00078 enum BinScale { LinearBins, LogBins, InvertedLogBins }; 00079 00080 void setFillColourMap(int); 00081 int getFillColourMap() const { return m_colourMap; } 00082 00083 void setEnergyScale(EnergyScale); 00084 EnergyScale getEnergyScale() const { return m_energyScale; } 00085 00086 void setSamplingMode(SamplingMode); 00087 SamplingMode getSamplingMode() const { return m_samplingMode; } 00088 00089 void setPlotStyle(PlotStyle style); 00090 PlotStyle getPlotStyle() const { return m_plotStyle; } 00091 00092 void setBinScale(BinScale scale); 00093 BinScale getBinScale() const { return m_binScale; } 00094 00095 void setThreshold(float); 00096 int getThreshold() const { return m_threshold; } 00097 00098 void setGain(float gain); 00099 float getGain() const; 00100 00101 void setNormalize(bool n); 00102 bool getNormalize() const; 00103 00104 virtual void toXml(QTextStream &stream, QString indent = "", 00105 QString extraAttributes = "") const; 00106 00107 public slots: 00108 void sliceableModelReplaced(const Model *, const Model *); 00109 void modelAboutToBeDeleted(Model *); 00110 00111 protected: 00112 virtual float getXForBin(int bin, int totalBins, float w) const; 00113 virtual int getBinForX(float x, int totalBins, float w) const; 00114 00115 virtual float getYForValue(float value, const View *v, float &norm) const; 00116 virtual float getValueForY(float y, const View *v) const; 00117 00118 virtual QString getFeatureDescriptionAux(View *v, QPoint &, 00119 bool includeBinDescription, 00120 int &minbin, int &maxbin, 00121 int &range) const; 00122 00123 // This curve may, of course, be flat -- the spectrum uses it for 00124 // normalizing the fft results by the fft size (with 1/(fftsize/2) 00125 // in each bin). 00126 typedef std::vector<float> BiasCurve; 00127 virtual void getBiasCurve(BiasCurve &) const { return; } 00128 00129 virtual float getThresholdDb() const; 00130 00131 virtual int getDefaultColourHint(bool dark, bool &impose); 00132 00133 const DenseThreeDimensionalModel *m_sliceableModel; 00134 int m_colourMap; 00135 EnergyScale m_energyScale; 00136 SamplingMode m_samplingMode; 00137 PlotStyle m_plotStyle; 00138 BinScale m_binScale; 00139 bool m_normalize; 00140 float m_threshold; 00141 float m_initialThreshold; 00142 float m_gain; 00143 mutable std::vector<int> m_scalePoints; 00144 mutable std::map<const View *, int> m_xorigins; 00145 mutable std::map<const View *, int> m_yorigins; 00146 mutable std::map<const View *, int> m_heights; 00147 mutable int m_currentf0; 00148 mutable int m_currentf1; 00149 mutable std::vector<float> m_values; 00150 }; 00151 00152 #endif