MachineIntelligenceCore:Visualization
WindowManager.hpp
Go to the documentation of this file.
1 
23 #ifndef SRC_VISUALIZATION_OPENGL_WINDOWMANAGER_HPP_
24 #define SRC_VISUALIZATION_OPENGL_WINDOWMANAGER_HPP_
25 
26 #include <boost/atomic.hpp>
27 #include <boost/thread/mutex.hpp>
28 
29 #include <iostream>
30 
31 
32 namespace mic {
33  namespace opengl {
34  namespace visualization {
35 
36  // Forward declaration of class window, to avoid circular window-manager references.
37  class Window;
38 
43  typedef std::pair<unsigned int, mic::opengl::visualization::Window*> id_win_pair_t;
44 
45 
50  typedef std::map<unsigned int, mic::opengl::visualization::Window*>::iterator id_win_it_t;
51 
56  class WindowManager {
57  public:
58 
62  virtual ~WindowManager();
63 
68  static WindowManager* getInstance();
69 
75 
82 
86  static void displayHandler(void);
87 
91  static void mouseHandler(int button, int state, int x, int y);
92 
98  static void reshapeHandler(int width_, int height_);
99 
106  static void keyboardHandler(unsigned char key_, int x_, int y_);
107 
111  static void idle(void);
112 
118  static void initializeGLUT(int argc, char *argv[]);
119 
125  void startVisualizationLoop();
126 
127  void terminateWindows(void);
128  //bool exit_signal;
129 
130  private:
134  static boost::atomic<WindowManager*> instance_;
135 
139  static boost::mutex instantiation_mutex;
140 
144  WindowManager();
145 
149  std::map<unsigned int, mic::opengl::visualization::Window*> window_registry;
150 
151 
152  };
153 
154 
159 #define VGL_MANAGER mic::opengl::visualization::WindowManager::getInstance()
160 
161 
162  } /* namespace visualization */
163  } /* namespace opengl */
164 } /* namespace mic */
165 
166 #endif /* SRC_VISUALIZATION_OPENGL_WINDOWMANAGER_HPP_ */
std::map< unsigned int, mic::opengl::visualization::Window * >::iterator id_win_it_t
Type used in iterating/searching for windows in registry.
std::pair< unsigned int, mic::opengl::visualization::Window * > id_win_pair_t
Type used in adding windows to registry.
static void reshapeHandler(int width_, int height_)
void registerWindow(mic::opengl::visualization::Window *window_)
static void keyboardHandler(unsigned char key_, int x_, int y_)
std::map< unsigned int, mic::opengl::visualization::Window * > window_registry
static void initializeGLUT(int argc, char *argv[])
mic::opengl::visualization::Window * findWindow(unsigned int id_)
void startVisualizationLoop()
Runs the main GL loop.
static boost::atomic< WindowManager * > instance_
Class responsible for management of all OpenGL windows - defined in the form of a singleton...
Parent class of all OpenGL-based windows (abstract).
Definition: Window.hpp:51
static void mouseHandler(int button, int state, int x, int y)