Workspace 6.21.5
Public Types | Public Slots | Signals | Public Member Functions | Properties | List of all members
WSGLWidget Class Reference

Widget for interactive rendering of a Scene object using OpenGL. More...

#include <Rendering/OpenGL/wsglwidget.h>

Inherits QWidget.

Public Types

enum  ManipulatorMode { NoManipulator , TranslateManipulator , RotateManipulator , ScaleManipulator }
 

Public Slots

void autoFit ()
 
void focusCameraOnPosition (const CSIRO::Mesh::Vector3d &pos)
 
void nextCamera ()
 
void previousCamera ()
 
void renderScene ()
 
void selectCurrItemElement (const Mesh::ElementType::Type *elementType, Mesh::ItemHandle::size_type elementIndex)
 
void selectCurrItemNode (Mesh::ItemHandle::size_type nodeIndex)
 
void selectItem (const QString &opIdPath)
 
void selectItem (CSIRO::Rendering::SceneInteractionWidgetItem *item)
 
void setCamera (const QString &name)
 
void setManipulatorMode (ManipulatorMode mode)
 
void setSelectionMode (RenderTargetType mode)
 

Signals

void heightChanged (int width)
 
void interactionQueued ()
 
void itemSelected (const CSIRO::Rendering::PickedItem &item, const CSIRO::Rendering::PickFilter &filter)
 
void mouseButtonPressed ()
 
void mouseButtonReleased ()
 
void mouseMove ()
 
void renderSceneSuccess ()
 
void selectionCleared ()
 
void settingsChanged (const CSIRO::Rendering::RenderSettings &settings)
 
void widthChanged (int width)
 

Public Member Functions

 WSGLWidget (QWidget *parent=nullptr)
 
 ~WSGLWidget () override
 
const QOpenGLContext * context () const
 
void doneCurrent ()
 
bool getAntialiasingEnabled () const
 
const QColor & getBackgroundColor () const
 
const QString & getCamera () const
 
bool getCameraFrustumsSelectable () const
 
const Mesh::Vector3dgetCenterOfOrbit () const
 
bool getDepthPeelingEnabled () const
 
float getLineWidth () const
 
unsigned getMaxSupportedDepthLayers () const
 
int getNumAntialiasingSamples () const
 
unsigned getNumDepthLayers () const
 
bool getOverrideSceneSettings () const
 
float getPointSize () const
 
const RenderSettingsgetRenderSettings () const
 
ScenegetScene ()
 
const ScenegetScene () const
 
bool getSelectionEnabled () const
 
bool getShowCameraFrustums () const
 
bool getShowHud () const
 
bool getShowSelectionButtons () const
 
bool getShowSymbols ()
 
float getSsaoAttenuation () const
 
bool getSsaoEnabled () const
 
int getSsaoNumSamples () const
 
float getSsaoSampleLength () const
 
float getSsaoStrength () const
 
bool getSuppressCameraWarnings () const
 
double getSymbolLineWidth () const
 
QImage grabFrameBuffer ()
 
void installInteractionFilter (QObject *filterObj)
 
bool isCameraSwitchable () const
 
bool lastRenderSucceeded () const
 
void makeCurrent ()
 
void setAntialiasingEnabled (bool b)
 
void setBackgroundColor (const QColor &color)
 
void setCameraFrustumsSelectable (bool b)
 
void setCameraSwitchable (bool b)
 
void setCenterOfOrbit (const Mesh::Vector3d &center)
 
void setDepthPeelingEnabled (bool b)
 
void setLineWidth (float width)
 
void setNumAntialiasingSamples (int n)
 
void setNumDepthLayers (unsigned n)
 
void setOverrideSceneSettings (bool b)
 
void setPointSize (float size)
 
void setRenderSettings (const RenderSettings &settings)
 
void setScene (Scene *scene)
 
void setSelectionEnabled (bool b)
 
void setShowCameraFrustums (bool b)
 
void setShowHud (bool b)
 
void setShowSelectionButtons (bool b)
 
void setShowSymbols (bool b)
 
void setSsaoAttenuation (float a)
 
void setSsaoEnabled (bool b)
 
void setSsaoNumSamples (int n)
 
void setSsaoSampleLength (float l)
 
void setSsaoStrength (float s)
 
void setSuppressCameraWarnings (bool b)
 
void setSymbolLineWidth (double width)
 
void setUndoDetails (QUndoStack &undoStack, DataExecution::Workspace &rootWorkspace, const QString &sceneIdPath)
 
void showEvent (QShowEvent *event) override
 
QSize sizeHint () const override
 

