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@1284: #ifndef SV_SLICE_LAYER_H Chris@1284: #define SV_SLICE_LAYER_H Chris@133: Chris@287: #include "SingleColourLayer.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@287: class SliceLayer : public SingleColourLayer Chris@133: { Chris@133: Q_OBJECT Chris@133: Chris@133: public: Chris@193: SliceLayer(); Chris@193: ~SliceLayer(); Chris@133: Chris@1406: const Model *getModel() const override { return 0; } Chris@193: Chris@193: void setSliceableModel(const Model *model); Chris@193: Chris@1406: void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const override; Chris@133: Chris@1406: QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const override; Chris@198: Chris@1406: int getVerticalScaleWidth(LayerGeometryProvider *v, bool, QPainter &) const override; Chris@1406: void paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect rect) const override; Chris@195: Chris@1406: ColourSignificance getLayerColourSignificance() const override { Chris@287: return ColourAndBackgroundSignificant; Chris@287: } Chris@287: Chris@1406: bool hasLightBackground() const override; Chris@1281: Chris@1406: PropertyList getProperties() const override; Chris@1406: QString getPropertyLabel(const PropertyName &) const override; Chris@1406: QString getPropertyIconName(const PropertyName &) const override; Chris@1406: PropertyType getPropertyType(const PropertyName &) const override; Chris@1406: QString getPropertyGroupName(const PropertyName &) const override; Chris@1406: int getPropertyRangeAndValue(const PropertyName &, Chris@1406: int *min, int *max, int *deflt) const override; Chris@1406: QString getPropertyValueLabel(const PropertyName &, Chris@1406: int value) const override; Chris@1406: RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const override; Chris@1406: void setProperty(const PropertyName &, int value) override; Chris@1406: void setProperties(const QXmlAttributes &) override; Chris@133: Chris@1406: bool getValueExtents(double &min, double &max, Chris@1406: bool &logarithmic, QString &unit) const override; Chris@133: Chris@1406: bool getDisplayExtents(double &min, double &max) const override; Chris@1406: bool setDisplayExtents(double min, double max) override; Chris@1238: Chris@1406: int getVerticalZoomSteps(int &defaultStep) const override; Chris@1406: int getCurrentVerticalZoomStep() const override; Chris@1406: void setVerticalZoomStep(int) override; Chris@1406: RangeMapper *getNewVerticalZoomRangeMapper() const override; Chris@1238: Chris@1389: virtual bool hasTimeXAxis() const override { return false; } Chris@1389: Chris@1389: virtual void zoomToRegion(const LayerGeometryProvider *, QRect) override; Chris@217: Chris@1406: bool isLayerScrollable(const LayerGeometryProvider *) const override { return false; } Chris@133: Chris@538: enum EnergyScale { LinearScale, MeterScale, dBScale, AbsoluteScale }; 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@1281: bool usesSolidColour() const { return m_plotStyle == PlotFilledBlocks; } Chris@1281: 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@284: void setThreshold(float); Chris@905: float getThreshold() const { return m_threshold; } Chris@284: 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@1406: void toXml(QTextStream &stream, QString indent = "", Chris@1406: QString extraAttributes = "") const override; 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@1386: /// Convert a (possibly non-integral) bin into x-coord. May be overridden Chris@1238: virtual double getXForBin(const LayerGeometryProvider *, double bin) const; Chris@1386: Chris@1386: /// Convert an x-coord into (possibly non-integral) bin. May be overridden Chris@1238: virtual double getBinForX(const LayerGeometryProvider *, double x) const; Chris@274: Chris@1386: /// Convert a point such as a bin number into x-coord, given max & Chris@1386: /// min. For use by getXForBin etc Chris@1386: double getXForScalePoint(const LayerGeometryProvider *, Chris@1386: double p, double pmin, double pmax) const; Chris@1386: Chris@1386: /// Convert an x-coord into a point such as a bin number, given Chris@1386: /// max & min. For use by getBinForX etc Chris@1386: double getScalePointForX(const LayerGeometryProvider *, Chris@1386: double x, double pmin, double pmax) const; Chris@1386: Chris@1238: virtual double getYForValue(const LayerGeometryProvider *v, double value, double &norm) const; Chris@1238: virtual double getValueForY(const LayerGeometryProvider *v, double y) const; Chris@198: Chris@918: virtual QString getFeatureDescriptionAux(LayerGeometryProvider *v, QPoint &, Chris@805: bool includeBinDescription, Chris@805: int &minbin, int &maxbin, Chris@805: 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@284: virtual float getThresholdDb() const; Chris@284: Chris@1406: int getDefaultColourHint(bool dark, bool &impose) override; Chris@287: Chris@1400: // Determine how the bins are lined up Chris@1400: // horizontally. BinsCentredOnScalePoint means we operate like a Chris@1400: // spectrum, where a bin maps to a specific frequency, and so the Chris@1400: // bin should be visually centred on the scale point that Chris@1400: // corresponds to that frequency. BinsSpanScalePoints means we Chris@1400: // have numbered or labelled bins that are not mapped to a Chris@1400: // continuous scale, like a typical chromagram output, and so bin Chris@1400: // N spans from scale point N to N+1. This is a fundamental Chris@1400: // quality of the class or input data, not a user-configurable Chris@1400: // property. Chris@1400: // Chris@1400: enum BinAlignment { Chris@1400: BinsCentredOnScalePoints, Chris@1400: BinsSpanScalePoints Chris@1400: }; Chris@1400: Chris@193: const DenseThreeDimensionalModel *m_sliceableModel; Chris@1400: BinAlignment m_binAlignment; Chris@197: int m_colourMap; Chris@1362: bool m_colourInverted; 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@284: float m_threshold; Chris@284: float m_initialThreshold; Chris@193: float m_gain; Chris@1238: int m_minbin; Chris@1238: int m_maxbin; Chris@195: mutable std::vector m_scalePoints; Chris@1284: mutable int m_scalePaintHeight; Chris@1238: mutable std::map m_xorigins; // LayerGeometryProvider id -> x Chris@1238: mutable std::map m_yorigins; // LayerGeometryProvider id -> y Chris@1238: mutable std::map m_heights; // LayerGeometryProvider id -> h Chris@906: mutable sv_frame_t m_currentf0; Chris@906: mutable sv_frame_t m_currentf1; Chris@198: mutable std::vector m_values; Chris@133: }; Chris@133: Chris@133: #endif