Mantid
|
This class provides a widget to display a Mantid Geometry object using OpenGL. More...
#include <MantidGLWidget.h>
Public Member Functions | |
MantidGLWidget (QWidget *parent=nullptr) | |
Default constructor. More... | |
void | setDisplayObject (std::shared_ptr< Mantid::Geometry::IObject > object) |
Set the Mantid geometry object. More... | |
~MantidGLWidget () override | |
Destructor. More... | |
Protected Member Functions | |
void | initializeGL () override |
Initialize the renderer. More... | |
void | paintGL () override |
Render the scene. More... | |
void | resizeGL (int width, int height) override |
Set up the viewport. More... | |
Private Member Functions | |
void | mouseMoveEvent (QMouseEvent *event) override |
Handle a MouseMoveEvent. More... | |
void | mousePressEvent (QMouseEvent *event) override |
Handle a MousePressEvent. More... | |
void | normalizeAngle (int *angle) |
Ensure the angle is in the range 0 < angle < 360. More... | |
void | setOrthoProjectionMatrix (GLdouble aspect_ratio) |
Calculate and set the orthographic projection matrix. More... | |
void | setXRotation (int angle) |
Set the rotation angle around the X-axis. More... | |
void | setYRotation (int angle) |
Set the rotation angle around the Y-axis. More... | |
void | setZRotation (int angle) |
Set the rotation angle around the Z-axis. More... | |
Private Attributes | |
GLdouble | m_bb_centres [3] |
The centre of the bounding box. More... | |
GLdouble | m_bb_widths [3] |
The separation of the bounding box sides in x,y,z respectively. More... | |
QPoint | m_click_point |
The location of the cursor when the mouse button was clicked. More... | |
std::shared_ptr< Mantid::Geometry::IObject > | m_display_object |
A Mantid geometry object. More... | |
GLdouble | m_scale_factor |
The scaling factor to use. More... | |
GLdouble | m_x_rot |
The current X, Y and Z rotations. More... | |
GLdouble | m_y_rot |
GLdouble | m_z_rot |
This class provides a widget to display a Mantid Geometry object using OpenGL.
Definition at line 36 of file MantidGLWidget.h.
MantidGLWidget::MantidGLWidget | ( | QWidget * | parent = nullptr | ) |
Default constructor.
Constructor.
Definition at line 27 of file MantidGLWidget.cpp.
References m_bb_centres, and m_bb_widths.
|
override |
Destructor.
Definition at line 44 of file MantidGLWidget.cpp.
|
overrideprotected |
Initialize the renderer.
Initialize the OpenGL display.
Definition at line 87 of file MantidGLWidget.cpp.
|
overrideprivate |
Handle a MouseMoveEvent.
Handle an event where the cursor is moved with the mouse.
event | A pointer to the QMouseEvent |
Definition at line 171 of file MantidGLWidget.cpp.
References m_click_point, m_x_rot, m_y_rot, m_z_rot, setXRotation(), setYRotation(), and setZRotation().
|
overrideprivate |
Handle a MousePressEvent.
Handle an event when a mouse button is pressed.
event | A pointer to the QMouseEvent |
Definition at line 165 of file MantidGLWidget.cpp.
References m_click_point.
|
private |
Ensure the angle is in the range 0 < angle < 360.
Adjust the angle given so that it is within the range 0 < x < (360 * 16) (Note: The factor of 16 is due to Qt using angles in 1/16th of a degree)
angle | :: The angle of rotation |
Definition at line 267 of file MantidGLWidget.cpp.
Referenced by setXRotation(), setYRotation(), and setZRotation().
|
overrideprotected |
Render the scene.
Render the 3D scene.
Definition at line 121 of file MantidGLWidget.cpp.
References m_display_object, m_x_rot, m_y_rot, and m_z_rot.
|
overrideprotected |
Set up the viewport.
Handle a resize event.
width | :: The width of the resized viewport |
height | :: The height of the resized viewport |
Definition at line 152 of file MantidGLWidget.cpp.
References height, and setOrthoProjectionMatrix().
void MantidGLWidget::setDisplayObject | ( | std::shared_ptr< Mantid::Geometry::IObject > | object | ) |
Set the Mantid geometry object.
Set the shape object.
object | :: A pointer to the Mantid::Geometry::Object |
Definition at line 50 of file MantidGLWidget.cpp.
References height, m_bb_centres, m_bb_widths, m_display_object, m_x_rot, m_y_rot, m_z_rot, and setOrthoProjectionMatrix().
|
private |
Calculate and set the orthographic projection matrix.
Definition at line 223 of file MantidGLWidget.cpp.
References bottom, height, left, m_bb_centres, m_bb_widths, right, and top.
Referenced by resizeGL(), and setDisplayObject().
|
private |
Set the rotation angle around the X-axis.
Set the current rotation angle around the X-axis.
angle | :: The angle of rotation |
Definition at line 191 of file MantidGLWidget.cpp.
References m_x_rot, and normalizeAngle().
Referenced by mouseMoveEvent().
|
private |
Set the rotation angle around the Y-axis.
Set the current rotation angle around the Y-axis.
angle | :: The angle of rotation |
Definition at line 203 of file MantidGLWidget.cpp.
References m_y_rot, and normalizeAngle().
Referenced by mouseMoveEvent().
|
private |
Set the rotation angle around the Z-axis.
Set the current rotation angle around the Z-axis.
angle | :: The angle of rotation |
Definition at line 215 of file MantidGLWidget.cpp.
References m_z_rot, and normalizeAngle().
Referenced by mouseMoveEvent().
|
private |
The centre of the bounding box.
Definition at line 85 of file MantidGLWidget.h.
Referenced by MantidGLWidget(), setDisplayObject(), and setOrthoProjectionMatrix().
|
private |
The separation of the bounding box sides in x,y,z respectively.
Definition at line 83 of file MantidGLWidget.h.
Referenced by MantidGLWidget(), setDisplayObject(), and setOrthoProjectionMatrix().
|
private |
The location of the cursor when the mouse button was clicked.
Definition at line 81 of file MantidGLWidget.h.
Referenced by mouseMoveEvent(), and mousePressEvent().
|
private |
A Mantid geometry object.
Definition at line 75 of file MantidGLWidget.h.
Referenced by paintGL(), and setDisplayObject().
|
private |
The scaling factor to use.
Definition at line 79 of file MantidGLWidget.h.
|
private |
The current X, Y and Z rotations.
Definition at line 77 of file MantidGLWidget.h.
Referenced by mouseMoveEvent(), paintGL(), setDisplayObject(), and setXRotation().
|
private |
Definition at line 77 of file MantidGLWidget.h.
Referenced by mouseMoveEvent(), paintGL(), setDisplayObject(), and setYRotation().
|
private |
Definition at line 77 of file MantidGLWidget.h.
Referenced by mouseMoveEvent(), paintGL(), setDisplayObject(), and setZRotation().