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

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

#include <WGEViewer.h>

+ Inheritance diagram for WGEViewer:

Classes

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

Public Types

typedef boost::shared_ptr
< WGEViewer
SPtr
 Convenience typedef. More...
 
typedef boost::shared_ptr
< const WGEViewer
ConstSPtr
 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::View > getView ()
 Getter for OpenSceneGraph View instance. 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< osg::Camera > camera)
 Sets the current camera. More...
 
osg::ref_ptr< osg::Camera > getCamera ()
 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...
 
osg::ref_ptr< WPickHandlergetPickHandler ()
 Getter for the pick 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...
 
- 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...
 

Protected Attributes

osg::ref_ptr< osgViewer::View > 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< WGEGroupNodem_scene
 reference to the scene which is displayed by viewer 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...
 
- Protected Attributes inherited from WGEGraphicsWindow
osg::ref_ptr
< osgViewer::GraphicsWindow > 
m_GraphicsWindow
 OpenSceneGraph render window. More...
 
osg::ref_ptr
< osg::GraphicsContext > 
m_GraphicsContext
 OpenSceneGraph render context. More...
 
osg::ref_ptr< osg::Referenced > m_WindowData
 Widget window data. More...
 

Additional Inherited Members

- Protected Member Functions inherited from WGEGraphicsWindow
void createContext (int x, int y, int width, int height)
 Creates a new OpenGL context in the calling thread. 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 67 of file WGEViewer.h.

Member Typedef Documentation

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

Convenience typedef.

Definition at line 79 of file WGEViewer.h.

typedef boost::shared_ptr< WGEViewer > WGEViewer::SPtr

Convenience typedef.

Definition at line 74 of file WGEViewer.h.

Constructor & Destructor Documentation

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.
Exceptions
WGEInitFailedthrown if initialization of graphics context or graphics window has failed.

Definition at line 56 of file WGEViewer.cpp.

References WGEGraphicsWindow::m_GraphicsContext, WGEGraphicsWindow::m_GraphicsWindow, m_pickHandler, m_queryCallback, m_rendered, m_screenCapture, and m_View.

WGEViewer::~WGEViewer ( )
virtual

Destructor.

Definition at line 119 of file WGEViewer.cpp.

References close().

Member Function Documentation

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.

Notes:
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 261 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 197 of file WGEViewer.cpp.

References WGEGraphicsWindow::close().

Referenced by ~WGEViewer().

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

Returns the camera currently in use.

Returns
the camera currently in use.

Definition at line 154 of file WGEViewer.cpp.

References m_View.

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

Returns current active camera manipulator.

Returns
the active camera manipulator.

Definition at line 143 of file WGEViewer.cpp.

References m_View.

Referenced by animationMode().

std::string WGEViewer::getName ( ) const

Returns the name of the viewer.

Returns
the name

Definition at line 203 of file WGEViewer.cpp.

References m_name.

std::string WGEViewer::getOpenGLVendor ( ) const

Queries the OpenGL vendor info.

Returns
Vendor string.

Definition at line 223 of file WGEViewer.cpp.

References m_queryCallback.

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

Getter for the pick handler.

Returns
the pick handler

Definition at line 208 of file WGEViewer.cpp.

References m_pickHandler.

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

Returns the currently set OSG node.

Returns
the node.

Definition at line 165 of file WGEViewer.cpp.

References m_scene.

WGEScreenCapture::RefPtr WGEViewer::getScreenCapture ( ) const

Returns the main cameras screen capture callback.

Returns
the screen capture callback.

Definition at line 218 of file WGEViewer.cpp.

References m_screenCapture.

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

Getter for OpenSceneGraph View instance.

Returns
the OSG Viewer instance.

Definition at line 130 of file WGEViewer.cpp.

References m_View.

bool WGEViewer::isAnimationMode ( ) const

Checks if the viewer is in animation mode.

Returns
true if in animation mode

Definition at line 292 of file WGEViewer.cpp.

References m_inAnimationMode.

WBoolFlag::SPtr WGEViewer::isFrameRendered ( ) const

Returns the flag which denotes whether a frame was rendered.

Returns
the flag.

Definition at line 228 of file WGEViewer.cpp.

References m_rendered.

void WGEViewer::paint ( )
virtual

Repaints the contents.

Mac only.

Definition at line 175 of file WGEViewer.cpp.

References m_View.

void WGEViewer::reset ( )

Resets the view using the installed manipulator.

Definition at line 213 of file WGEViewer.cpp.

References m_View.

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 182 of file WGEViewer.cpp.

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

void WGEViewer::setBgColor ( const WColor &  bgColor)

Determine the color of the viewer's background.

Parameters
bgColorthe new background color

Definition at line 170 of file WGEViewer.cpp.

References m_View.

void WGEViewer::setCamera ( osg::ref_ptr< osg::Camera >  camera)

Sets the current camera.

Parameters
camerathe OSG camera instance.

Definition at line 148 of file WGEViewer.cpp.

References m_View.

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

Sets the camera manipulator to use.

Parameters
manipulatorthe manipulator to use.

Definition at line 135 of file WGEViewer.cpp.

References m_inAnimationMode, and m_View.

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 159 of file WGEViewer.cpp.

References m_scene, and m_View.

Member Data Documentation

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 339 of file WGEViewer.h.

Referenced by animationMode().

bool WGEViewer::m_inAnimationMode
protected

True -> animation mode on.

Definition at line 334 of file WGEViewer.h.

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

std::string WGEViewer::m_name
protected

The name of the viewer.

Definition at line 253 of file WGEViewer.h.

Referenced by getName().

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

Pointer to the pick handler of the viewer.

Definition at line 258 of file WGEViewer.h.

Referenced by getPickHandler(), and WGEViewer().

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

The callback used for querying OpenGL features.

Definition at line 323 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 268 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 263 of file WGEViewer.h.

Referenced by getScene(), and setScene().

WGEScreenCapture::RefPtr WGEViewer::m_screenCapture
protected

The screen capture callback.

Definition at line 329 of file WGEViewer.h.

Referenced by getScreenCapture(), and WGEViewer().

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

The OpenSceneGraph view used in this (Composite)Viewer.

Definition at line 247 of file WGEViewer.h.

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


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