• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

kalzium

Avogadro::GLWidget

Avogadro::GLWidget Class Reference

#include <avogadro/glwidget.h>

Inheritance diagram for Avogadro::GLWidget:

Inheritance graph
[legend]

List of all members.


Detailed Description

GL widget class for rendering molecules.

Author:
Donald Ephraim Curtis

Marcus D. Hanwell

This widget provides a 3D graphical view of a molecule. In terms of the Model-View architecture we consider the Molecule the model and GLWidget a view of this model. The widget relies on various Engine subclasses to handle the rendering of the 3d objects.

Each engine is allocated a PrimitiveList object. This queue contains all primitivew which that engine is responsible for rendering for this GLWidget. Thus, we can have one queue containing only the bonds, and one queue containing only the atoms which would allow bonds and atoms to be rendered by two different engines.

Definition at line 171 of file src/glwidget.h.


Public Slots

void addEngine (Engine *engine)
void addPrimitive (Primitive *primitive)
void invalidateDLs ()
void loadDefaultEngines ()
void removeEngine (Engine *engine)
void removePrimitive (Primitive *primitive)
void setBackground (const QColor &background)
void setMolecule (Molecule *molecule)
void setTool (Tool *tool)
void updatePrimitive (Primitive *primitive)

Signals

void engineAdded (Engine *engine)
void engineRemoved (Engine *engine)
void moleculeChanged (Molecule *previous, Molecule *next)
void mouseMove (QMouseEvent *event)
void mousePress (QMouseEvent *event)
void mouseRelease (QMouseEvent *event)
void wheel (QWheelEvent *event)

Public Member Functions

int aCells ()
QColor background () const
int bCells ()
Camera * camera () const
int cCells ()
const Eigen::Vector3d & center () const
Color * colorMap () const
Atom * computeClickedAtom (const QPoint &p)
Bond * computeClickedBond (const QPoint &p)
Primitive * computeClickedPrimitive (const QPoint &p)
int deviceHeight ()
int deviceWidth ()
QList< EngineFactory * > engineFactories () const
QList< Engine * > engines () const
const Atom * farthestAtom () const
 GLWidget (Molecule *molecule, const QGLFormat &format, QWidget *parent=0, const GLWidget *shareWidget=0)
 GLWidget (const QGLFormat &format, QWidget *parent=0, const GLWidget *shareWidget=0)
 GLWidget (QWidget *parent=0)
QList< GLHit > hits (int x, int y, int w, int h)
bool isStable () const
QSize minimumSizeHint () const
Molecule * molecule ()
const Molecule * molecule () const
const Eigen::Vector3d & normalVector () const
Painter * painter () const
PrimitiveList primitives () const
int quality () const
const double & radius () const
double radius (const Primitive *p) const
virtual void readSettings (QSettings &settings)
bool renderAxes ()
bool renderDebug ()
void setColorMap (Color *)
void setQuality (int quality)
void setRenderAxes (bool renderAxes)
void setRenderDebug (bool renderDebug)
void setStable (bool stable)
void setToolGroup (ToolGroup *toolGroup)
void setUndoStack (QUndoStack *undoStack)
void setUnitCells (int a, int b, int c)
QSize sizeHint () const
Tool * tool () const
ToolGroup * toolGroup () const
ToolGroup toolManger () const
QUndoStack * undoStack () const
void updateGeometry ()
virtual void writeSettings (QSettings &settings) const
 ~GLWidget ()
Selection Methods
These methods are used to manipulate user-selected primitives.

Each view tracks a list of selected objects (e.g., atoms) which can be passed to engines, tools, or used for tasks like copying selected atoms, etc.

void clearSelected ()
bool isSelected (const Primitive *p) const
PrimitiveList selectedPrimitives () const
void setSelected (PrimitiveList primitives, bool select=true)
void toggleSelected (PrimitiveList primitiveList)

Static Public Member Functions

static GLWidget * current ()
static void setCurrent (GLWidget *current)

Static Public Attributes

static GLWidget * m_current = 0

Protected Member Functions

virtual bool event (QEvent *event)
virtual void initializeGL ()
void loadEngineFactories ()
virtual void mouseMoveEvent (QMouseEvent *event)
virtual void mousePressEvent (QMouseEvent *event)
virtual void mouseReleaseEvent (QMouseEvent *event)
virtual void paintEvent (QPaintEvent *event)
virtual void paintGL ()
virtual void render ()
virtual void renderAxesOverlay ()
virtual void renderCrystal (GLuint displayList)
virtual void renderCrystalAxes ()
virtual void renderDebugOverlay ()
virtual void resizeEvent (QResizeEvent *event)
virtual void resizeGL (int, int)
virtual void wheelEvent (QWheelEvent *event)

