annotate src/Modules/Output/Graphics/Devices/GraphicsOutputDevicePlotutils.h @ 175:384b794cf81f

- AWS
author tomwalters
date Wed, 11 Aug 2010 09:15:53 +0000
parents c5ac2f0c7fc5
children 73c6d61440ad
rev   line source
tomwalters@116 1 // Copyright 2006, Willem van Engen
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 Output device for output to a graphics file using plotutils
tomwalters@116 21 *
tomwalters@116 22 * \author Willem van Engen <cnbh@willem.engen.nl>
tomwalters@116 23 * \date created 2006/10/13
tomwalters@116 24 * \version \$Id: $
tomwalters@116 25 */
tomwalters@116 26
tomwalters@116 27 #ifndef __GRAPHICS_OUTPUT_DEVICE_PLOTUTILS_H__
tomwalters@116 28 #define __GRAPHICS_OUTPUT_DEVICE_PLOTUTILS_H__
tomwalters@116 29
tomwalters@116 30 #include <stdlib.h>
tomwalters@116 31 #include <stdio.h>
tomwalters@116 32
tomwalters@116 33 #include <plot.h>
tomwalters@116 34
tomwalters@116 35 #include "Support/util.h"
tomwalters@116 36 #include "Modules/Output/Graphics/Devices/GraphicsOutputDevice.h"
tomwalters@116 37
tomwalters@116 38 /*!
tomwalters@116 39 * \class GraphicsOutputDevicePlotutils "Output/GraphicsOutputDevicePlotutils.h"
tomwalters@116 40 * \brief Output class for output to a graphics file using plotutils
tomwalters@116 41 *
tomwalters@116 42 * This class outputs a graphics operation to file. It only supports 2d though,
tomwalters@116 43 * so the z-component is ignored.
tomwalters@116 44 */
tomwalters@116 45 class GraphicsOutputDevicePlotutils : public GraphicsOutputDevice {
tomwalters@116 46 public:
tomwalters@116 47 GraphicsOutputDevicePlotutils(Parameters *pParam);
tomwalters@116 48 virtual ~GraphicsOutputDevicePlotutils();
tomwalters@116 49
tomwalters@117 50 /*! \brief Initializes this output device, prepares plotting tools.
tomwalters@117 51 * \param sDir Directory or filename where to put images, max length
tomwalters@116 52 * is _MAX_PATH. Must end with slash!!!
tomwalters@117 53 * \return true on success, false on failure.
tomwalters@117 54 *
tomwalters@117 55 * sDir can be either a filename, in which case the output will be
tomwalters@117 56 * to that file, or a directory, in which case it will be filled
tomwalters@117 57 * with 6-digit numbered files. A new file is then created at every
tomwalters@117 58 * call to gGrab().
tomwalters@117 59 *
tomwalters@117 60 * As usual, make sure to call this function before any other. If this
tomwalters@117 61 * Initialize() failed, you shouldn't try the other functions either.
tomwalters@117 62 */
tomwalters@117 63 bool Initialize(const char *sDir);
tomwalters@117 64 bool Initialize();
tomwalters@116 65
tomwalters@116 66 void gGrab();
tomwalters@116 67 void gBeginLineStrip();
tomwalters@116 68 void gBeginQuadStrip();
tomwalters@117 69 using GraphicsOutputDevice::gVertex3f; // Because we overload it
tomwalters@117 70 void gVertex3f(float x, float y, float z);
tomwalters@117 71 void gColor3f(float r, float g, float b);
tomwalters@116 72 void gEnd();
tomwalters@117 73 void gText3f(float x, float y, float z, const char *sStr, bool bRotated = false);
tomwalters@117 74 void gRelease();
tomwalters@117 75 char* GetBuffer();
tomwalters@116 76 protected:
tomwalters@117 77 /*! \brief Open the file with given index for output
tomwalters@117 78 * \param index File number to open
tomwalters@117 79 * \return true on success, false on error
tomwalters@117 80 *
tomwalters@117 81 * This opens a file for output and sets up the plotting library.
tomwalters@117 82 */
tomwalters@117 83 bool OpenFile(unsigned int index);
tomwalters@116 84
tomwalters@117 85 //! \brief Closes a plot output file, if any is open.
tomwalters@117 86 void CloseFile();
tomwalters@116 87
tomwalters@117 88 //! \brief Internal initialisation function called by overloaded variants of Initialize()
tomwalters@117 89 void Init();
tomwalters@116 90
tomwalters@117 91 //! \brief The current output file's handle
tomwalters@117 92 FILE *m_pOutputFile;
tomwalters@117 93 //! \brief The plotutils plotter
tomwalters@117 94 int m_iPlotHandle;
tomwalters@117 95 //! \brief Output directory
tomwalters@117 96 char m_sDir[PATH_MAX];
tomwalters@117 97 //! \brief Current file number
tomwalters@117 98 unsigned int m_iFileNumber;
tomwalters@117 99 //! \brief true if this is the first vertex after gBegin()
tomwalters@117 100 bool m_bIsFirstVertex;
tomwalters@116 101
tomwalters@117 102 enum VertexType {
tomwalters@117 103 VertexTypeNone,
tomwalters@116 104 VertexTypeLine,
tomwalters@116 105 VertexTypeQuad
tomwalters@117 106 };
tomwalters@117 107 //! \brief The current vertex type
tomwalters@117 108 VertexType m_iVertexType;
tomwalters@117 109 //! \brief Begin vertex of current quad
tomwalters@117 110 float m_aPrevX[3], m_aPrevY[3];
tomwalters@117 111 //! \brief Current number of quad vertices stored
tomwalters@117 112 unsigned int m_iPrevVertexCount;
tomwalters@116 113
tomwalters@117 114 //! \brief Whether to invert the colors or not
tomwalters@117 115 bool m_bInvertColors;
tomwalters@116 116
tomwalters@117 117 //! \brief The size of the memory bitmap buffer as provided by open_memstream
tomwalters@117 118 size_t m_sMemoryBufferSize;
tomwalters@116 119
tomwalters@117 120 //! \brief Are we using a memory buffer for writing to (as opposed to a file)?
tomwalters@117 121 bool m_bUseMemoryBuffer;
tomwalters@116 122
tomwalters@117 123 //! \brief Pointer to the memory buffer in question
tomwalters@117 124 char *m_pMemoryBuffer;
tomwalters@116 125
tomwalters@117 126 //! \brief Width of the bitmap
tomwalters@117 127 unsigned int m_uWidth;
tomwalters@116 128
tomwalters@117 129 //! \brief Height of the bitmap
tomwalters@117 130 unsigned int m_uHeight;
tomwalters@116 131 };
tomwalters@116 132
tomwalters@116 133 #endif /* __GRAPHICS_OUTPUT_DEVICE_PLOTUTILS_H__ */