Mercurial > hg > svgui
comparison layer/Colour3DPlotRenderer.h @ 1073:cb4c9fb37ddc spectrogram-minor-refactor
More renderer stubbing
author | Chris Cannam |
---|---|
date | Wed, 29 Jun 2016 11:53:00 +0100 |
parents | 76b50b48e1e4 |
children | 2e1d6c2ed3ee |
comparison
equal
deleted
inserted
replaced
1072:76b50b48e1e4 | 1073:cb4c9fb37ddc |
---|---|
15 | 15 |
16 #ifndef COLOUR_3D_PLOT_RENDERER_H | 16 #ifndef COLOUR_3D_PLOT_RENDERER_H |
17 #define COLOUR_3D_PLOT_RENDERER_H | 17 #define COLOUR_3D_PLOT_RENDERER_H |
18 | 18 |
19 #include "ColourScale.h" | 19 #include "ColourScale.h" |
20 #include "ScrollableImageCache.h" | |
20 | 21 |
21 #include "base/ColumnOp.h" | 22 #include "base/ColumnOp.h" |
23 #include "base/MagnitudeRange.h" | |
22 | 24 |
25 #include <QRect> | |
26 #include <QPainter> | |
27 #include <QImage> | |
28 | |
29 class LayerGeometryProvider; | |
23 class DenseThreeDimensionalModel; | 30 class DenseThreeDimensionalModel; |
24 class Dense3DModelPeakCache; | 31 class Dense3DModelPeakCache; |
25 class FFTModel; | 32 class FFTModel; |
26 | |
27 // We will have one of these per view, for each layer | |
28 | 33 |
29 class Colour3DPlotRenderer | 34 class Colour3DPlotRenderer |
30 { | 35 { |
31 public: | 36 public: |
32 enum BinDisplay { | 37 enum BinDisplay { |
37 | 42 |
38 enum BinScale { | 43 enum BinScale { |
39 LinearBinScale, | 44 LinearBinScale, |
40 LogBinScale | 45 LogBinScale |
41 }; | 46 }; |
42 | 47 |
48 struct Sources { | |
49 Sources() : geometryProvider(0), source(0), peaks(0), fft(0) { } | |
50 | |
51 // These must all outlive this class | |
52 LayerGeometryProvider *geometryProvider; // always | |
53 DenseThreeDimensionalModel *source; // always | |
54 Dense3DModelPeakCache *peaks; // optionally | |
55 FFTModel *fft; // optionally | |
56 }; | |
57 | |
43 struct Parameters { | 58 struct Parameters { |
44 | |
45 Parameters() : | 59 Parameters() : |
46 source(0), peaks(0), fft(0), | |
47 colourScale(ColourScale::Parameters()), | 60 colourScale(ColourScale::Parameters()), |
48 normalization(ColumnOp::NoNormalization), | 61 normalization(ColumnOp::NoNormalization), |
49 binDisplay(AllBins), binScale(LinearBinScale), | 62 binDisplay(AllBins), |
50 alwaysOpaque(false), interpolate(false), invertVertical(false) { } | 63 binScale(LinearBinScale), |
51 | 64 alwaysOpaque(false), |
52 DenseThreeDimensionalModel *source; // always | 65 interpolate(false), |
53 Dense3DModelPeakCache *peaks; // optionally | 66 invertVertical(false) { } |
54 FFTModel *fft; // optionally | |
55 | 67 |
56 ColourScale colourScale; // complete ColourScale object by value | 68 ColourScale colourScale; // complete ColourScale object by value |
57 ColumnOp::Normalization normalization; | 69 ColumnOp::Normalization normalization; |
58 BinDisplay binDisplay; | 70 BinDisplay binDisplay; |
59 BinScale binScale; | 71 BinScale binScale; |
60 bool alwaysOpaque; | 72 bool alwaysOpaque; |
61 bool interpolate; | 73 bool interpolate; |
62 bool invertVertical; | 74 bool invertVertical; |
63 }; | 75 }; |
64 | 76 |
65 Colour3DPlotRenderer(Parameters parameters) : | 77 Colour3DPlotRenderer(Sources sources, Parameters parameters) : |
66 m_params(parameters) | 78 m_sources(sources), |
79 m_params(parameters), | |
80 m_bufferResolution(PixelResolution) | |
67 { } | 81 { } |
68 | 82 |
83 struct RenderResult { | |
84 /** | |
85 * The rect that was actually rendered. May be equal to the | |
86 * rect that was requested to render, or may be smaller if | |
87 * time ran out and the complete flag was not set. | |
88 */ | |
89 QRect rendered; | |
90 | |
91 /** | |
92 * The magnitude range of the data in the rendered area. | |
93 */ | |
94 MagnitudeRange range; | |
95 }; | |
96 | |
97 /** | |
98 * Render the requested area using the given painter, obtaining | |
99 * geometry (e.g. start frame) from the stored | |
100 * LayerGeometryProvider. | |
101 * | |
102 * If complete is false, as much of the rect will be rendered as | |
103 * can be managed given internal time constraints. The returned | |
104 * QRect (the rendered field in the RenderResult struct) will | |
105 * contain the area that was rendered. Note that we always render | |
106 * the full requested height, it's only width that is | |
107 * time-constrained. | |
108 * | |
109 * If complete is true, the whole rect will be rendered and the | |
110 * returned QRect will be equal to the passed QRect. | |
111 */ | |
112 RenderResult render(QPainter &paint, | |
113 QRect rect, | |
114 bool complete); | |
115 | |
69 private: | 116 private: |
117 Sources m_sources; | |
70 Parameters m_params; | 118 Parameters m_params; |
71 | 119 |
72 //!!! we do not have the ScrollableImageCache here; in | 120 // Draw buffer is the target of each partial repaint. It is always |
73 //!!! SpectrogramLayer terms we render onto the draw buffer | 121 // at view height (not model height) and is cleared and repainted |
122 // on each fragment render. The only reason it's stored as a data | |
123 // member is to avoid reallocation. | |
124 QImage m_drawBuffer; | |
74 | 125 |
126 // Indicates whether the draw buffer is rendered at bin resolution | |
127 // or at pixel resolution. Pixel resolution is used when the zoom | |
128 // level is such that each pixel is backed by more than one bin; | |
129 // bin resolution is used when the zoom level is such that each | |
130 // bin is drawn to more than one pixel. | |
131 enum BufferResolution { | |
132 BinResolution, | |
133 PixelResolution | |
134 }; | |
135 BufferResolution m_bufferResolution; | |
136 | |
137 // Image cache is our persistent record of the visible area. It is | |
138 // always the same size as the view (i.e. the paint size reported | |
139 // by the LayerGeometryProvider) and is scrolled and partially | |
140 // repainted internally as appropriate. A render request is | |
141 // carried out by repainting to cache (via the draw buffer) any | |
142 // area that is being requested but is not valid in the cache, and | |
143 // then repainting from cache to the requested painter. | |
144 ScrollableImageCache m_cache; | |
145 | |
146 | |
75 //!!! fft model scaling? | 147 //!!! fft model scaling? |
76 | 148 |
77 //!!! should we own the Dense3DModelPeakCache here? or should it persist | 149 //!!! should we own the Dense3DModelPeakCache here? or should it persist |
78 }; | 150 }; |
79 | 151 |