Properties

QColor background

Constructor & Destructor Documentation

Avogadro::GLWidget::GLWidget ( QWidget *  parent = 0  ) 

Constructor.

Parameters:
parent the widget parent.

Definition at line 450 of file glwidget.cpp.

Avogadro::GLWidget::GLWidget ( const QGLFormat &  format,
QWidget *  parent = 0,
const GLWidget *  shareWidget = 0 
) [explicit]

Constructor.

Parameters:
format the QGLFormat information.
parent the widget parent.

Definition at line 456 of file glwidget.cpp.

Avogadro::GLWidget::GLWidget ( Molecule *  molecule,
const QGLFormat &  format,
QWidget *  parent = 0,
const GLWidget *  shareWidget = 0 
)

Constructor.

Parameters:
molecule the molecule to view.
format the QGLFormat information.
parent the widget parent.

Definition at line 463 of file glwidget.cpp.

Avogadro::GLWidget::~GLWidget (  ) 

Destructor.

Definition at line 472 of file glwidget.cpp.


Member Function Documentation

int Avogadro::GLWidget::aCells (  ) 

Returns:
the number of unit cells to display along the a axis.

Definition at line 1594 of file glwidget.cpp.

void Avogadro::GLWidget::addEngine ( Engine *  engine  )  [slot]

Parameters:
engine Engine to add to this widget.

Definition at line 1272 of file glwidget.cpp.

void Avogadro::GLWidget::addPrimitive ( Primitive *  primitive  )  [slot]

Add the primitive to the widget.

This slot is called whenever a new primitive is added to our molecule model. It adds the primitive to the list in the appropriate group.

Parameters:
primitive pointer to a primitive to add to the view

Definition at line 1241 of file glwidget.cpp.

QColor Avogadro::GLWidget::background (  )  const

Returns:
the current background color of the rendering area.

int Avogadro::GLWidget::bCells (  ) 

Returns:
the number of unit cells to display along the b axis.

Definition at line 1599 of file glwidget.cpp.

Camera * Avogadro::GLWidget::camera (  )  const

Returns:
a pointer to the Camera of this widget.

Definition at line 1221 of file glwidget.cpp.

int Avogadro::GLWidget::cCells (  ) 

Returns:
the number of unit cells to display along the c axis.

Definition at line 1604 of file glwidget.cpp.

const Vector3d & Avogadro::GLWidget::center (  )  const

Returns:
the point at the center of the Molecule.

Definition at line 1137 of file glwidget.cpp.

void Avogadro::GLWidget::clearSelected (  ) 

Deselect all objects.

Definition at line 1571 of file glwidget.cpp.

Color * Avogadro::GLWidget::colorMap (  )  const

Returns:
the current global color map for Primitives.

Definition at line 625 of file glwidget.cpp.

Atom * Avogadro::GLWidget::computeClickedAtom ( const QPoint &  p  ) 

Take a point and figure out which is the closest Atom under that point.

Parameters:
p the point on the widget that was clicked.
Returns:
the closest Atom that was clicked or 0 if nothing.

Definition at line 1467 of file glwidget.cpp.

Bond * Avogadro::GLWidget::computeClickedBond ( const QPoint &  p  ) 

Take a point and figure out which is the closest Bond under that point.

Parameters:
p the point on the widget that was clicked.
Returns:
the closest Bond that was clicked or 0 if nothing.

Definition at line 1485 of file glwidget.cpp.

Primitive * Avogadro::GLWidget::computeClickedPrimitive ( const QPoint &  p  ) 

Take a point and figure out which is the closest Primitive under that point.

Parameters:
p the point on the widget that was clicked.
Returns:
the closest Primitive that was clicked or 0 if nothing.

Definition at line 1446 of file glwidget.cpp.

GLWidget * Avogadro::GLWidget::current (  )  [static]

Returns:
a pointer to the current GLWidget.

Definition at line 523 of file glwidget.cpp.

int Avogadro::GLWidget::deviceHeight (  )  [inline]

Returns:
the height of the widget in pixels.

Definition at line 225 of file src/glwidget.h.

int Avogadro::GLWidget::deviceWidth (  )  [inline]

Returns:
the width of the widget in pixels.

Definition at line 220 of file src/glwidget.h.

