Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGLSceneInfo.h
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Matevz Tadel, Feb 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGLSceneInfo_H
13 #define ROOT_TGLSceneInfo_H
14 
15 #include "Rtypes.h"
16 
17 #include "TGLBoundingBox.h"
18 #include "TGLUtil.h"
19 
20 class TGLViewerBase;
21 class TGLSceneBase;
22 class TGLClip;
23 class TGLRenderContext;
24 class TGLCamera;
25 
26 class TGLSceneInfo
27 {
28  friend class TGLSceneBase;
29 
30 public:
31  enum EClipTest { kClipNone, kClipOutside, kClipInside };
32 
33 private:
34  TGLSceneInfo(const TGLSceneInfo&); // Not implemented
35  TGLSceneInfo& operator=(const TGLSceneInfo&); // Not implemented
36 
37 protected:
38  TGLViewerBase * fViewer;
39  TGLSceneBase * fScene;
40  Bool_t fActive; // Show fScene in fViewer
41 
42  Short_t fLOD; // Optional override of scene lod
43  Short_t fStyle; // Optional override of scene style
44  Float_t fWFLineW; // Optional override of scene wire-frame line-width
45  Float_t fOLLineW; // Optional override of scene outline line-width
46  TGLClip * fClip; // Optional override of clipping-plane
47 
48  Short_t fLastLOD; // Last combined viewer/scene lod (set in scene::lodify-scene-info).
49  Short_t fLastStyle; // Last combined viewer/scene style (set in scene::pre-draw).
50  Float_t fLastWFLineW; // Last combined viewer/scene wire-frame line-width (set in scene::pre-draw).
51  Float_t fLastOLLineW; // Last combined viewer/scene outline line-width (set in scene::pre-draw).
52  TGLClip * fLastClip; // Last combined viewer/scene clip (set in scene::update)
53  TGLCamera * fLastCamera; // Last camera used.
54 
55  UInt_t fSceneStamp; // Scene's time-stamp on last update.
56  UInt_t fClipStamp; // Clip's time-stamp on last update.
57  UInt_t fCameraStamp; // Camera's time-stamp on last update.
58  Bool_t fUpdateTimeouted; // Set if update was interrupted.
59 
60  // Eventually we will allow additional per-scene transforamtion.
61  // TGLMatrix fSceneTrans;
62  // Also needed:
63  // *) transformed clipping planes of the camera
64  // *) transformed bounding-box of the scene
65  TGLBoundingBox fTransformedBBox;
66 
67  Bool_t fViewCheck; // Viewer side check if render is necessary.
68  Bool_t fInFrustum; // Is scene intersecting view-frustum.
69  Bool_t fInClip; // Is scene contained within clipping-volume.
70  Char_t fClipMode; // Clipping mode, can be disbled.
71  TGLPlaneSet_t fFrustumPlanes; // Clipping planes defined by frustum; only those intersecting the scene volume are kept.
72  TGLPlaneSet_t fClipPlanes; // Clipping planes from clip-object; which planes are kept depends on inside/outside mode.
73 
74  // Additional stuff (scene-class specific) can be added by sub-classing.
75  // For TGLScene these data include draw-lists after clipping.
76 
77 public:
78  TGLSceneInfo(TGLViewerBase* view=0, TGLSceneBase* scene=0);
79  virtual ~TGLSceneInfo() {}
80 
81  TGLViewerBase * GetViewer() const { return fViewer; }
82  TGLViewerBase & RefViewer() const { return *fViewer; }
83  TGLSceneBase * GetScene() const { return fScene; }
84  TGLSceneBase & RefScene() const { return *fScene; }
85 
86  Bool_t GetActive() const { return fActive; }
87  void SetActive(Bool_t a);
88 
89  void SetupTransformsAndBBox();
90 
91  const TGLBoundingBox& GetTransformedBBox() { return fTransformedBBox; }
92 
93  virtual void SetSceneTrans(TGLMatrix&) { ResetSceneStamp(); }
94 
95  Bool_t ViewCheck() const { return fViewCheck; }
96  void ViewCheck(Bool_t c) { fViewCheck = c; }
97  Bool_t IsInFrustum() const { return fInFrustum; }
98  void InFrustum(Bool_t f) { fInFrustum = f; }
99  Bool_t IsInClip() const { return fInClip; }
100  void InClip(Bool_t c) { fInClip = c; }
101  Char_t ClipMode() const { return fClipMode; }
102  void ClipMode(Char_t m) { fClipMode = m; }
103 
104  Bool_t ShouldClip() const { return fClipMode != kClipNone; }
105  Bool_t IsVisible() const { return fInFrustum && fInClip; }
106 
107  std::vector<TGLPlane>& FrustumPlanes() { return fFrustumPlanes; }
108  std::vector<TGLPlane>& ClipPlanes() { return fClipPlanes; }
109 
110  Short_t LOD() const { return fLOD; }
111  void SetLOD(Short_t lod) { fLOD = lod; }
112 
113  Short_t Style() const { return fStyle; }
114  void SetStyle(Short_t st) { fStyle = st; }
115 
116  Float_t WFLineW() const { return fWFLineW; }
117  void SetWFLineW(Float_t w) { fWFLineW = w; }
118  Float_t OLLineW() const { return fOLLineW; }
119  void SetOLLineW(Float_t w) { fOLLineW = w; }
120 
121  TGLClip* Clip() const { return fClip; }
122  void SetClip(TGLClip *p) { fClip = p; }
123 
124  Short_t LastLOD() const { return fLastLOD; }
125  void SetLastLOD(Short_t ld) { fLastLOD = ld; }
126 
127  Short_t LastStyle() const { return fLastStyle; }
128  void SetLastStyle(Short_t st) { fLastStyle = st; }
129 
130  Float_t LastWFLineW() const { return fLastWFLineW; }
131  void SetLastWFLineW(Float_t w) { fLastWFLineW = w; }
132  Float_t LastOLLineW() const { return fLastOLLineW; }
133  void SetLastOLLineW(Float_t w) { fLastOLLineW = w; }
134 
135  TGLClip* LastClip() const { return fLastClip; }
136  void SetLastClip(TGLClip *p) { fLastClip = p; }
137 
138  TGLCamera* LastCamera() const { return fLastCamera; }
139  void SetLastCamera(TGLCamera *p) { fLastCamera = p; }
140 
141  UInt_t SceneStamp() const { return fSceneStamp; }
142  void SetSceneStamp(UInt_t ts) { fSceneStamp = ts; }
143  void ResetSceneStamp() { fSceneStamp = 0; }
144 
145  UInt_t ClipStamp() const { return fClipStamp; }
146  void SetClipStamp(UInt_t ts) { fClipStamp = ts; }
147  void ResetClipStamp() { fClipStamp = 0; }
148 
149  UInt_t CameraStamp() const { return fCameraStamp; }
150  void SetCameraStamp(UInt_t ts) { fCameraStamp = ts; }
151  void ResetCameraStamp() { fCameraStamp = 0; }
152 
153  Bool_t HasUpdateTimeouted() const { return fUpdateTimeouted; }
154  void UpdateTimeouted() { fUpdateTimeouted = kTRUE; }
155  void ResetUpdateTimeouted() { fUpdateTimeouted = kFALSE; }
156 
157  ClassDef(TGLSceneInfo, 0) // Data about a scene within a viewer context.
158 }; // endclass TGLSceneInfo
159 
160 
161 #endif