Mercurial > hg > svgui
diff layer/Colour3DPlotLayer.h @ 1148:c0d841cb8ab9 tony-2.0-integration
Merge latest SV 3.0 branch code
author | Chris Cannam |
---|---|
date | Fri, 19 Aug 2016 15:58:57 +0100 |
parents | d930ff725f64 |
children | dd3901fe8623 |
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.h Tue Oct 20 12:55:09 2015 +0100 +++ b/layer/Colour3DPlotLayer.h Fri Aug 19 15:58:57 2016 +0100 @@ -13,10 +13,14 @@ COPYING included with this distribution for more information. */ -#ifndef _COLOUR_3D_PLOT_H_ -#define _COLOUR_3D_PLOT_H_ +#ifndef COLOUR_3D_PLOT_LAYER_H +#define COLOUR_3D_PLOT_LAYER_H #include "SliceableLayer.h" +#include "VerticalBinLayer.h" + +#include "ColourScale.h" +#include "Colour3DPlotRenderer.h" #include "data/model/DenseThreeDimensionalModel.h" @@ -30,14 +34,11 @@ * colour range. Its source is a DenseThreeDimensionalModel. * * This was the original implementation for the spectrogram view, but - * it was replaced with a more efficient implementation that derived - * the spectrogram itself from a DenseTimeValueModel instead of using - * a three-dimensional model. This class is retained in case it - * becomes useful, but it will probably need some cleaning up if it's - * ever actually used. + * it was replaced for that purpose with a more efficient + * implementation that derived the spectrogram itself from a + * DenseTimeValueModel instead of using a three-dimensional model. */ - -class Colour3DPlotLayer : public SliceableLayer +class Colour3DPlotLayer : public VerticalBinLayer { Q_OBJECT @@ -50,6 +51,7 @@ } virtual const Model *getModel() const { return m_model; } virtual void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; + virtual void setSynchronousPainting(bool synchronous); virtual int getVerticalScaleWidth(LayerGeometryProvider *v, bool, QPainter &) const; virtual void paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect rect) const; @@ -81,19 +83,14 @@ int *min, int *max, int *deflt) const; virtual QString getPropertyValueLabel(const PropertyName &, int value) const; + virtual QString getPropertyValueIconName(const PropertyName &, + int value) const; virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const; virtual void setProperty(const PropertyName &, int value); virtual void setProperties(const QXmlAttributes &); - enum ColourScale { - LinearScale, - LogScale, - PlusMinusOneScale, - AbsoluteScale - }; - - void setColourScale(ColourScale); - ColourScale getColourScale() const { return m_colourScale; } + void setColourScale(ColourScaleType); + ColourScaleType getColourScale() const { return m_colourScale; } void setColourMap(int map); int getColourMap() const; @@ -104,11 +101,6 @@ */ void setGain(float gain); float getGain() const; - - enum BinScale { - LinearBinScale, - LogBinScale - }; /** * Specify the scale for the y axis. @@ -117,31 +109,20 @@ BinScale getBinScale() const; /** - * Normalize each column to its maximum value, independent of its - * neighbours. + * Specify the normalization mode for individual columns. */ - void setNormalizeColumns(bool n); - bool getNormalizeColumns() const; + void setNormalization(ColumnNormalization); + ColumnNormalization getNormalization() const; /** - * Normalize each value against the maximum in the visible region. + * Specify whether to normalize the visible area. */ - void setNormalizeVisibleArea(bool n); + void setNormalizeVisibleArea(bool); bool getNormalizeVisibleArea() const; - /** - * Normalize each column to its maximum value, and then scale by - * the log of the (absolute) maximum value. - */ - void setNormalizeHybrid(bool n); - bool getNormalizeHybrid() const; - void setInvertVertical(bool i); bool getInvertVertical() const; - void setShowRectified(bool); - bool getShowRectified() const { return m_rectified; } - void setOpaque(bool i); bool getOpaque() const; @@ -176,42 +157,50 @@ protected: const DenseThreeDimensionalModel *m_model; // I do not own this - mutable QImage *m_cache; - mutable QImage *m_peaksCache; - mutable int m_cacheValidStart; - mutable int m_cacheValidEnd; - - ColourScale m_colourScale; - bool m_colourScaleSet; - int m_colourMap; - float m_gain; - BinScale m_binScale; - bool m_normalizeColumns; - bool m_normalizeVisibleArea; - bool m_normalizeHybrid; - bool m_invertVertical; - bool m_rectified; - bool m_opaque; - bool m_smooth; - int m_peakResolution; + ColourScaleType m_colourScale; + bool m_colourScaleSet; + int m_colourMap; + float m_gain; + BinScale m_binScale; + ColumnNormalization m_normalization; // of individual columns + bool m_normalizeVisibleArea; + bool m_invertVertical; + bool m_opaque; + bool m_smooth; + int m_peakResolution; // Minimum and maximum bin numbers visible within the view. We // always snap to whole bins at view edges. - int m_miny; - int m_maxy; + int m_miny; + int m_maxy; + bool m_synchronous; + + static ColourScaleType convertToColourScale(int value); + static int convertFromColourScale(ColourScaleType); + static std::pair<ColumnNormalization, bool> convertToColumnNorm(int value); + static int convertFromColumnNorm(ColumnNormalization norm, bool visible); + + mutable Dense3DModelPeakCache *m_peakCache; + const int m_peakCacheDivisor; + Dense3DModelPeakCache *getPeakCache() const; + + typedef std::map<int, MagnitudeRange> ViewMagMap; // key is view id + mutable ViewMagMap m_viewMags; + + typedef std::map<int, Colour3DPlotRenderer *> ViewRendererMap; // key is view id + mutable ViewRendererMap m_renderers; + + Colour3DPlotRenderer *getRenderer(const LayerGeometryProvider *) const; + void invalidateRenderers(); + /** * Return the y coordinate at which the given bin "starts" * (i.e. at the bottom of the bin, if the given bin is an integer * and the vertical scale is the usual way up). Bin number may be * fractional, to obtain a position part-way through a bin. */ - double getYForBin(LayerGeometryProvider *, double bin) const; - - /** - * As getYForBin, but rounding to integer values. - */ - int getIYForBin(LayerGeometryProvider *, int bin) const; + double getYForBin(const LayerGeometryProvider *, double bin) const; /** * Return the bin number, possibly fractional, at the given y @@ -219,25 +208,13 @@ * at which the bins "start" (i.e. the bottom of the visible bin, * if the vertical scale is the usual way up). */ - double getBinForY(LayerGeometryProvider *, double y) const; - - /** - * As getBinForY, but rounding to integer values. - */ - int getIBinForY(LayerGeometryProvider *, int y) const; + double getBinForY(const LayerGeometryProvider *, double y) const; DenseThreeDimensionalModel::Column getColumn(int col) const; - /** - * True if we have the opaque or smooth flag set, or if the cells - * are so small you can't see their borders. False for big, - * translucent cells. - */ - bool shouldPaintDenseIn(const LayerGeometryProvider *) const; + int getColourScaleWidth(QPainter &) const; - int getColourScaleWidth(QPainter &) const; - void fillCache(int firstBin, int lastBin) const; - void paintDense(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; + void paintWithRenderer(LayerGeometryProvider *v, QPainter &paint, QRect rect) const; }; #endif