GLSimpleMoleculeView Class Reference

#include <glsimplemoleculeview.h>

Inheritance diagram for GLSimpleMoleculeView:

GLView GLMoleculeView List of all members.

Detailed Description

This class shows a molecule in 3D using OpenGL.

It does not allow chaning of the molecule and is used in the program CrdView. Brabosphere uses the derived class GLMoleculeView with more features.

Definition at line 40 of file glsimplemoleculeview.h.

Public Types

enum  DisplayStyle {
  None, Lines, Tubes, BallAndStick,
  VanDerWaals
}
enum  DisplaySource { Molecule, Forces }

Public Slots

void updateAtomSet (const bool reset=false)
 Updates the view under influence of changes in the atomset.
void selectAll (const bool update=true)
 Selects all atoms.
void unselectAll (const bool update=true)
 Unselects all atoms.

Public Member Functions

 GLSimpleMoleculeView (AtomSet *atomset, QWidget *parent=0, const char *name=0)
 ~GLSimpleMoleculeView ()
 The default destructor.
unsigned int displayStyle (const DisplaySource source) const
 Returns the display style of a certain primitive.
bool isShowingElements () const
 Returns whether the atom elements are shown.
bool isShowingNumbers () const
 Returns whether the atom numbers are shown.
bool isShowingCharges (const unsigned int type) const
 Returns whether the atomic charges of the specified type are shown.
unsigned int selectedAtoms () const
 Returns the number of selected atoms.
void loadCML (QDomElement *root)
 Loads the view settings from a QDomElement.
void saveCML (QDomElement *root)
 Saves the view settings to a QDomElement.
void setDisplayStyle (const DisplaySource source, const unsigned int style)
 Sets the display style for a certain primitive. Does not redraw the scene.
void setLabels (const bool element, const bool number, const unsigned int type)
 Sets up showing of the atom labels. Does not redraw the scene.

Static Public Member Functions

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

Protected Types

enum  SelectionType {
  SELECTION_NONE, SELECTION_ATOM, SELECTION_BOND, SELECTION_ANGLE,
  SELECTION_TORSION, SELECTION_GROUP, SELECTION_BONDS, SELECTION_FORCES
}
enum  ShapeTypes {
  SHAPE_ATOMS, SHAPE_BONDS, SHAPE_FORCES, SHAPE_LABELS,
  SHAPE_IC, SHAPE_SELECTION, SHAPE_NEXT
}

Protected Slots

void reorderShapes ()
 Orders all drawn shapes according to their opacity.

Protected Member Functions

virtual void keyPressEvent (QKeyEvent *e)
 Overridden from GLView::keyPressEvent.
virtual void initializeGL ()
 Overridden from QGLWidget::initializeGL(). Initializes the OpenGL window.
virtual void drawItem (const unsigned int)
 Draws the item shapes[index].
virtual void updateGLSettings ()
 Updates the OpenGL settings.
virtual float boundingSphereRadius ()
 Calculates the radius of the bounding sphere.
void clicked (const QPoint &position)
 Implementation of GLView::clicked(). Handles mouse click events.
virtual void updateShapes ()
 Updates the contents of the shapes vector.

Protected Attributes

GLfloat centerX
 X-offset needed to center the molecule.
GLfloat centerY
 Y-offset needed to center the moelcule.
GLfloat centerZ
 Z-offset needed to center the molecule.
unsigned int selectionType
 Keeps track of the type of selection.
std::list< unsigned int > selectionList
 List that holds the selected atoms and their order.
std::vector< ShapePropertiesshapes
 the list of shapes ordered by opacity.

Static Protected Attributes

static GLMoleculeParameters moleculeParameters
 Holds the OpenGL molecule parameters.

Private Types

enum  Directions { DIRECTION_X, DIRECTION_Y, DIRECTION_Z }
enum  StartIndices {
  START_ATOMS = 100, START_BONDS = 1, START_FORCES = 2, START_SELECTEDATOMS = 3,
  START_SELECTEDBONDS = 4
}

Private Member Functions

GLuint makeObjects (const int numSlices)
 Generates the shapes for the atoms and the bonds.
void changeObjects (const GLuint startList, const int numSlices)
 Changes the quality of the atom and bond shapes.
void selectEntity (const QPoint position)
 Selects the entity (atom, bond, etc.) pointed to by the mouse position.
void processSelection (const unsigned int id)
 Changes the selection according to the change in selection of the entity with an ID id.
void centerMolecule ()
 Calculates the translations needed to center the molecule.
