SliceLayer.h

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

Generated on Wed Feb 20 15:45:28 2008 for SonicVisualiser by  doxygen 1.5.1