Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
vtocxCtrl.h
1 //
2 // vtocxCtrl.h
3 //
4 
5 #pragma once
6 
7 #include "SrcProperty.h"
8 #include "GLThread.h"
9 
10 #include <OpenThreads/Thread>
11 #include <OpenThreads/Mutex>
12 #include <osg/FrameStamp>
13 #include <osg/Timer>
14 
15 #include "Capture.h"
16 
17 class vtTerrainFlyer;
18 class vtTerrainScene;
19 class vtHeightConstrain;
20 
21 //
22 // CvtocxCtrl : See vtocxCtrl.cpp for implementation.
23 //
24 class CvtocxCtrl : public COleControl
25 {
26  DECLARE_DYNCREATE(CvtocxCtrl)
27 
28 // Constructor
29 public:
30  CvtocxCtrl();
31 
32 // Overrides
33 public:
34  virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
35  virtual void DoPropExchange(CPropExchange* pPX);
36  virtual void OnResetState();
37  virtual BOOL OnSetExtent(LPSIZEL lpSizeL);
38 
39 // Implementation
40 protected:
41  ~CvtocxCtrl();
42 
43  DECLARE_OLECREATE_EX(CvtocxCtrl) // Class factory and guid
44  DECLARE_OLETYPELIB(CvtocxCtrl) // GetTypeInfo
45  DECLARE_PROPPAGEIDS(CvtocxCtrl) // Property page IDs
46  DECLARE_OLECTLTYPE(CvtocxCtrl) // Type name and misc status
47 
48 // Message maps
49  DECLARE_MESSAGE_MAP()
50 
51 // Dispatch maps
52  DECLARE_DISPATCH_MAP()
53 
54  afx_msg void AboutBox();
55 
56  bool SetupGLContext(void);
57 // Event maps
58  DECLARE_EVENT_MAP()
59 
60 // Dispatch and event IDs
61 public:
62  enum {
63  dispidResetView = 31,
64  dispidJumpToNo = 30,
65  dispidContextMenu = 22,
66  dispidNavSpeed = 21,
67  dispidPositionZ = 20,
68  dispidPositionY = 19,
69  dispidPositionX = 18,
70  dispidFullscreen = 16,
71  dispidLocalSrc = 15,
72  dispidSrc = 14,
73  dispidTerrainPaths = 13,
74  dispidTerrainFile = 12,
75  dispidStereo = 2,
76  dispidClearColor = 1
77  };
78 
79  void frame(CDC *pdc = NULL);
80  void resize(const long w, const long h);
81  bool rendering() { return _rendering; }
82 #if CALL_VTP
83  void Create3DScene();
84  bool LoadTerrain(const char *terrain_file);
85  void Cleanup3DScene();
86  void AddTerrainPaths(const CString &terr_paths);
87 #endif
88  void PrepareToRender(HDC dc);
89 
90  static CvtocxCtrl *s_pSingleton;
91  void OnProgress(int pos) { m_Progress.SetPos(pos); }
92 
93 private:
94  HGLRC m_hGLContext; //Rendering context
95  CDC* m_pDC;
96  bool _ready;
97  Capture *m_pCapture;
98 
99  CGLThread<CvtocxCtrl> * m_glThread;
100  UINT_PTR m_nTimer;
101  bool _rendering;
102 #if CALL_VTP
103  vtTerrainScene *m_pTScene;
104  vtTerrainFlyer *m_pFlyer;
105  vtHeightConstrain *m_pConstrain;
106  bool m_bKeyState[512];
107 #endif
108  CProgressCtrl m_Progress;
109 
110 public:
111  afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
112  afx_msg void OnDestroy();
113  afx_msg void OnSize(UINT nType, int cx, int cy);
114  afx_msg void OnPaint();
115  afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
116  afx_msg void OnTimer(UINT_PTR nIDEvent);
117  virtual BOOL OnIdle(LONG lCount); // return TRUE if more idle processing
118 
119 protected:
120  void OnClearColorChanged(void);
121  OLE_COLOR m_ClearColor;
122  void OnStereoChanged(void);
123  BOOL m_Stereo;
124  void OnScreenChanged(void);
125 
126  BSTR GetTerrainFile(void);
127  void SetTerrainFile(LPCTSTR newVal);
128  CString m_TerrainFile;
129 
130  BSTR GetTerrainPaths(void);
131  void SetTerrainPaths(LPCTSTR newVal);
132  CString m_TerrainPaths;
133 
134  BSTR GetSrc(void);
135  void SetSrc(LPCTSTR newVal);
136  CSrcProperty m_Src;
137 
138  BSTR GetLocalSrc(void);
139  void SetLocalSrc(LPCTSTR newVal);
140  CString m_LocalSrc;
141 
142  void OnFullscreenChanged(void);
143  BOOL m_Fullscreen;
144  void OnPositionChanged(void);
145  DOUBLE m_PositionX;
146  DOUBLE m_PositionY;
147  DOUBLE m_PositionZ;
148 public:
149  afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
150 protected:
151  void OnNavSpeedChanged(void);
152  FLOAT m_NavSpeed;
153  void JumpToNo(LONG vp);
154  void ResetView();
155  void OnContextMenuChanged(void);
156  BOOL m_ContextMenu;
157 public:
158  afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
159  afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
160  afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
161 };
162