Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGLSceneBase.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_TGLSceneBase_H
13 #define ROOT_TGLSceneBase_H
14 
15 #include "TGLLockable.h"
16 #include "TGLBoundingBox.h"
17 
18 #include <TString.h>
19 
20 #include <list>
21 
22 class TGLViewerBase;
23 class TGLSceneInfo;
24 class TGLClip;
25 class TGLRnrCtx;
26 class TGLLogicalShape;
27 class TGLSelectRecord;
28 
29 // Avoid TObject inheritance due to clash with TObject::Draw as well
30 // as possible inheritance of TGLPadScene from VierualViewer3D.
31 
32 class TGLSceneBase : public TGLLockable // : public TObject / TNamed
33 {
34 private:
35  TGLSceneBase(const TGLSceneBase&); // Not implemented
36  TGLSceneBase& operator=(const TGLSceneBase&); // Not implemented
37 
38  static UInt_t fgSceneIDSrc;
39 
40 protected:
41  UInt_t fSceneID; // Unique scene id.
42  TString fName; // Object identifier.
43  TString fTitle; // Object title.
44 
45  UInt_t fTimeStamp; // Counter increased on every update.
46  UInt_t fMinorStamp; // Counter increased on minimal update.
47  Short_t fLOD; // Scene-lod.
48  Short_t fStyle; // Scene-style.
49  Float_t fWFLineW; // Scene wire-frame line-width.
50  Float_t fOLLineW; // Scene outline line-width.
51  TGLClip * fClip; // Scene clipping-plane.
52  Bool_t fSelectable; // Objects in the scene are selectable.
53 
54  // BoundingBox
55  mutable TGLBoundingBox fBoundingBox; // bounding box for scene (axis aligned) - lazy update - use BoundingBox() to access
56  mutable Bool_t fBoundingBoxValid; // bounding box valid?
57 
58  Bool_t fDoFrustumCheck; // Perform global frustum-check in UpdateSceneInfo()
59  Bool_t fDoClipCheck; // Perform global clip-plane-check in UpdateSceneInfo()
60 
61  // Interface to other components
62  typedef std::list<TGLViewerBase*> ViewerList_t;
63  typedef std::list<TGLViewerBase*>::iterator ViewerList_i;
64 
65  ViewerList_t fViewers;
66  Bool_t fAutoDestruct;
67 
68  // Possible future extensions
69  // TGLMatrix fGlobalTrans;
70 
71 public:
72  TGLSceneBase();
73  virtual ~TGLSceneBase();
74 
75  void AddViewer(TGLViewerBase* viewer);
76  void RemoveViewer(TGLViewerBase* viewer);
77  void TagViewersChanged();
78 
79  virtual const char* LockIdStr() const;
80 
81  virtual const char *GetName() const { return fName; }
82  virtual const char *GetTitle() const { return fTitle; }
83  virtual void SetName (const char *name) { fName = name; }
84  virtual void SetTitle(const char *title) { fTitle = title; }
85  virtual void SetNameTitle(const char *name, const char *title) { SetName(name); SetTitle(title); }
86 
87  virtual TGLSceneInfo* CreateSceneInfo(TGLViewerBase* view);
88  virtual void RebuildSceneInfo(TGLRnrCtx& ctx);
89  virtual void UpdateSceneInfo(TGLRnrCtx& ctx);
90  virtual void LodifySceneInfo(TGLRnrCtx& ctx);
91 
92  // Rendering
93  virtual void PreDraw (TGLRnrCtx& rnrCtx);
94  virtual void PreRender (TGLRnrCtx& rnrCtx);
95  virtual void Render (TGLRnrCtx& rnrCtx);
96  virtual void RenderOpaque (TGLRnrCtx& rnrCtx);
97  virtual void RenderTransp (TGLRnrCtx& rnrCtx);
98  virtual void RenderSelOpaque(TGLRnrCtx& rnrCtx);
99  virtual void RenderSelTransp(TGLRnrCtx& rnrCtx);
100  virtual void RenderSelOpaqueForHighlight(TGLRnrCtx& rnrCtx);
101  virtual void RenderSelTranspForHighlight(TGLRnrCtx& rnrCtx);
102  virtual void PostRender(TGLRnrCtx& rnrCtx);
103  virtual void PostDraw (TGLRnrCtx& rnrCtx);
104 
105  virtual TGLLogicalShape* FindLogical(TObject*) const { return 0; }
106 
107  // Selection interface
108  virtual Bool_t ResolveSelectRecord(TGLSelectRecord& rec, Int_t curIdx);
109 
110 
111  // Getters & setters
112 
113  UInt_t GetTimeStamp() const { return fTimeStamp; }
114  void IncTimeStamp() { ++fTimeStamp; fMinorStamp = 1; }
115 
116  UInt_t GetMinorStamp() const { return fMinorStamp; }
117  void IncMinorStamp() { ++fMinorStamp; }
118 
119  Short_t LOD() const { return fLOD; }
120  void SetLOD(Short_t lod) { fLOD = lod; }
121 
122  Short_t Style() const { return fStyle; }
123  void SetStyle(Short_t st) { fStyle = st; }
124 
125  TGLClip* Clip() const { return fClip; }
126  void SetClip(TGLClip *p) { fClip = p; }
127 
128  Bool_t GetSelectable() const { return fSelectable; }
129  void SetSelectable(Bool_t a) { fSelectable = a; }
130 
131  Bool_t GetAutoDestruct() const { return fAutoDestruct; }
132  void SetAutoDestruct(Bool_t a) { fAutoDestruct = a; }
133 
134  // BoundingBox
135 
136  virtual void CalcBoundingBox() const = 0;
137  void InvalidateBoundingBox() { fBoundingBoxValid = kFALSE; }
138  const TGLBoundingBox& BoundingBox() const
139  { if (!fBoundingBoxValid) CalcBoundingBox(); return fBoundingBox; }
140 
141 
142  ClassDef(TGLSceneBase, 0) // Base-class for OpenGL scenes.
143 }; // endclass TGLSceneBase
144 
145 
146 #endif