Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
MantidQt::CustomDialogs::MantidGLWidget Class Reference

This class provides a widget to display a Mantid Geometry object using OpenGL. More...

#include <MantidGLWidget.h>

Inheritance diagram for MantidQt::CustomDialogs::MantidGLWidget:

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::IObjectm_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
 

Detailed Description

This class provides a widget to display a Mantid Geometry object using OpenGL.

Author
Martyn Gigg, Tessella Support Services plc
Date
18/05/2009

Definition at line 36 of file MantidGLWidget.h.

Constructor & Destructor Documentation

◆ MantidGLWidget()

MantidGLWidget::MantidGLWidget ( QWidget *  parent = nullptr)

Default constructor.

Constructor.

Definition at line 27 of file MantidGLWidget.cpp.

References m_bb_centres, and m_bb_widths.

◆ ~MantidGLWidget()

MantidGLWidget::~MantidGLWidget ( )
override

Destructor.

Definition at line 44 of file MantidGLWidget.cpp.

Member Function Documentation

◆ initializeGL()

void MantidGLWidget::initializeGL ( )
overrideprotected

Initialize the renderer.

Initialize the OpenGL display.

Definition at line 87 of file MantidGLWidget.cpp.

◆ mouseMoveEvent()

void MantidGLWidget::mouseMoveEvent ( QMouseEvent *  event)
overrideprivate

Handle a MouseMoveEvent.

Handle an event where the cursor is moved with the mouse.

Parameters
eventA 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().

◆ mousePressEvent()

void MantidGLWidget::mousePressEvent ( QMouseEvent *  event)
overrideprivate

Handle a MousePressEvent.

Handle an event when a mouse button is pressed.

Parameters
eventA pointer to the QMouseEvent

Definition at line 165 of file MantidGLWidget.cpp.

References m_click_point.

◆ normalizeAngle()

void MantidGLWidget::normalizeAngle ( int *  angle)
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)

Parameters
angle:: The angle of rotation

Definition at line 267 of file MantidGLWidget.cpp.

Referenced by setXRotation(), setYRotation(), and setZRotation().

◆ paintGL()

void MantidGLWidget::paintGL ( )
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.

◆ resizeGL()

void MantidGLWidget::resizeGL ( int  width,
int  height 
)
overrideprotected

Set up the viewport.

Handle a resize event.

Parameters
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().

◆ setDisplayObject()

void MantidGLWidget::setDisplayObject ( std::shared_ptr< Mantid::Geometry::IObject object)

Set the Mantid geometry object.

Set the shape object.

Parameters
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().

◆ setOrthoProjectionMatrix()

void MantidGLWidget::setOrthoProjectionMatrix ( GLdouble  aspect_ratio)
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().

◆ setXRotation()

void MantidGLWidget::setXRotation ( int  angle)
private

Set the rotation angle around the X-axis.

Set the current rotation angle around the X-axis.

Parameters
angle:: The angle of rotation

Definition at line 191 of file MantidGLWidget.cpp.

References m_x_rot, and normalizeAngle().

Referenced by mouseMoveEvent().

◆ setYRotation()

void MantidGLWidget::setYRotation ( int  angle)
private

Set the rotation angle around the Y-axis.

Set the current rotation angle around the Y-axis.

Parameters
angle:: The angle of rotation

Definition at line 203 of file MantidGLWidget.cpp.

References m_y_rot, and normalizeAngle().

Referenced by mouseMoveEvent().

◆ setZRotation()

void MantidGLWidget::setZRotation ( int  angle)
private

Set the rotation angle around the Z-axis.

Set the current rotation angle around the Z-axis.

Parameters
angle:: The angle of rotation

Definition at line 215 of file MantidGLWidget.cpp.

References m_z_rot, and normalizeAngle().

Referenced by mouseMoveEvent().

Member Data Documentation

◆ m_bb_centres

GLdouble MantidQt::CustomDialogs::MantidGLWidget::m_bb_centres[3]
private

The centre of the bounding box.

Definition at line 85 of file MantidGLWidget.h.

Referenced by MantidGLWidget(), setDisplayObject(), and setOrthoProjectionMatrix().

◆ m_bb_widths

GLdouble MantidQt::CustomDialogs::MantidGLWidget::m_bb_widths[3]
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().

◆ m_click_point

QPoint MantidQt::CustomDialogs::MantidGLWidget::m_click_point
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().

◆ m_display_object

std::shared_ptr<Mantid::Geometry::IObject> MantidQt::CustomDialogs::MantidGLWidget::m_display_object
private

A Mantid geometry object.

Definition at line 75 of file MantidGLWidget.h.

Referenced by paintGL(), and setDisplayObject().

◆ m_scale_factor

GLdouble MantidQt::CustomDialogs::MantidGLWidget::m_scale_factor
private

The scaling factor to use.

Definition at line 79 of file MantidGLWidget.h.

◆ m_x_rot

GLdouble MantidQt::CustomDialogs::MantidGLWidget::m_x_rot
private

The current X, Y and Z rotations.

Definition at line 77 of file MantidGLWidget.h.

Referenced by mouseMoveEvent(), paintGL(), setDisplayObject(), and setXRotation().

◆ m_y_rot

GLdouble MantidQt::CustomDialogs::MantidGLWidget::m_y_rot
private

Definition at line 77 of file MantidGLWidget.h.

Referenced by mouseMoveEvent(), paintGL(), setDisplayObject(), and setYRotation().

◆ m_z_rot

GLdouble MantidQt::CustomDialogs::MantidGLWidget::m_z_rot
private

Definition at line 77 of file MantidGLWidget.h.

Referenced by mouseMoveEvent(), paintGL(), setDisplayObject(), and setZRotation().


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