kalzium
Avogadro::GLWidget Class Reference
#include <avogadro/glwidget.h>

Detailed Description
GL widget class for rendering molecules.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 |
) |
| 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 | ( | ) |
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] |
| 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 |
| 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 |
| void Avogadro::GLWidget::clearSelected | ( | ) |
| Color * Avogadro::GLWidget::colorMap | ( | ) | const |
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.
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.
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] |
| int Avogadro::GLWidget::deviceHeight | ( | ) | [inline] |
| int Avogadro::GLWidget::deviceWidth | ( | ) | [inline] |
| void Avogadro::GLWidget::engineAdded | ( | Engine * | engine | ) | [signal] |
| QList< EngineFactory * > Avogadro::GLWidget::engineFactories | ( | ) | const |
| void Avogadro::GLWidget::engineRemoved | ( | Engine * | engine | ) | [signal] |
| bool Avogadro::GLWidget::event | ( | QEvent * | event | ) | [protected, virtual] |
| const Atom * Avogadro::GLWidget::farthestAtom | ( | ) | const |
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 |
| 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] |
| 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 | ( | ) |
| const Molecule * Avogadro::GLWidget::molecule | ( | ) | const |
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 |
| Painter * Avogadro::GLWidget::painter | ( | ) | const |
| 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 |
| int Avogadro::GLWidget::quality | ( | ) | const |
| const double & Avogadro::GLWidget::radius | ( | ) | const |
| 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] |
| void Avogadro::GLWidget::removeEngine | ( | Engine * | engine | ) | [slot] |
| 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 | ( | ) |
| 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 | ( | ) |
| 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 | ) |
| 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 | ) |
| void Avogadro::GLWidget::setTool | ( | Tool * | tool | ) | [slot] |
| void Avogadro::GLWidget::setToolGroup | ( | ToolGroup * | toolGroup | ) |
| void Avogadro::GLWidget::setUndoStack | ( | QUndoStack * | undoStack | ) |
| 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 |
| ToolGroup * Avogadro::GLWidget::toolGroup | ( | ) | const |
| QUndoStack * Avogadro::GLWidget::undoStack | ( | ) | const |
| void Avogadro::GLWidget::updateGeometry | ( | ) |
| 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] |
KDE 4.2 API Reference