AvogadroLibs 1.97.0
Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | List of all members
GLWidget Class Reference

QOpenGLGLWidget derived object for displaying 3D molecular geometry. More...

#include <avogadro/qtopengl/glwidget.h>

Inheritance diagram for GLWidget:

Public Slots

void updateScene ()
 
void clearScene ()
 
void resetCamera ()
 
void resetGeometry ()
 
void setTools (const QList< QtGui::ToolPlugin * > &toolList)
 
void addTool (QtGui::ToolPlugin *tool)
 
void requestUpdate ()
 
void setActiveTool (const QString &name)
 
void setActiveTool (QtGui::ToolPlugin *tool)
 
void setDefaultTool (const QString &name)
 
void setDefaultTool (QtGui::ToolPlugin *tool)
 

Signals

void rendererInvalid ()
 

Public Member Functions

 GLWidget (QWidget *parent=nullptr)
 
void setMolecule (QtGui::Molecule *molecule)
 
Rendering::GLRendererrenderer ()
 
QList< QtGui::ToolPlugin * > tools () const
 
QtGui::ToolPluginactiveTool () const
 
QtGui::ToolPlugindefaultTool () const
 
bool isValid () const
 
QString error () const
 
QtGui::Moleculemolecule ()
 
const QtGui::Moleculemolecule () const
 
QtGui::ScenePluginModelsceneModel ()
 
const QtGui::ScenePluginModelsceneModel () const
 

Protected Slots

void updateTimeout ()
 

Protected Member Functions

void initializeGL () override
 
void resizeGL (int width, int height) override
 
void paintGL () override
 
void mouseDoubleClickEvent (QMouseEvent *) override
 
void mousePressEvent (QMouseEvent *) override
 
void mouseMoveEvent (QMouseEvent *) override
 
void mouseReleaseEvent (QMouseEvent *) override
 
void wheelEvent (QWheelEvent *) override
 
void keyPressEvent (QKeyEvent *) override
 
void keyReleaseEvent (QKeyEvent *) override
 

Detailed Description

Author
Marcus D. Hanwell

This class creates the GL context, and contains a renderer to render the 3D molecular geometry.

The GLWidget also manages a collection of ToolPlugins that are used to respond to user input events. Use setTools() or addTool() to add tools to the widget. Use setActiveTool() to indicate which tool is active. The active tool will be given the opportunity to handle input events first. If the active tool does not handle the event, the default tool will be used. If the default tool also ignores the event, it will be passed to QOpenGLWidget's handlers.

Member Function Documentation

◆ setMolecule()

void setMolecule ( QtGui::Molecule molecule)

Set the molecule the widget will render.

◆ molecule() [1/2]

QtGui::Molecule * molecule ( )

Get the molecule being rendered by the widget.

◆ molecule() [2/2]

const QtGui::Molecule * molecule ( ) const

Get the molecule being rendered by the widget.

◆ renderer()

Rendering::GLRenderer & renderer ( )

Get a reference to the renderer for the widget.

◆ tools()

QList< QtGui::ToolPlugin * > tools ( ) const
Returns
A list of the ToolPlugins owned by the GLWidget.

◆ activeTool()

QtGui::ToolPlugin * activeTool ( ) const
Returns
The active tool.

◆ defaultTool()

QtGui::ToolPlugin * defaultTool ( ) const
Returns
The default tool.

◆ sceneModel() [1/2]

QtGui::ScenePluginModel & sceneModel ( )

Get the GLWidget's ScenePluginModel, used to add, delete and modify the scene plugin items.

◆ sceneModel() [2/2]

const QtGui::ScenePluginModel & sceneModel ( ) const

Get the GLWidget's ScenePluginModel, used to add, delete and modify the scene plugin items.

◆ isValid()

bool isValid ( ) const

Check if the GLWidget was able to acquire a context, and set up the renderer correctly. If not valid, the error method may provide more information.

Returns
true if value, false if not.

◆ error()

QString error ( ) const

Get the error(s), if any, encountered when setting up the GLWidget.

Returns
A free form string containing errors encountered.

◆ updateScene

void updateScene ( )
slot

Update the scene plugins for the widget, this will generate geometry in the scene etc.

◆ clearScene

void clearScene ( )
slot

Clear the contents of the scene.

◆ resetCamera

void resetCamera ( )
slot

Reset the view to fit the entire scene.

◆ resetGeometry

void resetGeometry ( )
slot

Reset the geometry when the molecule etc changes.

◆ setTools

void setTools ( const QList< QtGui::ToolPlugin * > &  toolList)
slot

Make the tools in toolList available to the GLWidget. The GLWidget takes ownership of the tools.

◆ addTool

void addTool ( QtGui::ToolPlugin tool)
slot

Make tool available to the GLWidget. The GLWidget takes ownership of the tool.

◆ setActiveTool [1/2]

void setActiveTool ( const QString &  name)
slot

Set the active tool. This is the tool that will be used to handle input events first.

◆ setActiveTool [2/2]

void setActiveTool ( QtGui::ToolPlugin tool)
slot

Set the active tool. This is the tool that will be used to handle input events first.

◆ setDefaultTool [1/2]

void setDefaultTool ( const QString &  name)
slot

Set the default tool. This is the tool that will be used to handle input events that are ignored by the active tool.

◆ setDefaultTool [2/2]

void setDefaultTool ( QtGui::ToolPlugin tool)
slot

Set the default tool. This is the tool that will be used to handle input events that are ignored by the active tool.

◆ requestUpdate

void requestUpdate ( )
slot

Request an update, this will by default initiate a timer that will trigger in a specified time, enabling us to compress multiple events such as camera moves to maintain interactivity.

◆ updateTimeout

void updateTimeout ( )
protectedslot

Perform the update of the render, this should only be called by the timer.

◆ initializeGL()

void initializeGL ( )
overrideprotected

This is where the GL context is initialized.

◆ resizeGL()

void resizeGL ( int  width,
int  height 
)
overrideprotected

Take care of resizing the context.

◆ paintGL()

void paintGL ( )
overrideprotected

Main entry point for all GL rendering.

◆ mouseDoubleClickEvent()

void mouseDoubleClickEvent ( QMouseEvent *  )
overrideprotected

Reimplemented from QOpenGLWidget

◆ mousePressEvent()

void mousePressEvent ( QMouseEvent *  )
overrideprotected

Reimplemented from QOpenGLWidget

◆ mouseMoveEvent()

void mouseMoveEvent ( QMouseEvent *  )
overrideprotected

Reimplemented from QOpenGLWidget

◆ mouseReleaseEvent()

void mouseReleaseEvent ( QMouseEvent *  )
overrideprotected

Reimplemented from QOpenGLWidget

◆ wheelEvent()

void wheelEvent ( QWheelEvent *  )
overrideprotected

Reimplemented from QOpenGLWidget

◆ keyPressEvent()

void keyPressEvent ( QKeyEvent *  )
overrideprotected

Reimplemented from QOpenGLWidget

◆ keyReleaseEvent()

void keyReleaseEvent ( QKeyEvent *  )
overrideprotected

Reimplemented from QOpenGLWidget


The documentation for this class was generated from the following file: