OpenWalnut  1.5.0dev
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
WQtGLWidget Class Reference

A widget containing an open gl display area. More...

#include <WQtGLWidget.h>

+ Inheritance diagram for WQtGLWidget:
+ Collaboration diagram for WQtGLWidget:

Public Types

enum  CameraManipulators { TRACKBALL , TWO_D , NO_OP , ADVANCED }
 List of currently possible camera manipulators. More...
 

Public Slots

void reset ()
 Resets the contained view using the installed manipulator. More...
 
void setPresetViewLeft ()
 Sets the left preset view of the main viewer. More...
 
void setPresetViewRight ()
 Sets the right preset view of the main viewer. More...
 
void setPresetViewSuperior ()
 Sets the superior preset view of the main viewer. More...
 
void setPresetViewInferior ()
 Sets the inferior preset view of the main viewer. More...
 
void setPresetViewAnterior ()
 Sets the anterior preset view of the main viewer. More...
 
void setPresetViewPosterior ()
 Sets the posterior preset view of the main viewer. More...
 
void setFitScreenPosition ()
 Zooms and centers the view to fit the viewer. More...
 

Signals

void renderedFirstFrame ()
 Signals that the first frame was rendered. More...
 

Public Member Functions

 WQtGLWidget (std::string nameOfViewer, QWidget *parent=0, WGECamera::ProjectionMode projectionMode=WGECamera::ORTHOGRAPHIC, const QWidget *shareWidget=0)
 Default constructor. More...
 
virtual ~WQtGLWidget ()
 Destructor. More...
 
void setCameraManipulator (CameraManipulators manipulator)
 Sets the camera manipulator to use. More...
 
CameraManipulators getCameraManipulators ()
 Returns the actually set camera manipulator. More...
 
std::shared_ptr< WGEViewergetViewer () const
 Get the included viewer. More...
 
QMenugetCameraPresetsMenu ()
 The presets menu. More...
 
QMenugetCameraPresetsAndResetMenu ()
 The presets menu including the reset action. More...
 
QActiongetCameraResetAction ()
 The action to trigger a camera reset. More...
 
virtual void cleanUp ()
 Called on close. More...
 
void setPaused (bool pause=true)
 Pause rendering. More...
 
bool getPaused () const
 Query whether the view is paused or not. More...
 

Static Public Member Functions

static const QGLFormat getDefaultFormat ()
 Creates and returns a default OpenGL format description with vertical sync enabled. More...
 

Protected Member Functions

virtual void mouseDoubleClickEvent (QMouseEvent *event)
 Event handler for double clicks. More...
 
virtual void resizeGL (int width, int height)
 Event handler for resize events. More...
 
virtual void keyPressEvent (QKeyEvent *event)
 Event handler for key press. More...
 
virtual void keyReleaseEvent (QKeyEvent *event)
 Event handler for key release. More...
 
virtual void mousePressEvent (QMouseEvent *event)
 Event handler for mouse button press. More...
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 Event handler for mouse button release. More...
 
virtual void mouseMoveEvent (QMouseEvent *event)
 Event handler for mouse moves. More...
 
virtual void wheelEvent (QWheelEvent *event)
 Event handler for the mouse wheel. More...
 
virtual void paintEvent (QPaintEvent *event)
 QT Callback for handling repaints. More...
 
virtual void paintGL ()
 QT Callback for handling repaints. More...
 
int translateButton (QMouseEvent *event)
 Simply translate the mouse button from an event to an int. More...
 
virtual bool event (QEvent *event)
 Custom event dispatcher. More...
 
virtual void closeEvent (QCloseEvent *event)
 Called on close. More...
 

Protected Attributes

std::shared_ptr< WGEViewerm_Viewer
 The viewer to the scene. More...
 
std::string m_nameOfViewer
 The name of the viewer. More...
 
CameraManipulators m_CurrentManipulator
 Stores the current manipulator. More...
 
WGECamera::ProjectionMode m_initialProjectionMode
 Camera projection mode used to initialize widget. More...
 

Private Member Functions

void notifyFirstRenderedFrame ()
 Called by the WGEViewer to notify about the first frame rendered. More...
 

Private Attributes

QTimer m_Timer
 Timer for periodic repaints. More...
 
bool m_firstPaint
 This flag is set to true if the first paint call occured. More...
 
QMenum_cameraPresetMenu
 Camera menu. More...
 
QMenum_cameraPresetResetMenu
 Camera menu with reset action. More...
 
QActionm_cameraResetAction
 Camera reset. More...
 

Detailed Description

A widget containing an open gl display area.

This initializes OpenGL context and adds a view to the engine.

Definition at line 53 of file WQtGLWidget.h.

