OpenWalnut  1.4.0
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
WGEGraphicsWindow Class Reference

Class managing a single graphics context and OSG GraphicsWindow. More...

#include <WGEGraphicsWindow.h>

+ Inheritance diagram for WGEGraphicsWindow:

Public Types

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

 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 resize (int width, int height)
 Updates size information. More...
 
virtual void close ()
 Initiates a close event for this viewer. 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 Member Functions

void createContext (int x, int y, int width, int height)
 Creates a new OpenGL context in the calling thread. More...
 

Protected Attributes

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...
 

Private Attributes

bool m_closed
 Mark the window opened or closed. More...
 

Detailed Description

Class managing a single graphics context and OSG GraphicsWindow.

Definition at line 39 of file WGEGraphicsWindow.h.

Constructor & Destructor Documentation

WGEGraphicsWindow::WGEGraphicsWindow ( osg::ref_ptr< osg::Referenced >  wdata,
int  x,
int  y,
int  width,
int  height 
)

Default constructor.

Parameters
wdatathe WindowData instance for the widget to use as render widget. NULL on Mac!
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.
Exceptions
WGEInitFailedthrown if initialization of graphics context or graphics window has failed.

Definition at line 31 of file WGEGraphicsWindow.cpp.

References createContext(), m_GraphicsWindow, and m_WindowData.

WGEGraphicsWindow::~WGEGraphicsWindow ( )
virtual

Destructor.

Definition at line 60 of file WGEGraphicsWindow.cpp.

Member Function Documentation

void WGEGraphicsWindow::close ( )
virtual

Initiates a close event for this viewer.

It destroys the graphics context and invalidates the viewer. This should be called whenever a QT Widget closes to also free its OSG Viewer resources.

Reimplemented in WGEViewer.

Definition at line 112 of file WGEGraphicsWindow.cpp.

References m_GraphicsWindow.

Referenced by WGEViewer::close().

void WGEGraphicsWindow::createContext ( int  x,
int  y,
int  width,
int  height 
)
protected

Creates a new OpenGL context in the calling thread.

Needs to be called before any other OpenGL operation.

Parameters
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.

Definition at line 71 of file WGEGraphicsWindow.cpp.

References m_GraphicsContext, m_GraphicsWindow, and m_WindowData.

Referenced by WGEGraphicsWindow().

osg::ref_ptr< osgViewer::GraphicsWindow > WGEGraphicsWindow::getGraphicsWindow ( )

Getter for m_GraphicsWindow.

Returns
the OSG GraphicsWindow instance.

Definition at line 65 of file WGEGraphicsWindow.cpp.

References m_GraphicsWindow.

bool WGEGraphicsWindow::isClosed ( ) const
virtual

Check if the windows is open.

Returns
false if the window is not open anymore.

Definition at line 152 of file WGEGraphicsWindow.cpp.

References m_closed.

void WGEGraphicsWindow::keyEvent ( KeyEvents  eventType,
int  key 
)
virtual

Handles key events (if forwarded to this Viewer instance).

Parameters
keythe key code.
eventTypethe type of event.

Definition at line 117 of file WGEGraphicsWindow.cpp.

References m_GraphicsWindow.

void WGEGraphicsWindow::mouseEvent ( MouseEvents  eventType,
int  x,
int  y,
int  button 
)
virtual

Handles mouse events forwarded from widget.

Parameters
eventTypethe event type.
xx coordinate of event.
yy coordinate of event.
buttonmouse button.

Definition at line 130 of file WGEGraphicsWindow.cpp.

References m_GraphicsWindow.

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

Updates size information.

Parameters
widthnew width.
heightnew height.

Reimplemented in WGEViewer.

Definition at line 106 of file WGEGraphicsWindow.cpp.

References m_GraphicsWindow.

Referenced by WGEViewer::resize().

void WGEGraphicsWindow::setClosed ( bool  closed = true)
virtual

Set closed state.

Parameters
closedtrue if widget should be marked as closed.

Definition at line 157 of file WGEGraphicsWindow.cpp.

References m_closed.

Member Data Documentation

bool WGEGraphicsWindow::m_closed
private

Mark the window opened or closed.

Definition at line 159 of file WGEGraphicsWindow.h.

Referenced by isClosed(), and setClosed().

osg::ref_ptr<osg::GraphicsContext> WGEGraphicsWindow::m_GraphicsContext
protected

OpenSceneGraph render context.

Definition at line 148 of file WGEGraphicsWindow.h.

Referenced by createContext(), and WGEViewer::WGEViewer().

osg::ref_ptr<osgViewer::GraphicsWindow> WGEGraphicsWindow::m_GraphicsWindow
protected

OpenSceneGraph render window.

Definition at line 132 of file WGEGraphicsWindow.h.

Referenced by close(), createContext(), getGraphicsWindow(), keyEvent(), mouseEvent(), resize(), WGEGraphicsWindow(), and WGEViewer::WGEViewer().

osg::ref_ptr<osg::Referenced> WGEGraphicsWindow::m_WindowData
protected

Widget window data.

Definition at line 153 of file WGEGraphicsWindow.h.

Referenced by createContext(), and WGEGraphicsWindow().


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