OpenWalnut  1.5.0dev
Classes | Public Types | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
WGEViewer Class Reference

Class for managing one view to the scene. More...

#include <WGEViewer.h>

+ Inheritance diagram for WGEViewer:
+ Collaboration diagram for WGEViewer:

Classes

class  QueryCallback
 Small class used for querying glGet info during rendering. More...
 

Public Types

typedef std::shared_ptr< WGEViewerSPtr
 Convenience typedef. More...
 
typedef std::shared_ptr< const WGEViewerConstSPtr
 Convenience typedef. More...
 
- Public Types inherited from WGEGraphicsWindow
enum  KeyEvents { KEYPRESS , KEYRELEASE }
 Event types for the keyEvent() handler. More...
 
enum  MouseEvents {
  MOUSEPRESS , MOUSERELEASE , MOUSEDOUBLECLICK , MOUSEMOVE ,
  MOUSESCROLL
}
 Mouse event types for the mouseEvent() handler. More...
 

Public Member Functions

 WGEViewer (std::string name, osg::ref_ptr< osg::Referenced > wdata, int x, int y, int width, int height, WGECamera::ProjectionMode projectionMode=WGECamera::ORTHOGRAPHIC)
 Default constructor. More...
 
virtual ~WGEViewer ()
 Destructor. More...
 
virtual void paint ()
 Repaints the contents. More...
 
virtual void resize (int width, int height)
 Updates size information. More...
 
virtual void close ()
 Close the viewer, but wait for the rendering thread to finish. More...
 
osg::ref_ptr< osgViewer::Viewer > getView ()
 Getter for OpenSceneGraph View instance. More...
 
void handleVisibilityChange (bool visible)
 If the widget is not visible, we might be able to reduce CPU load. More...
 
void requestContinuousUpdate (bool continuous=true)
 Update the view automatically (the default). More...
 
void reset ()
 Resets the view using the installed manipulator. More...
 
void setCameraManipulator (osg::ref_ptr< osgGA::MatrixManipulator > manipulator)
 Sets the camera manipulator to use. More...
 
osg::ref_ptr< osgGA::MatrixManipulator > getCameraManipulator ()
 Returns current active camera manipulator. More...
 
void setCamera (osg::ref_ptr< WGECamera > camera)
 Sets the current camera. More...
 
osg::ref_ptr< WGECameragetCamera ()
 Returns the camera currently in use. More...
 
void setScene (osg::ref_ptr< WGEGroupNode > node)
 Sets the scene graph node to be used for rendering. More...
 
osg::ref_ptr< WGEGroupNodegetScene ()
 Returns the currently set OSG node. More...
 
std::string getName () const
 Returns the name of the viewer. More...
 
void setBgColor (const WColor &bgColor)
 Determine the color of the viewer's background. More...
 
WColor getBgColor () const
 Returns the current default background color. More...
 
osg::ref_ptr< WPickHandlergetPickHandler ()
 Getter for the pick handler Warning: At the moment only the orthographic projection mode supports a pick handler. More...
 
osg::ref_ptr< WMouseLocationHandlergetMouseLocationHandler ()
 Getter for the mouse loection handler. More...
 
std::string getOpenGLVendor () const
 Queries the OpenGL vendor info. More...
 
WBoolFlag::SPtr isFrameRendered () const
 Returns the flag which denotes whether a frame was rendered. More...
 
WGEScreenCapture::RefPtr getScreenCapture () const
 Returns the main cameras screen capture callback. More...
 
WGEAnimationManipulator::RefPtr animationMode (bool on=true)
 The (de-)activates the animation mode. More...
 
bool isAnimationMode () const
 Checks if the viewer is in animation mode. More...
 
WGEViewerEffectHorizon::SPtr getBackground ()
 Return the background render effect for modification. More...
 
WGEViewerEffectImageOverlay::SPtr getImageOverlay ()
 Return the overlay render effect for modification. More...
 
WGEViewerEffectVignette::SPtr getVignette ()
 Return the vignette render effect for modification. More...
 
WGEViewerEffectHorizon::ConstSPtr getBackground () const
 Return the background render effect for modification. More...
 
WGEViewerEffectImageOverlay::ConstSPtr getImageOverlay () const
 Return the overlay render effect for modification. More...
 
