00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __GLWORLDVIEWER_H__
00033 #define __GLWORLDVIEWER_H__
00034
00035
00036 #include "3rdparty/qglviewer_subset/qglviewer.h"
00037 #include "glscene.h"
00038 #include "glscreenviewer.h"
00039
00040
00078 class GLWorldViewer : public QGLViewer
00079 {
00080 public:
00081 GLWorldViewer( const GLScene* s, GLScreenViewer* screenViewer,
00082 QWidget* parent );
00083 GLWorldViewer( const GLScene* s, GLScreenViewer* screenViewer,
00084 const QGLFormat &format, QWidget* parent );
00085
00086 void resetCamera();
00087
00088
00089 bool autoGLClearEnabled() const { return autoGLClear; }
00090 bool autoGLFlushEnabled() const { return autoGLFlush; }
00091 bool frustumIsDrawn() const { return frustumEnabled; }
00092 void setDrawFrustum( bool enable ) { frustumEnabled = enable; }
00093 void setAutoGLClearEnabled( bool enable ) { autoGLClear = enable; }
00094 void setAutoGLFlushEnabled( bool enable ) { autoGLFlush = enable; }
00095
00096
00100 qglviewer::Vec backgroundColor() const { return myBackgroundColour; };
00102 void getBackgroundColor( float& r, float& g, float& b ) const
00103 {
00104 r = myBackgroundColour[0];
00105 g = myBackgroundColour[1];
00106 b = myBackgroundColour[2];
00107 }
00109 void getBackgroundColor( QColor& c ) const
00110 {
00111 c.setRgb(
00112 (int)(myBackgroundColour[0]*255.0),
00113 (int)(myBackgroundColour[1]*255.0),
00114 (int)(myBackgroundColour[2]*255.0) );
00115 };
00116
00123 void setBackgroundColor( const qglviewer::Vec& color )
00124 { myBackgroundColour = color; };
00126 void setBackgroundColor( float r, float g, float b )
00127 { setBackgroundColor(qglviewer::Vec(r, g ,b)); };
00129 void setBackgroundColor( const QColor &c ) {
00130 setBackgroundColor( (float)c.red() / 255.0,
00131 (float)c.green() / 255.0,
00132 (float)c.blue() / 255.0 );
00133 };
00134
00135
00136 protected :
00137 void sharedInit();
00138
00139 void drawFrustum( GLdouble* inverseProjectionMatrix );
00140
00141 virtual void init();
00142 virtual void draw();
00143 virtual void preDraw();
00144 virtual void postDraw();
00145
00146 virtual void keyPressEvent( QKeyEvent* e );
00147 virtual void keyReleaseEvent( QKeyEvent* e );
00148
00149 virtual void mousePressEvent( QMouseEvent* e );
00150 virtual void mouseReleaseEvent( QMouseEvent* e );
00151 virtual void mouseDoubleClickEvent( QMouseEvent* e );
00152 virtual void mouseMoveEvent( QMouseEvent* e );
00153
00154 void mouseEventTranslator( QMouseEvent* e, QEvent::Type mouseEventType );
00155
00156 GLboolean invert( const GLdouble src[16], GLdouble inverse[16] );
00157
00158 const GLScene* myScene;
00159 GLScreenViewer* myScreenViewer;
00160 const GLdouble* myScreenViewersProjection;
00161
00162 bool reinitRequired;
00163
00164 qglviewer::Vec myBackgroundColour;
00165
00166 bool autoGLClear;
00167 bool autoGLFlush;
00168 bool frustumEnabled;
00169
00170 int extModifierKey;
00171 };
00172
00173
00174 #endif // __GLWORLDVIEWER_H__