void Avogadro::GLWidget::engineAdded ( Engine *  engine  )  [signal]

Signal that an Engine has been added to the GLWidget.

QList< EngineFactory * > Avogadro::GLWidget::engineFactories (  )  const

Returns:
a list of the engine factories.

Definition at line 1231 of file glwidget.cpp.

void Avogadro::GLWidget::engineRemoved ( Engine *  engine  )  [signal]

Signal that an Engine has been removed from the GLWidget.

QList< Engine * > Avogadro::GLWidget::engines (  )  const

Returns:
a list of engines.

Definition at line 1226 of file glwidget.cpp.

bool Avogadro::GLWidget::event ( QEvent *  event  )  [protected, virtual]

Focus Event.

Definition at line 991 of file glwidget.cpp.

const Atom * Avogadro::GLWidget::farthestAtom (  )  const

Returns:
the Atom farthest away from the camera.

Definition at line 1152 of file glwidget.cpp.

QList< GLHit > Avogadro::GLWidget::hits ( int  x,
int  y,
int  w,
int  h 
)

Get the hits for a region starting at (x, y) of size (w * h).

Definition at line 1339 of file glwidget.cpp.

void Avogadro::GLWidget::initializeGL (  )  [protected, virtual]

Virtual function called by QGLWidget on initialization of the GL area.

Reimplemented from QGLWidget.

Definition at line 533 of file glwidget.cpp.

void Avogadro::GLWidget::invalidateDLs (  )  [slot]

Signal that something changed and the display lists should be invalidated.

Definition at line 1717 of file glwidget.cpp.

bool Avogadro::GLWidget::isSelected ( const Primitive *  p  )  const

Returns:
true if the Primitive is selected.

Definition at line 1578 of file glwidget.cpp.

bool Avogadro::GLWidget::isStable (  )  const

Returns:
true if the GLWidget is stable as determined by the tools and extensions.

Definition at line 1529 of file glwidget.cpp.

void Avogadro::GLWidget::loadDefaultEngines (  )  [slot]

Reset to default engines (one of each factory).

Definition at line 1698 of file glwidget.cpp.

void Avogadro::GLWidget::loadEngineFactories (  )  [protected]

Helper function to load all engine factories.

QSize Avogadro::GLWidget::minimumSizeHint (  )  const

Virtual function setting the minimum size hit for this widget.

Returns:
the minimum size the widget can take without causing unspecified behaviour.

Definition at line 1508 of file glwidget.cpp.

Molecule * Avogadro::GLWidget::molecule (  ) 

Returns:
the current Molecule being viewed.

Definition at line 1132 of file glwidget.cpp.

const Molecule * Avogadro::GLWidget::molecule (  )  const

Returns:
the current Molecule being viewed.

Definition at line 1127 of file glwidget.cpp.

void Avogadro::GLWidget::moleculeChanged ( Molecule *  previous,
Molecule *  next 
) [signal]

Signal that the Molecule has changed.

void Avogadro::GLWidget::mouseMove ( QMouseEvent *  event  )  [signal]

Signal for the mouse move event which is passed to the engines and tools.

void Avogadro::GLWidget::mouseMoveEvent ( QMouseEvent *  event  )  [protected, virtual]

Virtual function reaction to mouse being moved in the GL rendering area.

Definition at line 1036 of file glwidget.cpp.

void Avogadro::GLWidget::mousePress ( QMouseEvent *  event  )  [signal]

Signal for the mouse press event which is passed to the engines and tools.

void Avogadro::GLWidget::mousePressEvent ( QMouseEvent *  event  )  [protected, virtual]

Virtual function reaction to mouse press in the GL rendering area.

Definition at line 1001 of file glwidget.cpp.

void Avogadro::GLWidget::mouseRelease ( QMouseEvent *  event  )  [signal]

Signal for the mouse release event which is passed to the engines and tools.

void Avogadro::GLWidget::mouseReleaseEvent ( QMouseEvent *  event  )  [protected, virtual]

Virtual function reaction to mouse release in the GL rendering area.

Definition at line 1015 of file glwidget.cpp.

const Vector3d & Avogadro::GLWidget::normalVector (  )  const

Returns:
the normalVector for the entire Molecule.

Definition at line 1142 of file glwidget.cpp.

Painter * Avogadro::GLWidget::painter (  )  const

Returns the Painter of this widget.

For instance, to draw a sphere in this widget, you could do:

          painter()->drawSphere(center, radius)
See also:
class Painter

