GCOP
1.0
|
00001 #ifndef GCOP_VIEWER_H 00002 #define GCOP_VIEWER_H 00003 00004 #include <stdlib.h> 00005 #include <GL/glut.h> 00006 #include <map> 00007 #include "view.h" 00008 00009 namespace gcop { 00010 00011 00021 class Viewer { 00022 public: 00023 Viewer(); 00024 virtual ~Viewer(); 00025 00029 void Init(int* argc, char** argv); 00030 00035 void Start(); 00036 00040 void Add(View& view); 00041 00045 void Remove(View& view); 00046 00047 00052 void RenderViews(); 00053 00057 void DrawOrigin(GLUquadricObj *qobj = 0); 00058 00062 static void DrawFrame(GLUquadricObj *qobj = 0); 00063 00069 static void DrawArrow(double l = 1.0, GLUquadricObj *qobj = 0); 00070 00076 static void DrawArrow(const double v[3], GLUquadricObj *qobj = 0); 00077 00078 00084 static void DrawText(const char *str, float size = .2); 00085 00089 void DrawAll(); 00090 00095 void SetColor(const float rgb[3]); 00096 00097 float sphi; 00098 float stheta; 00099 float sx, sy, sz; 00100 float zNear; 00101 float zFar; 00102 float aspect; 00103 float xcam; 00104 float ycam; 00105 int width; 00106 int height; 00107 00108 float os; 00109 00110 float rgb[3]; 00111 00112 void Reshape(int width, int height); 00113 void Render(); 00114 void Keyboard(unsigned char ch, int x, int y); 00115 void Mouse(int button, int state, int x, int y); 00116 void Motion(int x, int y); 00117 00124 void SaveImage(const char* name = 0); 00125 00126 static GLuint LoadTexture(const char * fname, int wrap = true); 00127 00135 static void DrawCircle(double x = 0, double y = 0, double r = 1, int slices = 20); 00136 00137 int window; 00138 protected: 00139 00140 int downX; 00141 int downY; 00142 int leftButton; 00143 int middleButton; 00144 int rightButton; 00145 00146 pthread_mutex_t mut; 00147 00148 std::map<int, View*> views; 00149 00150 GLUquadricObj *aqobj; 00151 00152 public: 00153 bool animate; 00154 double animDelay; 00155 00156 bool saveFrames; 00157 const char* frameName; 00158 00159 bool saveDisplay; 00160 const char* displayName; 00161 int displayNo; 00162 00163 bool saveSnapshot; 00164 00165 bool altLight; 00166 00174 static void Cylinder(const double xa[3], const double xb[3], 00175 double r, int sd); 00176 00177 void SetCamera(float sphi, float stheta, 00178 float sx, float sy, float sz); 00179 00180 void SetCamera(const float params[5]); 00181 00182 00183 static void SetColor (float r, float g, float b, float alpha = 0); 00184 00185 static void SetMaterial( GLfloat ambientR, GLfloat ambientG, GLfloat ambientB, 00186 GLfloat diffuseR, GLfloat diffuseG, GLfloat diffuseB, 00187 GLfloat specularR, GLfloat specularG, GLfloat specularB, 00188 GLfloat shininess ); 00189 00190 static Viewer* instance; 00191 00192 protected: 00193 unsigned char *rgbimg; 00194 unsigned char *ppmimg; 00195 }; 00196 00197 } 00198 #endif 00199 00200