Member Enumeration Documentation

◆ CameraManipulators

List of currently possible camera manipulators.

Definition at line 77 of file WQtGLWidget.h.

Constructor & Destructor Documentation

◆ WQtGLWidget()

WQtGLWidget::WQtGLWidget ( std::string  nameOfViewer,
QWidget *  parent = 0,
WGECamera::ProjectionMode  projectionMode = WGECamera::ORTHOGRAPHIC,
const QWidget *  shareWidget = 0 
)
explicit

Default constructor.

Parameters
nameOfViewerName of the Viewer
parentParent widget.
projectionModedecides whether the widget uses perspective or othographic projection
shareWidgetthis widget will share OpenGL display lists and texture objects with shareWidget

Definition at line 54 of file WQtGLWidget.cpp.

References WKernel::getGraphicsEngine(), WQtGui::getIconManager(), WKernel::getRunningKernel(), m_cameraPresetMenu, m_cameraPresetResetMenu, m_cameraResetAction, m_initialProjectionMode, m_nameOfViewer, m_Timer, m_Viewer, notifyFirstRenderedFrame(), reset(), setFitScreenPosition(), setPresetViewAnterior(), setPresetViewInferior(), setPresetViewLeft(), setPresetViewPosterior(), setPresetViewRight(), and setPresetViewSuperior().

+ Here is the call graph for this function:

◆ ~WQtGLWidget()

WQtGLWidget::~WQtGLWidget ( )
virtual

Destructor.

Definition at line 132 of file WQtGLWidget.cpp.

References cleanUp(), wlog::debug(), and m_nameOfViewer.

+ Here is the call graph for this function:

Member Function Documentation

◆ cleanUp()

void WQtGLWidget::cleanUp ( )
virtual

Called on close.

Clean up all OpenGL stuff.

Definition at line 139 of file WQtGLWidget.cpp.

References WKernel::getGraphicsEngine(), WKernel::getRunningKernel(), and m_Viewer.

Referenced by ~WQtGLWidget().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ closeEvent()

void WQtGLWidget::closeEvent ( QCloseEvent *  event)
protectedvirtual

Called on close.

Accept the event to accept the close call.

Parameters
eventthe event.

Definition at line 149 of file WQtGLWidget.cpp.

References event().

+ Here is the call graph for this function:

◆ event()

bool WQtGLWidget::event ( QEvent event)
protectedvirtual

Custom event dispatcher.

Gets called by QT's Event system every time an event got sent to this widget. This event handler processes the notifyrender events. Others get forwarded.

Note
QT Doc says: use event() for custom events.
Parameters
eventthe event that got transmitted.
Returns
true if the event got handled properly.

Definition at line 372 of file WQtGLWidget.cpp.

References renderedFirstFrame().

Referenced by closeEvent(), keyPressEvent(), keyReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), paintEvent(), and translateButton().

+ Here is the caller graph for this function:

◆ getCameraManipulators()

WQtGLWidget::CameraManipulators WQtGLWidget::getCameraManipulators ( )

Returns the actually set camera manipulator.

Returns
the manipulator.

Definition at line 197 of file WQtGLWidget.cpp.

References m_CurrentManipulator.

◆ getCameraPresetsAndResetMenu()

QMenu * WQtGLWidget::getCameraPresetsAndResetMenu ( )

The presets menu including the reset action.

Returns
the menu

Definition at line 536 of file WQtGLWidget.cpp.

References m_cameraPresetResetMenu.

◆ getCameraPresetsMenu()

QMenu * WQtGLWidget::getCameraPresetsMenu ( )

The presets menu.

Returns
the menu

Definition at line 531 of file WQtGLWidget.cpp.

References m_cameraPresetMenu.

Referenced by WQtGLDockWidget::getCameraPresetMenu(), and WQtGLDockWidget::WQtGLDockWidget().

+ Here is the caller graph for this function:

◆ getCameraResetAction()

QAction * WQtGLWidget::getCameraResetAction ( )

The action to trigger a camera reset.

Returns
the action

Definition at line 541 of file WQtGLWidget.cpp.

References m_cameraResetAction.

Referenced by WQtGLDockWidget::WQtGLDockWidget().

+ Here is the caller graph for this function:

◆ getDefaultFormat()

const QGLFormat WQtGLWidget::getDefaultFormat ( )
static

Creates and returns a default OpenGL format description with vertical sync enabled.

Returns
the format descriptor

Definition at line 391 of file WQtGLWidget.cpp.

◆ getPaused()

bool WQtGLWidget::getPaused ( ) const

Query whether the view is paused or not.

Returns
true if paused

Definition at line 551 of file WQtGLWidget.cpp.

References getViewer().