WGEViewerEffectVignette::ConstSPtr getVignette () const
 Return the vignette render effect for modification. More...
 
void setEffectsActiveDefault (bool activeByDefault=true)
 Activate viewer effects by default. More...
 
WProperties::SPtr getProperties () const
 Return a pointer to the properties object of the view. More...
 
void setPaused (bool pause=true)
 Pause rendering. More...
 
bool getPaused () const
 Query whether the view is paused or not. More...
 
- Public Member Functions inherited from WGEGraphicsWindow
 WGEGraphicsWindow (osg::ref_ptr< osg::Referenced > wdata, int x, int y, int width, int height)
 Default constructor. More...
 
virtual ~WGEGraphicsWindow ()
 Destructor. More...
 
osg::ref_ptr< osgViewer::GraphicsWindow > getGraphicsWindow ()
 Getter for m_GraphicsWindow. More...
 
virtual void keyEvent (KeyEvents eventType, int key)
 Handles key events (if forwarded to this Viewer instance). More...
 
virtual void mouseEvent (MouseEvents eventType, int x, int y, int button)
 Handles mouse events forwarded from widget. More...
 
virtual bool isClosed () const
 Check if the windows is open. More...
 
virtual void setClosed (bool closed=true)
 Set closed state. More...
 

Protected Attributes

osg::ref_ptr< osgViewer::Viewer > m_View
 The OpenSceneGraph view used in this (Composite)Viewer. More...
 
std::string m_name
 The name of the viewer. More...
 
osg::ref_ptr< WPickHandlerm_pickHandler
 Pointer to the pick handler of the viewer. More...
 
osg::ref_ptr< WMouseLocationHandlerm_mouseLocationHandler
 Pointer to the mouse location handler of the viewer. More...
 
osg::ref_ptr< WGEGroupNodem_scene
 reference to the scene which is displayed by viewer More...
 
osg::ref_ptr< WGEGroupNodem_sceneMainNode
 Keep the currently set scene node. More...
 
WBoolFlag::SPtr m_rendered
 This flag is true and notifies after the first rendered frame. More...
 
osg::ref_ptr< QueryCallbackm_queryCallback
 The callback used for querying OpenGL features. More...
 
WGEScreenCapture::RefPtr m_screenCapture
 The screen capture callback. More...
 
bool m_inAnimationMode
 True -> animation mode on. More...
 
osg::ref_ptr< osgGA::MatrixManipulator > m_animationModeManipulatorBackup
 The manipulator that was set before entering animation mode. More...
 
WGEViewerEffectHorizon::SPtr m_effectHorizon
 Horizon effect. More...
 
WGEViewerEffectVignette::SPtr m_effectVignette
 Vignette effect. More...
 
WGEViewerEffectImageOverlay::SPtr m_effectImageOverlay
 Image overlay effect. More...
 
WProperties::SPtr m_properties
 The property object for the view. More...
 
- Protected Attributes inherited from WGEGraphicsWindow
osg::ref_ptr< osgViewer::GraphicsWindow > m_GraphicsWindow
 OpenSceneGraph render window. More...
 

Private Member Functions

void updateBgColor ()
 Update the default clear color (bg color). More...
 
void updateThrowing ()
 Update throw setting of the manipulator (if supported). More...
 

Private Attributes

WPropColor m_bgColor
 The default clear color (bg color). More...
 
WPropBool m_throwing
 The switch to enable the throw- functionality of some OSG manipulators. More...
 
bool m_paused
 Flag denoting whether the view is paused or not. More...
 

Detailed Description

Class for managing one view to the scene.

This includes viewport, camera and graphics context. It is, besides WGraphicsEngine, the ONLY entry point for each widget for accessing the graphics engine.

Definition at line 69 of file WGEViewer.h.

Member Typedef Documentation

◆ ConstSPtr

typedef std::shared_ptr< const WGEViewer > WGEViewer::ConstSPtr

Convenience typedef.

Definition at line 81 of file WGEViewer.h.

◆ SPtr

typedef std::shared_ptr< WGEViewer > WGEViewer::SPtr

Convenience typedef.

Definition at line 76 of file WGEViewer.h.

