32 #include <osg/Version>
33 #include <osgViewer/View>
34 #include <osgViewer/Viewer>
38 #if( ( OPENSCENEGRAPH_MAJOR_VERSION > 2 ) || ( OPENSCENEGRAPH_MAJOR_VERSION == 2 && ( OPENSCENEGRAPH_MINOR_VERSION > 9 || \
39 ( OPENSCENEGRAPH_MINOR_VERSION == 9 && OPENSCENEGRAPH_PATCH_VERSION >= 8 ) ) ) )
40 #include <osgGA/CameraManipulator>
43 typedef CameraManipulator MatrixManipulator;
46 #include <osgGA/MatrixManipulator>
49 #include "../common/WColor.h"
50 #include "../common/WFlag.h"
52 #include "WGECamera.h"
53 #include "WGEGraphicsWindow.h"
55 #include "WGEScreenCapture.h"
58 #include "animation/WGEAnimationManipulator.h"
60 #include "WGEViewerEffectHorizon.h"
61 #include "WGEViewerEffectVignette.h"
62 #include "WGEViewerEffectImageOverlay.h"
70 public std::enable_shared_from_this< WGEViewer >
76 typedef std::shared_ptr< WGEViewer >
SPtr;
81 typedef std::shared_ptr< const WGEViewer >
ConstSPtr;
95 WGEViewer( std::string name, osg::ref_ptr<osg::Referenced> wdata,
int x,
int y,
int width,
int height,
106 virtual void paint();
114 virtual void resize(
int width,
int height );
119 virtual void close();
126 osg::ref_ptr<osgViewer::Viewer>
getView();
166 void setCamera( osg::ref_ptr< WGECamera > camera );
180 void setScene( osg::ref_ptr< WGEGroupNode > node );
187 osg::ref_ptr< WGEGroupNode >
getScene();
344 osg::ref_ptr< osgViewer::Viewer >
m_View;
400 virtual void operator()( osg::RenderInfo& renderInfo )
const;
std::shared_ptr< WFlag< bool > > SPtr
Convenience typedef for a std::shared_ptr.
osg::ref_ptr< WGEAnimationManipulator > RefPtr
Convenience typedef.
ProjectionMode
List of possible camera modes.
Class managing a single graphics context and OSG GraphicsWindow.
Class to wrap around the osg Group node and providing a thread safe add/removal mechanism.
osg::ref_ptr< WGEScreenCapture > RefPtr
Convenience typedef.
osg::ref_ptr< const WGEViewerEffectHorizon > ConstSPtr
Convenience typedef for a std::shared_ptr< const WGEViewerEffectHorizon >.
osg::ref_ptr< WGEViewerEffectHorizon > SPtr
Convenience typedef for a std::shared_ptr< WGEViewerEffectHorizon >.
osg::ref_ptr< const WGEViewerEffectImageOverlay > ConstSPtr
Convenience typedef for a std::shared_ptr< const WGEViewerEffectImageOverlay >.
osg::ref_ptr< WGEViewerEffectImageOverlay > SPtr
Convenience typedef for a std::shared_ptr< WGEViewerEffectImageOverlay >.
osg::ref_ptr< const WGEViewerEffectVignette > ConstSPtr
Convenience typedef for a std::shared_ptr< const WGEViewerEffectVignette >.
osg::ref_ptr< WGEViewerEffectVignette > SPtr
Convenience typedef for a std::shared_ptr< WGEViewerEffectVignette >.
Small class used for querying glGet info during rendering.
std::string m_vendor
The vendor string.
WBoolFlag::SPtr m_run
True if callback was run once.
QueryCallback(osg::ref_ptr< WGECamera > camera, WBoolFlag::SPtr run)
Constructor.
virtual void operator()(osg::RenderInfo &renderInfo) const
Query operator.
std::string getVendor() const
Returns the queried vendor string.
osg::ref_ptr< WGECamera > m_camera
The camera to which this was connected.
virtual ~QueryCallback()
Destructor.
Class for managing one view to the scene.
osg::ref_ptr< osgViewer::Viewer > m_View
The OpenSceneGraph view used in this (Composite)Viewer.
WBoolFlag::SPtr isFrameRendered() const
Returns the flag which denotes whether a frame was rendered.
osg::ref_ptr< osgGA::MatrixManipulator > getCameraManipulator()
Returns current active camera manipulator.
void handleVisibilityChange(bool visible)
If the widget is not visible, we might be able to reduce CPU load.
void reset()
Resets the view using the installed manipulator.
WGEScreenCapture::RefPtr m_screenCapture
The screen capture callback.
virtual ~WGEViewer()
Destructor.
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.
std::string getName() const
Returns the name of the viewer.
WColor getBgColor() const
Returns the current default background color.
void setBgColor(const WColor &bgColor)
Determine the color of the viewer's background.
virtual void resize(int width, int height)
Updates size information.
void setEffectsActiveDefault(bool activeByDefault=true)
Activate viewer effects by default.
WGEViewerEffectHorizon::SPtr m_effectHorizon
Horizon effect.
osg::ref_ptr< WGECamera > getCamera()
Returns the camera currently in use.
WPropBool m_throwing
The switch to enable the throw- functionality of some OSG manipulators.
osg::ref_ptr< osgViewer::Viewer > getView()
Getter for OpenSceneGraph View instance.
osg::ref_ptr< WPickHandler > getPickHandler()
Getter for the pick handler Warning: At the moment only the orthographic projection mode supports a p...
bool isAnimationMode() const
Checks if the viewer is in animation mode.
std::shared_ptr< WGEViewer > SPtr
Convenience typedef.
WGEViewerEffectHorizon::SPtr getBackground()
Return the background render effect for modification.
osg::ref_ptr< QueryCallback > m_queryCallback
The callback used for querying OpenGL features.
WGEScreenCapture::RefPtr getScreenCapture() const
Returns the main cameras screen capture callback.
osg::ref_ptr< WGEGroupNode > m_scene
reference to the scene which is displayed by viewer
WGEViewerEffectImageOverlay::SPtr getImageOverlay()
Return the overlay render effect for modification.
void updateThrowing()
Update throw setting of the manipulator (if supported).
void setCameraManipulator(osg::ref_ptr< osgGA::MatrixManipulator > manipulator)
Sets the camera manipulator to use.
void setPaused(bool pause=true)
Pause rendering.
osg::ref_ptr< WPickHandler > m_pickHandler
Pointer to the pick handler of the viewer.
void setScene(osg::ref_ptr< WGEGroupNode > node)
Sets the scene graph node to be used for rendering.
void updateBgColor()
Update the default clear color (bg color).
std::string getOpenGLVendor() const
Queries the OpenGL vendor info.
WPropColor m_bgColor
The default clear color (bg color).
void requestContinuousUpdate(bool continuous=true)
Update the view automatically (the default).
osg::ref_ptr< WGEGroupNode > getScene()
Returns the currently set OSG node.
osg::ref_ptr< WGEGroupNode > m_sceneMainNode
Keep the currently set scene node.
WProperties::SPtr getProperties() const
Return a pointer to the properties object of the view.
WGEViewerEffectVignette::SPtr getVignette()
Return the vignette render effect for modification.
std::shared_ptr< const WGEViewer > ConstSPtr
Convenience typedef.
WGEAnimationManipulator::RefPtr animationMode(bool on=true)
The (de-)activates the animation mode.
WGEViewerEffectVignette::SPtr m_effectVignette
Vignette effect.
bool getPaused() const
Query whether the view is paused or not.
WBoolFlag::SPtr m_rendered
This flag is true and notifies after the first rendered frame.
osg::ref_ptr< WMouseLocationHandler > m_mouseLocationHandler
Pointer to the mouse location handler of the viewer.
WGEViewerEffectImageOverlay::SPtr m_effectImageOverlay
Image overlay effect.
osg::ref_ptr< osgGA::MatrixManipulator > m_animationModeManipulatorBackup
The manipulator that was set before entering animation mode.
virtual void close()
Close the viewer, but wait for the rendering thread to finish.
WProperties::SPtr m_properties
The property object for the view.
osg::ref_ptr< WMouseLocationHandler > getMouseLocationHandler()
Getter for the mouse loection handler.
bool m_inAnimationMode
True -> animation mode on.
bool m_paused
Flag denoting whether the view is paused or not.
void setCamera(osg::ref_ptr< WGECamera > camera)
Sets the current camera.
std::string m_name
The name of the viewer.
virtual void paint()
Repaints the contents.
Class to handle providing information about pixel position of mouse.
Class to handle events with a pick.
std::shared_ptr< WPropertyGroup > SPtr
shared pointer to object of this type