GLView Class Reference

#include <glview.h>

Inheritance diagram for GLView:

GLOrbitalView GLSimpleMoleculeView GLMoleculeView List of all members.

Detailed Description

This class serves as a base class for the OpenGL visualization classes.

These currently are:

It implements common routines like OpenGL-setup, mouse-interaction, keyboard-interaction, image-saving and animation. It contains a pure virtual so has to be subclassed.

Definition at line 38 of file glview.h.

Public Slots

void setModified (const bool status=true)
 Sets the 'modified' status of the scene. Defaults to true.
void toggleAnimation ()
 Toggles animation on/off.
void centerView (const bool update=true)
 Centers the view on the scene.
void resetOrientation (const bool update=true)
 Resets the orientation of the scene.
void zoomFit (const bool update=true)
 Calculates zPos so that the scene fits in the current window It uses the result of boundingSphereRadius, a pure virtual.
void resetView (const bool update=true)
 Resets translation/orientation/zoom of the scene.
void saveImage ()
 Saves the view to an image.

Signals

void modified ()
void changed ()

Public Member Functions

 GLView (QWidget *parent=0, const char *name=0)
virtual ~GLView ()
 The destructor.
bool isModified () const
 Returns whether the view has been modified and possibly needs to be saved.
bool isAnimating () const
 Returns whether the scene is animating.
unsigned int calculateFPS ()
 Returns the maximum attainable number of frames per second.

Static Public Member Functions

static void setParameters (GLBaseParameters params)
 Updates the OpenGL parameters and makes sure they are adapted at the next call to updateGL().

Protected Member Functions

void initializeGL ()
 Overridden from QGLWidget::initializeGL().
void resizeGL (int w, int h)
 Overridden from QGlWidget::resizeGL().
void paintGL ()
 Overridden from QGlWidget::paintGL(). Does the drawing of the OpenGL scene.
void mousePressEvent (QMouseEvent *e)
 Overridden from QGlWidget::mousePressEvent. Handles left mouse button presses.
void mouseMoveEvent (QMouseEvent *e)
 Overridden from QGlWidget::mouseMoveEvent. Handles left mouse button drags.
void mouseReleaseEvent (QMouseEvent *e)
 Overridden from QGlWidget::mouseReleaseEvent.
void keyPressEvent (QKeyEvent *e)
 Overridden from QGlWidget::mousepressEvent.
void wheelEvent (QWheelEvent *e)
 Overridden from QGlWidget::wheelEvent.
virtual void drawScene ()=0
void translateZ (const int amount)
 Handles the request for a translation in the Z-direction.
void translateXY (const int amountX, const int amountY)
 Handles the request for a translation in the X- or Y-direction.
virtual void clicked (const QPoint &)
 Handles leftbutton mouse clicks at the given position.
virtual void updateGLSettings ()
 Updates the OpenGL settings.
virtual float boundingSphereRadius ()=0
void updateFog (const float radius)
 Updates the fog parameters depending on the size of the object that's to be depth-cue'd.
void updateProjection ()
 Checks whether the projection type changed and does the necessary updating.
void setPerspective ()
 Sets the correct perspective.

Protected Attributes

GLfloat xPos
 Amount of translation on the x-axis.
GLfloat yPos
 Amount of translation on the y-axis.
GLfloat zPos
 Zoomfactor = distance camera from center.
Quaternion< float > * orientationQuaternion
 Orientation of the molecule in 4D.
QPoint mousePosition
 Position of the mouse.

Static Protected Attributes

static const int redrawWait = 33
 Number of msec to wait between updates (for a max of 30 FPS).
static const float fieldOfView = 60.0f
 Field of view for gluPerspective and slotZoomFit.
static GLBaseParameters baseParameters
 Holds the OpenGL base parameters.

Private Attributes

GLfloat xRot
 Amount of step-rotation around the x-axis.
GLfloat yRot
 Amount of step-rotation around the y-axis.
GLfloat zRot
 Amount of step-rotation around the z-axis.
QTimer * timer
 Timer object.
bool animation
 Is true if the scene should be animated.
int updateIndex
 Holds the index of the latest local update.
bool viewModified
 Holds the 'modified' status of the scene.
bool startingClick
 Keeps track of click vs. move events.
float maxRadius
 A copy of the result of boundingSphereRadius for use in translateZ.
bool currentPerspectiveProjection
 Is true if the current projection is perspective.

Static Private Attributes

static int staticUpdateIndex = 0
 holds the index of the latest update of the OpenGL parameters.


Constructor & Destructor Documentation

