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

Revision 1948, 6.5 KB checked in by mattausch, 18 years ago (diff)
RevLine 
[1252]1#ifndef __QTGLRENDERER_H
2#define __QTGLRENDERER_H
3
4#include <QtOpenGL>
5#include <QWaitCondition>
6
[1942]7//#include <QGLPixelBuffer>
8
[1252]9#include "Vector3.h"
10#include "Containers.h"
11#include "Halton.h"
12#include "Renderer.h"
13#include "GlRenderer.h"
14#include "Beam.h"
[1942]15#include "QtPreprocessorThread.h"
[1252]16class QWidget;
[1942]17//class QtPreprocessorThread;
[1252]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
[1942]34
[1252]35struct VssRayContainer;
36struct PvsRenderStatistics;
37struct RenderCostSample;
38
39
[1942]40class QtGlRendererBuffer : public QObject, public QGLPixelBuffer, public GlRendererBuffer
[1252]41{
42        Q_OBJECT
43public:
44        QtGlRendererBuffer(const int w,
[1942]45                const int h,
46                SceneGraph *sceneGraph,
47                ViewCellsManager *viewcells,
48                KdTree *tree);
[1252]49
[1942]50  ~QtGlRendererBuffer() {}
[1252]51
[1942]52  virtual void MakeCurrent();
53  virtual void DoneCurrent();
[1252]54
[1942]55  virtual int GetWidth() const { return width(); }
56  virtual int GetHeight() const { return height(); }
[1252]57
[1942]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 
[1252]68public:
[1942]69  signals:
70  void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &);
[1252]71};
72
73
[1942]74class QtRendererControlWidget : public QWidget
[1252]75{
[1942]76  Q_OBJECT
[1252]77public:
78
[1942]79  QListWidget *mPvsErrorWidget;
[1252]80
[1942]81  QtRendererControlWidget(QWidget * parent = 0, Qt::WFlags f = 0);
[1252]82
[1942]83  public slots:
[1252]84
[1942]85  void FocusNextPvsErrorFrame();
86  void UpdatePvsErrorItem(int i,
87                                                  GlRendererBuffer::PvsErrorEntry &);
[1252]88
[1942]89  signals:
[1252]90
[1942]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);
[1252]101
[1942]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);
[1926]115
[1252]116};
117
[1926]118
[1942]119class QtGlRendererWidget : public QGLWidget, public GlRendererWidget
[1252]120{
[1942]121  Q_OBJECT
[1252]122public:
123
[1942]124  // point of the last mouse click used for movement in the scene
125  Vector3 mousePoint;
[1252]126
[1942]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;
[1252]138
[1942]139  bool mShowPvsSizes;
140  float mSpatialFilterSize;
141 
142  Plane3 mSceneCutPlane;
143  float mTopDistance;
[1252]144
[1942]145  // some statistics
146  int mPvsSize;
147  float mRenderError;
148  float mTransferFunction;
[1252]149
[1942]150 
151  QtRendererControlWidget *mControlWidget;
[1252]152
[1942]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() {};
[1252]162
[1942]163  void SetThread(QtPreprocessorThread *t) {
164        mPreprocessorThread = t;
165  }
166  void
167  RenderRenderCost();
[1252]168
[1942]169  virtual void SetupCamera();
[1252]170
[1942]171  void initializeGL() {
172        InitGL();
173  }
174  void resizeGL(int w, int h);
175  void paintGL();
176  void timerEvent(QTimerEvent *) {
177          update();
178  }
[1252]179
[1942]180  void mousePressEvent(QMouseEvent *);
181  void mouseReleaseEvent(QMouseEvent *);
182  void mouseMoveEvent(QMouseEvent *);
[1252]183
[1942]184  void keyPressEvent ( QKeyEvent * e ) ;
[1252]185
[1942]186  void
187  RenderPvs();
[1252]188
[1942]189  float
190  RenderErrors();
191  void
192  RenderInfo();
[1252]193
[1942]194  virtual int GetWidth() const { return width(); }
195  virtual int GetHeight() const { return height(); }
[1252]196
[1942]197  // virtual void
198  //  SetupProjection(const int w, const int h, const float angle = 70.0f);
[1252]199
[1942]200  virtual void
201  SetupCameraProjection(const int w, const int h, const float angle = 70.0f);
[1252]202
[1942]203  void
204  RenderViewCells();
[1252]205
206
[1942]207  virtual void Show() {
208        show();
209  }
[1252]210
[1942]211 public slots:
[1252]212
[1942]213 void UpdateAllPvs();
214  void ComputeVisibility();
215  void StopComputation();
216  void SetRandomViewPoint();
[1252]217
[1942]218 void SetRenderErrors(bool b) {
219   mRenderErrors = b;
220   updateGL();
221 }
[1252]222
[1942]223  void SetRenderBoxes(bool b) {
224        mRenderBoxes = b;
225        updateGL();
226  }
[1252]227
[1942]228 void SetRenderFilter(bool b) {
229   mRenderFilter = b;
230   updateGL();
231 }
[1252]232
[1942]233  void SetRenderVisibilityEstimates(bool b) {
234        mRenderVisibilityEstimates = b;
235   updateGL();
236 }
[1252]237
[1942]238  void SetUseFilter(bool b) {
239   mUseFilter = b;
240   mPvsCache.Reset();
241   updateGL();
242 }
[1252]243
[1942]244  void SetUseSpatialFilter(bool b) {
245        mUseSpatialFilter = b;
246        mPvsCache.Reset();
247        updateGL();
248  }
[1926]249
[1942]250 
251  void
252  SetViewCellGranularity(int number);
[1926]253
[1942]254  void
255  SetTransferFunction(int number) {
256        mTransferFunction = number/1000.0f;
257        updateGL();
258  }
[1926]259
[1942]260  void
261  SetVisibilityFilterSize(int number);
[1926]262
[1942]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  }
[1926]276
[1942]277  void SetShowRays(bool b) {
278        mShowRays = b;
279        updateGL();
280  }
[1926]281
[1942]282  void SetShowRenderCost(bool b) {
283        mShowRenderCost = b;
284        updateGL();
285  }
[1926]286
[1942]287  void SetShowPvsSizes(bool b) {
288        mShowPvsSizes = b;
289        updateGL();
290  }
[1926]291
[1942]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();
[1252]308};
309
310
311class QtGlDebuggerWidget : public QGLWidget
312{
313        Q_OBJECT
314public:
[1942]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); }
[1252]323
[1942]324    void initCommon();
325    void initPbuffer();
[1252]326
[1942]327 
328         QtGlRendererBuffer *mRenderBuffer;
[1252]329
[1942]330         Beam mBeam;
331         int mSamples;
332         Intersectable *mSourceObject;
[1252]333
334private:
[1942]335    GLuint dynamicTexture;
336    int timerId;
[1252]337};
338
339extern QtGlDebuggerWidget *debuggerWidget;
340
341};
342
343#endif
344
Note: See TracBrowser for help on using the repository browser.