annotate trunk/src/Modules/Output/Graphics/Devices/GraphicsOutputDevicePlotutils.h @ 706:f8e90b5d85fd tip

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