GLView::GLView QWidget *  parent = 0,
const char *  name = 0
 

Definition at line 57 of file glview.cpp.

GLView::~GLView  )  [virtual]
 

The destructor.

Definition at line 82 of file glview.cpp.


Member Function Documentation

bool GLView::isModified  )  const
 

Returns whether the view has been modified and possibly needs to be saved.

Definition at line 89 of file glview.cpp.

bool GLView::isAnimating  )  const
 

Returns whether the scene is animating.

Definition at line 96 of file glview.cpp.

unsigned int GLView::calculateFPS  ) 
 

Returns the maximum attainable number of frames per second.

It draws as much frames as possible in 5 seconds.

Definition at line 103 of file glview.cpp.

void GLView::setParameters GLBaseParameters  params  )  [static]
 

Updates the OpenGL parameters and makes sure they are adapted at the next call to updateGL().

Definition at line 137 of file glview.cpp.

void GLView::modified  )  [signal]
 

void GLView::changed  )  [signal]
 

void GLView::setModified const bool  status = true  )  [slot]
 

Sets the 'modified' status of the scene. Defaults to true.

Definition at line 150 of file glview.cpp.

void GLView::toggleAnimation  )  [slot]
 

Toggles animation on/off.

Definition at line 167 of file glview.cpp.

void GLView::centerView const bool  update = true  )  [slot]
 

Centers the view on the scene.

Definition at line 185 of file glview.cpp.

void GLView::resetOrientation const bool  update = true  )  [slot]
 

Resets the orientation of the scene.

Definition at line 196 of file glview.cpp.

void GLView::zoomFit const bool  update = true  )  [slot]
 

Calculates zPos so that the scene fits in the current window It uses the result of boundingSphereRadius, a pure virtual.

Definition at line 206 of file glview.cpp.

void GLView::resetView const bool  update = true  )  [slot]
 

Resets translation/orientation/zoom of the scene.

Definition at line 236 of file glview.cpp.

void GLView::saveImage  )  [slot]
 

Saves the view to an image.

Definition at line 247 of file glview.cpp.

void GLView::initializeGL  )  [protected]
 

Overridden from QGLWidget::initializeGL().

Initializes the OpenGL window.

Reimplemented in GLSimpleMoleculeView.

Definition at line 309 of file glview.cpp.

void GLView::resizeGL int  w,
int  h
[protected]
 

Overridden from QGlWidget::resizeGL().

Resizes the OpenGL viewport according to the size of the widget.

Definition at line 365 of file glview.cpp.

void GLView::paintGL  )  [protected]
 

Overridden from QGlWidget::paintGL(). Does the drawing of the OpenGL scene.

Definition at line 378 of file glview.cpp.

void GLView::mousePressEvent QMouseEvent *  e  )  [protected]
 

Overridden from QGlWidget::mousePressEvent. Handles left mouse button presses.

Definition at line 432 of file glview.cpp.

void GLView::mouseMoveEvent QMouseEvent *  e  )  [protected]
 

Overridden from QGlWidget::mouseMoveEvent. Handles left mouse button drags.

Reimplemented in GLMoleculeView.

Definition at line 445 of file glview.cpp.

void GLView::mouseReleaseEvent QMouseEvent *  e  )  [protected]
 

Overridden from QGlWidget::mouseReleaseEvent.

Handles left mouse button releases.

Definition at line 489 of file glview.cpp.

void GLView::keyPressEvent QKeyEvent *  e  )  [protected]
 

Overridden from QGlWidget::mousepressEvent.

Handles key presses.

  • <left> : rotate left
  • <right> : rotate right
  • <up> : rotate up
  • <down> : rotate down
  • <shift>+<left> : rotate counterclockwise
  • <shift>+<right>: rotate clockwise
  • <shift>+<up> : zoom in
  • <shift>+<down> : zoom out
  • <ctrl>+<left> : translate left
  • <ctrl>+<right> : translate right
  • <ctrl>+<up> : translate up
  • <ctrl>+<down> : translate down
  • <ctrl>+<shift>+<left>: change internal coordinate of selection (smaller). Implementation in GLMoleculeView.
  • <ctrl>+<shift>+<right>: change internal coordinate of selection (larger). Implementation in GLMoleculeView.

Reimplemented in GLMoleculeView, and GLSimpleMoleculeView.

Definition at line 506 of file glview.cpp.

void GLView::wheelEvent QWheelEvent *  e  )  [protected]
 

Overridden from QGlWidget::wheelEvent.

Handles scrolls with the scrollwheel of the mouse. It provides an alternative way of zooming.

