RobWorkProject  23.9.11-
Public Types | Public Member Functions | Protected Member Functions | List of all members
SceneOpenGLViewer Class Reference

Class representing an OpenGL based QT Widget for 3D visualization of the SceneGraph SceneOpenGL. More...

#include <SceneOpenGLViewer.hpp>

Inherits QOpenGLWidget, and SceneViewerWidget.

Public Types

typedef rw::core::Ptr< SceneOpenGLViewerPtr
 Smart pointer type for SceneOpenGLViewer.
 
- Public Types inherited from SceneViewerWidget
typedef rw::core::Ptr< SceneViewerWidgetPtr
 Smart pointer type for a SceneViewerWidget.
 
- Public Types inherited from SceneViewer
typedef rw::core::Ptr< SceneViewerPtr
 smart pointer type to this class
 
typedef boost::function< void(const rw::math::Vector3D<> &)> PositionSelectedListener
 Defines a listener for position change events. More...
 
typedef rw::core::Event< PositionSelectedListener, const rw::math::Vector3D<> & > PositionSelectedEvent
 Defines event for PositionChanged.
 

Public Member Functions

 SceneOpenGLViewer (QWidget *parent=0)
 Constructor. More...
 
 SceneOpenGLViewer (rw::core::PropertyMap &pmap, QWidget *parent=0)
 Constructs an OpenGL based QT Widget. More...
 
virtual ~SceneOpenGLViewer ()
 Destructor.
 
rw::graphics::SceneGraph::RenderInfogetRenderInfo ()
 Get rendering info for the scene. More...
 
rw::graphics::DrawableNode::Ptr getPivotDrawable ()
 Get the drawable used for pivoting. More...
 
QWidget * getWidget ()
 Get the Qt widget for visualization of the scene. More...
 
rw::graphics::SceneGraph::Ptr getScene ()
 get the current scene graph More...
 
rw::core::PropertyMapgetPropertyMap ()
 get propertymap More...
 
virtual rw::graphics::SceneCamera::Ptr getViewCamera ()
 Get the view camera. More...
 
void setWorldNode (rw::graphics::GroupNode::Ptr wnode)
 Set the world group node. More...
 
rw::graphics::GroupNode::Ptr getWorldNode ()
 Get the world node. More...
 
virtual View::Ptr createView (const std::string &name, bool enableBackground=false)
 Create a new view. More...
 
virtual View::Ptr getMainView ()
 Get the main view. More...
 
virtual void destroyView (View::Ptr view)
 Destroy view. More...
 
virtual void selectView (View::Ptr view)
 Select a view. More...
 
virtual View::Ptr getCurrentView ()
 Get the currently selected view. More...
 
virtual std::vector< View::PtrgetViews ()
 Get all views. More...
 
void updateState (const rw::kinematics::State &state)
 Set a new state. More...
 
void updateView ()
 Update the view. More...
 
rw::math::Vector3D getViewCenter ()
 Get the view center. More...
 
void setLogo (const std::string &string)
 set the logo that is displayed in the 3d scene More...
 
const std::string & getLogo () const
 get the logo that is displayed in the 3d scene More...
 
virtual void setTransform (const rw::math::Transform3D<> &t3d)
 set the orientation of the view. The view will look in the positive direction of the z-axis, with x-axis as the width and the y-axis as the height. Origin of view is in the center of the image. More...
 
rw::graphics::DrawableNode::Ptr pickDrawable (int x, int y)
 picks the drawable in the scene that intersects with the ray (x,y,-1) in camera coordinates. More...
 
rw::graphics::DrawableNode::Ptr pickDrawable (rw::graphics::SceneGraph::RenderInfo &info, int x, int y)
 
void saveBufferToFile (const std::string &filename, const int fillR, const int fillG, const int fillB)
 Saves the current 3D view to disk as either jpg, bmp or png. More...
 
void clear ()
 Clears the list of Drawables and WorkCells.
 
void keyPressEvent (QKeyEvent *e)
 key pressed listener function. Key events in the opengl view will trigger this method. More...
 
void setCameraController (CameraController::Ptr camController)
 set the camera view controller. More...
 
CameraController::Ptr getCameraController ()
 Returns the camera controller. More...
 
void propertyChangedListener (rw::core::PropertyBase *base)
 listener callback for property changed in getPropertyMap More...
 
rw::kinematics::FramepickFrame (int x, int y)
 picks the frame that has drawables that intersect the ray cast into the screen from the screen coordinates x and y. More...
 
void renderView (View::Ptr view)
 Render a view. More...
 
- Public Member Functions inherited from SceneViewer
 SceneViewer ()
 Constructor.
 