void drawScene ()
 Implementation of the pure virtual GLView::drawScene().
void drawAtoms ()
 Draws the atoms in the OpenGL scene.
void drawBonds ()
 Draws the bonds in the OpenGL scene in a format depending in the OpenGL parameters.
void drawLabels ()
 Draws the element types and numbers.
void drawForces ()
 Draws the forces.
void drawICValue ()
 Draws the value for the currently selected internal coordinate.
void drawSelections ()
 Draws the selected atoms and internal coordinates.

Private Attributes

int atomObject
 The OpenGL atom shape object pointer.
int bondObject
 The OpenGL bond shape object pointer.
int forceObjectLines
 The OpenGL force shape object pointer for lines style.
int forceObjectTubes
 The OpenGL force shape object pointer for tubes style.
unsigned int moleculeStyle
 The rendering style of the molecule.
unsigned int forcesStyle
 The rendering style of the forces.
bool showElements
 Is true if elements should be shown.
bool showNumbers
 Is true if atom numbers should be shown.
unsigned int chargeType
 Determines the type of charges to be shown.
AtomSetatoms
 The list of atoms.
GLfloat selectionLineWidth
 The linewidth for drawing selected bonds.
GLfloat selectionPointSize
 The pointsize for drawing selected atoms.
float scaleFactor
 scalefactor for scenes exceeding 50A in radius
QFont labelFont
 The font used to render labels and other values.

Static Private Attributes

static const float cylinderHeight = 10.0f
 The cylinder height. A too low value shows severe bugs in the Mesa OpenGL implementation.

Classes

struct  ShapeProperties
 Utility struct for sorting of shapes by decreasing opacity. More...


Member Enumeration Documentation

enum GLSimpleMoleculeView::DisplayStyle
 

Enumerator:
None 
Lines 
Tubes 
BallAndStick 
VanDerWaals 

Definition at line 50 of file glsimplemoleculeview.h.

enum GLSimpleMoleculeView::DisplaySource
 

Enumerator:
Molecule 
Forces 

Definition at line 52 of file glsimplemoleculeview.h.

enum GLSimpleMoleculeView::SelectionType [protected]
 

Enumerator:
SELECTION_NONE 
SELECTION_ATOM 
SELECTION_BOND 
SELECTION_ANGLE 
SELECTION_TORSION 
SELECTION_GROUP 
SELECTION_BONDS 
SELECTION_FORCES 

Definition at line 78 of file glsimplemoleculeview.h.

enum GLSimpleMoleculeView::ShapeTypes [protected]
 

Enumerator:
SHAPE_ATOMS 
SHAPE_BONDS 
SHAPE_FORCES 
SHAPE_LABELS 
SHAPE_IC 
SHAPE_SELECTION 
SHAPE_NEXT 

Definition at line 81 of file glsimplemoleculeview.h.

enum GLSimpleMoleculeView::Directions [private]
 

Enumerator:
DIRECTION_X 
DIRECTION_Y 
DIRECTION_Z 

Definition at line 119 of file glsimplemoleculeview.h.

enum GLSimpleMoleculeView::StartIndices [private]
 

Enumerator:
START_ATOMS 
START_BONDS 
START_FORCES 
START_SELECTEDATOMS 
START_SELECTEDBONDS 

Definition at line 120 of file glsimplemoleculeview.h.


Constructor & Destructor Documentation

GLSimpleMoleculeView::GLSimpleMoleculeView AtomSet atomset,
QWidget *  parent = 0,
const char *  name = 0
 

Definition at line 59 of file glsimplemoleculeview.cpp.

GLSimpleMoleculeView::~GLSimpleMoleculeView  ) 
 

The default destructor.

Definition at line 84 of file glsimplemoleculeview.cpp.


Member Function Documentation

unsigned int GLSimpleMoleculeView::displayStyle const DisplaySource  source  )  const
 

Returns the display style of a certain primitive.

Definition at line 92 of file glsimplemoleculeview.cpp.

bool GLSimpleMoleculeView::isShowingElements  )  const
 

Returns whether the atom elements are shown.

Definition at line 102 of file glsimplemoleculeview.cpp.

bool GLSimpleMoleculeView::isShowingNumbers  )  const
 

Returns whether the atom numbers are shown.

Definition at line 109 of file glsimplemoleculeview.cpp.

bool GLSimpleMoleculeView::isShowingCharges const unsigned int  type  )  const
 

Returns whether the atomic charges of the specified type are shown.

Definition at line 116 of file glsimplemoleculeview.cpp.

