annotate trunk/src/Modules/Output/Graphics/GraphicsView.h @ 398:3ee03a6b95a0

- All \t to two spaces (style guide compliance)
author tomwalters
date Fri, 15 Oct 2010 05:46:53 +0000
parents 7a573750b186
children 7bfed53caacf
rev   line source
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@398 45 /*! \brief Create a new view
tomwalters@398 46 * \param params A parameter store
tomwalters@398 47 *
tomwalters@398 48 */
tomwalters@398 49 GraphicsView(Parameters *params);
tomwalters@398 50 virtual ~GraphicsView();
tomwalters@397 51
tomwalters@398 52 /*! \brief Create a copy of this GraphicsView
tomwalters@398 53 * \param pDev Output device to bind to
tomwalters@398 54 * \return Newly created GraphicsView, to be freed by the caller.
tomwalters@398 55 * \deprecated Possibly, use Initialize()
tomwalters@398 56 */
tomwalters@398 57 virtual GraphicsView *Clone(GraphicsOutputDevice *pDev) = 0;
tomwalters@397 58
tomwalters@398 59 /*! \brief (Re-)initialize this graphics view and it's device
tomwalters@398 60 * \param pParam Main parameter store to bind to
tomwalters@398 61 * \param pDev Graphics output device to draw to
tomwalters@398 62 * \return true on success, false on error
tomwalters@398 63 *
tomwalters@398 64 * It is possible to call Initialize() multiple times for binding
tomwalters@398 65 * to another graphics device or updating the parameters. This method
tomwalters@398 66 * does read all parameters than can be changed at run-time.
tomwalters@398 67 *
tomwalters@398 68 * One of the Initialize() functions _must_ be called before actually
tomwalters@398 69 * using it for plotting.
tomwalters@398 70 */
tomwalters@398 71 virtual bool InitializeInternal(const SignalBank &bank);
tomwalters@397 72
tomwalters@398 73 /*! \brief Set the axes' scale
tomwalters@398 74 * \param iXScale Scale type of the horizontal axis
tomwalters@398 75 * \param iYScale Scale type of the vertical axis for signal data
tomwalters@398 76 * \param iFreqScale Scale type of the vertical axis
tomwalters@398 77 * \deprecated Possibly, use AimParameters and Initialize
tomwalters@398 78 * \todo const arguments
tomwalters@398 79 */
tomwalters@398 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@398 85 virtual void Process(const SignalBank &bank);
tomwalters@397 86
tomwalters@397 87 protected:
tomwalters@398 88 /*! \brief Plot the data of a signal
tomwalters@398 89 * \param pSig Signal to plot
tomwalters@398 90 * \param yOffset Vertical offset (between 0 and 1), where to plot 0 signal value.
tomwalters@398 91 * \param height Height of the signal to plot (between 0 and 1)
tomwalters@398 92 * \param xScale Scaling in x-direction. 1.0 makes it cover the whole length. 0.5 only the left half.
tomwalters@398 93 */
tomwalters@398 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@398 99 /*! \brief Plot the axes for a signal bank
tomwalters@398 100 * \param pSig Signal to plot the axes for
tomwalters@398 101 */
tomwalters@398 102 virtual void PlotAxes(const SignalBank &bank) = 0;
tomwalters@397 103
tomwalters@398 104 //! \brief Calls the correct m_pDev->gBegin*() for the current PlotType
tomwalters@398 105 virtual void BeginDataStrip();
tomwalters@398 106 /*! \brief Plot a data point (with smart reduction)
tomwalters@398 107 * \param x X-coordinate of point (in OpenGL space)
tomwalters@398 108 * \param y y-coordinate of point (in OpenGL space)
tomwalters@398 109 * \param val Value to plot (from -0.5..0.5)
tomwalters@398 110 * \param height Height to use for plotting (in OpenGL space)
tomwalters@398 111 * \param isLast True if this is the last point of this batch to draw
tomwalters@398 112 *
tomwalters@398 113 * This method tries to reduce the number of actual graphics output
tomwalters@398 114 * operations using it's interpolation methods (e.g., a line).
tomwalters@398 115 */
tomwalters@398 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@398 122 /*! \brief Plot a data point (directly)
tomwalters@398 123 * \param x X-coordinate of point (in OpenGL space)
tomwalters@398 124 * \param y y-coordinate of point (in OpenGL space)
tomwalters@398 125 * \param val Value to plot (from -0.5..0.5)
tomwalters@398 126 * \param height Height to use for plotting (in OpenGL space)
tomwalters@398 127 */
tomwalters@398 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@398 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@398 145 //! \brief Where to plot to
tomwalters@398 146 GraphicsOutputDevice *m_pDev;
tomwalters@397 147
tomwalters@398 148 //! \brief Main parameter store
tomwalters@398 149 Parameters *m_pParam;
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@397 180 };
tomwalters@397 181
tomwalters@397 182 #endif /* __GRAPHICS_VIEW_H__ */