Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef UTILS__ObjectAndSensorViewer_H_
00021 #define UTILS__ObjectAndSensorViewer_H_
00022
00029 #include <cstdlib>
00030 #include <cmath>
00031 #include <cstring>
00032 #include <cctype>
00033 #include <assert.h>
00034 #include <stdio.h>
00035 #include "TactileSensor/SimulatedTactileSensor.hpp"
00036
00037 #include "Graphics/Utils/CompatGL.hpp"
00038
00039 namespace Graphics
00040 {
00041
00042 class ObjectAndSensorViewer;
00044 typedef ObjectAndSensorViewer* ObjectAndSensorViewerPtr;
00045
00049 class ObjectAndSensorViewer
00050 {
00051 public:
00052
00053 static Sensing::SimulatedTactileSensor *sensor1;
00054 static Sensing::SimulatedTactileSensor *sensor2;
00055 static Sensing::SimulatedTactileSensor *sensor3;
00056
00060 protected:
00061 ObjectAndSensorViewer(void)
00062 {
00063 for(int i=0; i<2; i++)
00064 {
00065 GLUTmouse[i] = 0;
00066 }
00067
00068 for(int i=0; i<3; i++)
00069 {
00070 GLUTbutton[i] = 0;
00071 }
00072
00073 }
00074
00075 public:
00081 static ObjectAndSensorViewerPtr& getInstance(void)
00082 {
00083 if( !instance )
00084 instance = new ObjectAndSensorViewer();
00085 return instance;
00086 }
00087
00088
00089
00093 static void SGLUTInit(int *argc, char **argv)
00094 {
00095 instance = getInstance();
00096 instance->GLUTInit( argc, argv);
00097 }
00098
00102 static void SGLUTMainLoop(void)
00103 {
00104 instance->GLUTMainLoop();
00105 }
00106
00111 void GLUTInit(int *argc, char **argv);
00112
00117 void GLUTMainLoop(void);
00118
00119 protected:
00121 static ObjectAndSensorViewer* instance;
00122
00123
00124 static int GLUTwindow;
00125 static int GLUTwindow2;
00126 static int GLUTwindow_height;
00127 static int GLUTwindow_width;
00128 static int GLUTwindow2_height;
00129 static int GLUTwindow2_width;
00130 static int GLUTmouse[2];
00131 static int GLUTbutton[3];
00132 static int GLUTmodifiers;
00133
00134 static int scaling;
00135 static int translating;
00136 static int rotating;
00137 static int zoom;
00138
00139 static float object_translation[3];
00140 static float object_angle[3];
00141
00142
00143 static bool mdl;
00144 static bool sns;
00145
00146
00147
00148
00152 static void SGLUTRedraw(void)
00153 {
00154 instance->GLUTRedraw();
00155 }
00156
00160 static void SGLUTRedraw2(void)
00161 {
00162 instance->GLUTRedraw2();
00163 }
00164
00169 static void SdrawObject(void)
00170 {
00171 instance->drawObject();
00172 }
00173
00175 static void SGLUTStop(void)
00176 {
00177 instance->GLUTStop();
00178 }
00179
00181 static void SGLUTResize(int w, int h)
00182 {
00183 instance->GLUTResize(w,h);
00184 }
00185
00187 static void SGLUTMotion(int x, int y)
00188 {
00189 instance->GLUTMotion(x,y);
00190 }
00191
00193 static void SGLUTMouse(int button, int state, int x, int y)
00194 {
00195 instance->GLUTMouse(button,state,x,y);
00196 }
00197
00199 static void SGLUTSpecial(int key, int x, int y)
00200 {
00201 instance->GLUTSpecial(key, x,y);
00202 }
00203
00205 static void SGLUTKeyboard(unsigned char key, int x, int y)
00206 {
00207 instance->GLUTKeyboard(key, x, y);
00208 }
00209
00210
00215 virtual void GLUTRedraw(void);
00216
00217
00222 virtual void GLUTRedraw2(void);
00223
00228 virtual void drawObject(void);
00229
00235 void GLUTStop(void);
00236
00242 void GLUTResize(int w, int h);
00243
00249 virtual void GLUTMotion(int x, int y);
00250
00256 void GLUTMouse(int button, int state, int x, int y);
00257
00263 void GLUTSpecial(int key, int x, int y);
00264
00270 void GLUTKeyboard(unsigned char key, int x, int y);
00271
00272 private:
00273 static GLUquadricObj* quad;
00274
00275 };
00276
00277 }
00278
00279 #endif
00280