GLSupport.h

Go to the documentation of this file.
00001 //# GLSupport.h: GLLogIO and a couple support routines.
00002 //# Copyright (C) 2001
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
00027 
00028 // <summary>
00029 //      Support functions for GLPixelCanvas.
00030 // </summary>
00031 // <synopsis>
00032 // The GLLogIO class extends the LogIO class to add tracing support.
00033 // Also, a couple of miscellaneous support routines are defined.
00034 // </synopsis>
00035 // <prerequisite>
00036 // <li> <linkto class="LogIO">LogIO</linkto>
00037 // </prerequisite>
00038 // <use visibility=local>
00039 //
00040 // <thrown>
00041 //  None
00042 // </thrown>
00043 //
00044 
00045 #ifndef TRIALDISPLAY_GLSUPPORT_H
00046 #define TRIALDISPLAY_GLSUPPORT_H
00047 
00048 #include <casa/aips.h>
00049 #include <casa/Logging/LogIO.h>
00050 #include <casa/BasicSL/String.h>
00051 
00052 namespace casa { //# NAMESPACE CASA - BEGIN
00053 
00054 // GLLogIO adds tracing support to the AIPS++ LogIO object.
00055         class GLLogIO : public LogIO {
00056         public:
00057                 GLLogIO();
00058                 virtual ~GLLogIO();
00059                 // Print tracing information. Also calls glcheck.
00060                 // This is the main use for GLLogIO.
00061                 // nspaces is the number of spaces to indent name and any errors.
00062                 // If errorsonly is True, don't print anything if there are no
00063                 // errors.
00064                 void trace(const char *name, int nspaces, Bool errorsonly=False);
00065 
00066                 // Append a line to buffer then add a newline.
00067                 // msg is indented by nspaces spaces. msg may contain newline
00068                 // characters.
00069                 void append(const char *msg, uInt nspaces=0);
00070                 // Adds nspaces to buffer.
00071                 void indent(uInt nspaces=0);
00072                 // Deletes current buffer contents.
00073                 void clear();
00074                 // Copies any current OpenGL error messages to internal buffer.
00075                 int glcheck(uInt nspaces);
00076 
00077                 // Logging to standard AIPS++ disrupts trace formatting. These
00078                 // routines allow redirecting or delaying output.
00079                 // NOTE: There is only 1 instance of the use iostream flag or String
00080                 // for all instances of GLLogIO.
00081 
00082                 // Post messages to an iostream instead of LogIO object.
00083                 static void postToStream(Bool useStream=False);
00084 
00085                 // Post messages to str for later use. Disables if NULL.
00086                 // If str is non NULL, no output is done until postString is called.
00087                 // Replacing an existing string does not cause the existing string
00088                 // to be posted.
00089                 static void postToString(String *str=NULL);
00090 
00091                 // If an output string exists, copy it to an output stream if
00092                 // it exists. If the output stream doesn't exist, copy it to
00093                 // the LogIO object. The string is then cleared.
00094                 // Ignore if the string doesn't exist.
00095                 void postString();
00096                 // Copy string to either output stream or LogIO object. The string
00097                 // is not cleared.
00098                 void postString(const String &str);
00099                 // Copy internal buffer to output. Then clear internal buffer.
00100                 void post();
00101         private:
00102         private:
00103                 String  buffer_;
00104                 static Bool postToStream_;
00105                 static String   *ostring_;
00106         };
00107 
00108         enum GLTraceLevel {GLTraceNone, GLTraceErrors=1, GLTraceInfo=2,
00109                            GLTraceCalls=4, GLTraceImages=8,
00110                            GLTraceGraphics=0x10, GLTraceMath=0x20,
00111                            GLTraceOther=0x40,
00112                            GLTraceNormal= 0x3F, GLTraceAll= ~0
00113                           };
00114 
00115 // Convert various OpenGL constants to their string representations.
00116         const char *GLbufferToString(int b);
00117         const char *GLformatToString(GLenum format);
00118 // Given a glPushAttrib argument, append the string with the arg's
00119 // string representation.
00120         void GLAttribToString(GLbitfield bits, String &str);
00121 
00122 //const char *GLtypeToString(GLenum type);
00123 
00124 } //# NAMESPACE CASA - END
00125 
00126 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1