Constructor & Destructor Documentation

◆ WGEViewer()

WGEViewer::WGEViewer ( std::string  name,
osg::ref_ptr< osg::Referenced >  wdata,
int  x,
int  y,
int  width,
int  height,
WGECamera::ProjectionMode  projectionMode = WGECamera::ORTHOGRAPHIC 
)

Default constructor.

Parameters
namethe name of the viewer
wdatathe WindowData instance for the widget to use as render widget
xX coordinate of widget where to create the context.
yY coordinate of widget where to create the context.
widthWidth of the widget.
heightHeight of the Widget.
projectionModeProjection mode of the viewer. Currently only the orthographic mode allows the use of a pick handler.
Exceptions
WGEInitFailedthrown if initialization of graphics context or graphics window has failed.

Definition at line 56 of file WGEViewer.cpp.

References m_bgColor, m_effectHorizon, m_effectImageOverlay, m_effectVignette, WGEGraphicsWindow::m_GraphicsWindow, m_mouseLocationHandler, m_pickHandler, m_properties, m_queryCallback, m_rendered, m_scene, m_screenCapture, m_throwing, m_View, updateBgColor(), and updateThrowing().

+ Here is the call graph for this function:

◆ ~WGEViewer()

WGEViewer::~WGEViewer ( )
virtual

Destructor.

Definition at line 147 of file WGEViewer.cpp.

References close().

+ Here is the call graph for this function:

Member Function Documentation

◆ animationMode()

WGEAnimationManipulator::RefPtr WGEViewer::animationMode ( bool  on = true)

The (de-)activates the animation mode.

In animation mode, a special camera manipulator is used instead of the currently set. This manipulator can then play some animation path in realtime, frame-rate independent or in frame-per-frame mode which is useful if combined with the getScreenCapture() record function.

If animation mode is turned off again, the previously set manipulator / camera setting is restored.

Note
do not modify camera or camera manipulator manually while in animation mode.
Parameters
ontrue to turn on.
Returns
the animation manipulator. This, and only this should be used to provide the animation.

Definition at line 317 of file WGEViewer.cpp.

References getCameraManipulator(), m_animationModeManipulatorBackup, m_inAnimationMode, and m_View.

+ Here is the call graph for this function:

◆ close()

void WGEViewer::close ( )
virtual

Close the viewer, but wait for the rendering thread to finish.

Reimplemented from WGEGraphicsWindow.

Definition at line 245 of file WGEViewer.cpp.

References WGEGraphicsWindow::close(), and m_effectImageOverlay.

Referenced by ~WGEViewer().

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

◆ getBackground() [1/2]

WGEViewerEffectHorizon::SPtr WGEViewer::getBackground ( )

Return the background render effect for modification.

Returns
the effect

Definition at line 353 of file WGEViewer.cpp.

References m_effectHorizon.

Referenced by setEffectsActiveDefault().

+ Here is the caller graph for this function:

◆ getBackground() [2/2]

WGEViewerEffectHorizon::ConstSPtr WGEViewer::getBackground ( ) const

Return the background render effect for modification.

Returns
the effect

Definition at line 368 of file WGEViewer.cpp.

References m_effectHorizon.

◆ getBgColor()

WColor WGEViewer::getBgColor ( ) const

Returns the current default background color.

This color is only visible if no camera effect overrides it.

Returns
The color.

Definition at line 220 of file WGEViewer.cpp.

References m_bgColor.

◆ getCamera()

osg::ref_ptr< WGECamera > WGEViewer::getCamera ( )

Returns the camera currently in use.

Returns
the camera currently in use.

Definition at line 177 of file WGEViewer.cpp.

References m_View.

◆ getCameraManipulator()

osg::ref_ptr< osgGA::MatrixManipulator > WGEViewer::getCameraManipulator ( )

Returns current active camera manipulator.

Returns
the active camera manipulator.

Definition at line 166 of file WGEViewer.cpp.

References m_View.

Referenced by animationMode(), and updateThrowing().

+ Here is the caller graph for this function:

◆ getImageOverlay() [1/2]

WGEViewerEffectImageOverlay::SPtr WGEViewer::getImageOverlay ( )

Return the overlay render effect for modification.

Returns
the effect

