X11Device.h

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.1.1.1 $
00022 // $Date: 2000/09/15 08:23:27 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/renderer/X11Device.h,v $
00024                                                                         
00025                                                                         
00026 #ifndef X11Device_H
00027 #define X11Device_H
00028 
00029 #include <Device.h>
00030 #include <X11/Xlib.h>
00031 #include <X11/Xutil.h>
00032 #include <X11/X.h>
00033 #include <X11/Xatom.h>
00034 
00035 #define MAX_NUM_POINTS_FOR_POLYGON 64
00036 #define X11_MAX_COLORS 256
00037 
00038 class X11Device: public  Device
00039 {
00040  public:
00041   X11Device();
00042   ~X11Device();
00043   
00044   // Specify a 2D point to the hardware  
00045   virtual void V2F(float x, float y);
00046 
00047   // Specify a color to the hardware
00048   virtual void C3F(float r, float g, float b);
00049 
00050   // Gets the width of the current window
00051   virtual int GetWidth();
00052 
00053   // Gets the height of the current window
00054   virtual int GetHeight();
00055 
00056   // Call when about to begin/end drawing a polygon. All V2F calls
00057   // from then on until ENDPOLYGON will be interpreted as 
00058   // vertices of the polygon
00059   virtual void BGNPOLYGON();
00060   virtual void ENDPOLYGON();
00061 
00062 
00063   // Same as BGNPOLYGON but for wireframe polygons
00064   virtual void BGNCLOSEDLINE();
00065   virtual void ENDCLOSEDLINE();
00066 
00067   // Call when about to begin drawing a set of points. All V2F
00068   // calls from then on until ENDPOINT will be interpreted as
00069   // points.
00070   virtual void BGNPOINT();
00071   virtual void ENDPOINT();
00072 
00073   // draw text
00074   virtual void drawText(float x, float y, char *text, int length);  
00075   
00076   // Necessary when operating in XWINDOWS mode since the drawn
00077   // image is buffered until this call is made.
00078   virtual void STARTIMAGE();
00079   virtual void ENDIMAGE();
00080 
00081   // Opens a window of the specified width & height.
00082   virtual void WINOPEN(int width, int height);
00083 
00084   // Clears the currently opened window
00085   virtual void CLEAR();
00086 
00087  private:
00088   void initX11(void); // procedure called once on construction of first X11Device
00089 
00090    Window theWindow; // the window associated with the X11Device
00091   GC theGC;         // the graphic context associated with the X11Device
00092   int winOpen;
00093   unsigned long foreground, background;  
00094   XSizeHints hints; // conatins the infor about where window is and its size
00095   int height;       // current height of the window
00096 
00097   XStandardColormap theMap;  
00098   XEvent theEvent;
00099   
00100   int numPoints;        
00101   int drawingPolygon;
00102   XPoint polygonPointArray[MAX_NUM_POINTS_FOR_POLYGON+1]; // +1 for wireframe 
00103   
00104   // class variables
00105   static int numX11Device;     // the number of X11Device objects in app  
00106   static Display *theDisplay;  // the display all X11Devices display on
00107   static Colormap cmap;        // the colormap all X11Device objects share      
00108   static int theScreen;        // the screen 
00109   static unsigned long pixels[X11_MAX_COLORS]; // the pixels we obtain from default
00110   static XColor colors[X11_MAX_COLORS];   // the colors we define for our pixels
00111   static int colorFlag;        // flag indicating num of colors in colormap
00112 
00113 };
00114 
00115 #endif
00116 
00117 
00118 
00119   
00120 

Generated on Mon Oct 23 15:05:27 2006 for OpenSees by doxygen 1.5.0