+ Here is the call graph for this function:

◆ getViewer()

std::shared_ptr< WGEViewer > WQtGLWidget::getViewer ( ) const

◆ keyPressEvent()

void WQtGLWidget::keyPressEvent ( QKeyEvent *  event)
protectedvirtual

Event handler for key press.

Parameters
eventthe event description.

Definition at line 254 of file WQtGLWidget.cpp.

References event(), and m_Viewer.

+ Here is the call graph for this function:

◆ keyReleaseEvent()

void WQtGLWidget::keyReleaseEvent ( QKeyEvent *  event)
protectedvirtual

Event handler for key release.

Parameters
eventthe event description.

Definition at line 286 of file WQtGLWidget.cpp.

References event(), WGraphicsEngine::getGraphicsEngine(), m_Viewer, and setCameraManipulator().

+ Here is the call graph for this function:

◆ mouseDoubleClickEvent()

void WQtGLWidget::mouseDoubleClickEvent ( QMouseEvent *  event)
protectedvirtual

Event handler for double clicks.

Parameters
eventthe event description.

Definition at line 336 of file WQtGLWidget.cpp.

References event(), m_Viewer, and translateButton().

+ Here is the call graph for this function:

◆ mouseMoveEvent()

void WQtGLWidget::mouseMoveEvent ( QMouseEvent *  event)
protectedvirtual

Event handler for mouse moves.

Parameters
eventthe event description.

Definition at line 352 of file WQtGLWidget.cpp.

References event(), and m_Viewer.

+ Here is the call graph for this function:

◆ mousePressEvent()

void WQtGLWidget::mousePressEvent ( QMouseEvent *  event)
protectedvirtual

Event handler for mouse button press.

Parameters
eventthe event description.

Definition at line 328 of file WQtGLWidget.cpp.

References event(), m_Viewer, and translateButton().

+ Here is the call graph for this function:

◆ mouseReleaseEvent()

void WQtGLWidget::mouseReleaseEvent ( QMouseEvent *  event)
protectedvirtual

Event handler for mouse button release.

Parameters
eventthe event description.

Definition at line 344 of file WQtGLWidget.cpp.

References event(), m_Viewer, and translateButton().

+ Here is the call graph for this function:

◆ notifyFirstRenderedFrame()

void WQtGLWidget::notifyFirstRenderedFrame ( )
private

Called by the WGEViewer to notify about the first frame rendered.

Definition at line 398 of file WQtGLWidget.cpp.

Referenced by WQtGLWidget().

+ Here is the caller graph for this function:

◆ paintEvent()

void WQtGLWidget::paintEvent ( QPaintEvent *  event)
protectedvirtual

QT Callback for handling repaints.

Parameters
eventevent descriptor.

Definition at line 207 of file WQtGLWidget.cpp.

References event(), WKernel::getGraphicsEngine(), WKernel::getRunningKernel(), and m_firstPaint.

+ Here is the call graph for this function:

◆ paintGL()

void WQtGLWidget::paintGL ( )
protectedvirtual

QT Callback for handling repaints.

Definition at line 219 of file WQtGLWidget.cpp.

References m_Viewer.

◆ renderedFirstFrame

void WQtGLWidget::renderedFirstFrame ( )
signal

Signals that the first frame was rendered.

Referenced by event().

+ Here is the caller graph for this function:

◆ reset

void WQtGLWidget::reset ( )
slot

Resets the contained view using the installed manipulator.

Definition at line 383 of file WQtGLWidget.cpp.

References m_Viewer.

Referenced by WQtGLWidget().

+ Here is the caller graph for this function:

◆ resizeGL()

void WQtGLWidget::resizeGL ( int  width,
int  height 
)
protectedvirtual

Event handler for resize events.

Parameters
widththe new width.
heightthe new height.

Definition at line 230 of file WQtGLWidget.cpp.

References m_Viewer.

◆ setCameraManipulator()

void WQtGLWidget::setCameraManipulator ( WQtGLWidget::CameraManipulators  manipulator)

Sets the camera manipulator to use.

Parameters
manipulatorthe manipulator.

Definition at line 155 of file WQtGLWidget.cpp.

References WLogger::addLogMessage(), WLogger::getLogger(), m_CurrentManipulator, and m_Viewer.

Referenced by keyReleaseEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFitScreenPosition

void WQtGLWidget::setFitScreenPosition ( )
slot

Zooms and centers the view to fit the viewer.

Definition at line 511 of file WQtGLWidget.cpp.

References WKernel::getRunningKernel(), getViewer(), m_Viewer, and wlog::warn().

Referenced by WQtGLWidget().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPaused()

void WQtGLWidget::setPaused ( bool  pause = true)