virtual ~SceneViewer ()
 Destructor.
 
virtual void destroyView (View::Ptr view)=0
 Destroy view. More...
 
virtual void selectView (View::Ptr view)=0
 Select a view. More...
 
virtual void renderView (View::Ptr view)=0
 Render a view. More...
 
PositionSelectedEventpositionSelectedEvent ()
 Returns PositionChangedEvent object needed for subscription to and firing of event. More...
 
virtual rw::math::Transform3D getTransform ()
 get the current rotation of the view More...
 

Protected Member Functions

void initializeGL ()
 Overridden from QOpenGLWidget.
 
void paintGL ()
 Overridden from QOpenGLWidget.
 
void resizeGL (int width, int height)
 Overridden from QOpenGLWidget.
 
void mouseDoubleClickEvent (QMouseEvent *event)
 Overridden from QOpenGLWidget.
 
void mousePressEvent (QMouseEvent *event)
 Overridden from QOpenlGLWidget.
 
void mouseMoveEvent (QMouseEvent *event)
 Overridden from QOpenGLWidget.
 
void wheelEvent (QWheelEvent *event)
 Overridden from QOpenGLWidget.
 
void setWorkCellScene (rw::core::Ptr< rw::graphics::WorkCellScene > wcscene)
 Set the WorkCell scene. More...
 
void zoom (double amount)
 Move the camera along its z-axis. More...
 
void autoZoom ()
 Automatically fits all frames inside the viewport by moving camera in its z-axis. More...
 

Additional Inherited Members

- Protected Attributes inherited from SceneViewer
PositionSelectedEvent _positionSelectedEvent
 Event for selection of a position.
 
rw::core::Ptr< class WorkCellScene_wcscene
 The WorkCell scene.
 

Detailed Description

Class representing an OpenGL based QT Widget for 3D visualization of the SceneGraph SceneOpenGL.

One of the main responsibilities of the view is to define an opengl context in which the scenegraph can operate and render.

The view will add a "view" camera group and a "view" camera to the scene which it will control through its gui events (mouse and keyboard).

Multiple camera

Constructor & Destructor Documentation

◆ SceneOpenGLViewer() [1/2]

SceneOpenGLViewer ( QWidget *  parent = 0)

Constructor.

Parameters
parent[in] the parent widget (the owner of this widget).

◆ SceneOpenGLViewer() [2/2]

SceneOpenGLViewer ( rw::core::PropertyMap pmap,
QWidget *  parent = 0 
)

Constructs an OpenGL based QT Widget.

Parameters
pmap[in] propertyies for the viewer.
parent[in] the parent widget (the owner of this widget).

Member Function Documentation

◆ autoZoom()

void autoZoom ( )
protectedvirtual

Automatically fits all frames inside the viewport by moving camera in its z-axis.

Implements SceneViewer.

◆ createView()

virtual View::Ptr createView ( const std::string &  name,
bool  enableBackground = false 
)
virtual

Create a new view.

Parameters
name[in] name of view.
enableBackground[in] (optional) enable the background. Default is false.
Returns
the new view.

Implements SceneViewer.

◆ destroyView()

virtual void destroyView ( View::Ptr  view)
virtual

Destroy view.

Parameters
view[in] the view to destroy.

◆ getCameraController()

CameraController::Ptr getCameraController ( )
inline

Returns the camera controller.

Camera controller

◆ getCurrentView()

virtual View::Ptr getCurrentView ( )
inlinevirtual

Get the currently selected view.

Returns
the view.

Implements SceneViewer.

◆ getLogo()

const std::string& getLogo ( ) const
inlinevirtual

get the logo that is displayed in the 3d scene

Implements SceneViewer.

◆ getMainView()

virtual View::Ptr getMainView ( )
inlinevirtual

Get the main view.

Returns
main view.

Implements SceneViewer.

◆ getPivotDrawable()

rw::graphics::DrawableNode::Ptr getPivotDrawable ( )
inlinevirtual

Get the drawable used for pivoting.

Returns
the drawable node.

Implements SceneViewerWidget.

◆ getPropertyMap()

rw::core::PropertyMap& getPropertyMap ( )
inlinevirtual

get propertymap

Implements SceneViewer.

◆ getRenderInfo()

rw::graphics::SceneGraph::RenderInfo& getRenderInfo ( )
inlinevirtual

Get rendering info for the scene.

Returns
the render info.

Implements SceneViewerWidget.

◆ getScene()

rw::graphics::SceneGraph::Ptr getScene ( )
inlinevirtual

get the current scene graph

Implements SceneViewer.

