OpenWalnut
1.4.0
|
Class for managing one view to the scene. More...
#include <WGEViewer.h>
Classes | |
class | QueryCallback |
Small class used for querying glGet info during rendering. More... | |
Public Types | |
typedef boost::shared_ptr < WGEViewer > | SPtr |
Convenience typedef. | |
typedef boost::shared_ptr < const WGEViewer > | ConstSPtr |
Convenience typedef. | |
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. | |
virtual | ~WGEViewer () |
Destructor. | |
virtual void | paint () |
Repaints the contents. | |
virtual void | resize (int width, int height) |
Updates size information. | |
virtual void | close () |
Close the viewer, but wait for the rendering thread to finish. | |
osg::ref_ptr< osgViewer::View > | getView () |
Getter for OpenSceneGraph View instance. | |
void | reset () |
Resets the view using the installed manipulator. | |
void | setCameraManipulator (osg::ref_ptr< osgGA::MatrixManipulator > manipulator) |
Sets the camera manipulator to use. | |
osg::ref_ptr < osgGA::MatrixManipulator > | getCameraManipulator () |
Returns current active camera manipulator. | |
void | setCamera (osg::ref_ptr< WGECamera > camera) |
Sets the current camera. | |
osg::ref_ptr< WGECamera > | getCamera () |
Returns the camera currently in use. | |
void | setScene (osg::ref_ptr< WGEGroupNode > node) |
Sets the scene graph node to be used for rendering. | |
osg::ref_ptr< WGEGroupNode > | getScene () |
Returns the currently set OSG node. | |
std::string | getName () const |
Returns the name of the viewer. | |
void | setBgColor (const WColor &bgColor) |
Determine the color of the viewer's background. | |
WColor | getBgColor () const |
Returns the current default background color. | |
osg::ref_ptr< WPickHandler > | getPickHandler () |
Getter for the pick handler. | |
std::string | getOpenGLVendor () const |
Queries the OpenGL vendor info. | |
WBoolFlag::SPtr | isFrameRendered () const |
Returns the flag which denotes whether a frame was rendered. | |
WGEScreenCapture::RefPtr | getScreenCapture () const |
Returns the main cameras screen capture callback. | |
WGEAnimationManipulator::RefPtr | animationMode (bool on=true) |
The (de-)activates the animation mode. | |
bool | isAnimationMode () const |
Checks if the viewer is in animation mode. | |
WGEViewerEffectHorizon::SPtr | getBackground () |
Return the background render effect for modification. | |
WGEViewerEffectImageOverlay::SPtr | getImageOverlay () |
Return the overlay render effect for modification. | |
WGEViewerEffectVignette::SPtr | getVignette () |
Return the vignette render effect for modification. | |
WGEViewerEffectHorizon::ConstSPtr | getBackground () const |
Return the background render effect for modification. | |
WGEViewerEffectImageOverlay::ConstSPtr | getImageOverlay () const |
Return the overlay render effect for modification. | |
WGEViewerEffectVignette::ConstSPtr | getVignette () const |
Return the vignette render effect for modification. | |
void | setEffectsActiveDefault (bool activeByDefault=true) |
Activate viewer effects by default. | |
WProperties::SPtr | getProperties () const |
Return a pointer to the properties object of the view. | |
Protected Attributes | |
osg::ref_ptr< osgViewer::View > | m_View |
The OpenSceneGraph view used in this (Composite)Viewer. | |
std::string | m_name |
The name of the viewer. | |
osg::ref_ptr< WPickHandler > | m_pickHandler |
Pointer to the pick handler of the viewer. | |
osg::ref_ptr< WGEGroupNode > | m_scene |
reference to the scene which is displayed by viewer | |
osg::ref_ptr< WGEGroupNode > | m_sceneMainNode |
Keep the currently set scene node. | |
WBoolFlag::SPtr | m_rendered |
This flag is true and notifies after the first rendered frame. | |
osg::ref_ptr< QueryCallback > | m_queryCallback |
The callback used for querying OpenGL features. | |
WGEScreenCapture::RefPtr | m_screenCapture |
The screen capture callback. | |
bool | m_inAnimationMode |
True -> animation mode on. | |
osg::ref_ptr < osgGA::MatrixManipulator > | m_animationModeManipulatorBackup |
The manipulator that was set before entering animation mode. | |
WGEViewerEffectHorizon::SPtr | m_effectHorizon |
Horizon effect. | |
WGEViewerEffectVignette::SPtr | m_effectVignette |
Vignette effect. | |
WGEViewerEffectImageOverlay::SPtr | m_effectImageOverlay |
Image overlay effect. | |
WProperties::SPtr | m_properties |
The property object for the view. | |
Private Member Functions | |
void | updateBgColor () |
Update the default clear color (bg color). | |
void | updateThrowing () |
Update throw setting of the manipulator (if supported). | |
Private Attributes | |
WPropColor | m_bgColor |
The default clear color (bg color). | |
WPropBool | m_throwing |
The switch to enable the throw- functionality of some OSG manipulators. |
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 71 of file WGEViewer.h.
typedef boost::shared_ptr< const WGEViewer > WGEViewer::ConstSPtr |
Convenience typedef.
Definition at line 83 of file WGEViewer.h.
typedef boost::shared_ptr< WGEViewer > WGEViewer::SPtr |
Convenience typedef.
Definition at line 78 of file WGEViewer.h.
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.
name | the name of the viewer |
wdata | the WindowData instance for the widget to use as render widget |
x | X coordinate of widget where to create the context. |
y | Y coordinate of widget where to create the context. |
width | Width of the widget. |
height | Height of the Widget. |
projectionMode | Projection mode of the viewer. |
WGEInitFailed | thrown 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_pickHandler, m_properties, m_queryCallback, m_rendered, m_scene, m_screenCapture, m_throwing, m_View, updateBgColor(), and updateThrowing().
WGEViewer::~WGEViewer | ( | ) | [virtual] |
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.
on | true to turn on. |
Definition at line 318 of file WGEViewer.cpp.
References getCameraManipulator(), m_animationModeManipulatorBackup, m_inAnimationMode, and m_View.
void WGEViewer::close | ( | ) | [virtual] |
Close the viewer, but wait for the rendering thread to finish.
Reimplemented from WGEGraphicsWindow.
Definition at line 254 of file WGEViewer.cpp.
Referenced by ~WGEViewer().
Return the background render effect for modification.
Definition at line 354 of file WGEViewer.cpp.
References m_effectHorizon.
Referenced by setEffectsActiveDefault().
Return the background render effect for modification.
Definition at line 369 of file WGEViewer.cpp.
References m_effectHorizon.
WColor WGEViewer::getBgColor | ( | ) | const |
Returns the current default background color.
This color is only visible if no camera effect overrides it.
Definition at line 227 of file WGEViewer.cpp.
References m_bgColor.
osg::ref_ptr< WGECamera > WGEViewer::getCamera | ( | ) |
Returns the camera currently in use.
Definition at line 184 of file WGEViewer.cpp.
References m_View.
osg::ref_ptr< osgGA::MatrixManipulator > WGEViewer::getCameraManipulator | ( | ) |
Returns current active camera manipulator.
Definition at line 173 of file WGEViewer.cpp.
References m_View.
Referenced by animationMode(), and updateThrowing().
Return the overlay render effect for modification.
Definition at line 359 of file WGEViewer.cpp.
References m_effectImageOverlay.
Referenced by setEffectsActiveDefault().
Return the overlay render effect for modification.
Definition at line 374 of file WGEViewer.cpp.
References m_effectImageOverlay.
std::string WGEViewer::getName | ( | ) | const |
Returns the name of the viewer.
Definition at line 260 of file WGEViewer.cpp.
References m_name.
std::string WGEViewer::getOpenGLVendor | ( | ) | const |
Queries the OpenGL vendor info.
Definition at line 280 of file WGEViewer.cpp.
References m_queryCallback.
osg::ref_ptr< WPickHandler > WGEViewer::getPickHandler | ( | ) |
Getter for the pick handler.
Definition at line 265 of file WGEViewer.cpp.
References m_pickHandler.
WProperties::SPtr WGEViewer::getProperties | ( | ) | const |
Return a pointer to the properties object of the view.
Definition at line 384 of file WGEViewer.cpp.
References m_properties.
osg::ref_ptr< WGEGroupNode > WGEViewer::getScene | ( | ) |
Returns the currently set OSG node.
Definition at line 203 of file WGEViewer.cpp.
References m_sceneMainNode.
Returns the main cameras screen capture callback.
Definition at line 275 of file WGEViewer.cpp.
References m_screenCapture.
osg::ref_ptr< osgViewer::View > WGEViewer::getView | ( | ) |
Getter for OpenSceneGraph View instance.
Definition at line 160 of file WGEViewer.cpp.
References m_View.
Return the vignette render effect for modification.
Definition at line 364 of file WGEViewer.cpp.
References m_effectVignette.
Referenced by setEffectsActiveDefault().
Return the vignette render effect for modification.
Definition at line 379 of file WGEViewer.cpp.
References m_effectVignette.
bool WGEViewer::isAnimationMode | ( | ) | const |
Checks if the viewer is in animation mode.
Definition at line 349 of file WGEViewer.cpp.
References m_inAnimationMode.
WBoolFlag::SPtr WGEViewer::isFrameRendered | ( | ) | const |
Returns the flag which denotes whether a frame was rendered.
Definition at line 285 of file WGEViewer.cpp.
References m_rendered.
void WGEViewer::paint | ( | ) | [virtual] |
void WGEViewer::reset | ( | ) |
Resets the view using the installed manipulator.
Definition at line 270 of file WGEViewer.cpp.
References m_View.
void WGEViewer::resize | ( | int | width, |
int | height | ||
) | [virtual] |
Updates size information.
Also updates camera.
width | new width. |
height | new height. |
Reimplemented from WGEGraphicsWindow.
Definition at line 239 of file WGEViewer.cpp.
References m_View, and WGECamera::resize().
void WGEViewer::setBgColor | ( | const WColor & | bgColor | ) |
Determine the color of the viewer's background.
bgColor | the new background color |
Definition at line 222 of file WGEViewer.cpp.
References m_bgColor.
void WGEViewer::setCamera | ( | osg::ref_ptr< WGECamera > | camera | ) |
Sets the current camera.
camera | the OSG camera instance. |
Definition at line 178 of file WGEViewer.cpp.
References m_View.
void WGEViewer::setCameraManipulator | ( | osg::ref_ptr< osgGA::MatrixManipulator > | manipulator | ) |
Sets the camera manipulator to use.
manipulator | the manipulator to use. |
Definition at line 165 of file WGEViewer.cpp.
References m_inAnimationMode, and m_View.
void WGEViewer::setEffectsActiveDefault | ( | bool | activeByDefault = true | ) |
Activate viewer effects by default.
If the user has deactivated them, this method does not cause any change.
activeByDefault | if true all effects are active by default |
Definition at line 389 of file WGEViewer.cpp.
References getBackground(), getImageOverlay(), and getVignette().
void WGEViewer::setScene | ( | osg::ref_ptr< WGEGroupNode > | node | ) |
Sets the scene graph node to be used for rendering.
node | part of the scene graph |
Definition at line 189 of file WGEViewer.cpp.
References m_effectHorizon, m_effectImageOverlay, m_effectVignette, m_scene, and m_sceneMainNode.
void WGEViewer::updateBgColor | ( | ) | [private] |
Update the default clear color (bg color).
Called by the m_bgColor property.
Definition at line 217 of file WGEViewer.cpp.
References m_bgColor, and m_View.
Referenced by WGEViewer().
void WGEViewer::updateThrowing | ( | ) | [private] |
Update throw setting of the manipulator (if supported).
Definition at line 208 of file WGEViewer.cpp.
References getCameraManipulator(), m_throwing, and WGEZoomTrackballManipulator::setThrow().
Referenced by WGEViewer().
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 414 of file WGEViewer.h.
Referenced by animationMode().
WPropColor WGEViewer::m_bgColor [private] |
The default clear color (bg color).
Definition at line 439 of file WGEViewer.h.
Referenced by getBgColor(), setBgColor(), updateBgColor(), and WGEViewer().
Horizon effect.
Definition at line 419 of file WGEViewer.h.
Referenced by getBackground(), setScene(), and WGEViewer().
Image overlay effect.
Definition at line 429 of file WGEViewer.h.
Referenced by getImageOverlay(), setScene(), and WGEViewer().
Vignette effect.
Definition at line 424 of file WGEViewer.h.
Referenced by getVignette(), setScene(), and WGEViewer().
bool WGEViewer::m_inAnimationMode [protected] |
True -> animation mode on.
Definition at line 409 of file WGEViewer.h.
Referenced by animationMode(), isAnimationMode(), and setCameraManipulator().
std::string WGEViewer::m_name [protected] |
osg::ref_ptr<WPickHandler> WGEViewer::m_pickHandler [protected] |
Pointer to the pick handler of the viewer.
Definition at line 328 of file WGEViewer.h.
Referenced by getPickHandler(), and WGEViewer().
WProperties::SPtr WGEViewer::m_properties [protected] |
The property object for the view.
Definition at line 434 of file WGEViewer.h.
Referenced by getProperties(), and WGEViewer().
osg::ref_ptr< QueryCallback > WGEViewer::m_queryCallback [protected] |
The callback used for querying OpenGL features.
Definition at line 398 of file WGEViewer.h.
Referenced by getOpenGLVendor(), and WGEViewer().
WBoolFlag::SPtr WGEViewer::m_rendered [protected] |
This flag is true and notifies after the first rendered frame.
Definition at line 343 of file WGEViewer.h.
Referenced by isFrameRendered(), and WGEViewer().
osg::ref_ptr< WGEGroupNode > WGEViewer::m_scene [protected] |
reference to the scene which is displayed by viewer
Definition at line 333 of file WGEViewer.h.
Referenced by setScene(), and WGEViewer().
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 338 of file WGEViewer.h.
Referenced by getScene(), and setScene().
WGEScreenCapture::RefPtr WGEViewer::m_screenCapture [protected] |
The screen capture callback.
Definition at line 404 of file WGEViewer.h.
Referenced by getScreenCapture(), and WGEViewer().
WPropBool WGEViewer::m_throwing [private] |
The switch to enable the throw- functionality of some OSG manipulators.
Definition at line 444 of file WGEViewer.h.
Referenced by updateThrowing(), and WGEViewer().
osg::ref_ptr< osgViewer::View > WGEViewer::m_View [protected] |
The OpenSceneGraph view used in this (Composite)Viewer.
Definition at line 317 of file WGEViewer.h.
Referenced by animationMode(), getCamera(), getCameraManipulator(), getView(), paint(), reset(), resize(), setCamera(), setCameraManipulator(), updateBgColor(), and WGEViewer().