Definition at line 1334 of file glwidget.cpp.

void Avogadro::GLWidget::paintEvent ( QPaintEvent *  event  )  [protected, virtual]

Virtual function called when the GL area needs repainting.

Reimplemented from QGLWidget.

Definition at line 970 of file glwidget.cpp.

void Avogadro::GLWidget::paintGL (  )  [protected, virtual]

Virtual function called by GLWidget before render() to set up the display correctly.

Reimplemented from QGLWidget.

Definition at line 951 of file glwidget.cpp.

PrimitiveList Avogadro::GLWidget::primitives (  )  const

Returns:
list of primitives for this widget

Definition at line 1236 of file glwidget.cpp.

int Avogadro::GLWidget::quality (  )  const

Returns:
the global quality of the widget.

Definition at line 640 of file glwidget.cpp.

const double & Avogadro::GLWidget::radius (  )  const

Returns:
the radius of the Molecule.

Definition at line 1147 of file glwidget.cpp.

double Avogadro::GLWidget::radius ( const Primitive *  p  )  const

Returns:
the radius of the primitive object for this glwidget.

Definition at line 1513 of file glwidget.cpp.

void Avogadro::GLWidget::readSettings ( QSettings &  settings  )  [virtual]

Read the settings of the GLWidget and restore them.

Definition at line 1659 of file glwidget.cpp.

void Avogadro::GLWidget::removeEngine ( Engine *  engine  )  [slot]

Parameters:
engine Engine to remove from this widget.

Definition at line 1282 of file glwidget.cpp.

void Avogadro::GLWidget::removePrimitive ( Primitive *  primitive  )  [slot]

Remove a primitive.

This slot is called whenever a primitive of our molecule model has been removed and we need to take it off our list. Additionally we need to update other items in our view that are impacted by this change.

Parameters:
primitive object to remove.

Definition at line 1260 of file glwidget.cpp.

void Avogadro::GLWidget::render (  )  [protected, virtual]

Render the scene.

To be used in both modes GL_RENDER and GL_SELECT. This function calls the render functions of the engines as well as the paint events of the tools and is where everything drawn onto the widget is called from.

Definition at line 667 of file glwidget.cpp.

bool Avogadro::GLWidget::renderAxes (  ) 

Returns:
true if the x, y, z axes are being rendered.

Definition at line 651 of file glwidget.cpp.

void Avogadro::GLWidget::renderAxesOverlay (  )  [protected, virtual]

Render x, y, z axes as an overlay on the bottom left of the widget.

Definition at line 873 of file glwidget.cpp.

void Avogadro::GLWidget::renderCrystal ( GLuint  displayList  )  [protected, virtual]

Render a full crystal cell Called by render() automatically.

Parameters:
displayList the display list of the primitive unit cell

Definition at line 739 of file glwidget.cpp.

void Avogadro::GLWidget::renderCrystalAxes (  )  [protected, virtual]

Render crystal unit cell axes called by renderCrystal() automatically.

Definition at line 775 of file glwidget.cpp.

bool Avogadro::GLWidget::renderDebug (  ) 

Returns:
true if the debug panel is being drawn

Definition at line 662 of file glwidget.cpp.

void Avogadro::GLWidget::renderDebugOverlay (  )  [protected, virtual]

Render a debug overlay with extra debug information on the GLWidget.

Definition at line 928 of file glwidget.cpp.

void Avogadro::GLWidget::resizeEvent ( QResizeEvent *  event  )  [protected, virtual]

Called on resize of the GLWidget to perform resizing of the display.

Reimplemented from QGLWidget.

Definition at line 578 of file glwidget.cpp.

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

Virtual function called whn the GL area is resized.

Reimplemented from QGLWidget.

Definition at line 598 of file glwidget.cpp.

PrimitiveList Avogadro::GLWidget::selectedPrimitives (  )  const

Returns:
the current selected primitives (all Primitive types)

Definition at line 1553 of file glwidget.cpp.

void Avogadro::GLWidget::setBackground ( const QColor &  background  )  [slot]

Set the background color of the rendering area (the default is black).

Parameters:
background the new background color.

Definition at line 603 of file glwidget.cpp.

void Avogadro::GLWidget::setColorMap ( Color *  map  ) 

Set the current global color map for Primitives.

Definition at line 620 of file glwidget.cpp.

void Avogadro::GLWidget::setCurrent ( GLWidget *  current  )  [static]

Set this instance of the GLWidget as the current GLWidget instance.

Definition at line 528 of file glwidget.cpp.

