Logo ROOT  
Reference Guide
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 
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 
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 
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; }
115 
116  UInt_t GetMinorStamp() const { return 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; }
130 
133 
134  // BoundingBox
135 
136  virtual void CalcBoundingBox() const = 0;
139  { if (!fBoundingBoxValid) CalcBoundingBox(); return fBoundingBox; }
140 
141 
142  ClassDef(TGLSceneBase, 0) // Base-class for OpenGL scenes.
143 }; // endclass TGLSceneBase
144 
145 
146 #endif
TGLSceneBase::fDoFrustumCheck
Bool_t fDoFrustumCheck
Definition: TGLSceneBase.h:58
TGLSceneBase::fMinorStamp
UInt_t fMinorStamp
Definition: TGLSceneBase.h:46
TGLSceneBase::PreDraw
virtual void PreDraw(TGLRnrCtx &rnrCtx)
Perform basic pre-render initialization:
Definition: TGLSceneBase.cxx:311
TGLSceneBase::fSelectable
Bool_t fSelectable
Definition: TGLSceneBase.h:52
TGLSceneBase::TGLSceneBase
TGLSceneBase(const TGLSceneBase &)
TGLSceneBase
Scene base-class – provides basic interface expected by the TGLViewer or its sub-classes:
Definition: TGLSceneBase.h:33
TGLSceneBase::fViewers
ViewerList_t fViewers
Definition: TGLSceneBase.h:65
TGLSceneBase::SetAutoDestruct
void SetAutoDestruct(Bool_t a)
Definition: TGLSceneBase.h:132
TGLSceneBase::RenderOpaque
virtual void RenderOpaque(TGLRnrCtx &rnrCtx)
Render opaque elements.
Definition: TGLSceneBase.cxx:441
TGLSceneBase::GetTitle
virtual const char * GetTitle() const
Definition: TGLSceneBase.h:82
TGLSceneBase::fBoundingBox
TGLBoundingBox fBoundingBox
Definition: TGLSceneBase.h:55
TGLSceneBase::PostDraw
virtual void PostDraw(TGLRnrCtx &rnrCtx)
Finalize drawing.
Definition: TGLSceneBase.cxx:496
TGLSceneBase::SetClip
void SetClip(TGLClip *p)
Definition: TGLSceneBase.h:126
TGLSceneBase::fOLLineW
Float_t fOLLineW
Definition: TGLSceneBase.h:50
TGLSceneBase::GetSelectable
Bool_t GetSelectable() const
Definition: TGLSceneBase.h:128
Float_t
float Float_t
Definition: RtypesCore.h:57
TGLSceneBase::UpdateSceneInfo
virtual void UpdateSceneInfo(TGLRnrCtx &ctx)
Fill scene-info with information needed for rendering, take into account the render-context (viewer s...
Definition: TGLSceneBase.cxx:172
Int_t
int Int_t
Definition: RtypesCore.h:45
TGLSceneBase::~TGLSceneBase
virtual ~TGLSceneBase()
Destructor.
Definition: TGLSceneBase.cxx:75
TGLSceneBase::Style
Short_t Style() const
Definition: TGLSceneBase.h:122
TGLSceneBase::fTimeStamp
UInt_t fTimeStamp
Definition: TGLSceneBase.h:45
TString
Basic string class.
Definition: TString.h:136
TGLSceneBase::RenderSelOpaqueForHighlight
virtual void RenderSelOpaqueForHighlight(TGLRnrCtx &rnrCtx)
Render selected opaque elements for highlight.
Definition: TGLSceneBase.cxx:469
TGLBoundingBox.h
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGLBoundingBox
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
Definition: TGLBoundingBox.h:33
TGLSceneBase::PreRender
virtual void PreRender(TGLRnrCtx &rnrCtx)
Perform pre-render initialization - fill rnrCtx with values stored during PreDraw().
Definition: TGLSceneBase.cxx:402
TString.h
TGLSceneBase::fSceneID
UInt_t fSceneID
Definition: TGLSceneBase.h:41
bool
TGLSceneBase::RenderSelTransp
virtual void RenderSelTransp(TGLRnrCtx &rnrCtx)
Render selected transparent elements for highlight.
Definition: TGLSceneBase.cxx:462
TGLSceneBase::fDoClipCheck
Bool_t fDoClipCheck
Definition: TGLSceneBase.h:59
TGLSceneBase::RemoveViewer
void RemoveViewer(TGLViewerBase *viewer)
Remove viewer from the list.
Definition: TGLSceneBase.cxx:100
TGLSceneBase::SetStyle
void SetStyle(Short_t st)
Definition: TGLSceneBase.h:123
TGLViewerBase
Base class for GL viewers.
Definition: TGLViewerBase.h:37
TGLLockable.h
TGLSceneBase::RenderSelOpaque
virtual void RenderSelOpaque(TGLRnrCtx &rnrCtx)
Render selected opaque elements.
Definition: TGLSceneBase.cxx:455
TGLSceneBase::fAutoDestruct
Bool_t fAutoDestruct
Definition: TGLSceneBase.h:66
TGLSceneBase::ViewerList_t
std::list< TGLViewerBase * > ViewerList_t
Definition: TGLSceneBase.h:62
TGLSceneBase::LodifySceneInfo
virtual void LodifySceneInfo(TGLRnrCtx &ctx)
Setup LOD-dependant values in scene-info.
Definition: TGLSceneBase.cxx:286
TGLSceneBase::SetName
virtual void SetName(const char *name)
Definition: TGLSceneBase.h:83
TGLSceneBase::fWFLineW
Float_t fWFLineW
Definition: TGLSceneBase.h:49
TGLSceneBase::SetLOD
void SetLOD(Short_t lod)
Definition: TGLSceneBase.h:120
TGLSceneBase::CalcBoundingBox
virtual void CalcBoundingBox() const =0
TGLSelectRecord
Standard selection record including information about containing scene and details ob out selected ob...
Definition: TGLSelectRecord.h:75
TGLSceneBase::fClip
TGLClip * fClip
Definition: TGLSceneBase.h:51
a
auto * a
Definition: textangle.C:12
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TGLSceneBase::IncMinorStamp
void IncMinorStamp()
Definition: TGLSceneBase.h:117
TGLSceneBase::LockIdStr
virtual const char * LockIdStr() const
Name printed on locking info messages.
Definition: TGLSceneBase.cxx:131
TGLSceneBase::Clip
TGLClip * Clip() const
Definition: TGLSceneBase.h:125
TGLSceneBase::GetName
virtual const char * GetName() const
Definition: TGLSceneBase.h:81
TGLSceneBase::GetMinorStamp
UInt_t GetMinorStamp() const
Definition: TGLSceneBase.h:116
TGLLockable
Simple locking interface used by viewer and scene.
Definition: TGLLockable.h:18
Short_t
short Short_t
Definition: RtypesCore.h:39
TGLSceneBase::fTitle
TString fTitle
Definition: TGLSceneBase.h:43
TGLSceneBase::SetSelectable
void SetSelectable(Bool_t a)
Definition: TGLSceneBase.h:129
TGLSceneBase::FindLogical
virtual TGLLogicalShape * FindLogical(TObject *) const
Definition: TGLSceneBase.h:105
TGLSceneBase::fName
TString fName
Definition: TGLSceneBase.h:42
TGLSceneBase::fgSceneIDSrc
static UInt_t fgSceneIDSrc
Definition: TGLSceneBase.h:38
unsigned int
TGLSceneBase::fStyle
Short_t fStyle
Definition: TGLSceneBase.h:48
TGLSceneBase::RenderTransp
virtual void RenderTransp(TGLRnrCtx &rnrCtx)
Render transparent elements.
Definition: TGLSceneBase.cxx:448
TGLSceneBase::TagViewersChanged
void TagViewersChanged()
Tag all viewers as changed.
Definition: TGLSceneBase.cxx:118
TGLSceneBase::TGLSceneBase
TGLSceneBase()
Definition: TGLSceneBase.cxx:49
TGLSceneBase::fLOD
Short_t fLOD
Definition: TGLSceneBase.h:47
TGLClip
Abstract clipping shape - derives from TGLPhysicalShape Adds clip mode (inside/outside) and pure virt...
Definition: TGLClip.h:32
TGLSceneBase::BoundingBox
const TGLBoundingBox & BoundingBox() const
Definition: TGLSceneBase.h:138
TGLSceneBase::RenderSelTranspForHighlight
virtual void RenderSelTranspForHighlight(TGLRnrCtx &rnrCtx)
Render selected transparent elements.
Definition: TGLSceneBase.cxx:476
TGLSceneBase::LOD
Short_t LOD() const
Definition: TGLSceneBase.h:119
TGLSceneBase::RebuildSceneInfo
virtual void RebuildSceneInfo(TGLRnrCtx &ctx)
Fill scene-info with very basic information that is practically view independent.
Definition: TGLSceneBase.cxx:154
TGLSceneBase::GetTimeStamp
UInt_t GetTimeStamp() const
Definition: TGLSceneBase.h:113
TGLSceneBase::operator=
TGLSceneBase & operator=(const TGLSceneBase &)
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGLSceneBase::ResolveSelectRecord
virtual Bool_t ResolveSelectRecord(TGLSelectRecord &rec, Int_t curIdx)
Process selection record rec.
Definition: TGLSceneBase.cxx:513
TGLSceneBase::PostRender
virtual void PostRender(TGLRnrCtx &rnrCtx)
Perform post-render clean-up.
Definition: TGLSceneBase.cxx:483
TGLLogicalShape
Abstract logical shape - a GL 'drawable' - base for all shapes - faceset sphere etc.
Definition: TGLLogicalShape.h:30
name
char name[80]
Definition: TGX11.cxx:110
TGLSceneBase::InvalidateBoundingBox
void InvalidateBoundingBox()
Definition: TGLSceneBase.h:137
TGLSceneBase::AddViewer
void AddViewer(TGLViewerBase *viewer)
Add viewer to the list.
Definition: TGLSceneBase.cxx:86
TGLSceneBase::Render
virtual void Render(TGLRnrCtx &rnrCtx)
This function does rendering of all stages, the shapes are rendered in the following order: opaque,...
Definition: TGLSceneBase.cxx:430
TGLSceneBase::fBoundingBoxValid
Bool_t fBoundingBoxValid
Definition: TGLSceneBase.h:56
TGLSceneBase::IncTimeStamp
void IncTimeStamp()
Definition: TGLSceneBase.h:114
TGLSceneBase::SetTitle
virtual void SetTitle(const char *title)
Definition: TGLSceneBase.h:84
TGLSceneInfo
Base class for extended scene context.
Definition: TGLSceneInfo.h:28
TGLSceneBase::CreateSceneInfo
virtual TGLSceneInfo * CreateSceneInfo(TGLViewerBase *view)
Create a scene-info instance appropriate for this scene class.
Definition: TGLSceneBase.cxx:144
TGLSceneBase::SetNameTitle
virtual void SetNameTitle(const char *name, const char *title)
Definition: TGLSceneBase.h:85
TGLSceneBase::ViewerList_i
std::list< TGLViewerBase * >::iterator ViewerList_i
Definition: TGLSceneBase.h:63
TGLRnrCtx
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:41
TGLSceneBase::GetAutoDestruct
Bool_t GetAutoDestruct() const
Definition: TGLSceneBase.h:131