annotate src/Modules/Output/Graphics/GraphicsView.h @ 116:47b009f2c936

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