Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Canvas.h
1 //
2 // Name: canvas.h
3 //
4 // Copyright (c) 2001-2011 Virtual Terrain Project
5 // Free for all uses, see license.txt for details.
6 //
7 
8 #ifndef CANVASH
9 #define CANVASH
10 
11 #if !wxUSE_GLCANVAS
12 #error Please set wxUSE_GLCANVAS to 1 in setup.h.
13 #endif
14 #include "wx/glcanvas.h"
15 
16 //
17 // Extent wxWidget's canvas to integrate with vtlib and OSG
18 //
19 class vtGLCanvas: public wxGLCanvas
20 {
21 public:
22  vtGLCanvas(wxWindow *parent, const wxWindowID id, const wxPoint &pos,
23  const wxSize &size, long style, const wxString &name, int *gl_attrib);
24  ~vtGLCanvas(void);
25 
26  // SpaceNavigator methods
27  void EnableSpaceNav();
28  void SetSpaceNavSpeed(float f);
29  void SetSpaceNavAllowRoll(bool b);
30 
31 #ifndef __WXMAC__
32  void OnPaint(wxPaintEvent& event);
33 #endif
34  void OnSize(wxSizeEvent& event);
35  void OnEraseBackground(wxEraseEvent& event);
36  void OnMouseCaptureLost(wxMouseCaptureLostEvent & event);
37  void OnChar(wxKeyEvent& event);
38  void OnKeyDown(wxKeyEvent& event);
39  void OnKeyUp(wxKeyEvent& event);
40  void OnMouseEvent(wxMouseEvent& event);
41  void OnClose(wxCloseEvent& event);
42  void OnIdle(wxIdleEvent &event);
43 
44 #ifndef __WXMAC__
45  bool m_bPainting;
46  bool m_bFirstPaint;
47 #endif
48  bool m_bRunning;
49  bool m_bCapture;
50 
51 #if WIN32
52  // Hook into the default window procedure
53  virtual WXLRESULT MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
54 #endif
55 
56  // Override to be notified
57  virtual void OnAfterUpdate() {}
58  virtual void OnCanvasChar(wxKeyEvent& event) {}
59 
60 protected:
61  bool m_pbKeyState[512];
62 
63  // The number of mousemoves we've gotten since last redraw
64  int m_iConsecutiveMousemoves;
65 
66  DECLARE_EVENT_TABLE()
67 };
68 
69 void EnableContinuousRendering(bool bTrue);
70 
71 #endif // CANVASH
72