Properties

bool antialiasing
 
QColor backgroundColor
 
QString camera
 
bool cameraFrustumsSelectable
 
bool cameraSwitchable
 
QString centerOfOrbit
 
bool depthPeeling
 
float lineWidth
 
bool modelSelection
 
unsigned numDepthLayers
 
int numSamples
 
bool overrideSceneSettings
 
float pointSize
 
bool showCameraFrustums
 
bool showHud
 
bool showSelectionButtons
 
bool showSymbols
 
float ssaoAttenuation
 
bool ssaoEnabled
 
int ssaoNumSamples
 
float ssaoSampleLength
 
float ssaoStrength
 
bool suppressCameraWarnings
 
double symbolLineWidth
 

Detailed Description

The interactive controls are the specific combinations of mouse buttons and keyboard modifiers. The currently defined interactions are given in the following table:

Key / mouseEffect
Shift + LMB Pan camera in opposite direction to mouse movement. This gives the impression of using the mouse to move the scene in the direction of mouse movement.
Ctrl + LMB Rotate view by moving camera about the focal point
Ctrl + Shift + LMB Rotate view about an axis perpendicular to the viewing plane. The movement should feel like the mouse has grabbed the scene and causes it to rotate about the viewing axis.
Mouse wheel up/down Modify the field of view in/out. This is somewhat like a zoom without actually moving the camera position.
Shift + wheel up/down Move the camera location forwards/backwards. This is sometimes referred to as a dolly camera movement.
Ctrl + wheel up/down Move the near clipping plane forwards/backwards
Ctrl + Shift + wheel up/down Move the far clipping plane forwards/backwards
See also
CameraInteraction

Member Enumeration Documentation

◆ ManipulatorMode

Enumerator
NoManipulator 
TranslateManipulator 
RotateManipulator 
ScaleManipulator 

Constructor & Destructor Documentation

◆ WSGLWidget()

WSGLWidget ( QWidget *  parent = nullptr)
Note
All WSGLWidget instances will share a common context. This is important as it allows memory to be conserved across instances. If you need to display different data in between widgets, make sure the IDs are not identical in the cache.
Parameters
parentThe widget that this WSGLWidget is parented to.

◆ ~WSGLWidget()

~WSGLWidget ( )
overridedefault

Member Function Documentation

◆ autoFit

void autoFit ( )
slot

Make the whole scene fit inside the viewport and put the orbit center at the center of the scene's bounding box.

◆ context()

const QOpenGLContext * context ( ) const

◆ doneCurrent()

void doneCurrent ( )

◆ focusCameraOnPosition

void focusCameraOnPosition ( const CSIRO::Mesh::Vector3d pos)
slot

Reposition the camera to have it's orbit centre at this position

◆ getAntialiasingEnabled()

bool getAntialiasingEnabled ( ) const

◆ getBackgroundColor()

const QColor & getBackgroundColor ( ) const
Returns
The background color the widget will use when rendering.

◆ getCamera()

const QString & getCamera ( ) const
Returns
The current camera defining the view into the scene.

◆ getCameraFrustumsSelectable()

bool getCameraFrustumsSelectable ( ) const

◆ getCenterOfOrbit()

const Mesh::Vector3d & getCenterOfOrbit ( ) const
Returns
The point about which mouse orbit rotations will occur.

◆ getDepthPeelingEnabled()

bool getDepthPeelingEnabled ( ) const

◆ getLineWidth()

float getLineWidth ( ) const

◆ getMaxSupportedDepthLayers()

unsigned getMaxSupportedDepthLayers ( ) const

◆ getNumAntialiasingSamples()

int getNumAntialiasingSamples ( ) const

◆ getNumDepthLayers()

unsigned getNumDepthLayers ( ) const

◆ getOverrideSceneSettings()

bool getOverrideSceneSettings ( ) const
Returns
true if the Scene's render settings are being override by the widgets.

◆ getPointSize()

float getPointSize ( ) const

◆ getRenderSettings()

const RenderSettings & getRenderSettings ( ) const

◆ getScene() [1/2]

Scene * getScene ( )
Returns
The current scene object being rendered, or a null pointer if no scene has been set.

◆ getScene() [2/2]

