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

Revision 1785, 6.9 KB checked in by bittner, 18 years ago (diff)

merge, filter update, renderebuffer made functional

  • Property svn:executable set to *
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 UpdateAllPvs();
94  void SetViewCellGranularity(int);
95  void SetTransferFunction(int);
96  void SetSceneCut(int);
97  void SetTopDistance(int);
98  void SetVisibilityFilterSize(int);
99  void SetSpatialFilterSize(int);
100
101  void SetShowRays(bool);
102  void SetRenderFilter(bool);
103  void SetRenderVisibilityEstimates(bool);
104  void SetUseFilter(bool);
105  void SetUseSpatialFilter(bool);
106  void SetRenderErrors(bool);
107  void SetRenderBoxes(bool);
108  void SetShowViewCells(bool);
109  void SetShowRenderCost(bool);
110  void SetShowPvsSizes(bool);
111  void SetTopView(bool);
112  void SetCutViewCells(bool);
113  void SetCutScene(bool);
114
115};
116
117
118struct PvsCache {
119  PvsCache():mViewCell(NULL) {}
120  void Reset() { mViewCell = NULL; mPvs.Clear(); }
121  ViewCell *mViewCell;
122  ObjectPvs mPvs;
123};
124
125class QtGlRendererWidget : public QGLWidget, public GlRendererWidget
126{
127  Q_OBJECT
128public:
129
130  // point of the last mouse click used for movement in the scene
131  Vector3 mousePoint;
132
133  bool mTopView;
134  bool mRenderViewCells;
135  bool mCutViewCells;
136  bool mCutScene;
137  bool mRenderErrors;
138  bool mRenderFilter;
139  bool mRenderVisibilityEstimates;
140  bool mUseFilter;
141  bool mUseSpatialFilter;
142  bool mShowRenderCost;
143  bool mShowRays;
144
145  bool mShowPvsSizes;
146  float mSpatialFilterSize;
147 
148  Plane3 mSceneCutPlane;
149  float mTopDistance;
150
151  // some statistics
152  int mPvsSize;
153  float mRenderError;
154  float mTransferFunction;
155
156  float mManipulatorLastQuat[4];
157  float mManipulatorScale;
158  PvsCache mPvsCache;
159 
160  QtRendererControlWidget *mControlWidget;
161
162  QtPreprocessorThread *mPreprocessorThread;
163 
164  QtGlRendererWidget(SceneGraph *sceneGraph,
165                                         ViewCellsManager *viewcells,
166                                         KdTree *tree,
167                                         QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WFlags f = 0
168                                         );
169 
170  QtGlRendererWidget() {};
171
172  void SetThread(QtPreprocessorThread *t) {
173        mPreprocessorThread = t;
174  }
175  void
176  RenderRenderCost();
177
178  virtual void SetupCamera();
179  // setup a transformation for manipulator
180  void
181  SetupManipulator();
182
183  void initializeGL() {
184        InitGL();
185  }
186  void resizeGL(int w, int h);
187  void paintGL();
188  void timerEvent(QTimerEvent *) {
189          update();
190  }
191
192  void mousePressEvent(QMouseEvent *);
193  void mouseReleaseEvent(QMouseEvent *);
194  void mouseMoveEvent(QMouseEvent *);
195
196  void keyPressEvent ( QKeyEvent * e ) ;
197
198  void
199  RenderPvs();
200
201  float
202  RenderErrors();
203  void
204  RenderInfo();
205
206  virtual int GetWidth() const { return width(); }
207  virtual int GetHeight() const { return height(); }
208
209  // virtual void
210  //  SetupProjection(const int w, const int h, const float angle = 70.0f);
211
212  virtual void
213  SetupCameraProjection(const int w, const int h, const float angle = 70.0f);
214
215  virtual void
216  SetupManipulatorProjection(const int w, const int h, const float angle = 70.0f);
217
218  void
219  RenderViewCells();
220
221
222  virtual void Show() {
223        show();
224  }
225
226 public slots:
227
228 void UpdateAllPvs();
229  void ComputeVisibility();
230  void StopComputation();
231
232 void SetRenderErrors(bool b) {
233   mRenderErrors = b;
234   updateGL();
235 }
236
237  void SetRenderBoxes(bool b) {
238        mRenderBoxes = b;
239        updateGL();
240  }
241
242 void SetRenderFilter(bool b) {
243   mRenderFilter = b;
244   updateGL();
245 }
246
247  void SetRenderVisibilityEstimates(bool b) {
248        mRenderVisibilityEstimates = b;
249   updateGL();
250 }
251
252  void SetUseFilter(bool b) {
253   mUseFilter = b;
254   mPvsCache.Reset();
255   updateGL();
256 }
257
258  void SetUseSpatialFilter(bool b) {
259        mUseSpatialFilter = b;
260        mPvsCache.Reset();
261        updateGL();
262  }
263
264 
265  void
266  SetViewCellGranularity(int number);
267
268  void
269  SetTransferFunction(int number) {
270        mTransferFunction = number/1000.0f;
271        updateGL();
272  }
273
274  void
275  SetVisibilityFilterSize(int number);
276
277  void
278  SetSpatialFilterSize(int number);
279 
280  void
281  SetSceneCut(int cut);
282 
283  void
284  SetTopDistance(int dist);
285 
286  void SetShowViewCells(bool b) {
287        mRenderViewCells = b;
288        updateGL();
289  }
290
291  void SetShowRays(bool b) {
292        mShowRays = b;
293        updateGL();
294  }
295
296  void SetShowRenderCost(bool b) {
297        mShowRenderCost = b;
298        updateGL();
299  }
300
301  void SetShowPvsSizes(bool b) {
302        mShowPvsSizes = b;
303        updateGL();
304  }
305
306  void SetTopView(bool b) {
307        mTopView = b;
308        updateGL();
309  }
310
311  void SetCutViewCells(bool b) {
312        mCutViewCells = b;
313        updateGL();
314  }
315  void SetCutScene(bool b) {
316        mCutScene = b;
317        updateGL();
318  }
319
320
321};
322
323
324class QtGlDebuggerWidget : public QGLWidget
325{
326        Q_OBJECT
327public:
328    QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent = NULL);
329    ~QtGlDebuggerWidget();
330    void initializeGL();
331    void resizeGL(int w, int h);
332    void paintGL();
333    void timerEvent(QTimerEvent *) { update(); }
334    void mousePressEvent(QMouseEvent *) { killTimer(timerId); }
335    void mouseReleaseEvent(QMouseEvent *) { timerId = startTimer(20); }
336
337    void initCommon();
338    void initPbuffer();
339
340 
341         QtGlRendererBuffer *mRenderBuffer;
342
343         Beam mBeam;
344         int mSamples;
345         Intersectable *mSourceObject;
346
347private:
348    GLuint dynamicTexture;
349    int timerId;
350};
351
352extern QtGlDebuggerWidget *debuggerWidget;
353
354};
355
356#endif
357
Note: See TracBrowser for help on using the repository browser.