Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/QtGeoViewer/Src/QtGeoViewer/View3D.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 54 - (show annotations) (download) (as text)
Sat Dec 20 09:38:40 2014 UTC (9 years, 3 months ago) by qw_fuku
File MIME type: text/x-chdr
File size: 7372 byte(s)
test
1 #pragma once
2
3 #include <LibQtGeoViewerCore/SceneMain.h>
4 #include <LibQtGeoViewerCore/Cursor3D.h>
5
6 #include "QtViewBase.h"
7
8 #include "Camera.h"
9 #include "GeometryRender.h"
10 #include "View3DConfig.h"
11 #include "CloseVertInfo.h"
12 #include "Modifier.h"
13 #include "GLWidgetList.h"
14 #include "CameraRecords.h"
15 #include "SelRange.h"
16 #include "PostProcBuffer.h"
17
18 #include "ShaderLibrary.h"
19 #include "Shader/ShaderInterface.h"
20
21 #include "PostprocLibrary.h"
22 #include "Postproc/PostprocInterface.h"
23
24 #include "../GLUtility/FBOPicker.h"
25
26 #include <C2/gl/Projection.h>
27 #include <C2/gl/Manipulator.h>
28 #include <C2/gl/Light.h>
29
30 #include <C2/util/optional.h>
31
32 #include <QGestureEvent>
33
34 using namespace gl;
35
36
37 namespace lib_gl
38 {
39 class GlPicker;
40 }
41
42
43 class View3D :
44 public QtViewBase,
45 public SceneObserver
46 {
47 Q_OBJECT
48
49 public:
50 View3D(void);
51
52 virtual bool InitializeView(MyGLWidget* ParentWidget);
53 void RegisterScene(SceneMain* scene);
54
55 void SetLightStrengthByStdRatio(float rat);
56
57 virtual void FinalizeView(void);
58
59 void BeginRender(void);
60 void EndRender(void);
61
62 virtual void OnPaint(void);
63 virtual void OnResize(int width, int height);
64
65 virtual void OnMousePress(QMouseEvent *e);
66 virtual void OnMouseRelease(QMouseEvent *e);
67 virtual void OnMouseDoubleClick(QMouseEvent *e);
68 virtual void OnMouseMove(QMouseEvent *e);
69
70 virtual void OnWheel(QWheelEvent *e);
71
72 virtual void OnGesturePan(QPanGesture *gesture);
73 virtual void OnGesturePinch(QPinchGesture *gesture);
74
75 virtual void OnKeyPress(QKeyEvent *e);
76 virtual void OnKeyRelease(QKeyEvent *e);
77 bool KeyPressOnRotCamera(QKeyEvent *e, const Modifier& m);
78
79 // SceneObserver���m�C�x���g
80 virtual void OnGeometryBuild(const SceneMain& scene);
81
82 void ReleaseRenderbuffer(MeshBuf* mbuf);
83
84 void RecordCamera(void);
85 void MoveToRecordedCamera(int camera_idx, bool animation);
86 void RemoveRecordedCamera(int camera_idx);
87 void ClearRecordedCamera(void);
88
89 void ResetPrimaryObjectLists(void);
90 void ReleaseAllRenderBuffer(void);
91
92 void DrawCloseVertInfo(void);
93
94 void DrawCutPlane(void) const;
95 void DrawObjectsBBox(void) const;
96
97 void RepaintParent(void);
98
99 std::vector<int> PickObjectAroundMouse(const QPoint& pos, int sel_range);
100 bool IsInRange(int x, int y, const QImage& bmp) const;
101 int QColorToIndex(const QColor& c) const;
102
103 float GetGeomDepth(int x, int y);
104 util::Optional<lm::vec3f> GetGeomDepht3DPos(int x, int y);
105
106 void LookDepth(void);
107 bool LookPixelDepth(int x, int y);
108 void Look3DCursor(void);
109 void ResetCursorMeasure(void);
110 void UpdateCursorCutNormal(void);
111
112 void MoveCaemraTo(ViewPoint vp);
113 void MoveLookPosToCenter(void);
114 void MoveLookPosToOrigin(void);
115 void AdjustCameraDistAuto(void);
116
117 protected:
118 void PaintMain(bool showOnlyGeom);
119 void Render3D(Camera& camera, bool showOnlyGeom);
120 void Render3DScene(Camera& camera, bool showOnlyGeom);
121 void Render3DWithPostproc(Camera& camera);
122 void UpdatePostProcContext(Camera& camera);
123 void RenderClipRange(void);
124
125 void RenderBillboard(void);
126 void RenderSelRange(void);
127 void RenderShadowmapBuf(void);
128
129 void ClearRenderBuffer(void);
130 void SetDefalutLightState(const Camera& camera);
131 void SetDefalutCullState(void);
132
133 void DrawAllGeom(bool UseShader);
134 void DrawAllGeomMeshStd(bool UseShader, std::vector<GeomObject*>& target);
135 void DrawAllGeomVLinks(std::vector<GeomObject*>& target);
136 void DrawAllGeomPolyline(std::vector<GeomObject*>& target);
137 void DrawPolyline(MeshBuf& mbuf);
138 void DrawPolylineHighlight(MeshBuf& mbuf);
139 void DrawPolylineGeom(const MeshBuf& mbuf, const lib_geo::BasePolyline& pl);
140 void DrawAllGeomMeshIndexColor(int index_offset);
141
142 void DrawOptions_Before(void);
143 void DrawOptions_After(void);
144
145 void DrawGeomMeshHighlight(void);
146 void DrawSelVert(MeshBuf& mbuf, int vert_idx);
147 void PickMouseClosePoint(int x, int y);
148 void DrawSelection_VertSel(void);
149 void GetSelVertsFromPickBuf(lib_gl::GlPicker& picker, unsigned int depth);
150 void DrawVertexLinker(MeshBuf& mbuf);
151 void DrawLookPos(void);
152
153 void DrawEnvImage(Camera& camera);
154 void DrawGround(void);
155 void DrawAxis(void);
156 void DrawMiniAxis(void);
157 void Draw3DCursor(void);
158 void Draw3DCursorAxis(const lm::vec3f& p, const lm::vec3f& c);
159 void Draw3DCursorCoord(const lm::vec3f& p);
160 void Draw3DCursorMeasure(void);
161 void Draw3DCursorBary(void);
162
163 void DrawAllGeomCrossSection(void);
164 void DrawAllGeomCrossSectionLine(std::vector<GeomObject*>& objects);
165
166 void BeginCutPlaneConfig(bool forCut);
167 void EndCutPlaneConfig(void);
168
169 void DrawClipRangeGraph(Camera& camera);
170
171 void GetClipLimit(float& t, float& b) const;
172
173 void DrawRenderTime(void);
174
175 // mouse events
176 bool MouseMove_OnSelRange (QMouseEvent* e, QPointF& diff);
177 bool MouseMove_OnZoomSelRange (QMouseEvent* e, QPointF& diff);
178 bool MouseMove_OnUpdateCloseVert (QMouseEvent* e, QPointF& diff);
179 bool MouseMove_OnCameraControl (QMouseEvent* e, QPointF& diff);
180 bool MouseMove_OnLightControl (QMouseEvent* e, QPointF& diff);
181 bool MouseMove_OnCursorControl (QMouseEvent* e);
182
183 lm::vec3f Move3DCursor(lm::vec3f& cp, double px, double py);
184
185 bool UpdateCloseVert(QMouseEvent* e);
186
187 void DrawCenterCross(void);
188
189 bool IsRequireUpdateShadowmap(void);
190
191 ShaderInterface* GetPrimaryShader(void);
192 void SetShaderResources(void);
193
194 void UpdateShadowmap(void);
195 void DrawAllGeomForShadowbuf(void);
196
197 void SelectVertsSelRange(bool select_add);
198
199 void DrawLightPos(const lib_gl::Light& light);
200
201 void PushAndIdentityGLModelProjMatrix(void);
202 void PushAndIdentityGLAllMatrix(void);
203 void PopGLModelProjMatrix(void);
204 void PopGLAllMatrix(void);
205
206 void SelectClosestVertOnMouseDown(QMouseEvent *e);
207 void SelectObjectOnMouseDown(QMouseEvent *e);
208
209 bool CheckCameraIsReverse(void) const;
210
211 private:
212 GeometryRender& GetRender(const MeshBuf* mbuf);
213
214 void RenderCurrentTextureToBillboard(int left, int top, int width, int height);
215
216 void ZoomSelRange(void);
217
218 bool IsVisibleObject(const GeomObject& obj) const;
219 std::vector<GeomObject*> GetVisibleObjects(void);
220
221 MeshBuf* GetAndUpdateCursorCloseMBuf(void);
222 void TestOnCursorColseElement(void);
223
224 void UpdateModifierTip(QKeyEvent* e, const Modifier& m);
225 bool IsModifierEvent(QKeyEvent* e);
226
227 void GetAllVisibleObjects(std::vector<GeomObject*>& objects);
228
229 signals:
230 void SelectedObjectChanged(int sel_idx);
231 void SelectedMatChanged(int sel_idx);
232
233 void CameraMoved(void);
234 void StatusTipChanged(QString msg);
235
236
237 public:
238 GLWidgetList* m_Widgets;
239
240 Camera m_Camera;
241 bool m_CameraReverse;
242
243 CameraRecords m_CameraRecord;
244
245 lib_gl::Light m_HeadLight; //!< �J�����������u������, �����w�b�h���C�g�������C�g
246 lib_gl::Light m_ControlLight; //!< �}�E�X�������������C�g
247
248 View3DConfig m_Config;
249
250 SceneMain* m_Scene;
251
252 ShaderLibrary m_ShaderLib;
253 ShaderContext m_ShaderContext;
254
255 PosprocLibrary m_PPLib;
256 PostprocContext m_PPContext;
257 MultPathRenderBuf m_PPBuf;
258
259 lib_graph::color4f m_BGColor;
260
261 float m_GridAxisScale;
262
263 bool m_FpsMode;
264
265
266 private:
267 boost::ptr_map<const MeshBuf*, GeometryRender> m_RenderMap;
268
269 bool m_GlewInitialized;
270
271 int m_LastRenderTime;
272
273 SelRange m_SelRange;
274 SelRange m_ZoomSelRange;
275
276 CloseVertInfo m_CloseVertInfo;
277
278 QPointF m_LastMousePos;
279
280 FBOPicker m_FboPicker;
281 };
282

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26