Chris@133: Chris@133: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@133: Chris@133: /* Chris@133: Sonic Visualiser Chris@133: An audio file viewer and annotation editor. Chris@133: Centre for Digital Music, Queen Mary, University of London. Chris@182: This file copyright 2006 QMUL. Chris@133: Chris@133: This program is free software; you can redistribute it and/or Chris@133: modify it under the terms of the GNU General Public License as Chris@133: published by the Free Software Foundation; either version 2 of the Chris@133: License, or (at your option) any later version. See the file Chris@133: COPYING included with this distribution for more information. Chris@133: */ Chris@133: Chris@193: #ifndef _SLICE_LAYER_H_ Chris@193: #define _SLICE_LAYER_H_ Chris@133: Chris@133: #include "Layer.h" Chris@133: Chris@153: #include "base/Window.h" Chris@153: Chris@193: #include "data/model/DenseThreeDimensionalModel.h" Chris@133: Chris@133: #include Chris@133: Chris@193: class SliceLayer : public Layer Chris@133: { Chris@133: Q_OBJECT Chris@133: Chris@133: public: Chris@193: SliceLayer(); Chris@193: ~SliceLayer(); Chris@133: Chris@193: // virtual void setModel(const Model *model); Chris@193: // virtual const Model *getModel() const { return m_model; } Chris@193: virtual const Model *getModel() const { return 0; } Chris@193: Chris@193: void setSliceableModel(const Model *model); Chris@193: Chris@133: virtual void paint(View *v, QPainter &paint, QRect rect) const; Chris@133: Chris@198: virtual QString getFeatureDescription(View *v, QPoint &) const; Chris@198: Chris@195: virtual int getVerticalScaleWidth(View *v, QPainter &) const; Chris@195: virtual void paintVerticalScale(View *v, QPainter &paint, QRect rect) const; Chris@195: Chris@153: virtual PropertyList getProperties() const; Chris@153: virtual QString getPropertyLabel(const PropertyName &) const; Chris@153: virtual PropertyType getPropertyType(const PropertyName &) const; Chris@153: virtual QString getPropertyGroupName(const PropertyName &) const; Chris@153: virtual int getPropertyRangeAndValue(const PropertyName &, Chris@216: int *min, int *max, int *deflt) const; Chris@153: virtual QString getPropertyValueLabel(const PropertyName &, Chris@153: int value) const; Chris@167: virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const; Chris@153: virtual void setProperty(const PropertyName &, int value); Chris@133: virtual void setProperties(const QXmlAttributes &); Chris@133: Chris@133: virtual bool getValueExtents(float &min, float &max, Chris@133: bool &logarithmic, QString &unit) const; Chris@133: Chris@217: virtual bool hasTimeXAxis() const { return false; } Chris@217: Chris@248: virtual bool isLayerScrollable(const View *) const { return false; } Chris@133: Chris@193: enum EnergyScale { LinearScale, MeterScale, dBScale }; Chris@153: Chris@193: enum SamplingMode { NearestSample, SampleMean, SamplePeak }; Chris@153: Chris@197: enum PlotStyle { PlotLines, PlotSteps, PlotBlocks, PlotFilledBlocks }; Chris@153: Chris@193: enum BinScale { LinearBins, LogBins, InvertedLogBins }; Chris@153: Chris@153: void setBaseColour(QColor); Chris@153: QColor getBaseColour() const { return m_colour; } Chris@153: Chris@197: void setFillColourMap(int); Chris@197: int getFillColourMap() const { return m_colourMap; } Chris@197: Chris@153: void setEnergyScale(EnergyScale); Chris@153: EnergyScale getEnergyScale() const { return m_energyScale; } Chris@153: Chris@193: void setSamplingMode(SamplingMode); Chris@193: SamplingMode getSamplingMode() const { return m_samplingMode; } Chris@153: Chris@193: void setPlotStyle(PlotStyle style); Chris@193: PlotStyle getPlotStyle() const { return m_plotStyle; } Chris@193: Chris@193: void setBinScale(BinScale scale); Chris@193: BinScale getBinScale() const { return m_binScale; } Chris@153: Chris@153: void setGain(float gain); Chris@153: float getGain() const; Chris@153: Chris@153: void setNormalize(bool n); Chris@153: bool getNormalize() const; Chris@153: Chris@153: virtual QString toXmlString(QString indent = "", Chris@153: QString extraAttributes = "") const; Chris@153: Chris@193: public slots: Chris@193: void sliceableModelReplaced(const Model *, const Model *); Chris@193: void modelAboutToBeDeleted(Model *); Chris@133: Chris@133: protected: Chris@265: virtual float getXForBin(int bin, int totalBins, float w) const; Chris@265: virtual int getBinForX(float x, int totalBins, float w) const; Chris@274: Chris@274: virtual float getYForValue(float value, const View *v, float &norm) const; Chris@274: virtual float getValueForY(float y, const View *v) const; Chris@198: Chris@199: virtual QString getFeatureDescription(View *v, QPoint &, Chris@199: bool includeBinDescription, Chris@199: int &minbin, int &maxbin, Chris@199: int &range) const; Chris@199: Chris@254: // This curve may, of course, be flat -- the spectrum uses it for Chris@254: // normalizing the fft results by the fft size (with 1/(fftsize/2) Chris@254: // in each bin). Chris@254: typedef std::vector BiasCurve; Chris@254: virtual void getBiasCurve(BiasCurve &) const { return; } Chris@254: Chris@193: const DenseThreeDimensionalModel *m_sliceableModel; Chris@193: QColor m_colour; Chris@197: int m_colourMap; Chris@193: EnergyScale m_energyScale; Chris@193: SamplingMode m_samplingMode; Chris@193: PlotStyle m_plotStyle; Chris@193: BinScale m_binScale; Chris@193: bool m_normalize; Chris@193: float m_gain; Chris@195: mutable std::vector m_scalePoints; Chris@267: mutable std::map m_xorigins; Chris@274: mutable std::map m_yorigins; Chris@274: mutable std::map m_heights; Chris@198: mutable size_t m_currentf0; Chris@198: mutable size_t m_currentf1; Chris@198: mutable std::vector m_values; Chris@133: }; Chris@133: Chris@133: #endif