◆ getViewCamera()

virtual rw::graphics::SceneCamera::Ptr getViewCamera ( )
inlinevirtual

Get the view camera.

Returns
a scene camera.

Implements SceneViewer.

◆ getViewCenter()

rw::math::Vector3D getViewCenter ( )
inlinevirtual

Get the view center.

Returns
the center.

Implements SceneViewer.

◆ getViews()

virtual std::vector<View::Ptr> getViews ( )
inlinevirtual

Get all views.

Returns
the views.

Implements SceneViewer.

◆ getWidget()

QWidget* getWidget ( )
inlinevirtual

Get the Qt widget for visualization of the scene.

Returns
the Qt widget.

Implements SceneViewerWidget.

◆ getWorldNode()

rw::graphics::GroupNode::Ptr getWorldNode ( )
inlinevirtual

Get the world node.

Returns
the world node.

Implements SceneViewer.

◆ keyPressEvent()

void keyPressEvent ( QKeyEvent *  e)

key pressed listener function. Key events in the opengl view will trigger this method.

Parameters
e[in] the event.

◆ pickDrawable() [1/2]

rw::graphics::DrawableNode::Ptr pickDrawable ( int  x,
int  y 
)
virtual

picks the drawable in the scene that intersects with the ray (x,y,-1) in camera coordinates.

Parameters
x[in] first camera coordinate.
y[in] second camera coordinate.
Returns
the picked drawable.

Implements SceneViewer.

◆ pickDrawable() [2/2]

rw::graphics::DrawableNode::Ptr pickDrawable ( rw::graphics::SceneGraph::RenderInfo info,
int  x,
int  y 
)
virtual

◆ pickFrame()

rw::kinematics::Frame* pickFrame ( int  x,
int  y 
)

picks the frame that has drawables that intersect the ray cast into the screen from the screen coordinates x and y.

Parameters
x[in] x coordinate
y[in] y coordinate
Returns
the frame that was selected, Null if no frames where selected.

◆ propertyChangedListener()

void propertyChangedListener ( rw::core::PropertyBase base)

listener callback for property changed in getPropertyMap

Parameters
base

◆ renderView()

void renderView ( View::Ptr  view)

Render a view.

Parameters
view[in] the view to render

◆ saveBufferToFile()

void saveBufferToFile ( const std::string &  filename,
const int  fillR,
const int  fillG,
const int  fillB 
)
virtual

Saves the current 3D view to disk as either jpg, bmp or png.

If failing a std::string is thrown with a detailed description of what when wrong.

Parameters
filename[in] Path and name of the file. The filename extension should be either ".jpg", ".bmp" or ".png" to specify which format to use.
fillR[in] Fill color if viewport is smaller than image, red component [0,255]
fillG[in] Fill color if viewport is smaller than image, green component [0,255]
fillB[in] Fill color if viewport is smaller than image, blue component [0,255]

Implements SceneViewer.

◆ selectView()

virtual void selectView ( View::Ptr  view)
virtual

Select a view.

Parameters
view[in] the view to select.

◆ setCameraController()

void setCameraController ( CameraController::Ptr  camController)
inline

set the camera view controller.

Parameters
camController

◆ setLogo()

void setLogo ( const std::string &  string)
inlinevirtual

set the logo that is displayed in the 3d scene

Implements SceneViewer.

◆ setTransform()

virtual void setTransform ( const rw::math::Transform3D<> &  t3d)
inlinevirtual

set the orientation of the view. The view will look in the positive direction of the z-axis, with x-axis as the width and the y-axis as the height. Origin of view is in the center of the image.

Parameters
t3d[in] transform relative to world

Reimplemented from SceneViewer.

◆ setWorkCellScene()

void setWorkCellScene ( rw::core::Ptr< rw::graphics::WorkCellScene wcscene)
inlineprotectedvirtual

Set the WorkCell scene.

Parameters
wcscene[in] the workcell scene.

Reimplemented from SceneViewer.

◆ setWorldNode()

void setWorldNode ( rw::graphics::GroupNode::Ptr  wnode)
virtual

Set the world group node.

Parameters
wnode[in] the world node.

Implements SceneViewer.

◆ updateState()

void updateState ( const rw::kinematics::State state)
virtual

Set a new state.

Parameters
state[in] new state.

Implements SceneViewer.

◆ updateView()

void updateView ( )
inlinevirtual

Update the view.

Implements SceneViewer.

◆ zoom()

void zoom ( double  amount)
protectedvirtual

Move the camera along its z-axis.

Parameters
amount[in] the amount of zoom.

Implements SceneViewer.


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