annotate layer/SliceLayer.h @ 1269:f2894944c6b8

Make the overlays at either end translucent, so they don't completely crop out any underlying text or necessary info (e.g. selection extents)
author Chris Cannam
date Thu, 19 Apr 2018 14:35:59 +0100
parents a34a2a25907c
children fc9d9f1103fa
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@916 41 virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const;
Chris@133 42
Chris@918 43 virtual QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const;
Chris@198 44
Chris@918 45 virtual int getVerticalScaleWidth(LayerGeometryProvider *v, bool, QPainter &) const;
Chris@918 46 virtual void paintVerticalScale(LayerGeometryProvider *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@1266 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@905 65 virtual bool getValueExtents(double &min, double &max,
Chris@133 66 bool &logarithmic, QString &unit) const;
Chris@133 67
Chris@1238 68 virtual bool getDisplayExtents(double &min, double &max) const;
Chris@1238 69 virtual bool setDisplayExtents(double min, double max);
Chris@1238 70
Chris@1238 71 virtual int getVerticalZoomSteps(int &defaultStep) const;
Chris@1238 72 virtual int getCurrentVerticalZoomStep() const;
Chris@1238 73 virtual void setVerticalZoomStep(int);
Chris@1238 74 virtual RangeMapper *getNewVerticalZoomRangeMapper() const;
Chris@1238 75
Chris@217 76 virtual bool hasTimeXAxis() const { return false; }
Chris@217 77
Chris@918 78 virtual bool isLayerScrollable(const LayerGeometryProvider *) const { return false; }
Chris@133 79
Chris@538 80 enum EnergyScale { LinearScale, MeterScale, dBScale, AbsoluteScale };
Chris@153 81
Chris@193 82 enum SamplingMode { NearestSample, SampleMean, SamplePeak };
Chris@153 83
Chris@197 84 enum PlotStyle { PlotLines, PlotSteps, PlotBlocks, PlotFilledBlocks };
Chris@153 85
Chris@193 86 enum BinScale { LinearBins, LogBins, InvertedLogBins };
Chris@153 87
Chris@197 88 void setFillColourMap(int);
Chris@197 89 int getFillColourMap() const { return m_colourMap; }
Chris@197 90
Chris@153 91 void setEnergyScale(EnergyScale);
Chris@153 92 EnergyScale getEnergyScale() const { return m_energyScale; }
Chris@153 93
Chris@193 94 void setSamplingMode(SamplingMode);
Chris@193 95 SamplingMode getSamplingMode() const { return m_samplingMode; }
Chris@153 96
Chris@193 97 void setPlotStyle(PlotStyle style);
Chris@193 98 PlotStyle getPlotStyle() const { return m_plotStyle; }
Chris@193 99
Chris@193 100 void setBinScale(BinScale scale);
Chris@193 101 BinScale getBinScale() const { return m_binScale; }
Chris@153 102
Chris@284 103 void setThreshold(float);
Chris@905 104 float getThreshold() const { return m_threshold; }
Chris@284 105
Chris@153 106 void setGain(float gain);
Chris@153 107 float getGain() const;
Chris@153 108
Chris@153 109 void setNormalize(bool n);
Chris@153 110 bool getNormalize() const;
Chris@153 111
Chris@316 112 virtual void toXml(QTextStream &stream, QString indent = "",
Chris@316 113 QString extraAttributes = "") const;
Chris@153 114
Chris@193 115 public slots:
Chris@193 116 void sliceableModelReplaced(const Model *, const Model *);
Chris@193 117 void modelAboutToBeDeleted(Model *);
Chris@133 118
Chris@133 119 protected:
Chris@1238 120 virtual double getXForBin(const LayerGeometryProvider *, double bin) const;
Chris@1238 121 virtual double getBinForX(const LayerGeometryProvider *, double x) const;
Chris@274 122
Chris@1238 123 virtual double getYForValue(const LayerGeometryProvider *v, double value, double &norm) const;
Chris@1238 124 virtual double getValueForY(const LayerGeometryProvider *v, double y) const;
Chris@198 125
Chris@918 126 virtual QString getFeatureDescriptionAux(LayerGeometryProvider *v, QPoint &,
Chris@805 127 bool includeBinDescription,
Chris@805 128 int &minbin, int &maxbin,
Chris@805 129 int &range) const;
Chris@199 130
Chris@254 131 // This curve may, of course, be flat -- the spectrum uses it for
Chris@254 132 // normalizing the fft results by the fft size (with 1/(fftsize/2)
Chris@254 133 // in each bin).
Chris@254 134 typedef std::vector<float> BiasCurve;
Chris@254 135 virtual void getBiasCurve(BiasCurve &) const { return; }
Chris@254 136
Chris@284 137 virtual float getThresholdDb() const;
Chris@284 138
Chris@287 139 virtual int getDefaultColourHint(bool dark, bool &impose);
Chris@287 140
Chris@193 141 const DenseThreeDimensionalModel *m_sliceableModel;
Chris@197 142 int m_colourMap;
Chris@193 143 EnergyScale m_energyScale;
Chris@193 144 SamplingMode m_samplingMode;
Chris@193 145 PlotStyle m_plotStyle;
Chris@193 146 BinScale m_binScale;
Chris@193 147 bool m_normalize;
Chris@284 148 float m_threshold;
Chris@284 149 float m_initialThreshold;
Chris@193 150 float m_gain;
Chris@1238 151 int m_minbin;
Chris@1238 152 int m_maxbin;
Chris@195 153 mutable std::vector<int> m_scalePoints;
Chris@1238 154 mutable std::map<int, int> m_xorigins; // LayerGeometryProvider id -> x
Chris@1238 155 mutable std::map<int, int> m_yorigins; // LayerGeometryProvider id -> y
Chris@1238 156 mutable std::map<int, int> m_heights; // LayerGeometryProvider id -> h
Chris@906 157 mutable sv_frame_t m_currentf0;
Chris@906 158 mutable sv_frame_t m_currentf1;
Chris@198 159 mutable std::vector<float> m_values;
Chris@133 160 };
Chris@133 161
Chris@133 162 #endif