unsigned int GLSimpleMoleculeView::selectedAtoms  )  const
 

Returns the number of selected atoms.

Definition at line 123 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::loadCML QDomElement *  root  ) 
 

Loads the view settings from a QDomElement.

Definition at line 129 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::saveCML QDomElement *  root  ) 
 

Saves the view settings to a QDomElement.

Definition at line 180 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::setDisplayStyle const DisplaySource  source,
const unsigned int  style
 

Sets the display style for a certain primitive. Does not redraw the scene.

Definition at line 202 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::setLabels const bool  element,
const bool  number,
const unsigned int  type
 

Sets up showing of the atom labels. Does not redraw the scene.

Definition at line 223 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::setParameters GLMoleculeParameters  params  )  [static]
 

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

Definition at line 236 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::updateAtomSet const bool  reset = false  )  [slot]
 

Updates the view under influence of changes in the atomset.

It has to be called under the following conditions:

  • a new coordinate set has been read
  • atoms have been added/removed/changes When reset = true, the scene will be reset completely

Definition at line 249 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::selectAll const bool  update = true  )  [slot]
 

Selects all atoms.

Definition at line 302 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::unselectAll const bool  update = true  )  [slot]
 

Unselects all atoms.

Definition at line 328 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::reorderShapes  )  [protected, slot]
 

Orders all drawn shapes according to their opacity.

Definition at line 344 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::keyPressEvent QKeyEvent *  e  )  [protected, virtual]
 

Overridden from GLView::keyPressEvent.

Handles key presses for font changes (no public interface yet)

Reimplemented from GLView.

Reimplemented in GLMoleculeView.

Definition at line 356 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::initializeGL  )  [protected, virtual]
 

Overridden from QGLWidget::initializeGL(). Initializes the OpenGL window.

Reimplemented from GLView.

Definition at line 377 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::drawItem const unsigned int   )  [protected, virtual]
 

Draws the item shapes[index].

It should be overridden by a subclass to draw new shapes. It is not made pure virtual because implementation is not mandatory.

Reimplemented in GLMoleculeView.

Definition at line 419 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::updateGLSettings  )  [protected, virtual]
 

Updates the OpenGL settings.

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

Reimplemented from GLView.

Definition at line 435 of file glsimplemoleculeview.cpp.

float GLSimpleMoleculeView::boundingSphereRadius  )  [protected, virtual]
 

Calculates the radius of the bounding sphere.

Implements GLView.

Reimplemented in GLMoleculeView.

Definition at line 391 of file glsimplemoleculeview.cpp.

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

Implementation of GLView::clicked(). Handles mouse click events.

Reimplemented from GLView.

Definition at line 428 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::updateShapes  )  [protected, virtual]
 

Updates the contents of the shapes vector.

Reimplemented in GLMoleculeView.

Definition at line 475 of file glsimplemoleculeview.cpp.

GLuint GLSimpleMoleculeView::makeObjects const int  numSlices  )  [private]
 

Generates the shapes for the atoms and the bonds.

Definition at line 518 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::changeObjects const GLuint  startList,
const int  numSlices
[private]
 

Changes the quality of the atom and bond shapes.

Definition at line 527 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::selectEntity const QPoint  position  )  [private]
 

Selects the entity (atom, bond, etc.) pointed to by the mouse position.

Definition at line 586 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::processSelection const unsigned int  id  )  [private]
 

Changes the selection according to the change in selection of the entity with an ID id.

Definition at line 644 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::centerMolecule  )  [private]
 

Calculates the translations needed to center the molecule.

The center of mass cannot be used, just the largest extents of the molecule.

Definition at line 693 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::drawScene  )  [private, virtual]
 

Implementation of the pure virtual GLView::drawScene().

Changed from protected to private as subclasses should implement drawItem. Does the drawing of the OpenGL scene (called from paintGL). The default state is lighting enabled. If certain routine need to disable lighting they are required to enable it again at the end.

Implements GLView.

Definition at line 733 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::drawAtoms  )  [private]
 

Draws the atoms in the OpenGL scene.

Definition at line 814 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::drawBonds  )  [private]
 

Draws the bonds in the OpenGL scene in a format depending in the OpenGL parameters.

if bonds don't need to be selected individually, all bonds can be stored together in an OpenGL display list.

Definition at line 852 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::drawLabels  )  [private]
 

Draws the element types and numbers.

Definition at line 972 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::drawForces  )  [private]
 

Draws the forces.

If forces don't need to be selected individually, all forces can be stored together in an OpenGL display list.

