OpenFOAM logo
Open Source CFD Toolkit

GLstream.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     GLstream
00027 
00028 Description
00029 
00030 SourceFiles
00031     Gstream.C
00032     GstreamIO.C
00033 
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef GLstream_H
00038 #define GLstream_H
00039 
00040 #include <GL/gl.h>
00041 #include <GL/glx.h>
00042 
00043 #include <X11/Xlib.h>
00044 #include <X11/Xutil.h>
00045 
00046 #include "List.H"
00047 #include "Gstream.H"
00048 #include "lineStyle.H"
00049 #include "shapes2D.H"
00050 #include "GEvent.H"
00051 #include "colour.H"
00052 
00053 
00054 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00055 
00056 namespace Foam
00057 {
00058 
00059 /*---------------------------------------------------------------------------*\
00060                            Class GLstream Declaration
00061 \*---------------------------------------------------------------------------*/
00062 
00063 class GLstream
00064 :
00065     public virtual Gstream
00066 {
00067     // Private data
00068 
00069         Display *mydisplay;
00070 
00071 
00072     List<short> dashSty;
00073     GLuint base;      // something to do with plotting characters on the screen
00074 
00075     // X() and Y() : return the raw GLstream coordinates associated
00076     // with particular points
00077 
00078     double x(const point2D&);
00079     double y(const point2D&);
00080 
00081     // and the X and Y values of the point associated with a particular
00082     // coord
00083 
00084     double x(const coord2D&);
00085     double y(const coord2D&);
00086 
00087     // convert a point to the appropriate coord
00088 
00089     coord2D P2C(const point2D&);
00090 
00091     // and the other way around
00092 
00093     point2D C2P(const coord2D&);
00094 
00095     //- open a window
00096     void openSesame(const colour&, const colour&);
00097 
00098     short convertLinestyleToGL(const scalarList&);
00099 
00100     // deal with characters for fonts
00101 
00102     void makeRasterFont();
00103     void printString(char *s);
00104 
00105 
00106 public:
00107 
00108     // Constructors
00109 
00110         // Construct from components
00111         GLstream
00112         (
00113             const word&,
00114             const colour&,
00115             const colour&,
00116             double,
00117             double,
00118             double = 0.5,
00119             double = 0.5,
00120             int widthX = 800,
00121             int widthY = 800
00122         );
00123 
00124 
00125     // Destructor
00126 
00127         ~GLstream();
00128 
00129 
00130     // Member Functions
00131 
00132         // Event Handlers
00133 
00134             //- Wait for any keypress then return true
00135             int waitForEvent();
00136 
00137             //- Wait for any keypress then return true
00138             int waitForEvent(GEvent &);
00139 
00140 
00141         // Change Context
00142 
00143             virtual void setColour(const colour&);
00144             virtual void setLineStyle(const lineStyle&);
00145             virtual void clear();
00146 
00147         // Draw
00148 
00149             virtual void draw(const line2D&);
00150             virtual void draw(const rectangle2D&);
00151             virtual void draw(const polygon2D&);
00152             virtual void draw(const string2D&);
00153             virtual void draw(const structuredScalars2D&);
00154 
00155 
00156     // Friend Functions
00157 
00158         friend colour structuredScalars2D::newColour(const scalar&) const;
00159 };
00160 
00161 
00162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00163 
00164 } // End namespace Foam
00165 
00166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00167 
00168 #include "GLstreamI.H"
00169 
00170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00171 
00172 #endif
00173 
00174 // ************************************************************************* //
For further information go to www.openfoam.org