Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
canvas.h
1 //
2 // Name: Canvas.h
3 //
4 // Copyright (c) 2001-2008 Virtual Terrain Project
5 // Free for all uses, see license.txt for details.
6 //
7 
8 #ifndef CANVASH
9 #define CANVASH
10 
11 //#include "vtui_UI.h"
12 //#include "vtlib/vtlib.h"
13 
14 #if !wxUSE_GLCANVAS
15 #error Please set wxUSE_GLCANVAS to 1 in setup.h.
16 #endif
17 #include "wx/glcanvas.h"
18 
19 class vtGLCanvas;
20 class vtTransform;
21 class vtScene;
22 class vtMouseEvent;
23 
25  public:
27  ~vtGLCanvasListener() {}
28  virtual void AfterUpdate(vtGLCanvas*) = 0;
29  virtual bool OnChar(vtGLCanvas*, wxKeyEvent*) = 0;
30  virtual bool OnMouse(vtGLCanvas*, vtMouseEvent*) = 0;
31 };
32 //
33 // A Canvas for the main view area.
34 //
35 class vtGLCanvas: public wxGLCanvas
36 {
37  public:
38  vtGLCanvas(wxWindow *parent, const wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
39  const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = _T("vtGLCanvas"),
40  int* gl_attrib = NULL, vtGLCanvasListener *listener=NULL);
41  ~vtGLCanvas(void);
42 
43  // SpaceNavigator methods
44  void SetSpaceNavTarget(vtTransform *t);
45  void SetSpaceNavSpeed(float f);
46  void SetSpaceNavAllowRoll(bool b);
47 
48 #ifndef __WXMAC__
49  void OnPaint(wxPaintEvent& event);
50 #endif
51  void OnSize(wxSizeEvent& event);
52  void OnEraseBackground(wxEraseEvent& event);
53  void OnMouseCaptureLost(wxMouseCaptureLostEvent & event);
54  void OnChar(wxKeyEvent& event);
55  void OnKeyDown(wxKeyEvent& event);
56  void OnKeyUp(wxKeyEvent& event);
57  void OnMouseEvent(wxMouseEvent& event);
58  void OnClose(wxCloseEvent& event);
59  void QueueRefresh(bool eraseBackground);
60  void OnIdle(wxIdleEvent &event);
61 
62 #ifndef __WXMAC__
63  bool m_bPainting;
64  bool m_bFirstPaint;
65 #endif
66  bool m_bRunning;
67  bool m_bShowFrameRateChart;
68  bool m_bCapture;
69 
70  vtGLCanvasListener* m_Listener;
71 #if WIN32
72  // Hook into the default window procedure
73  virtual WXLRESULT MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
74 #endif
75  friend class vtGLCanvasListener;
76  protected:
77  bool m_pbKeyState[512];
78 
79  // The number of mousemoves we've gotten since last redraw
80  int m_iConsecutiveMousemoves;
81  DECLARE_EVENT_TABLE()
82  };
83 
84 void EnableContinuousRendering(bool bTrue);
85 
86 #endif // CANVASH
87