Definition at line 1021 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::drawICValue  )  [private]
 

Draws the value for the currently selected internal coordinate.

Definition at line 1104 of file glsimplemoleculeview.cpp.

void GLSimpleMoleculeView::drawSelections  )  [private]
 

Draws the selected atoms and internal coordinates.

Definition at line 1247 of file glsimplemoleculeview.cpp.


Member Data Documentation

GLfloat GLSimpleMoleculeView::centerX [protected]
 

X-offset needed to center the molecule.

Definition at line 107 of file glsimplemoleculeview.h.

GLfloat GLSimpleMoleculeView::centerY [protected]
 

Y-offset needed to center the moelcule.

Definition at line 108 of file glsimplemoleculeview.h.

GLfloat GLSimpleMoleculeView::centerZ [protected]
 

Z-offset needed to center the molecule.

Definition at line 109 of file glsimplemoleculeview.h.

unsigned int GLSimpleMoleculeView::selectionType [protected]
 

Keeps track of the type of selection.

Definition at line 110 of file glsimplemoleculeview.h.

std::list<unsigned int> GLSimpleMoleculeView::selectionList [protected]
 

List that holds the selected atoms and their order.

Definition at line 111 of file glsimplemoleculeview.h.

std::vector<ShapeProperties> GLSimpleMoleculeView::shapes [protected]
 

the list of shapes ordered by opacity.

Definition at line 112 of file glsimplemoleculeview.h.

GLMoleculeParameters GLSimpleMoleculeView::moleculeParameters [static, protected]
 

Initial value:

 {5, 1.0f, 0.2f, 0.2f, BallAndStick, Tubes, 1000, false, true,
0x00FF00, 0x00FFFF, 0xFFFF00, 50, 0xFFFF0, false, 100}
Holds the OpenGL molecule parameters.

Definition at line 115 of file glsimplemoleculeview.h.

int GLSimpleMoleculeView::atomObject [private]
 

The OpenGL atom shape object pointer.

Definition at line 137 of file glsimplemoleculeview.h.

int GLSimpleMoleculeView::bondObject [private]
 

The OpenGL bond shape object pointer.

Definition at line 138 of file glsimplemoleculeview.h.

int GLSimpleMoleculeView::forceObjectLines [private]
 

The OpenGL force shape object pointer for lines style.

Definition at line 139 of file glsimplemoleculeview.h.

int GLSimpleMoleculeView::forceObjectTubes [private]
 

The OpenGL force shape object pointer for tubes style.

Definition at line 140 of file glsimplemoleculeview.h.

unsigned int GLSimpleMoleculeView::moleculeStyle [private]
 

The rendering style of the molecule.

Definition at line 141 of file glsimplemoleculeview.h.

unsigned int GLSimpleMoleculeView::forcesStyle [private]
 

The rendering style of the forces.

Definition at line 142 of file glsimplemoleculeview.h.

bool GLSimpleMoleculeView::showElements [private]
 

Is true if elements should be shown.

Definition at line 143 of file glsimplemoleculeview.h.

bool GLSimpleMoleculeView::showNumbers [private]
 

Is true if atom numbers should be shown.

Definition at line 144 of file glsimplemoleculeview.h.

unsigned int GLSimpleMoleculeView::chargeType [private]
 

Determines the type of charges to be shown.

Definition at line 145 of file glsimplemoleculeview.h.

AtomSet* GLSimpleMoleculeView::atoms [private]
 

The list of atoms.

Reimplemented in GLMoleculeView.

Definition at line 146 of file glsimplemoleculeview.h.

GLfloat GLSimpleMoleculeView::selectionLineWidth [private]
 

The linewidth for drawing selected bonds.

Definition at line 147 of file glsimplemoleculeview.h.

GLfloat GLSimpleMoleculeView::selectionPointSize [private]
 

The pointsize for drawing selected atoms.

Definition at line 148 of file glsimplemoleculeview.h.

float GLSimpleMoleculeView::scaleFactor [private]
 

scalefactor for scenes exceeding 50A in radius

Definition at line 149 of file glsimplemoleculeview.h.

QFont GLSimpleMoleculeView::labelFont [private]
 

The font used to render labels and other values.

Definition at line 150 of file glsimplemoleculeview.h.

const float GLSimpleMoleculeView::cylinderHeight = 10.0f [static, private]
 

The cylinder height. A too low value shows severe bugs in the Mesa OpenGL implementation.

Definition at line 153 of file glsimplemoleculeview.h.


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