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

Revision 1824, 6.7 KB checked in by bittner, 18 years ago (diff)

global lines support

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