Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
OpenGLCanvas.hh
1 #ifndef __OpenGLCanvas_hh__
2 #define __OpenGLCanvas_hh__
3 
4 /** \author Jan Woetzel 01/2003 - 12/2004 */
5 #include <bias_config.h>
6 
7 #ifndef BIAS_HAVE_WXWIDGETS
8 # error Please recompile BIAS with USE_WXWIDGETS to use this lib.
9 #endif // BIAS_HAVE_WXWIDGETS
10 
11 #ifndef BIAS_HAVE_OPENGL
12 # error Please recompile BIAS with USE_OPENGL to use this lib.
13 #endif // BIAS_HAVE_OPENGL
14 
15 //#ifndef BIAS_HAVE_GLUT
16 //# error Please recompile BIAS with USE_GLUT (gl utility toolkit) to use this lib.
17 //#endif // BIAS_HAVE_GLUT
18 
19 
20 
21 // must be defined to connect the OnIdle handler at all:
22 #ifndef OPENGLCANVAS_CONNECT_ONIDLE
23 # define OPENGLCANVAS_CONNECT_ONIDLE 1
24 #endif //OPENGLCANVAS_CONNECT_ONIDLE
25 
26 // behave like glut with continuous rendering using OnIdle function
27 // useful only for animations, otherwise CPU time is consumed although the same
28 // view is rendered again and again. (JW)
29 // true: repaint in OnIdle event handler
30 // false: do not repaint bad for animations, but good for CPU if there is no aniamtion.
31 #ifndef OPENGLCANVAS_DEFAULT_idleRepaintEnabled
32 # define OPENGLCANVAS_DEFAULT_idleRepaintEnabled true
33 #endif
34 
35 // true: use realtime wall clock, good for animation taht should not depend on GPU performance/resolution
36 // false: use fixed incremental counter on each rendering, good for feedback of visual performance of animations.
37 #ifndef OPENGLCANVAS_DEFAULT_realtimeAnimation
38 # define OPENGLCANVAS_DEFAULT_realtimeAnimation true
39 #endif
40 
41 // HACK: expected fps, only for similar speed in realtime and free running mode
42 //#define TARGET_FPS 500
43 #define TARGET_FPS 200
44 
45 
46 // TODO: integrate trackball/virtual camera clas, e.g. based on GLhelper interactor. (JW)
47 
48 // BIAS
49 #include <Gui/OpenGLCanvasBase.hh>
50 #include <Gui/CameraViewController.hh>
51 
52 
53 namespace BIAS {
54  /**
55  @class OpenGLCanvas
56  @ingroup g_gui
57  @brief OpenGL canvases with additinal event handling (JW)
58 
59  In addition to OpenGLCanvasbase "automatioc" event handling is integrated,
60  e.g.
61  -Display value under mouse in status bar,
62  -internal storage of camera view,
63  -navigation through mouse and keys
64  And it is optionally adding
65  -automatic repaint by Onidle function (like in glut)
66  -automatic update of time for animations.
67  \author Jan Woetzel */
68  class BIASGui_EXPORT OpenGLCanvas : public OpenGLCanvasBase
69  {
70  public:
71  virtual ~OpenGLCanvas(); ///< destructor
72 
73  // ctors
75  wxFrame* parent
76  ,wxWindowID id = -1
77  ,const wxPoint& pos = wxDefaultPosition
78  ,const wxSize& size = wxDefaultSize
79  ,long style = 0
80  ,const wxString& name = AsciiToWx("OpenGLCanvas")
81  ,int* attribList = NULL
82  ,const wxPalette& palette = wxNullPalette
83  );
84 
85  ///
86  /// constructor using a shared context
88  wxFrame* parent
89  ,wxGLContext* sharedContext = NULL
90  ,wxWindowID id = -1
91  ,const wxPoint& pos = wxDefaultPosition
92  ,const wxSize& size = wxDefaultSize
93  ,long style=0
94  ,const wxString& name=AsciiToWx("OpenGLCanvas")
95  ,int* attribList = 0
96  ,const wxPalette& palette = wxNullPalette
97  );
98 
99  virtual void InitMembers();
100 
101  virtual void GetInfoGL(std::ostream & os=std::cout);
102 
103  /// display call to be overridden by child classes
104  virtual void Display();
105 
106  virtual void DisplayCameraView();
107  virtual void DisplayCameraViewInternalParams();
108  virtual void DisplayCameraViewExternalParams();
109 
110  /// sets the internal time param, by default based on realtime wall clock
111  virtual void UpdateTime();
112 
113  /// change of size and aspect ratio.
114  virtual void Reshape();
115 
116  void OnMotion( wxMouseEvent &event );
117  void OnMouseDown( wxMouseEvent &event );
118  void OnMouseWheel( wxMouseEvent &event );
119  void OnIdle(wxIdleEvent& event);
120 
121  //void OnLeftDoubleClick( wxMouseEvent &event );
122  //void OnRightDoubleClick( wxMouseEvent &event );
123  //void OnMiddleDoubleClick( wxMouseEvent &event );
124  //void OnMouseWheel( wxMouseEvent &event );
125 
126  public:
127  // true to repaint in OnIdle
128  static bool idleRepaintEnabled;
129  // auto update time?
130  static bool realtimeAnimation;
131 
132 
133  public:
134  CameraViewController GetViewController() const;
135  CameraViewController & GetViewController();
136 
137  protected:
138  // for (interactive) view control, holds parameters of virtual camera
140 
141 
142  //wxPoint _pos; // mouse position
143  GLenum _polygonmodeGL; // GL_POINT GL_LINE GL_FILL
144 
145 
146  // override parent classes event handling table:
147  DECLARE_EVENT_TABLE()
148 
149  }; // OpenGLCanvas
150 
151 } // namespace BIAS
152 #endif
static bool realtimeAnimation
wxString AsciiToWx(const char *thestring)
Converts a C string to a wxString.
Definition: StringConv.hh:32
OpenGL canvases with additinal event handling (JW)
Definition: OpenGLCanvas.hh:68
base for (interactively) manipulating a (virtual) camera view.
base class for OpenGL canvases you could derive from to get base functionality (JW) ...
CameraViewController * p_viewCtrl_
static bool idleRepaintEnabled