Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

GLView Class Reference

GL rendering view class. More...

#include <GLView.h>

List of all members.

Public Methods

Construction/Desctruction
Public API functions
Layout-related functions

Public Slots

Static Public Methods

Protected Methods

Internal GL-related functions
Event handlers

Detailed Description

This class encapsulates the GL rendering viewport and provides basic rendering functionality. The viewport calls in the user-defined implementation of render() from the selected effect to display it. Also contained in the class are event hadlers for keyboard and mouse (see descriptions for details), as well as functions that automatically set and handle all necessary view/projection tranformations as well as resizing and updates.

Note:
See notes on individual functions for details.


Constructor & Destructor Documentation

GLView::GLView ( QWidget * parent,
GLFramework * parentGui,
QGLFormat * glFormat,
const char * name = 0 )
 

Parameters:
parent   Pointer to the parent widget.
parentGui   Pointer to the parent GUI. Must point to the parent instance of GLFramework, as opposed to the 1st parameter, which can also point to another widget.
glFormat   Pointer to a QGLFormat context descriptor object.
name   Symbolic name for this widget.

Constructs an object and obtains a pointer to the parent GLFramework widget. Internal parameters are initialized here as well.

Todo:
Some additional init may be added here later.

GLView::~GLView ( ) [virtual]
 

Destroys the object. Empty for now, but may be modified later to include removal of dynamically allocated memory.


Member Function Documentation

void GLView::setCameraAngles ( GLdouble azimuth,
GLdouble elev,
GLdouble twist )
 

Parameters:
azimuth   Azimuth angle of the viewpoint.
elevation   Elevation angle of the viewpoint.
twist   Twist (Rotation on Z axis) angle of the viewpoint.

Sets the camera azimuth, elevation and twist angles and redraws the window.

Note:
This function will be changed as the virtual trackball is rewritten.
See also:
setFieldOfView()

void GLView::setFieldOfView ( GLdouble fov )
 

Parameters:
fov   New FOV angle to be set.

Sets the Field of View angle and adjusts the projection matrix accordingly. The window is updated after projection matrix has been adjusted.

See also:
setProjectionParams()

void GLView::setProjectionParams ( GLdouble fov,
GLdouble nearClip,
GLdouble farClip,
GLdouble distance )
 

Parameters:
fov   New FOV angle.
nearClip   New distance to the near clipping plane.
farClip   New distance to the far clipping plane.
distance   New distance between the camera and the world origin.

Sets the perspective projection parameters. Used internally by GLEffect::init() to pass projection parameters of the current effect to GLView.

See also:
resizeGL()

void GLView::setCurrentEffect ( GLEffect * effect )
 

Parameters:
effect   The effect object to be set as current effect.

Sets the current effect and initializes it. This also resets and reinitializes the GL viewport (see initializeGL() for explanation why this is done).
Exceptions:
Can   issue an error message and quit the program if the pointer contained in effect parameter was bad.

See also:
initializeGL(), setProjectionParams()

void GLView::polish ( ) [virtual, slot]
 

This is called to perform any initialization that's necessary before the widget is displayed, but is too early to be called from the class constructor. Does nothing for now but may be modified later if required.

Note:
For internal use only.

void GLView::changeProjectionMode ( bool orthoMode ) [slot]
 

Parameters:
orthoMode   If true, the view switches to orthographic projection,otherwise the view assumes pespective projection.

Toggles the view between perspective and orthographic projection modes.

See also:
resizeGL()

void GLView::switchToTrackball ( bool on ) [slot]
 

Parameters:
activate   If true, the view switches to virtual trackball mode,otherwise it will return to normal mode.

Toggles the view between virtual trackball mode and normal viewing mode. This function also remembers the previous state of mouse tracking and then disables it when in virtual trackball mode. After the trackball is deactivated, the previous mouse tracking state will be restored.

See also:
paintGL()

void GLView::resetView ( ) [slot]
 

Resets the camera orientation (but not the zoom extents/FOV)

See also:
resetFOV()

void GLView::resetFOV ( ) [slot]
 

Resets the FOV (or zoom extents when in orhtographic mode)

