source: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h @ 1942

Revision 1942, 6.5 KB checked in by bittner, 17 years ago (diff)

tmp commit

Line 
1#ifndef __QTGLRENDERER_H
2#define __QTGLRENDERER_H
3
4#include <QtOpenGL>
5#include <QWaitCondition>
6
7//#include <QGLPixelBuffer>
8
9#include "Vector3.h"
10#include "Containers.h"
11#include "Halton.h"
12#include "Renderer.h"
13#include "GlRenderer.h"
14#include "Beam.h"
15#include "QtPreprocessorThread.h"
16class QWidget;
17//class QtPreprocessorThread;
18
19namespace GtpVisibilityPreprocessor {
20
21class SceneGraph;
22class ViewCellsManager;
23class Mesh;
24class MeshInstance;
25class Intersectable;
26class Material;
27class Beam;
28class KdTree;
29class GlRendererBuffer;
30class BeamSampleStatistics;
31class OcclusionQuery;
32class TransformedMeshInstance;
33
34
35struct VssRayContainer;
36struct PvsRenderStatistics;
37struct RenderCostSample;
38
39
40class QtGlRendererBuffer : public QObject, public QGLPixelBuffer, public GlRendererBuffer
41{
42        Q_OBJECT
43public:
44        QtGlRendererBuffer(const int w,
45                const int h,
46                SceneGraph *sceneGraph,
47                ViewCellsManager *viewcells,
48                KdTree *tree);
49
50  ~QtGlRendererBuffer() {}
51
52  virtual void MakeCurrent();
53  virtual void DoneCurrent();
54
55  virtual int GetWidth() const { return width(); }
56  virtual int GetHeight() const { return height(); }
57
58  int ComputePvs() const { return 0; }
59 
60  float
61  GetPixelError(int &pvsSize);
62 
63  int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const;
64     
65 
66 
67 
68public:
69  signals:
70  void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &);
71};
72
73
74class QtRendererControlWidget : public QWidget
75{
76  Q_OBJECT
77public:
78
79  QListWidget *mPvsErrorWidget;
80
81  QtRendererControlWidget(QWidget * parent = 0, Qt::WFlags f = 0);
82
83  public slots:
84
85  void FocusNextPvsErrorFrame();
86  void UpdatePvsErrorItem(int i,
87                                                  GlRendererBuffer::PvsErrorEntry &);
88
89  signals:
90
91  void ComputeVisibility();
92  void StopComputation();
93  void SetRandomViewPoint();
94  void UpdateAllPvs();
95  void SetViewCellGranularity(int);
96  void SetTransferFunction(int);
97  void SetSceneCut(int);
98  void SetTopDistance(int);
99  void SetVisibilityFilterSize(int);
100  void SetSpatialFilterSize(int);
101
102  void SetShowRays(bool);
103  void SetRenderFilter(bool);
104  void SetRenderVisibilityEstimates(bool);
105  void SetUseFilter(bool);
106  void SetUseSpatialFilter(bool);
107  void SetRenderErrors(bool);
108  void SetRenderBoxes(bool);
109  void SetShowViewCells(bool);
110  void SetShowRenderCost(bool);
111  void SetShowPvsSizes(bool);
112  void SetTopView(bool);
113  void SetCutViewCells(bool);
114  void SetCutScene(bool);
115
116};
117
118
119class QtGlRendererWidget : public QGLWidget, public GlRendererWidget
120{
121  Q_OBJECT
122public:
123
124  // point of the last mouse click used for movement in the scene
125  Vector3 mousePoint;
126
127  bool mTopView;
128  bool mRenderViewCells;
129  bool mCutViewCells;
130  bool mCutScene;
131  bool mRenderErrors;
132  bool mRenderFilter;
133  bool mRenderVisibilityEstimates;
134  bool mUseFilter;
135  bool mUseSpatialFilter;
136  bool mShowRenderCost;
137  bool mShowRays;
138
139  bool mShowPvsSizes;
140  float mSpatialFilterSize;
141 
142  Plane3 mSceneCutPlane;
143  float mTopDistance;
144
145  // some statistics
146  int mPvsSize;
147  float mRenderError;
148  float mTransferFunction;
149
150 
151  QtRendererControlWidget *mControlWidget;
152
153  QtPreprocessorThread *mPreprocessorThread;
154 
155  QtGlRendererWidget(SceneGraph *sceneGraph,
156                                         ViewCellsManager *viewcells,
157                                         KdTree *tree,
158                                         QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0
159                                         );
160 
161  QtGlRendererWidget() {};
162
163  void SetThread(QtPreprocessorThread *t) {
164        mPreprocessorThread = t;
165  }
166  void
167  RenderRenderCost();
168
169  virtual void SetupCamera();
170
171  void initializeGL() {
172        InitGL();
173  }
174  void resizeGL(int w, int h);
175  void paintGL();
176  void timerEvent(QTimerEvent *) {
177          update();
178  }
179
180  void mousePressEvent(QMouseEvent *);
181  void mouseReleaseEvent(QMouseEvent *);
182  void mouseMoveEvent(QMouseEvent *);
183
184  void keyPressEvent ( QKeyEvent * e ) ;
185
186  void
187  RenderPvs();
188
189  float
190  RenderErrors();
191  void
192  RenderInfo();
193
194  virtual int GetWidth() const { return width(); }
195  virtual int GetHeight() const { return height(); }
196
197  // virtual void
198  //  SetupProjection(const int w, const int h, const float angle = 70.0f);
199
200  virtual void
201  SetupCameraProjection(const int w, const int h, const float angle = 70.0f);
202
203  void
204  RenderViewCells();
205
206
207  virtual void Show() {
208        show();
209  }
210
211 public slots:
212
213 void UpdateAllPvs();
214  void ComputeVisibility();
215  void StopComputation();
216  void SetRandomViewPoint();
217
218 void SetRenderErrors(bool b) {
219   mRenderErrors = b;
220   updateGL();
221 }
222
223  void SetRenderBoxes(bool b) {
224        mRenderBoxes = b;
225        updateGL();
226  }
227
228 void SetRenderFilter(bool b) {
229   mRenderFilter = b;
230   updateGL();
231 }
232
233  void SetRenderVisibilityEstimates(bool b) {
234        mRenderVisibilityEstimates = b;
235   updateGL();
236 }
237
238  void SetUseFilter(bool b) {
239   mUseFilter = b;
240   mPvsCache.Reset();
241   updateGL();
242 }
243
244  void SetUseSpatialFilter(bool b) {
245        mUseSpatialFilter = b;
246        mPvsCache.Reset();
247        updateGL();
248  }
249
250 
251  void
252  SetViewCellGranularity(int number);
253
254  void
255  SetTransferFunction(int number) {
256        mTransferFunction = number/1000.0f;
257        updateGL();
258  }
259
260  void
261  SetVisibilityFilterSize(int number);
262
263  void
264  SetSpatialFilterSize(int number);
265 
266  void
267  SetSceneCut(int cut);
268 
269  void
270  SetTopDistance(int dist);
271 
272  void SetShowViewCells(bool b) {
273        mRenderViewCells = b;
274        updateGL();
275  }
276
277  void SetShowRays(bool b) {
278        mShowRays = b;
279        updateGL();
280  }
281
282  void SetShowRenderCost(bool b) {
283        mShowRenderCost = b;
284        updateGL();
285  }
286
287  void SetShowPvsSizes(bool b) {
288        mShowPvsSizes = b;
289        updateGL();
290  }
291
292  void SetTopView(bool b) {
293        mTopView = b;
294        updateGL();
295  }
296
297  void SetCutViewCells(bool b) {
298        mCutViewCells = b;
299        updateGL();
300  }
301  void SetCutScene(bool b) {
302        mCutScene = b;
303        updateGL();
304  }
305
306  signals:
307  void PvsUpdated();
308};
309
310
311class QtGlDebuggerWidget : public QGLWidget
312{
313        Q_OBJECT
314public:
315    QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent = NULL);
316    ~QtGlDebuggerWidget();
317    void initializeGL();
318    void resizeGL(int w, int h);
319    void paintGL();
320    void timerEvent(QTimerEvent *) { update(); }
321    void mousePressEvent(QMouseEvent *) { killTimer(timerId); }
322    void mouseReleaseEvent(QMouseEvent *) { timerId = startTimer(20); }
323
324    void initCommon();
325    void initPbuffer();
326
327 
328         QtGlRendererBuffer *mRenderBuffer;
329
330         Beam mBeam;
331         int mSamples;
332         Intersectable *mSourceObject;
333
334private:
335    GLuint dynamicTexture;
336    int timerId;
337};
338
339extern QtGlDebuggerWidget *debuggerWidget;
340
341};
342
343#endif
344
Note: See TracBrowser for help on using the repository browser.