Definition at line 358 of file WGEViewer.cpp.

References m_effectImageOverlay.

Referenced by setEffectsActiveDefault().

+ Here is the caller graph for this function:

◆ getImageOverlay() [2/2]

WGEViewerEffectImageOverlay::ConstSPtr WGEViewer::getImageOverlay ( ) const

Return the overlay render effect for modification.

Returns
the effect

Definition at line 373 of file WGEViewer.cpp.

References m_effectImageOverlay.

◆ getMouseLocationHandler()

osg::ref_ptr< WMouseLocationHandler > WGEViewer::getMouseLocationHandler ( )

Getter for the mouse loection handler.

Returns
the mouse location handler

Definition at line 264 of file WGEViewer.cpp.

References m_mouseLocationHandler.

◆ getName()

std::string WGEViewer::getName ( ) const

Returns the name of the viewer.

Returns
the name

Definition at line 254 of file WGEViewer.cpp.

References m_name.

◆ getOpenGLVendor()

std::string WGEViewer::getOpenGLVendor ( ) const

Queries the OpenGL vendor info.

Returns
Vendor string.

Definition at line 279 of file WGEViewer.cpp.

References m_queryCallback.

◆ getPaused()

bool WGEViewer::getPaused ( ) const

Query whether the view is paused or not.

Returns
true if paused

Definition at line 400 of file WGEViewer.cpp.

References m_paused.

◆ getPickHandler()

osg::ref_ptr< WPickHandler > WGEViewer::getPickHandler ( )

Getter for the pick handler Warning: At the moment only the orthographic projection mode supports a pick handler.

Returns
the pick handler

Definition at line 259 of file WGEViewer.cpp.

References m_pickHandler.

◆ getProperties()

WProperties::SPtr WGEViewer::getProperties ( ) const

Return a pointer to the properties object of the view.

Returns
the properties.

Definition at line 383 of file WGEViewer.cpp.

References m_properties.

◆ getScene()

osg::ref_ptr< WGEGroupNode > WGEViewer::getScene ( )

Returns the currently set OSG node.

Returns
the node.

Definition at line 196 of file WGEViewer.cpp.

References m_sceneMainNode.

◆ getScreenCapture()

WGEScreenCapture::RefPtr WGEViewer::getScreenCapture ( ) const

Returns the main cameras screen capture callback.

Returns
the screen capture callback.

Definition at line 274 of file WGEViewer.cpp.

References m_screenCapture.

◆ getView()

osg::ref_ptr< osgViewer::Viewer > WGEViewer::getView ( )

Getter for OpenSceneGraph View instance.

Returns
the OSG Viewer instance.

Definition at line 153 of file WGEViewer.cpp.

References m_View.

Referenced by handleVisibilityChange(), and requestContinuousUpdate().

+ Here is the caller graph for this function:

◆ getVignette() [1/2]

WGEViewerEffectVignette::SPtr WGEViewer::getVignette ( )

Return the vignette render effect for modification.

Returns
the effect

Definition at line 363 of file WGEViewer.cpp.

References m_effectVignette.

Referenced by setEffectsActiveDefault().

+ Here is the caller graph for this function:

◆ getVignette() [2/2]

WGEViewerEffectVignette::ConstSPtr WGEViewer::getVignette ( ) const

Return the vignette render effect for modification.

Returns
the effect

Definition at line 378 of file WGEViewer.cpp.

References m_effectVignette.

◆ handleVisibilityChange()

void WGEViewer::handleVisibilityChange ( bool  visible)

If the widget is not visible, we might be able to reduce CPU load.

This does not hide the widget.

Parameters
visibletrue to show again.

Definition at line 405 of file WGEViewer.cpp.

References getView().

+ Here is the call graph for this function:

◆ isAnimationMode()

bool WGEViewer::isAnimationMode ( ) const

Checks if the viewer is in animation mode.

Returns
true if in animation mode

Definition at line 348 of file WGEViewer.cpp.

References m_inAnimationMode.

◆ isFrameRendered()

WBoolFlag::SPtr WGEViewer::isFrameRendered ( ) const

Returns the flag which denotes whether a frame was rendered.

Returns
the flag.

Definition at line 284 of file WGEViewer.cpp.