Definition at line 565 of file glview.cpp.

virtual void GLView::drawScene  )  [protected, pure virtual]
 

Implemented in GLOrbitalView, and GLSimpleMoleculeView.

void GLView::translateZ const int  amount  )  [protected]
 

Handles the request for a translation in the Z-direction.

Here the complete scene is translated (=zoomed).

Definition at line 576 of file glview.cpp.

void GLView::translateXY const int  amountX,
const int  amountY
[protected]
 

Handles the request for a translation in the X- or Y-direction.

Here the complete scene is translated.

Definition at line 596 of file glview.cpp.

void GLView::clicked const QPoint &   )  [protected, virtual]
 

Handles leftbutton mouse clicks at the given position.

No implementation in this base class. Not a pure virtual because it does not need an implementation by the derived classes.

Reimplemented in GLSimpleMoleculeView.

Definition at line 607 of file glview.cpp.

void GLView::updateGLSettings  )  [protected, virtual]
 

Updates the OpenGL settings.

It is only called when an update is really needed (determined by staticUpdateIndex != updateIndex).

Reimplemented in GLSimpleMoleculeView.

Definition at line 615 of file glview.cpp.

virtual float GLView::boundingSphereRadius  )  [protected, pure virtual]
 

Implemented in GLMoleculeView, GLOrbitalView, and GLSimpleMoleculeView.

void GLView::updateFog const float  radius  )  [protected]
 

Updates the fog parameters depending on the size of the object that's to be depth-cue'd.

Definition at line 674 of file glview.cpp.

void GLView::updateProjection  )  [protected]
 

Checks whether the projection type changed and does the necessary updating.

Definition at line 687 of file glview.cpp.

void GLView::setPerspective  )  [protected]
 

Sets the correct perspective.

Definition at line 700 of file glview.cpp.


Member Data Documentation

GLfloat GLView::xPos [protected]
 

Amount of translation on the x-axis.

Definition at line 89 of file glview.h.

GLfloat GLView::yPos [protected]
 

Amount of translation on the y-axis.

Definition at line 90 of file glview.h.

GLfloat GLView::zPos [protected]
 

Zoomfactor = distance camera from center.

Definition at line 91 of file glview.h.

Quaternion<float>* GLView::orientationQuaternion [protected]
 

Orientation of the molecule in 4D.

Definition at line 92 of file glview.h.

QPoint GLView::mousePosition [protected]
 

Position of the mouse.

Definition at line 94 of file glview.h.

const int GLView::redrawWait = 33 [static, protected]
 

Number of msec to wait between updates (for a max of 30 FPS).

Definition at line 97 of file glview.h.

const float GLView::fieldOfView = 60.0f [static, protected]
 

Field of view for gluPerspective and slotZoomFit.

Definition at line 98 of file glview.h.

GLBaseParameters GLView::baseParameters [static, protected]
 

Initial value:

 {1.0f, 1.0f, 1.0f, 0xffffff, 0.80f, 100.0f,
                                           0x000000, false, true, false, true}
Holds the OpenGL base parameters.

Definition at line 99 of file glview.h.

GLfloat GLView::xRot [private]
 

Amount of step-rotation around the x-axis.

Definition at line 104 of file glview.h.

GLfloat GLView::yRot [private]
 

Amount of step-rotation around the y-axis.

Definition at line 105 of file glview.h.

GLfloat GLView::zRot [private]
 

Amount of step-rotation around the z-axis.

Definition at line 106 of file glview.h.

QTimer* GLView::timer [private]
 

Timer object.

Definition at line 107 of file glview.h.

bool GLView::animation [private]
 

Is true if the scene should be animated.

Definition at line 108 of file glview.h.

int GLView::updateIndex [private]
 

Holds the index of the latest local update.

Definition at line 109 of file glview.h.

bool GLView::viewModified [private]
 

Holds the 'modified' status of the scene.

Definition at line 110 of file glview.h.

bool GLView::startingClick [private]
 

Keeps track of click vs. move events.

Definition at line 111 of file glview.h.

float GLView::maxRadius [private]
 

A copy of the result of boundingSphereRadius for use in translateZ.

Definition at line 112 of file glview.h.

bool GLView::currentPerspectiveProjection [private]
 

Is true if the current projection is perspective.

Definition at line 113 of file glview.h.

int GLView::staticUpdateIndex = 0 [static, private]
 

holds the index of the latest update of the OpenGL parameters.

Definition at line 116 of file glview.h.


Generated on Fri May 19 14:31:58 2006 for Brabosphere by  doxygen 1.4.6-NO