const Scene * getScene ( ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ getSelectionEnabled()

bool getSelectionEnabled ( ) const

◆ getShowCameraFrustums()

bool getShowCameraFrustums ( ) const

◆ getShowHud()

bool getShowHud ( ) const
Returns
True if the heads-up display should be included in the render.
See also
setShowHud()

◆ getShowSelectionButtons()

bool getShowSelectionButtons ( ) const

◆ getShowSymbols()

bool getShowSymbols ( )
Returns
True if symbols should be displayed in the renderer (e.g. symbols for clip planes, cameras etc.)

◆ getSsaoAttenuation()

float getSsaoAttenuation ( ) const

◆ getSsaoEnabled()

bool getSsaoEnabled ( ) const

◆ getSsaoNumSamples()

int getSsaoNumSamples ( ) const

◆ getSsaoSampleLength()

float getSsaoSampleLength ( ) const

◆ getSsaoStrength()

float getSsaoStrength ( ) const

◆ getSuppressCameraWarnings()

bool getSuppressCameraWarnings ( ) const

◆ getSymbolLineWidth()

double getSymbolLineWidth ( ) const

◆ grabFrameBuffer()

QImage grabFrameBuffer ( )

◆ heightChanged

void heightChanged ( int  width)
signal

◆ installInteractionFilter()

void installInteractionFilter ( QObject *  filterObj)
Parameters
filterObjThe event filter to install on the main GL canvas inside the widget.

Installs an event filter on the main QOpenGLWidget contained within this widget. This allows calling code to install custom event handling code to handle special mouse / keypresses that are not included in the default WSGLWidget.

◆ interactionQueued

void interactionQueued ( )
signal

◆ isCameraSwitchable()

bool isCameraSwitchable ( ) const
Returns
If the user will be allowed to switch to a different camera, a value of true will be returned.
See also
setCameraSwitchable(), nextCamera(), previousCamera()

◆ itemSelected

void itemSelected ( const CSIRO::Rendering::PickedItem item,
const CSIRO::Rendering::PickFilter filter 
)
signal

◆ lastRenderSucceeded()

bool lastRenderSucceeded ( ) const

◆ makeCurrent()

void makeCurrent ( )

◆ mouseButtonPressed

void mouseButtonPressed ( )
signal

◆ mouseButtonReleased

void mouseButtonReleased ( )
signal

◆ mouseMove

void mouseMove ( )
signal

◆ nextCamera

void nextCamera ( )
slot

If the widget permits switching cameras, this function will switch to the next camera in the list of cameras from the last scene rendered.

◆ previousCamera

void previousCamera ( )
slot

If the widget permits switching cameras, this function will switch to the preceding camera in the list of cameras from the last scene rendered.

◆ renderScene

void renderScene ( )
slot

◆ renderSceneSuccess

void renderSceneSuccess ( )
signal

◆ selectCurrItemElement

void selectCurrItemElement ( const Mesh::ElementType::Type elementType,
Mesh::ItemHandle::size_type  elementIndex 
)
slot

◆ selectCurrItemNode

void selectCurrItemNode ( Mesh::ItemHandle::size_type  nodeIndex)
slot

◆ selectionCleared

void selectionCleared ( )
signal

◆ selectItem [1/2]

void selectItem ( const QString &  opIdPath)
slot

◆ selectItem [2/2]

void selectItem ( CSIRO::Rendering::SceneInteractionWidgetItem item)
slot

◆ setAntialiasingEnabled()

void setAntialiasingEnabled ( bool  b)

◆ setBackgroundColor()

void setBackgroundColor ( const QColor &  color)
Parameters
colorThe background color the widget should use when rendering.

◆ setCamera

void setCamera ( const QString &  cameraName)
slot
Parameters
cameraNameThe name of the camera to use for the view into the scene. If the scene does not have the named camera, a default internal camera will be used, which is usually not going to be what you want but at least allows you to see the scene.

◆ setCameraFrustumsSelectable()

void setCameraFrustumsSelectable ( bool  b)

◆ setCameraSwitchable()

void setCameraSwitchable ( bool  b)
Parameters
bIf true, the user will be allowed to switch to a different camera (eg through the context menu). If false, the context menu won't contain any entries to do this and both nextCamera() and previousCamera() will do nothing. The default is to allow camera switching.
See also
isCameraSwitchable(), nextCamera(), previousCamera()

◆ setCenterOfOrbit()

void setCenterOfOrbit ( const Mesh::Vector3d center)
Parameters
centerThe new point about which subsequent mouse orbits will rotate.

◆ setDepthPeelingEnabled()

void setDepthPeelingEnabled ( bool  b)

◆ setLineWidth()

void setLineWidth ( float  width)

◆ setManipulatorMode

void setManipulatorMode ( ManipulatorMode  mode)
slot

◆ setNumAntialiasingSamples()

void setNumAntialiasingSamples ( int  n)

◆ setNumDepthLayers()

void setNumDepthLayers ( unsigned  n)

◆ setOverrideSceneSettings()

void setOverrideSceneSettings ( bool  b)
Parameters
bWhether or not to override the scene's render settings.

◆ setPointSize()

void setPointSize ( float  size)

◆ setRenderSettings()

void setRenderSettings ( const RenderSettings settings)

◆ setScene()

void setScene ( Scene scene)
Parameters
sceneThe new scene the widget should render.

The old scene is not deleted, since the widget does not take ownership of the scene. If scene is a null pointer, then the widget will not render any scene at all (it is not an error to do this).

◆ setSelectionEnabled()

void setSelectionEnabled ( bool  b)

◆ setSelectionMode

void setSelectionMode ( RenderTargetType  mode)
slot

◆ setShowCameraFrustums()

void setShowCameraFrustums ( bool  b)

◆ setShowHud()

void setShowHud ( bool  b)
Parameters
bSet to true if the heads-up display should be included in the render or false if it should be kept hidden.
See also
getShowHud()

◆ setShowSelectionButtons()

void setShowSelectionButtons ( bool  b)
Parameters
bIf true, the selection buttons will be shown on the WSGLWidget

Shows / hides the selection buttons on the WSGL widget. Does not disable model selection.

See also
setSelectionEnabled

◆ setShowSymbols()

void setShowSymbols ( bool  b)
Parameters
bEnable or disable the display of symbols in the renderer.

◆ setSsaoAttenuation()

void setSsaoAttenuation ( float  a)

◆ setSsaoEnabled()

void setSsaoEnabled ( bool  b)

◆ setSsaoNumSamples()

void setSsaoNumSamples ( int  n)

◆ setSsaoSampleLength()

void setSsaoSampleLength ( float  l)

◆ setSsaoStrength()

void setSsaoStrength ( float  s)

◆ setSuppressCameraWarnings()

void setSuppressCameraWarnings ( bool  b)

◆ setSymbolLineWidth()

void setSymbolLineWidth ( double  width)

◆ settingsChanged

void settingsChanged ( const CSIRO::Rendering::RenderSettings settings)
signal

◆ setUndoDetails()

void setUndoDetails ( QUndoStack &  undoStack,
DataExecution::Workspace rootWorkspace,
const QString &  sceneIdPath 
)
Parameters
undoStackThe undo stack to give to the widget to allow manipulator events to be reversed using undo / redo.
rootWorkspaceThe workspace that contains the scene we are rendering. We need this because UndoCommands may exist beyond the lifetime of both the Scene and this widget, so we need to make sure we retrieve them both (if they exist) on demand.
sceneIdPathThe path to the operation that creates the scene, relative to rootWorkspace.

Sets up the details required for undoing manipulator events in the widget. If this is not invoked prior to renderScene() is called, undo will not be able to be used.

◆ showEvent()

void showEvent ( QShowEvent *  event)
override

◆ sizeHint()

QSize sizeHint ( ) const
override

◆ widthChanged

void widthChanged ( int  width)
signal

Property Documentation

◆ antialiasing

bool antialiasing
readwrite

◆ backgroundColor

QColor backgroundColor
readwrite

◆ camera

QString camera
readwrite

◆ cameraFrustumsSelectable

bool cameraFrustumsSelectable
readwrite

◆ cameraSwitchable

bool cameraSwitchable
readwrite

◆ centerOfOrbit

QString centerOfOrbit
readwrite

◆ depthPeeling

bool depthPeeling
readwrite

◆ lineWidth

float lineWidth
readwrite

◆ modelSelection

bool modelSelection
readwrite

◆ numDepthLayers

unsigned numDepthLayers
readwrite

◆ numSamples

int numSamples
readwrite

◆ overrideSceneSettings

bool overrideSceneSettings
readwrite

◆ pointSize

float pointSize
readwrite

◆ showCameraFrustums

bool showCameraFrustums
readwrite

◆ showHud

bool showHud
readwrite

◆ showSelectionButtons

bool showSelectionButtons
readwrite

◆ showSymbols

bool showSymbols
readwrite

◆ ssaoAttenuation

float ssaoAttenuation
readwrite

◆ ssaoEnabled

bool ssaoEnabled
readwrite

◆ ssaoNumSamples

int ssaoNumSamples
readwrite

◆ ssaoSampleLength

float ssaoSampleLength
readwrite

◆ ssaoStrength

float ssaoStrength
readwrite

◆ suppressCameraWarnings

bool suppressCameraWarnings
readwrite

◆ symbolLineWidth

double symbolLineWidth
readwrite