tomwalters@116: // Copyright 2006-2010, Willem van Engen, Thomas Walters tomwalters@116: // tomwalters@116: // AIM-C: A C++ implementation of the Auditory Image Model tomwalters@116: // http://www.acousticscale.org/AIMC tomwalters@116: // tomwalters@116: // Licensed under the Apache License, Version 2.0 (the "License"); tomwalters@116: // you may not use this file except in compliance with the License. tomwalters@116: // You may obtain a copy of the License at tomwalters@116: // tomwalters@116: // http://www.apache.org/licenses/LICENSE-2.0 tomwalters@116: // tomwalters@116: // Unless required by applicable law or agreed to in writing, software tomwalters@116: // distributed under the License is distributed on an "AS IS" BASIS, tomwalters@116: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. tomwalters@116: // See the License for the specific language governing permissions and tomwalters@116: // limitations under the License. tomwalters@116: tomwalters@116: /*! tomwalters@116: * \file tomwalters@116: * \brief General graphics view definition tomwalters@116: * tomwalters@116: * \author Willem van Engen tomwalters@116: * \date created 2006/09/26 tomwalters@116: * \version \$Id: $ tomwalters@116: */ tomwalters@116: tomwalters@116: #ifndef __GRAPHICS_VIEW_H__ tomwalters@116: #define __GRAPHICS_VIEW_H__ tomwalters@116: tomwalters@116: #include "Support/Parameters.h" tomwalters@116: #include "Support/SignalBank.h" tomwalters@116: #include "Modules/Output/Graphics/Scale/Scale.h" tomwalters@116: #include "Modules/Output/Graphics/Devices/GraphicsOutputDevice.h" tomwalters@116: #include "Modules/Output/Graphics/GraphAxisSpec.h" tomwalters@116: tomwalters@116: /*! tomwalters@116: * \class GraphicsView "Modules/Output/Graphics/GraphicsView.h" tomwalters@116: * \brief General graphics view module tomwalters@116: * tomwalters@116: * This class is a general graph drawing class for one or more Signals. tomwalters@116: * \sa Signal, SignalBank tomwalters@116: */ tomwalters@116: class GraphicsView : public Module { tomwalters@116: public: tomwalters@116: /*! \brief Create a new view tomwalters@116: * \param params A parameter store tomwalters@116: * tomwalters@116: */ tomwalters@116: GraphicsView(Parameters *params); tomwalters@116: virtual ~GraphicsView(); tomwalters@116: tomwalters@116: /*! \brief Create a copy of this GraphicsView tomwalters@116: * \param pDev Output device to bind to tomwalters@116: * \return Newly created GraphicsView, to be freed by the caller. tomwalters@116: * \deprecated Possibly, use Initialize() tomwalters@116: */ tomwalters@116: virtual GraphicsView *Clone(GraphicsOutputDevice *pDev) = 0; tomwalters@116: tomwalters@116: /*! \brief (Re-)initialize this graphics view and it's device tomwalters@116: * \param pParam Main parameter store to bind to tomwalters@116: * \param pDev Graphics output device to draw to tomwalters@116: * \return true on success, false on error tomwalters@116: * tomwalters@116: * It is possible to call Initialize() multiple times for binding tomwalters@116: * to another graphics device or updating the parameters. This method tomwalters@116: * does read all parameters than can be changed at run-time. tomwalters@116: * tomwalters@116: * One of the Initialize() functions _must_ be called before actually tomwalters@116: * using it for plotting. tomwalters@116: */ tomwalters@116: virtual bool InitializeInternal(const SignalBank &bank); tomwalters@116: tomwalters@116: /*! \brief Set the axes' scale tomwalters@116: * \param iXScale Scale type of the horizontal axis tomwalters@116: * \param iYScale Scale type of the vertical axis for signal data tomwalters@116: * \param iFreqScale Scale type of the vertical axis tomwalters@116: * \deprecated Possibly, use AimParameters and Initialize tomwalters@116: * \todo const arguments tomwalters@116: */ tomwalters@116: virtual void SetAxisScale(Scale::ScaleType iXScale, tomwalters@116: Scale::ScaleType iYScale, tomwalters@116: Scale::ScaleType iFreqScale); tomwalters@116: tomwalters@116: tomwalters@116: virtual void Process(const SignalBank &bank); tomwalters@116: tomwalters@116: protected: tomwalters@116: /*! \brief Plot the data of a signal tomwalters@116: * \param pSig Signal to plot tomwalters@116: * \param yOffset Vertical offset (between 0 and 1), where to plot 0 signal value. tomwalters@116: * \param height Height of the signal to plot (between 0 and 1) tomwalters@116: * \param xScale Scaling in x-direction. 1.0 makes it cover the whole length. 0.5 only the left half. tomwalters@116: */ tomwalters@116: virtual void PlotData(const vector &signal, tomwalters@116: float yOffset, tomwalters@116: float height, tomwalters@116: float xScale) = 0; tomwalters@116: tomwalters@116: /*! \brief Plot the axes for a signal bank tomwalters@116: * \param pSig Signal to plot the axes for tomwalters@116: */ tomwalters@116: virtual void PlotAxes(const SignalBank &bank) = 0; tomwalters@116: tomwalters@116: //! \brief Calls the correct m_pDev->gBegin*() for the current PlotType tomwalters@116: virtual void BeginDataStrip(); tomwalters@116: /*! \brief Plot a data point (with smart reduction) tomwalters@116: * \param x X-coordinate of point (in OpenGL space) tomwalters@116: * \param y y-coordinate of point (in OpenGL space) tomwalters@116: * \param val Value to plot (from -0.5..0.5) tomwalters@116: * \param height Height to use for plotting (in OpenGL space) tomwalters@116: * \param isLast True if this is the last point of this batch to draw tomwalters@116: * tomwalters@116: * This method tries to reduce the number of actual graphics output tomwalters@116: * operations using it's interpolation methods (e.g., a line). tomwalters@116: */ tomwalters@116: virtual void PlotDataPoint(float x, tomwalters@116: float y, tomwalters@116: float val, tomwalters@116: float height, tomwalters@116: bool isLast); tomwalters@116: tomwalters@116: /*! \brief Plot a data point (directly) tomwalters@116: * \param x X-coordinate of point (in OpenGL space) tomwalters@116: * \param y y-coordinate of point (in OpenGL space) tomwalters@116: * \param val Value to plot (from -0.5..0.5) tomwalters@116: * \param height Height to use for plotting (in OpenGL space) tomwalters@116: */ tomwalters@116: virtual void PlotDataPointDirect(float x, float y, float val, float height); tomwalters@116: tomwalters@116: /*! \brief Plot a strobe point tomwalters@116: * \param x X-coordinate of centre (in OpenGL space) tomwalters@116: * \param y Y-coordinate of centre (in OpenGL space) tomwalters@116: * \param size Size of the block drawn tomwalters@116: * \param colour_r Red colour intensity tomwalters@116: * \param colour_g Green colour intensity tomwalters@116: * \param colour_b Blue colour intensity tomwalters@116: */ tomwalters@116: virtual void PlotStrobePoint(float x, tomwalters@116: float y, tomwalters@116: float size, tomwalters@116: float color_r, tomwalters@116: float color_g, tomwalters@116: float color_b); tomwalters@116: tomwalters@116: //! \brief Where to plot to tomwalters@116: GraphicsOutputDevice *m_pDev; tomwalters@116: tomwalters@116: //! \brief Main parameter store tomwalters@116: Parameters *m_pParam; tomwalters@116: tomwalters@116: //! \brief Axes specifications tomwalters@116: GraphAxisSpec *m_pAxisX, *m_pAxisY, *m_pAxisFreq; tomwalters@116: tomwalters@116: //! \brief Graph margins tomwalters@116: float m_fMarginLeft, m_fMarginRight, m_fMarginTop, m_fMarginBottom; tomwalters@116: tomwalters@116: //! \brief Whether labels are plotted or not tomwalters@116: bool m_bPlotLabels; tomwalters@116: tomwalters@116: //! \brief Graphics device type tomwalters@116: enum GraphType { tomwalters@116: GraphTypeNone, tomwalters@116: GraphTypeLine, tomwalters@116: GraphTypeColormap tomwalters@116: }; tomwalters@116: GraphType m_iGraphType; tomwalters@116: tomwalters@116: /*! \brief Minimum distance between subsequent values for plotting a point tomwalters@116: * tomwalters@116: * This value is set in Initialize() from parameter graph.mindistance. tomwalters@116: */ tomwalters@116: float m_fMinPlotDistance; tomwalters@116: tomwalters@116: //! \brief true if this next point is the first of the strip tomwalters@116: bool m_bFirstPoint; tomwalters@116: //! \brief Value of previously plotted point tomwalters@116: float m_fPrevVal, m_fPrevX, m_fPrevY, m_fPrevHeight; tomwalters@116: //! \brief Number of times m_fValPrev was within range m_fMinPlotDistance tomwalters@116: int m_iPrevValEqual; tomwalters@116: }; tomwalters@116: tomwalters@116: #endif /* __GRAPHICS_VIEW_H__ */