References m_rendered.

◆ paint()

void WGEViewer::paint ( )
virtual

Repaints the contents.

Mac only.

Definition at line 225 of file WGEViewer.cpp.

References m_View.

◆ requestContinuousUpdate()

void WGEViewer::requestContinuousUpdate ( bool  continuous = true)

Update the view automatically (the default).

Use this to disable it explicitly.

Parameters
continuous

Definition at line 410 of file WGEViewer.cpp.

References getView().

+ Here is the call graph for this function:

◆ reset()

void WGEViewer::reset ( )

Resets the view using the installed manipulator.

Definition at line 269 of file WGEViewer.cpp.

References m_View.

◆ resize()

void WGEViewer::resize ( int  width,
int  height 
)
virtual

Updates size information.

Also updates camera.

Parameters
widthnew width.
heightnew height.

Reimplemented from WGEGraphicsWindow.

Definition at line 230 of file WGEViewer.cpp.

References m_View, WGECamera::resize(), and WGEGraphicsWindow::resize().

+ Here is the call graph for this function:

◆ setBgColor()

void WGEViewer::setBgColor ( const WColor &  bgColor)

Determine the color of the viewer's background.

Note
This is only useful when the background effect is disabled.
Parameters
bgColorthe new background color

Definition at line 215 of file WGEViewer.cpp.

References m_bgColor.

◆ setCamera()

void WGEViewer::setCamera ( osg::ref_ptr< WGECamera camera)

Sets the current camera.

Parameters
camerathe OSG camera instance.

Definition at line 171 of file WGEViewer.cpp.

References m_View.

◆ setCameraManipulator()

void WGEViewer::setCameraManipulator ( osg::ref_ptr< osgGA::MatrixManipulator >  manipulator)

Sets the camera manipulator to use.

Parameters
manipulatorthe manipulator to use.

Definition at line 158 of file WGEViewer.cpp.

References m_inAnimationMode, and m_View.

◆ setEffectsActiveDefault()

void WGEViewer::setEffectsActiveDefault ( bool  activeByDefault = true)

Activate viewer effects by default.

If the user has deactivated them, this method does not cause any change.

Parameters
activeByDefaultif true all effects are active by default

Definition at line 388 of file WGEViewer.cpp.

References getBackground(), getImageOverlay(), and getVignette().

+ Here is the call graph for this function:

◆ setPaused()

void WGEViewer::setPaused ( bool  pause = true)

Pause rendering.

This does not free the viewer. It simply pauses rendering. Be warned. This does not necessarily improve performance with multiple views. This depends on the osgViewer components used and the underlying GUI (i.e. Qt).

Parameters
pausetrue to pause.

Definition at line 395 of file WGEViewer.cpp.

References m_paused.

◆ setScene()

void WGEViewer::setScene ( osg::ref_ptr< WGEGroupNode node)

Sets the scene graph node to be used for rendering.

Parameters
nodepart of the scene graph

Definition at line 182 of file WGEViewer.cpp.

References m_effectHorizon, m_effectImageOverlay, m_effectVignette, m_scene, and m_sceneMainNode.

◆ updateBgColor()

void WGEViewer::updateBgColor ( )
private

Update the default clear color (bg color).

Called by the m_bgColor property.

Definition at line 210 of file WGEViewer.cpp.

References m_bgColor, and m_View.

Referenced by WGEViewer().

+ Here is the caller graph for this function:

◆ updateThrowing()

void WGEViewer::updateThrowing ( )
private

Update throw setting of the manipulator (if supported).

Definition at line 201 of file WGEViewer.cpp.

References getCameraManipulator(), m_throwing, and WGEZoomTrackballManipulator::setThrow().

Referenced by WGEViewer().

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

Member Data Documentation

◆ m_animationModeManipulatorBackup

osg::ref_ptr<osgGA::MatrixManipulator> WGEViewer::m_animationModeManipulatorBackup
protected

The manipulator that was set before entering animation mode.

Null if not in animation mode.

Definition at line 445 of file WGEViewer.h.

Referenced by animationMode().

◆ m_bgColor

WPropColor WGEViewer::m_bgColor
private

The default clear color (bg color).

Definition at line 470 of file WGEViewer.h.

