Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

glworldviewer.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  File:    glworldviewer.h
00004  Created: by Aidan Lane, January  26, 2004
00005  Updated: by Aidan Lane, February 26, 2004
00006  
00007  This file is part of Glitch
00008  Copyright (C) 2003-2004  Monash University, Clayton Campus, Australia
00009  Created by Aidan Lane, under the supervision of Jon McCormack.
00010  
00011  This program was developed to aid the students studying the CSE3313
00012  Computer Graphics course at Monash University.
00013  
00014  This software may contain portions that are copyright (C) 1993,
00015  Silicon Graphics, Inc. All Rights Reserved.
00016  
00017  Glitch is free software; you can redistribute it and/or modify
00018  it under the terms of the GNU General Public License as published by
00019  the Free Software Foundation, version 2.
00020  
00021  Glitch is distributed in the hope that it will be useful,
00022  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  GNU General Public License for more details.
00025  
00026  You should have received a copy of the GNU General Public License
00027  along with this program; if not, write to the Free Software
00028  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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     // The glClear, glFlush and the frustum are all enabled by default
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__

Generated on Fri Feb 27 12:01:39 2004 for Glitch by doxygen 1.3.2