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
|
tom@399
|
30 #include "Support/Module.h"
|
tomwalters@397
|
31 #include "Support/Parameters.h"
|
tomwalters@397
|
32 #include "Support/SignalBank.h"
|
tomwalters@397
|
33 #include "Modules/Output/Graphics/Scale/Scale.h"
|
tomwalters@397
|
34 #include "Modules/Output/Graphics/Devices/GraphicsOutputDevice.h"
|
tomwalters@397
|
35 #include "Modules/Output/Graphics/GraphAxisSpec.h"
|
tomwalters@397
|
36
|
tom@399
|
37 namespace aimc {
|
tom@399
|
38
|
tomwalters@397
|
39 /*!
|
tomwalters@397
|
40 * \class GraphicsView "Modules/Output/Graphics/GraphicsView.h"
|
tomwalters@397
|
41 * \brief General graphics view module
|
tomwalters@397
|
42 *
|
tomwalters@397
|
43 * This class is a general graph drawing class for one or more Signals.
|
tomwalters@397
|
44 * \sa Signal, SignalBank
|
tomwalters@397
|
45 */
|
tomwalters@397
|
46 class GraphicsView : public Module {
|
tomwalters@397
|
47 public:
|
tomwalters@398
|
48 /*! \brief Create a new view
|
tomwalters@398
|
49 * \param params A parameter store
|
tomwalters@398
|
50 *
|
tomwalters@398
|
51 */
|
tomwalters@398
|
52 GraphicsView(Parameters *params);
|
tomwalters@398
|
53 virtual ~GraphicsView();
|
tomwalters@397
|
54
|
tomwalters@398
|
55 /*! \brief Create a copy of this GraphicsView
|
tomwalters@398
|
56 * \param pDev Output device to bind to
|
tomwalters@398
|
57 * \return Newly created GraphicsView, to be freed by the caller.
|
tomwalters@398
|
58 * \deprecated Possibly, use Initialize()
|
tomwalters@398
|
59 */
|
tomwalters@398
|
60 virtual GraphicsView *Clone(GraphicsOutputDevice *pDev) = 0;
|
tomwalters@397
|
61
|
tomwalters@398
|
62 /*! \brief (Re-)initialize this graphics view and it's device
|
tomwalters@398
|
63 * \param pParam Main parameter store to bind to
|
tomwalters@398
|
64 * \param pDev Graphics output device to draw to
|
tomwalters@398
|
65 * \return true on success, false on error
|
tomwalters@398
|
66 *
|
tomwalters@398
|
67 * It is possible to call Initialize() multiple times for binding
|
tomwalters@398
|
68 * to another graphics device or updating the parameters. This method
|
tomwalters@398
|
69 * does read all parameters than can be changed at run-time.
|
tomwalters@398
|
70 *
|
tomwalters@398
|
71 * One of the Initialize() functions _must_ be called before actually
|
tomwalters@398
|
72 * using it for plotting.
|
tomwalters@398
|
73 */
|
tomwalters@398
|
74 virtual bool InitializeInternal(const SignalBank &bank);
|
tom@399
|
75 virtual void ResetInternal();
|
tomwalters@398
|
76 /*! \brief Set the axes' scale
|
tomwalters@398
|
77 * \param iXScale Scale type of the horizontal axis
|
tomwalters@398
|
78 * \param iYScale Scale type of the vertical axis for signal data
|
tomwalters@398
|
79 * \param iFreqScale Scale type of the vertical axis
|
tomwalters@398
|
80 * \deprecated Possibly, use AimParameters and Initialize
|
tomwalters@398
|
81 * \todo const arguments
|
tomwalters@398
|
82 */
|
tomwalters@398
|
83 virtual void SetAxisScale(Scale::ScaleType iXScale,
|
tomwalters@397
|
84 Scale::ScaleType iYScale,
|
tomwalters@397
|
85 Scale::ScaleType iFreqScale);
|
tomwalters@397
|
86
|
tomwalters@397
|
87
|
tomwalters@398
|
88 virtual void Process(const SignalBank &bank);
|
tomwalters@397
|
89
|
tomwalters@397
|
90 protected:
|
tomwalters@398
|
91 /*! \brief Plot the data of a signal
|
tomwalters@398
|
92 * \param pSig Signal to plot
|
tomwalters@398
|
93 * \param yOffset Vertical offset (between 0 and 1), where to plot 0 signal value.
|
tomwalters@398
|
94 * \param height Height of the signal to plot (between 0 and 1)
|
tomwalters@398
|
95 * \param xScale Scaling in x-direction. 1.0 makes it cover the whole length. 0.5 only the left half.
|
tomwalters@398
|
96 */
|
tomwalters@398
|
97 virtual void PlotData(const vector<float> &signal,
|
tomwalters@569
|
98 float sample_rate,
|
tomwalters@397
|
99 float yOffset,
|
tomwalters@397
|
100 float height,
|
tomwalters@397
|
101 float xScale) = 0;
|
tomwalters@569
|
102
|
tomwalters@569
|
103 virtual void PlotStrobes(const vector<float>& signal,
|
tomwalters@569
|
104 const vector<int>& strobes,
|
tomwalters@569
|
105 float sample_rate,
|
tomwalters@569
|
106 float y_offset,
|
tomwalters@569
|
107 float height,
|
tomwalters@569
|
108 float x_scale,
|
tomwalters@569
|
109 float diameter) = 0;
|
tomwalters@569
|
110
|
tomwalters@569
|
111 virtual void PlotStrobe(float x,
|
tomwalters@569
|
112 float y,
|
tomwalters@569
|
113 float val,
|
tomwalters@569
|
114 float height,
|
tomwalters@569
|
115 float diameter);
|
tomwalters@397
|
116
|
tomwalters@398
|
117 /*! \brief Plot the axes for a signal bank
|
tomwalters@398
|
118 * \param pSig Signal to plot the axes for
|
tomwalters@398
|
119 */
|
tomwalters@398
|
120 virtual void PlotAxes(const SignalBank &bank) = 0;
|
tomwalters@397
|
121
|
tomwalters@398
|
122 //! \brief Calls the correct m_pDev->gBegin*() for the current PlotType
|
tomwalters@398
|
123 virtual void BeginDataStrip();
|
tomwalters@398
|
124 /*! \brief Plot a data point (with smart reduction)
|
tomwalters@398
|
125 * \param x X-coordinate of point (in OpenGL space)
|
tomwalters@398
|
126 * \param y y-coordinate of point (in OpenGL space)
|
tomwalters@398
|
127 * \param val Value to plot (from -0.5..0.5)
|
tomwalters@398
|
128 * \param height Height to use for plotting (in OpenGL space)
|
tomwalters@398
|
129 * \param isLast True if this is the last point of this batch to draw
|
tomwalters@398
|
130 *
|
tomwalters@398
|
131 * This method tries to reduce the number of actual graphics output
|
tomwalters@398
|
132 * operations using it's interpolation methods (e.g., a line).
|
tomwalters@398
|
133 */
|
tomwalters@398
|
134 virtual void PlotDataPoint(float x,
|
tomwalters@397
|
135 float y,
|
tomwalters@397
|
136 float val,
|
tomwalters@397
|
137 float height,
|
tomwalters@397
|
138 bool isLast);
|
tomwalters@397
|
139
|
tomwalters@398
|
140 /*! \brief Plot a data point (directly)
|
tomwalters@398
|
141 * \param x X-coordinate of point (in OpenGL space)
|
tomwalters@398
|
142 * \param y y-coordinate of point (in OpenGL space)
|
tomwalters@398
|
143 * \param val Value to plot (from -0.5..0.5)
|
tomwalters@398
|
144 * \param height Height to use for plotting (in OpenGL space)
|
tomwalters@398
|
145 */
|
tomwalters@398
|
146 virtual void PlotDataPointDirect(float x, float y, float val, float height);
|
tomwalters@397
|
147
|
tomwalters@398
|
148 //! \brief Where to plot to
|
tomwalters@398
|
149 GraphicsOutputDevice *m_pDev;
|
tomwalters@397
|
150
|
tomwalters@398
|
151 //! \brief Axes specifications
|
tomwalters@398
|
152 GraphAxisSpec *m_pAxisX, *m_pAxisY, *m_pAxisFreq;
|
tomwalters@397
|
153
|
tomwalters@398
|
154 //! \brief Graph margins
|
tomwalters@398
|
155 float m_fMarginLeft, m_fMarginRight, m_fMarginTop, m_fMarginBottom;
|
tomwalters@397
|
156
|
tomwalters@398
|
157 //! \brief Whether labels are plotted or not
|
tomwalters@398
|
158 bool m_bPlotLabels;
|
tomwalters@397
|
159
|
tomwalters@398
|
160 //! \brief Graphics device type
|
tomwalters@398
|
161 enum GraphType {
|
tomwalters@398
|
162 GraphTypeNone,
|
tomwalters@397
|
163 GraphTypeLine,
|
tomwalters@397
|
164 GraphTypeColormap
|
tomwalters@398
|
165 };
|
tomwalters@398
|
166 GraphType m_iGraphType;
|
tomwalters@397
|
167
|
tomwalters@398
|
168 /*! \brief Minimum distance between subsequent values for plotting a point
|
tomwalters@398
|
169 *
|
tomwalters@398
|
170 * This value is set in Initialize() from parameter graph.mindistance.
|
tomwalters@398
|
171 */
|
tomwalters@398
|
172 float m_fMinPlotDistance;
|
tomwalters@397
|
173
|
tomwalters@398
|
174 //! \brief true if this next point is the first of the strip
|
tomwalters@398
|
175 bool m_bFirstPoint;
|
tomwalters@398
|
176 //! \brief Value of previously plotted point
|
tomwalters@398
|
177 float m_fPrevVal, m_fPrevX, m_fPrevY, m_fPrevHeight;
|
tomwalters@398
|
178 //! \brief Number of times m_fValPrev was within range m_fMinPlotDistance
|
tomwalters@398
|
179 int m_iPrevValEqual;
|
tomwalters@411
|
180 float frame_rate_;
|
tomwalters@411
|
181 int previous_start_time_;
|
tom@399
|
182
|
tom@399
|
183 bool initialized_;
|
tomwalters@569
|
184 bool plotting_strobes_;
|
tomwalters@397
|
185 };
|
tom@399
|
186 } // namespace aimc
|
tomwalters@397
|
187 #endif /* __GRAPHICS_VIEW_H__ */
|