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

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