Pause rendering.

This does not free the viewer. It simply pauses rendering.

Parameters
pausetrue to pause.

Definition at line 546 of file WQtGLWidget.cpp.

References getViewer().

Referenced by WQtGLDockWidget::closeEvent(), and WQtGLDockWidget::showEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPresetViewAnterior

void WQtGLWidget::setPresetViewAnterior ( )
slot

Sets the anterior preset view of the main viewer.

Definition at line 475 of file WQtGLWidget.cpp.

References m_Viewer, and wlog::warn().

Referenced by WQtGLWidget().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPresetViewInferior

void WQtGLWidget::setPresetViewInferior ( )
slot

Sets the inferior preset view of the main viewer.

Definition at line 457 of file WQtGLWidget.cpp.

References m_Viewer, and wlog::warn().

Referenced by WQtGLWidget().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPresetViewLeft

void WQtGLWidget::setPresetViewLeft ( )
slot

Sets the left preset view of the main viewer.

Definition at line 403 of file WQtGLWidget.cpp.

References m_Viewer, and wlog::warn().

Referenced by WQtGLWidget().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPresetViewPosterior

void WQtGLWidget::setPresetViewPosterior ( )
slot

Sets the posterior preset view of the main viewer.

Definition at line 493 of file WQtGLWidget.cpp.

References m_Viewer, and wlog::warn().

Referenced by WQtGLWidget().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPresetViewRight

void WQtGLWidget::setPresetViewRight ( )
slot

Sets the right preset view of the main viewer.

Definition at line 421 of file WQtGLWidget.cpp.

References m_Viewer, and wlog::warn().

Referenced by WQtGLWidget().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPresetViewSuperior

void WQtGLWidget::setPresetViewSuperior ( )
slot

Sets the superior preset view of the main viewer.

Definition at line 439 of file WQtGLWidget.cpp.

References m_Viewer, and wlog::warn().

Referenced by WQtGLWidget().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ translateButton()

int WQtGLWidget::translateButton ( QMouseEvent *  event)
protected

Simply translate the mouse button from an event to an int.

Parameters
eventthe QT Event.
Returns
the translated button number.

Definition at line 239 of file WQtGLWidget.cpp.

References event().

Referenced by mouseDoubleClickEvent(), mousePressEvent(), and mouseReleaseEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wheelEvent()

void WQtGLWidget::wheelEvent ( QWheelEvent *  event)
protectedvirtual

Event handler for the mouse wheel.

Parameters
eventthe event description.

Definition at line 360 of file WQtGLWidget.cpp.

References m_Viewer.

Member Data Documentation

◆ m_cameraPresetMenu

QMenu* WQtGLWidget::m_cameraPresetMenu
private

Camera menu.

Definition at line 335 of file WQtGLWidget.h.

Referenced by getCameraPresetsMenu(), and WQtGLWidget().

◆ m_cameraPresetResetMenu

QMenu* WQtGLWidget::m_cameraPresetResetMenu
private

Camera menu with reset action.

Definition at line 340 of file WQtGLWidget.h.

Referenced by getCameraPresetsAndResetMenu(), and WQtGLWidget().

◆ m_cameraResetAction

QAction* WQtGLWidget::m_cameraResetAction
private

Camera reset.

Definition at line 345 of file WQtGLWidget.h.

Referenced by getCameraResetAction(), and WQtGLWidget().

◆ m_CurrentManipulator

CameraManipulators WQtGLWidget::m_CurrentManipulator
protected

Stores the current manipulator.

Definition at line 290 of file WQtGLWidget.h.

Referenced by getCameraManipulators(), and setCameraManipulator().

◆ m_firstPaint

bool WQtGLWidget::m_firstPaint
private

This flag is set to true if the first paint call occured.

See the paint method for details.

Definition at line 325 of file WQtGLWidget.h.

Referenced by paintEvent().

◆ m_initialProjectionMode

WGECamera::ProjectionMode WQtGLWidget::m_initialProjectionMode
protected

Camera projection mode used to initialize widget.

May not be the actual one!

Definition at line 295 of file WQtGLWidget.h.

Referenced by WQtGLWidget().

◆ m_nameOfViewer

std::string WQtGLWidget::m_nameOfViewer
protected

The name of the viewer.

Definition at line 207 of file WQtGLWidget.h.

Referenced by WQtGLWidget(), and ~WQtGLWidget().

◆ m_Timer

QTimer WQtGLWidget::m_Timer
private

Timer for periodic repaints.

Definition at line 320 of file WQtGLWidget.h.

Referenced by WQtGLWidget().

◆ m_Viewer

std::shared_ptr<WGEViewer> WQtGLWidget::m_Viewer
protected

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