Referenced by getBgColor(), setBgColor(), updateBgColor(), and WGEViewer().

◆ m_effectHorizon

WGEViewerEffectHorizon::SPtr WGEViewer::m_effectHorizon
protected

Horizon effect.

Definition at line 450 of file WGEViewer.h.

Referenced by getBackground(), setScene(), and WGEViewer().

◆ m_effectImageOverlay

WGEViewerEffectImageOverlay::SPtr WGEViewer::m_effectImageOverlay
protected

Image overlay effect.

Definition at line 460 of file WGEViewer.h.

Referenced by close(), getImageOverlay(), setScene(), and WGEViewer().

◆ m_effectVignette

WGEViewerEffectVignette::SPtr WGEViewer::m_effectVignette
protected

Vignette effect.

Definition at line 455 of file WGEViewer.h.

Referenced by getVignette(), setScene(), and WGEViewer().

◆ m_inAnimationMode

bool WGEViewer::m_inAnimationMode
protected

True -> animation mode on.

Definition at line 440 of file WGEViewer.h.

Referenced by animationMode(), isAnimationMode(), and setCameraManipulator().

◆ m_mouseLocationHandler

osg::ref_ptr<WMouseLocationHandler> WGEViewer::m_mouseLocationHandler
protected

Pointer to the mouse location handler of the viewer.

Definition at line 359 of file WGEViewer.h.

Referenced by getMouseLocationHandler(), and WGEViewer().

◆ m_name

std::string WGEViewer::m_name
protected

The name of the viewer.

Definition at line 349 of file WGEViewer.h.

Referenced by getName().

◆ m_paused

bool WGEViewer::m_paused
private

Flag denoting whether the view is paused or not.

Definition at line 490 of file WGEViewer.h.

Referenced by getPaused(), and setPaused().

◆ m_pickHandler

osg::ref_ptr<WPickHandler> WGEViewer::m_pickHandler
protected

Pointer to the pick handler of the viewer.

Definition at line 354 of file WGEViewer.h.

Referenced by getPickHandler(), and WGEViewer().

◆ m_properties

WProperties::SPtr WGEViewer::m_properties
protected

The property object for the view.

Definition at line 465 of file WGEViewer.h.

Referenced by getProperties(), and WGEViewer().

◆ m_queryCallback

osg::ref_ptr< QueryCallback > WGEViewer::m_queryCallback
protected

The callback used for querying OpenGL features.

Definition at line 429 of file WGEViewer.h.

Referenced by getOpenGLVendor(), and WGEViewer().

◆ m_rendered

WBoolFlag::SPtr WGEViewer::m_rendered
protected

This flag is true and notifies after the first rendered frame.

Definition at line 374 of file WGEViewer.h.

Referenced by isFrameRendered(), and WGEViewer().

◆ m_scene

osg::ref_ptr< WGEGroupNode > WGEViewer::m_scene
protected

reference to the scene which is displayed by viewer

Definition at line 364 of file WGEViewer.h.

Referenced by setScene(), and WGEViewer().

◆ m_sceneMainNode

osg::ref_ptr< WGEGroupNode > WGEViewer::m_sceneMainNode
protected

Keep the currently set scene node.

Unlike m_scene, it is the user set node.

Definition at line 369 of file WGEViewer.h.

Referenced by getScene(), and setScene().

◆ m_screenCapture

WGEScreenCapture::RefPtr WGEViewer::m_screenCapture
protected

The screen capture callback.

Definition at line 435 of file WGEViewer.h.

Referenced by getScreenCapture(), and WGEViewer().

◆ m_throwing

WPropBool WGEViewer::m_throwing
private

The switch to enable the throw- functionality of some OSG manipulators.

Definition at line 475 of file WGEViewer.h.

Referenced by updateThrowing(), and WGEViewer().

◆ m_View

osg::ref_ptr< osgViewer::Viewer > WGEViewer::m_View
protected

The OpenSceneGraph view used in this (Composite)Viewer.

Definition at line 344 of file WGEViewer.h.

Referenced by animationMode(), getCamera(), getCameraManipulator(), getView(), paint(), reset(), resize(), setCamera(), setCameraManipulator(), updateBgColor(), and WGEViewer().


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