MachineIntelligenceCore:Visualization
mic::opengl::visualization::WindowManager Class Reference

Class responsible for management of all OpenGL windows - defined in the form of a singleton, with double-checked locking pattern (DCLP) based access to instance. More...

#include <WindowManager.hpp>

Public Member Functions

virtual ~WindowManager ()
 
void registerWindow (mic::opengl::visualization::Window *window_)
 
mic::opengl::visualization::WindowfindWindow (unsigned int id_)
 
void startVisualizationLoop ()
 Runs the main GL loop. More...
 
void terminateWindows (void)
 

Static Public Member Functions

static WindowManagergetInstance ()
 
static void displayHandler (void)
 
static void mouseHandler (int button, int state, int x, int y)
 
static void reshapeHandler (int width_, int height_)
 
static void keyboardHandler (unsigned char key_, int x_, int y_)
 
static void idle (void)
 
static void initializeGLUT (int argc, char *argv[])
 

Private Member Functions

 WindowManager ()
 

Private Attributes

std::map< unsigned int,
mic::opengl::visualization::Window * > 
window_registry
 

Static Private Attributes

static boost::atomic
< WindowManager * > 
instance_
 
static boost::mutex instantiation_mutex
 

Detailed Description

Class responsible for management of all OpenGL windows - defined in the form of a singleton, with double-checked locking pattern (DCLP) based access to instance.

Author
tkornuta

Definition at line 56 of file WindowManager.hpp.

Constructor & Destructor Documentation

mic::opengl::visualization::WindowManager::~WindowManager ( )
virtual

Virtual destructor.

Definition at line 156 of file WindowManager.cpp.

mic::opengl::visualization::WindowManager::WindowManager ( )
private

Private constructor. Initializes GLUT!

Definition at line 152 of file WindowManager.cpp.

Referenced by getInstance().

Member Function Documentation

void mic::opengl::visualization::WindowManager::displayHandler ( void  )
static

Refreshes the content of the window.

Definition at line 82 of file WindowManager.cpp.

References mic::opengl::visualization::Window::displayHandler(), and VGL_MANAGER.

Here is the call graph for this function:

mic::opengl::visualization::Window * mic::opengl::visualization::WindowManager::findWindow ( unsigned int  id_)

Finds window in the registry.

Parameters
id_Window id.
Returns
Pointer to the window object or NULL if window id was not found.

Definition at line 70 of file WindowManager.cpp.

References window_registry.

WindowManager * mic::opengl::visualization::WindowManager::getInstance ( )
static

Method for accessing the object instance, with double-checked locking optimization.

Returns
Instance of the WindowManager singleton.

Definition at line 42 of file WindowManager.cpp.

References instance_, instantiation_mutex, and WindowManager().

Here is the call graph for this function:

void mic::opengl::visualization::WindowManager::idle ( void  )
static

Idle function. Iterates through the window registry and updates all windows.

Definition at line 122 of file WindowManager.cpp.

References VGL_MANAGER, and window_registry.

void mic::opengl::visualization::WindowManager::initializeGLUT ( int  argc,
char *  argv[] 
)
static

Initializes GLUT.

Parameters
argc
argv

Definition at line 160 of file WindowManager.cpp.

References VGL_MANAGER.

void mic::opengl::visualization::WindowManager::keyboardHandler ( unsigned char  key_,
int  x_,
int  y_ 
)
static

Handles the keypressed event.

Parameters
key_Pressed key.
x_X coodrinate (unused).
y_Y coordinate (unused).

Definition at line 114 of file WindowManager.cpp.

References VGL_MANAGER.

void mic::opengl::visualization::WindowManager::mouseHandler ( int  button,
int  state,
int  x,
int  y 
)
static

Refreshes the content of the window.

Definition at line 98 of file WindowManager.cpp.

References mic::opengl::visualization::Window::mouseHandler(), and VGL_MANAGER.

Here is the call graph for this function:

void mic::opengl::visualization::WindowManager::registerWindow ( mic::opengl::visualization::Window window_)

Adds window to registry.

Parameters
window_Pointer to the registered window.

Definition at line 62 of file WindowManager.cpp.

References mic::opengl::visualization::Window::getId(), and window_registry.

Here is the call graph for this function:

void mic::opengl::visualization::WindowManager::reshapeHandler ( int  width_,
int  height_ 
)
static

Changes size of the window.

Parameters
width_New width.
height_New height.

Definition at line 106 of file WindowManager.cpp.

References mic::opengl::visualization::Window::reshapeHandler(), and VGL_MANAGER.

Here is the call graph for this function:

void mic::opengl::visualization::WindowManager::startVisualizationLoop ( )

Runs the main GL loop.

It must be executed in the main thread (!!) and it is an infinite loop (!!), so the proper application must be executed in a separate thread.

Definition at line 170 of file WindowManager.cpp.

void mic::opengl::visualization::WindowManager::terminateWindows ( void  )

Definition at line 135 of file WindowManager.cpp.

Member Data Documentation

boost::atomic< WindowManager * > mic::opengl::visualization::WindowManager::instance_
staticprivate

Private instance - accessed as atomic operation.

Definition at line 134 of file WindowManager.hpp.

Referenced by getInstance().

boost::mutex mic::opengl::visualization::WindowManager::instantiation_mutex
staticprivate

Mutex used for instantiation of the instance.

Definition at line 139 of file WindowManager.hpp.

Referenced by getInstance().

std::map<unsigned int, mic::opengl::visualization::Window*> mic::opengl::visualization::WindowManager::window_registry
private

Window dispatcher, storing pointers to all OpenGL windows.

Definition at line 149 of file WindowManager.hpp.

Referenced by findWindow(), idle(), and registerWindow().


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