void Avogadro::GLWidget::setMolecule ( Molecule *  molecule  )  [slot]

Set the molecule model for this view.

Parameters:
molecule the molecule to view.

Definition at line 1064 of file glwidget.cpp.

void Avogadro::GLWidget::setQuality ( int  quality  ) 

Parameters:
quality set the global quality of the widget.

Reimplemented in KalziumGLWidget.

Definition at line 633 of file glwidget.cpp.

void Avogadro::GLWidget::setRenderAxes ( bool  renderAxes  ) 

Set to render x, y, z axes as an overlay in the bottom left of the widget.

Definition at line 645 of file glwidget.cpp.

void Avogadro::GLWidget::setRenderDebug ( bool  renderDebug  ) 

Set to render the "debug info" (i.e., FPS, number of atoms, etc.

)

Definition at line 656 of file glwidget.cpp.

void Avogadro::GLWidget::setSelected ( PrimitiveList  primitives,
bool  select = true 
)

Change the selection status for the atoms in the supplied list.

All objects in the list will have the same selection status.

Parameters:
primitives the set of objects to update.
select whether to select or deselect the objects.

Definition at line 1539 of file glwidget.cpp.

void Avogadro::GLWidget::setStable ( bool  stable  ) 

Parameters:
stable the new stable value.

Definition at line 1534 of file glwidget.cpp.

void Avogadro::GLWidget::setTool ( Tool *  tool  )  [slot]

Set the active Tool of the GLWidget.

Definition at line 1292 of file glwidget.cpp.

void Avogadro::GLWidget::setToolGroup ( ToolGroup *  toolGroup  ) 

Set the ToolGroup of the GLWidget.

Definition at line 1299 of file glwidget.cpp.

void Avogadro::GLWidget::setUndoStack ( QUndoStack *  undoStack  ) 

Parameters:
undoStack the new undoStack.

Definition at line 1314 of file glwidget.cpp.

void Avogadro::GLWidget::setUnitCells ( int  a,
int  b,
int  c 
)

Set the number of unit cells for a periodic molecule like a crystal a, b, and c, are the three primitive unit cell axes.

Does nothing if the molecule does not have a unit cell defined.

Parameters:
a number of unit cells to display along the a axis.
b number of unit cells to display along the b axis.
c number of unit cells to display along the c axis.

Definition at line 1584 of file glwidget.cpp.

QSize Avogadro::GLWidget::sizeHint (  )  const

Virtual function setting the size hint for this widget.

Returns:
the preferred size of the widget.

Definition at line 1503 of file glwidget.cpp.

void Avogadro::GLWidget::toggleSelected ( PrimitiveList  primitiveList  ) 

Toggle the selection for the atoms in the supplied list.

That is, if the primitive is selected, deselect it and vice-versa.

Parameters:
primitives the set of objects to update.

Definition at line 1558 of file glwidget.cpp.

Tool * Avogadro::GLWidget::tool (  )  const

Returns:
the active Tool.

Definition at line 1324 of file glwidget.cpp.

ToolGroup * Avogadro::GLWidget::toolGroup (  )  const

Returns:
the ToolGroup of the GLWidget.

Definition at line 1329 of file glwidget.cpp.

ToolGroup Avogadro::GLWidget::toolManger (  )  const

Returns:
the ToolGroup manager.

QUndoStack * Avogadro::GLWidget::undoStack (  )  const

Returns:
the current GLWidget undoStack.

Definition at line 1319 of file glwidget.cpp.

void Avogadro::GLWidget::updateGeometry (  ) 

update the Molecule geometry.

Definition at line 1157 of file glwidget.cpp.

void Avogadro::GLWidget::updatePrimitive ( Primitive *  primitive  )  [slot]

Update a primitive.

This slot is called whenever a primitive of our molecule model has been changed and we need to check our view.

Note:
In some cases we are passed the molecule itself meaning that more than one thing has changed in the molecule.
Parameters:
primitive object which changed.

Definition at line 1252 of file glwidget.cpp.

void Avogadro::GLWidget::wheel ( QWheelEvent *  event  )  [signal]

Signal for the mouse wheel event which is passed to the engines and tools.

void Avogadro::GLWidget::wheelEvent ( QWheelEvent *  event  )  [protected, virtual]

Virtual function reaction to mouse while in the GL rendering area.

Definition at line 1054 of file glwidget.cpp.

void Avogadro::GLWidget::writeSettings ( QSettings &  settings  )  const [virtual]

Write the settings of the