WindowDevice.hGo 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.4 $ 00022 // $Date: 2003/02/26 18:56:09 $ 00023 // $Source: /usr/local/cvs/OpenSees/SRC/renderer/WindowDevice.h,v $ 00024 00025 #ifndef WindowDevice_H 00026 #define WindowDevice_H 00027 00028 #include <Device.h> 00029 00030 #ifdef _UNIX 00031 // include the X11 stuff 00032 #include <X11/Xlib.h> 00033 #include <X11/Xutil.h> 00034 #include <X11/X.h> 00035 #include <X11/Xatom.h> 00036 #else 00037 // include open gl stuff for win32 00038 #include <windows.h> 00039 #include <gl\gl.h> 00040 #include <gl\glaux.h> 00041 #endif 00042 00043 #define MAX_NUM_POINTS_FOR_POLYGON 64 00044 #define X11_MAX_COLORS 256 00045 00046 class WindowDevice: public Device 00047 { 00048 public: 00049 WindowDevice(); 00050 ~WindowDevice(); 00051 00052 // Specify a 2D point to the hardware 00053 virtual void V2F(float x, float y); 00054 00055 // Specify a color to the hardware 00056 virtual void C3F(float r, float g, float b); 00057 00058 // Gets the width of the current window 00059 virtual int GetWidth(); 00060 00061 // Gets the height of the current window 00062 virtual int GetHeight(); 00063 00064 // Call when about to begin/end drawing a polygon. All V2F calls 00065 // from then on until ENDPOLYGON will be interpreted as 00066 // vertices of the polygon 00067 virtual void BGNPOLYGON(); 00068 virtual void ENDPOLYGON(); 00069 00070 00071 // Same as BGNPOLYGON but for wireframe polygons 00072 virtual void BGNCLOSEDLINE(); 00073 virtual void ENDCLOSEDLINE(); 00074 00075 // Call when about to begin drawing a set of points. All V2F 00076 // calls from then on until ENDPOINT will be interpreted as 00077 // points. 00078 virtual void BGNPOINT(); 00079 virtual void ENDPOINT(); 00080 00081 // draw text 00082 virtual void drawText(float x, float y, char *text, int length); 00083 00084 // Necessary when operating in XWINDOWS mode since the drawn 00085 // image is buffered until this call is made. 00086 virtual void STARTIMAGE(); 00087 virtual void ENDIMAGE(); 00088 00089 // Opens a window of the specified width & height. 00090 virtual void WINOPEN(const char *title, int xLoc, int yLoc, int width, int height); 00091 00092 // Clears the currently opened window 00093 virtual void CLEAR(); 00094 00095 private: 00096 void initWindow(void); // procedure called on construction of 1st Window 00097 #ifdef _UNIX 00098 // X11 stuff 00099 00100 Window theWindow; // the window associated with the Window 00101 GC theGC; // the graphic context associated with the Window 00102 XSizeHints hints; // conatins the infor about where window is and its size 00103 static unsigned long foreground, background; 00104 XStandardColormap theMap; 00105 XEvent theEvent; 00106 static Display *theDisplay; // the display all Window objecs display on 00107 static Colormap cmap; // the colormap all X11 Window objects share 00108 static int theScreen; // the screen 00109 static unsigned long pixels[X11_MAX_COLORS]; // pixels obtained from default 00110 static XColor colors[X11_MAX_COLORS]; // colors we define for our pixels 00111 static int colorFlag; // flag indicating num of colors in colormap 00112 XPoint polygonPointArray[MAX_NUM_POINTS_FOR_POLYGON+1]; // +1 for wireframe 00113 #else 00114 // win32 stuff 00115 HDC theHDC; // device context 00116 HGLRC theHRC; // openGL context 00117 HWND theWND; // the window 00118 #endif 00119 00120 int winOpen; 00121 int height; // current height of window in pixels 00122 int width; // current width of window in pixels 00123 int numPoints; 00124 int drawingPolygon; 00125 int xLoc; 00126 int yLoc; 00127 00128 char title[50]; 00129 00130 // class variables 00131 static int numWindowDevice; // the number of WindowDevice objects in app 00132 }; 00133 00134 #endif 00135 00136 00137 00138 |