tomwalters@397
|
1 // Copyright 2006-2010, Willem van Engen, Thomas Walters
|
tomwalters@397
|
2 //
|
tomwalters@397
|
3 // AIM-C: A C++ implementation of the Auditory Image Model
|
tomwalters@397
|
4 // http://www.acousticscale.org/AIMC
|
tomwalters@397
|
5 //
|
tomwalters@397
|
6 // Licensed under the Apache License, Version 2.0 (the "License");
|
tomwalters@397
|
7 // you may not use this file except in compliance with the License.
|
tomwalters@397
|
8 // You may obtain a copy of the License at
|
tomwalters@397
|
9 //
|
tomwalters@397
|
10 // http://www.apache.org/licenses/LICENSE-2.0
|
tomwalters@397
|
11 //
|
tomwalters@397
|
12 // Unless required by applicable law or agreed to in writing, software
|
tomwalters@397
|
13 // distributed under the License is distributed on an "AS IS" BASIS,
|
tomwalters@397
|
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
tomwalters@397
|
15 // See the License for the specific language governing permissions and
|
tomwalters@397
|
16 // limitations under the License.
|
tomwalters@397
|
17
|
tomwalters@397
|
18 /*!
|
tomwalters@397
|
19 * \file
|
tomwalters@397
|
20 * \brief General graphics view definition
|
tomwalters@397
|
21 *
|
tomwalters@397
|
22 * \author Willem van Engen <cnbh@willem.engen.nl>
|
tomwalters@397
|
23 * \date created 2006/09/26
|
tomwalters@397
|
24 * \version \$Id: $
|
tomwalters@397
|
25 */
|
tomwalters@397
|
26
|
tomwalters@397
|
27 #ifndef __GRAPHICS_VIEW_H__
|
tomwalters@397
|
28 #define __GRAPHICS_VIEW_H__
|
tomwalters@397
|
29
|
tomwalters@397
|
30 #include "Support/Parameters.h"
|
tomwalters@397
|
31 #include "Support/SignalBank.h"
|
tomwalters@397
|
32 #include "Modules/Output/Graphics/Scale/Scale.h"
|
tomwalters@397
|
33 #include "Modules/Output/Graphics/Devices/GraphicsOutputDevice.h"
|
tomwalters@397
|
34 #include "Modules/Output/Graphics/GraphAxisSpec.h"
|
tomwalters@397
|
35
|
tomwalters@397
|
36 /*!
|
tomwalters@397
|
37 * \class GraphicsView "Modules/Output/Graphics/GraphicsView.h"
|
tomwalters@397
|
38 * \brief General graphics view module
|
tomwalters@397
|
39 *
|
tomwalters@397
|
40 * This class is a general graph drawing class for one or more Signals.
|
tomwalters@397
|
41 * \sa Signal, SignalBank
|
tomwalters@397
|
42 */
|
tomwalters@397
|
43 class GraphicsView : public Module {
|
tomwalters@397
|
44 public:
|
tomwalters@397
|
45 /*! \brief Create a new view
|
tomwalters@397
|
46 * \param params A parameter store
|
tomwalters@397
|
47 *
|
tomwalters@397
|
48 */
|
tomwalters@397
|
49 GraphicsView(Parameters *params);
|
tomwalters@397
|
50 virtual ~GraphicsView();
|
tomwalters@397
|
51
|
tomwalters@397
|
52 /*! \brief Create a copy of this GraphicsView
|
tomwalters@397
|
53 * \param pDev Output device to bind to
|
tomwalters@397
|
54 * \return Newly created GraphicsView, to be freed by the caller.
|
tomwalters@397
|
55 * \deprecated Possibly, use Initialize()
|
tomwalters@397
|
56 */
|
tomwalters@397
|
57 virtual GraphicsView *Clone(GraphicsOutputDevice *pDev) = 0;
|
tomwalters@397
|
58
|
tomwalters@397
|
59 /*! \brief (Re-)initialize this graphics view and it's device
|
tomwalters@397
|
60 * \param pParam Main parameter store to bind to
|
tomwalters@397
|
61 * \param pDev Graphics output device to draw to
|
tomwalters@397
|
62 * \return true on success, false on error
|
tomwalters@397
|
63 *
|
tomwalters@397
|
64 * It is possible to call Initialize() multiple times for binding
|
tomwalters@397
|
65 * to another graphics device or updating the parameters. This method
|
tomwalters@397
|
66 * does read all parameters than can be changed at run-time.
|
tomwalters@397
|
67 *
|
tomwalters@397
|
68 * One of the Initialize() functions _must_ be called before actually
|
tomwalters@397
|
69 * using it for plotting.
|
tomwalters@397
|
70 */
|
tomwalters@397
|
71 virtual bool InitializeInternal(const SignalBank &bank);
|
tomwalters@397
|
72
|
tomwalters@397
|
73 /*! \brief Set the axes' scale
|
tomwalters@397
|
74 * \param iXScale Scale type of the horizontal axis
|
tomwalters@397
|
75 * \param iYScale Scale type of the vertical axis for signal data
|
tomwalters@397
|
76 * \param iFreqScale Scale type of the vertical axis
|
tomwalters@397
|
77 * \deprecated Possibly, use AimParameters and Initialize
|
tomwalters@397
|
78 * \todo const arguments
|
tomwalters@397
|
79 */
|
tomwalters@397
|
80 virtual void SetAxisScale(Scale::ScaleType iXScale,
|
tomwalters@397
|
81 Scale::ScaleType iYScale,
|
tomwalters@397
|
82 Scale::ScaleType iFreqScale);
|
tomwalters@397
|
83
|
tomwalters@397
|
84
|
tomwalters@397
|
85 virtual void Process(const SignalBank &bank);
|
tomwalters@397
|
86
|
tomwalters@397
|
87 protected:
|
tomwalters@397
|
88 /*! \brief Plot the data of a signal
|
tomwalters@397
|
89 * \param pSig Signal to plot
|
tomwalters@397
|
90 * \param yOffset Vertical offset (between 0 and 1), where to plot 0 signal value.
|
tomwalters@397
|
91 * \param height Height of the signal to plot (between 0 and 1)
|
tomwalters@397
|
92 * \param xScale Scaling in x-direction. 1.0 makes it cover the whole length. 0.5 only the left half.
|
tomwalters@397
|
93 */
|
tomwalters@397
|
94 virtual void PlotData(const vector<float> &signal,
|
tomwalters@397
|
95 float yOffset,
|
tomwalters@397
|
96 float height,
|
tomwalters@397
|
97 float xScale) = 0;
|
tomwalters@397
|
98
|
tomwalters@397
|
99 /*! \brief Plot the axes for a signal bank
|
tomwalters@397
|
100 * \param pSig Signal to plot the axes for
|
tomwalters@397
|
101 */
|
tomwalters@397
|
102 virtual void PlotAxes(const SignalBank &bank) = 0;
|
tomwalters@397
|
103
|
tomwalters@397
|
104 //! \brief Calls the correct m_pDev->gBegin*() for the current PlotType
|
tomwalters@397
|
105 virtual void BeginDataStrip();
|
tomwalters@397
|
106 /*! \brief Plot a data point (with smart reduction)
|
tomwalters@397
|
107 * \param x X-coordinate of point (in OpenGL space)
|
tomwalters@397
|
108 * \param y y-coordinate of point (in OpenGL space)
|
tomwalters@397
|
109 * \param val Value to plot (from -0.5..0.5)
|
tomwalters@397
|
110 * \param height Height to use for plotting (in OpenGL space)
|
tomwalters@397
|
111 * \param isLast True if this is the last point of this batch to draw
|
tomwalters@397
|
112 *
|
tomwalters@397
|
113 * This method tries to reduce the number of actual graphics output
|
tomwalters@397
|
114 * operations using it's interpolation methods (e.g., a line).
|
tomwalters@397
|
115 */
|
tomwalters@397
|
116 virtual void PlotDataPoint(float x,
|
tomwalters@397
|
117 float y,
|
tomwalters@397
|
118 float val,
|
tomwalters@397
|
119 float height,
|
tomwalters@397
|
120 bool isLast);
|
tomwalters@397
|
121
|
tomwalters@397
|
122 /*! \brief Plot a data point (directly)
|
tomwalters@397
|
123 * \param x X-coordinate of point (in OpenGL space)
|
tomwalters@397
|
124 * \param y y-coordinate of point (in OpenGL space)
|
tomwalters@397
|
125 * \param val Value to plot (from -0.5..0.5)
|
tomwalters@397
|
126 * \param height Height to use for plotting (in OpenGL space)
|
tomwalters@397
|
127 */
|
tomwalters@397
|
128 virtual void PlotDataPointDirect(float x, float y, float val, float height);
|
tomwalters@397
|
129
|
tomwalters@397
|
130 /*! \brief Plot a strobe point
|
tomwalters@397
|
131 * \param x X-coordinate of centre (in OpenGL space)
|
tomwalters@397
|
132 * \param y Y-coordinate of centre (in OpenGL space)
|
tomwalters@397
|
133 * \param size Size of the block drawn
|
tomwalters@397
|
134 * \param colour_r Red colour intensity
|
tomwalters@397
|
135 * \param colour_g Green colour intensity
|
tomwalters@397
|
136 * \param colour_b Blue colour intensity
|
tomwalters@397
|
137 */
|
tomwalters@397
|
138 virtual void PlotStrobePoint(float x,
|
tomwalters@397
|
139 float y,
|
tomwalters@397
|
140 float size,
|
tomwalters@397
|
141 float color_r,
|
tomwalters@397
|
142 float color_g,
|
tomwalters@397
|
143 float color_b);
|
tomwalters@397
|
144
|
tomwalters@397
|
145 //! \brief Where to plot to
|
tomwalters@397
|
146 GraphicsOutputDevice *m_pDev;
|
tomwalters@397
|
147
|
tomwalters@397
|
148 //! \brief Main parameter store
|
tomwalters@397
|
149 Parameters *m_pParam;
|
tomwalters@397
|
150
|
tomwalters@397
|
151 //! \brief Axes specifications
|
tomwalters@397
|
152 GraphAxisSpec *m_pAxisX, *m_pAxisY, *m_pAxisFreq;
|
tomwalters@397
|
153
|
tomwalters@397
|
154 //! \brief Graph margins
|
tomwalters@397
|
155 float m_fMarginLeft, m_fMarginRight, m_fMarginTop, m_fMarginBottom;
|
tomwalters@397
|
156
|
tomwalters@397
|
157 //! \brief Whether labels are plotted or not
|
tomwalters@397
|
158 bool m_bPlotLabels;
|
tomwalters@397
|
159
|
tomwalters@397
|
160 //! \brief Graphics device type
|
tomwalters@397
|
161 enum GraphType {
|
tomwalters@397
|
162 GraphTypeNone,
|
tomwalters@397
|
163 GraphTypeLine,
|
tomwalters@397
|
164 GraphTypeColormap
|
tomwalters@397
|
165 };
|
tomwalters@397
|
166 GraphType m_iGraphType;
|
tomwalters@397
|
167
|
tomwalters@397
|
168 /*! \brief Minimum distance between subsequent values for plotting a point
|
tomwalters@397
|
169 *
|
tomwalters@397
|
170 * This value is set in Initialize() from parameter graph.mindistance.
|
tomwalters@397
|
171 */
|
tomwalters@397
|
172 float m_fMinPlotDistance;
|
tomwalters@397
|
173
|
tomwalters@397
|
174 //! \brief true if this next point is the first of the strip
|
tomwalters@397
|
175 bool m_bFirstPoint;
|
tomwalters@397
|
176 //! \brief Value of previously plotted point
|
tomwalters@397
|
177 float m_fPrevVal, m_fPrevX, m_fPrevY, m_fPrevHeight;
|
tomwalters@397
|
178 //! \brief Number of times m_fValPrev was within range m_fMinPlotDistance
|
tomwalters@397
|
179 int m_iPrevValEqual;
|
tomwalters@397
|
180 };
|
tomwalters@397
|
181
|
tomwalters@397
|
182 #endif /* __GRAPHICS_VIEW_H__ */
|