See also:
resetView()

void GLView::saveCurrentRenderedImage ( ) [slot]
 

This function ask the user to specify a file name on disk and uses it to save the current rendering to a file. If no name is specified or the dialog is cancelled, the image will not be saved.

Note:
Only PNG images are supported at this moment (being the most versatile of all formats directly supported by Qt without use of external imaging libraries)

void GLView::initializeGL ( ) [protected, virtual]
 

This function initializes internal states and parameters. It also sets the size of GL viewport and establishes the perspective projection according to fovAngle, nearClipPlane, farClipPlane, and aspect ratio of the viewport, whose values are obtained from the currently selected effect. The projection parameters are kept until a new effect is set.

Most basic openGL functionality is initially de-activated here in order to reset the GL rendering context when calling a new effect. This is done to avoid such situations as one effect enabling GL_ALPHA_TEST and accidentally leaving it enabled, and the next selected effect looking incorrectly as a result because it didn't want GL_ALPHA_TEST.

Attention:
The above mechanism protects you from unexpected side effects, but you will have to explicitly enable any openGL modes your effect requires.

See also:
setProjectionParams()

void GLView::paintGL ( ) [protected, virtual]
 

Positions the camera and draws the window. Displaying the currently selected effect is accomplished by invoking its render() function. The rendering context is double-buffered by default. This method also renders the axis tripod and axes visual aids when in virtual trackball mode.

void GLView::resizeGL ( int width,
int height ) [protected, virtual]
 

Parameters:
width   New width of viewport, in pixels.
height   New height of viewport, in pixels.

This function is used internally by GLView to re-establish the viewport & projection matrix. It is automatically invoked when the application window is resized and sets the size of GL viewport and perspective projection mode dependent on current values of fovAngle, nearClipPlane, farClipPlane and aspect ratio of the viewport, as well as initial viewpoint position.

Note:
This function must never be explicitly called.

See also:
initializeGL(), setProjectionParams()

void GLView::mouseMoveEvent ( QMouseEvent * mEv ) [protected, virtual]
 

Parameters:
mEv   A mouse event pointer supplied by the window.

Passes mouse move events to the corresponding event handler of the current effect.

This event handler also calculates the rotation axis and angle when in virtual trackball mode, or changes the zoom extents when in zoom mode.

void GLView::mousePressEvent ( QMouseEvent * mEv ) [protected, virtual]
 

Parameters:
mEv   A mouse event pointer supplied by the window.

Passes mouse press events to the corresponding event handler of the current effect. This event handler also sets up the first direction vector and any necessary rotation locks while in virtual trackball mode. Furthermore this changes the mouse cursor to appropriate images when entering various rotation/zoom modes.

See also:
mouseMoveEvent() *

void GLView::mouseReleaseEvent ( QMouseEvent * mEv ) [protected, virtual]
 

Parameters:
mEv   A mouse event pointer supplied by the window

Passes mouse release events to the corresponding event handler of the current effect. This handler also resets any rotation locks and rotation angle & axis parameters, and returns to normal orbiting cursor.

void GLView::keyPressEvent ( QKeyEvent * kEv ) [protected, virtual]
 

Parameters:
kEv   A keyboard event pointer supplied by the window.

Passes keyboard press events to the corresponding event handler of the current event.

void GLView::wheelEvent ( QWheelEvent * wEv ) [protected, virtual]
 

Parameters:
wEv   A wheel event pointer supplied by the window.

Passes mouse wheel events to the corresponding event handler of the current effect. The GLView object is set up to automatically assume focus when a wheel event arrives.

Note:
The default implementation of this handler in GLEffect ignores wheel events, because this is required by Qt framework to properly pass such events to the parent window.

See also:
GLEffect::wheelEvent() *

void GLView::getOpenGLCaps ( ) [static]
 

This function reports back general openGL capabilities. The output is sent to the console.

Remarks:
In the future I will probably modify this to send the report to a file or a suitable dialog window.


The documentation for this class was generated from the following files:
Generated at Fri Apr 19 16:53:06 2002 for GLFramework by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001