Logo ROOT  
Reference Guide
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Matevz Tadel, Feb 2007
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 *************************************************************************/
12#ifndef ROOT_TGLScene_H
13#define ROOT_TGLScene_H
15#include "TGLSceneBase.h"
16#include "TGLSceneInfo.h"
18#include <map>
19#include <vector>
21class TGLObject;
22class TGLCamera;
23class TGLLogicalShape;
28class TGLScene : public TGLSceneBase
31 TGLScene(const TGLScene&); // Not implemented
32 TGLScene& operator=(const TGLScene&); // Not implemented
34 // Compare physical-shape volumes/diagonals -- for draw-vec sorting
36 const TGLPhysicalShape* shape2);
38 const TGLPhysicalShape* shape2);
40 // Logical shapes
41 typedef std::map<TObject*, TGLLogicalShape*> LogicalShapeMap_t;
42 typedef LogicalShapeMap_t::value_type LogicalShapeMapValueType_t;
43 typedef LogicalShapeMap_t::iterator LogicalShapeMapIt_t;
44 typedef LogicalShapeMap_t::const_iterator LogicalShapeMapCIt_t;
46 // Physical Shapes
47 typedef std::map<UInt_t, TGLPhysicalShape*> PhysicalShapeMap_t;
48 typedef PhysicalShapeMap_t::value_type PhysicalShapeMapValueType_t;
49 typedef PhysicalShapeMap_t::iterator PhysicalShapeMapIt_t;
50 typedef PhysicalShapeMap_t::const_iterator PhysicalShapeMapCIt_t;
54 {
55 const TGLPhysicalShape* fPhysical; // Physical shape.
57 Float_t fPixelSize; // Size of largest lod-axis in pixels.
58 Short_t fPixelLOD; // Size in LOD units.
59 Short_t fFinalLOD; // Corrected with SceneLOD and quantized.
62 fPhysical(pshp), fPixelSize(0), fPixelLOD(0), fFinalLOD(0) {}
63 };
65 typedef std::vector<DrawElement_t> DrawElementVec_t;
66 typedef std::vector<DrawElement_t>::iterator DrawElementVec_i;
68 typedef std::vector<DrawElement_t*> DrawElementPtrVec_t;
69 typedef std::vector<DrawElement_t*>::iterator DrawElementPtrVec_i;
71 // List of physical shapes ordered by volume/diagonal
72 typedef std::vector<const TGLPhysicalShape*> ShapeVec_t;
73 typedef ShapeVec_t::iterator ShapeVec_i;
75 // ----------------------------------------------------------------
76 // SceneInfo ... extended scene context
78 class TSceneInfo : public TGLSceneInfo
79 {
80 private:
83 protected:
87 public:
98 TSceneInfo(TGLViewerBase* view=0, TGLScene* scene=0);
99 virtual ~TSceneInfo();
101 void ClearAfterRebuild();
102 void ClearAfterUpdate();
104 void Lodify(TGLRnrCtx& ctx);
106 void PreDraw();
107 void PostDraw();
109 // ---------------
110 // Draw statistics
115 std::map<TClass*, UInt_t> fByShapeCnt;
117 void ResetDrawStats();
118 void UpdateDrawStats(const TGLPhysicalShape& shape, Short_t lod);
119 void DumpDrawStats(); // Debug
120 };
121 friend class TSceneInfo; // for solaris cc
130 // GLcontext
134 // Smart Refresh -- will go in this version
138 // State that requires recreation of display-lists
142 // ----------------------------------------------------------------
143 // ----------------------------------------------------------------
146 TGLScene();
147 virtual ~TGLScene();
149 virtual void CalcBoundingBox() const;
152 virtual void RebuildSceneInfo(TGLRnrCtx& rnrCtx);
153 virtual void UpdateSceneInfo(TGLRnrCtx& rnrCtx);
154 virtual void LodifySceneInfo(TGLRnrCtx& rnrCtx);
157 // Rendering
158 virtual void PreDraw (TGLRnrCtx& rnrCtx);
159 // virtual void PreRender (TGLRnrCtx& rnrCtx);
160 // virtual void Render (TGLRnrCtx& rnrCtx);
161 virtual void RenderOpaque (TGLRnrCtx& rnrCtx);
162 virtual void RenderTransp (TGLRnrCtx& rnrCtx);
163 virtual void RenderSelOpaque(TGLRnrCtx& rnrCtx);
164 virtual void RenderSelTransp(TGLRnrCtx& rnrCtx);
165 virtual void RenderSelOpaqueForHighlight(TGLRnrCtx& rnrCtx);
166 virtual void RenderSelTranspForHighlight(TGLRnrCtx& rnrCtx);
168 virtual void RenderHighlight(TGLRnrCtx& rnrCtx,
169 DrawElementPtrVec_t& elVec);
171 // virtual void PostRender(TGLRnrCtx& rnrCtx);
172 virtual void PostDraw (TGLRnrCtx& rnrCtx);
174 virtual void RenderAllPasses(TGLRnrCtx& rnrCtx,
175 DrawElementPtrVec_t& elVec,
176 Bool_t check_timeout);
179 virtual void RenderElements (TGLRnrCtx& rnrCtx,
180 DrawElementPtrVec_t& elVec,
181 Bool_t check_timeout,
182 const TGLPlaneSet_t* clipPlanes = 0);
184 // Selection
185 virtual Bool_t ResolveSelectRecord(TGLSelectRecord& rec, Int_t curIdx);
187 // Basic logical shape management
188 virtual void AdoptLogical(TGLLogicalShape& shape);
189 virtual Bool_t DestroyLogical(TObject* logid, Bool_t mustFind=kTRUE);
190 virtual Int_t DestroyLogicals();
191 virtual TGLLogicalShape* FindLogical(TObject* logid) const;
193 // Basic physical shape management
194 virtual void AdoptPhysical(TGLPhysicalShape& shape);
195 virtual Bool_t DestroyPhysical(UInt_t phid);
196 virtual Int_t DestroyPhysicals();
197 virtual TGLPhysicalShape* FindPhysical(UInt_t phid) const;
199 virtual UInt_t GetMaxPhysicalID();
201 // ----------------------------------------------------------------
202 // Updates / removals of logical and physical shapes
204 virtual Bool_t BeginUpdate();
205 virtual void EndUpdate(Bool_t minorChange=kTRUE, Bool_t sceneChanged=kTRUE, Bool_t updateViewers=kTRUE);
207 virtual void UpdateLogical(TObject* logid);
209 virtual void UpdatePhysical(UInt_t phid, Double_t* trans, UChar_t* col);
210 virtual void UpdatePhysical(UInt_t phid, Double_t* trans, Color_t cidx=-1, UChar_t transp=0);
212 virtual void UpdatePhysioLogical(TObject* logid, Double_t* trans, UChar_t* col);
213 virtual void UpdatePhysioLogical(TObject* logid, Double_t* trans, Color_t cidx, UChar_t transp);
215 // Temporary export for setting selected-state of physical shapes.
219 // ----------------------------------------------------------------
220 // SmartRefresh
223 void EndSmartRefresh();
227 // ----------------------------------------------------------------
228 // GL-context holding display-list definitions
233 // ----------------------------------------------------------------
234 // Helpers
236 UInt_t SizeOfScene() const;
237 void DumpMapSizes() const;
239 static void RGBAFromColorIdx(Float_t rgba[4], Color_t ci, Char_t transp=0);
241 static Bool_t IsOutside(const TGLBoundingBox& box,
242 const TGLPlaneSet_t& planes);
244 ClassDef(TGLScene, 0); // Standard ROOT OpenGL scene with logial/physical shapes.
bool Bool_t
Definition: RtypesCore.h:63
short Color_t
Definition: RtypesCore.h:92
unsigned char UChar_t
Definition: RtypesCore.h:38
char Char_t
Definition: RtypesCore.h:33
unsigned int UInt_t
Definition: RtypesCore.h:46
float Float_t
Definition: RtypesCore.h:57
short Short_t
Definition: RtypesCore.h:39
const Bool_t kTRUE
Definition: RtypesCore.h:100
#define ClassDef(name, id)
Definition: Rtypes.h:335
std::vector< TGLPlane > TGLPlaneSet_t
Definition: TGLUtil.h:571
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
Definition: TGLCamera.h:44
Identifier of a shared GL-context.
Definition: TGLContext.h:81
Abstract logical shape - a GL 'drawable' - base for all shapes - faceset sphere etc.
Base-class for direct OpenGL renderers.
Definition: TGLObject.h:22
Concrete physical shape - a GL drawable.
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:41
Scene base-class – provides basic interface expected by the TGLViewer or its sub-classes:
Definition: TGLSceneBase.h:33
Base class for extended scene context.
Definition: TGLSceneInfo.h:28
DrawElementPtrVec_t fSelTranspElements
Definition: TGLScene.h:96
void PostDraw()
Clean-up after drawing, nothing to be done here.
Definition: TGLScene.cxx:169
DrawElementPtrVec_t fTranspElements
Definition: TGLScene.h:94
void ClearAfterRebuild()
Clear DrawElementVector fVisibleElement and optionally resize it so that it doesn't take more space t...
Definition: TGLScene.cxx:101
Bool_t CmpDrawElements(const DrawElement_t &de1, const DrawElement_t &de2)
void ResetDrawStats()
Reset draw statistics.
Definition: TGLScene.cxx:176
void DumpDrawStats()
Output draw stats to Info stream.
Definition: TGLScene.cxx:218
TSceneInfo(TGLViewerBase *view=0, TGLScene *scene=0)
Definition: TGLScene.cxx:48
DrawElementVec_t fVisibleElements
Definition: TGLScene.h:90
void PreDraw()
Prepare for drawing - fill DrawElementPtrVectors from the contents of fVisibleElements if there was s...
Definition: TGLScene.cxx:138
virtual ~TSceneInfo()
Definition: TGLScene.cxx:60
DrawElementPtrVec_t fOpaqueElements
Definition: TGLScene.h:93
ShapeVec_t fShapesOfInterest
Definition: TGLScene.h:88
void ClearDrawElementVec(DrawElementVec_t &vec, Int_t maxSize)
Clear given vec and if it grew too large compared to the size of shape-of-interest also resize it.
Definition: TGLScene.cxx:68
void UpdateDrawStats(const TGLPhysicalShape &shape, Short_t lod)
Update draw stats, for newly drawn 'shape'.
Definition: TGLScene.cxx:187
std::map< TClass *, UInt_t > fByShapeCnt
Definition: TGLScene.h:115
DrawElementPtrVec_t fSelOpaqueElements
Definition: TGLScene.h:95
void ClearAfterUpdate()
Clear DrawElementPtrVectors and optionally resize them so that they don't take more space then requir...
Definition: TGLScene.cxx:113
void Lodify(TGLRnrCtx &ctx)
Quantize LODs for given render-context.
Definition: TGLScene.cxx:128
void ClearDrawElementPtrVec(DrawElementPtrVec_t &vec, Int_t maxSize)
Clear given vec and if it grew too large compared to the size of shape-of-interest also resize it.
Definition: TGLScene.cxx:84
TGLScene provides management and rendering of ROOT's default 3D /object representation as logical and...
Definition: TGLScene.h:29
Float_t fLastLineWidthScale
Definition: TGLScene.h:140
virtual void RenderSelOpaque(TGLRnrCtx &rnrCtx)
Render selected opaque elements.
Definition: TGLScene.cxx:633
std::vector< DrawElement_t > DrawElementVec_t
Definition: TGLScene.h:65
virtual TGLPhysicalShape * FindPhysical(UInt_t phid) const
Find and return physical shape identified by unique 'ID'.
Definition: TGLScene.cxx:1221
std::map< UInt_t, TGLPhysicalShape * > PhysicalShapeMap_t
Definition: TGLScene.h:47
PhysicalShapeMap_t::const_iterator PhysicalShapeMapCIt_t
Definition: TGLScene.h:50
virtual TSceneInfo * CreateSceneInfo(TGLViewerBase *view)
Create a scene-info instance appropriate for this scene class.
Definition: TGLScene.cxx:347
virtual void DestroyPhysicalInternal(PhysicalShapeMapIt_t pit)
Virtual function to destroy a physical.
Definition: TGLScene.cxx:1149
virtual Bool_t BeginUpdate()
Put scene in update mode, return true if lock acquired.
Definition: TGLScene.cxx:1245
virtual void AdoptPhysical(TGLPhysicalShape &shape)
Adopt dynamically created physical 'shape' - add to internal map and take responsibility for deleting...
Definition: TGLScene.cxx:1129
void ReleaseGLCtxIdentity()
Release all GL resources for current context identity.
Definition: TGLScene.cxx:311
LogicalShapeMap_t::const_iterator LogicalShapeMapCIt_t
Definition: TGLScene.h:44
TGLContextIdentity * GetGLCtxIdentity() const
Definition: TGLScene.h:230
virtual void RenderSelTransp(TGLRnrCtx &rnrCtx)
Render selected transparent elements.
Definition: TGLScene.cxx:643
virtual void EndUpdate(Bool_t minorChange=kTRUE, Bool_t sceneChanged=kTRUE, Bool_t updateViewers=kTRUE)
Exit scene update mode.
Definition: TGLScene.cxx:1265
Float_t fLastPointSizeScale
Definition: TGLScene.h:139
static Bool_t ComparePhysicalVolumes(const TGLPhysicalShape *shape1, const TGLPhysicalShape *shape2)
Compare 'shape1' and 'shape2' bounding box volumes - return kTRUE if 'shape1' bigger than 'shape2'.
Definition: TGLScene.cxx:356
LogicalShapeMap_t fLogicalShapes
Definition: TGLScene.h:125
virtual void PreDraw(TGLRnrCtx &rnrCtx)
Initialize rendering.
Definition: TGLScene.cxx:568
virtual Int_t DestroyPhysicals()
Destroy physical shapes.
Definition: TGLScene.cxx:1183
virtual void RenderAllPasses(TGLRnrCtx &rnrCtx, DrawElementPtrVec_t &elVec, Bool_t check_timeout)
Do full rendering of scene.
Definition: TGLScene.cxx:725
virtual void AdoptLogical(TGLLogicalShape &shape)
Adopt dynamically created logical 'shape' - add to internal map and take responsibility for deleting.
Definition: TGLScene.cxx:1018
virtual void RenderTransp(TGLRnrCtx &rnrCtx)
Render transparent elements.
Definition: TGLScene.cxx:623
static Bool_t IsOutside(const TGLBoundingBox &box, const TGLPlaneSet_t &planes)
Check if box is outside of all planes.
Definition: TGLScene.cxx:1543
TGLScene(const TGLScene &)
virtual void PostDraw(TGLRnrCtx &rnrCtx)
Called after the rendering is finished.
Definition: TGLScene.cxx:707
void EndSmartRefresh()
Wipes logicals in refresh-cache.
Definition: TGLScene.cxx:1439
virtual Bool_t DestroyLogical(TObject *logid, Bool_t mustFind=kTRUE)
Destroy logical shape defined by unique 'ID'.
Definition: TGLScene.cxx:1036
std::vector< const TGLPhysicalShape * > ShapeVec_t
Definition: TGLScene.h:72
Bool_t fInSmartRefresh
Definition: TGLScene.h:135
UInt_t SizeOfScene() const
Return memory cost of scene.
Definition: TGLScene.cxx:1491
PhysicalShapeMap_t::iterator PhysicalShapeMapIt_t
Definition: TGLScene.h:49
LogicalShapeMap_t fSmartRefreshCache
Definition: TGLScene.h:136
virtual void RenderHighlight(TGLRnrCtx &rnrCtx, DrawElementPtrVec_t &elVec)
Definition: TGLScene.cxx:672
PhysicalShapeMap_t fPhysicalShapes
Definition: TGLScene.h:126
std::vector< DrawElement_t >::iterator DrawElementVec_i
Definition: TGLScene.h:66
LogicalShapeMap_t::iterator LogicalShapeMapIt_t
Definition: TGLScene.h:43
PhysicalShapeMap_t::value_type PhysicalShapeMapValueType_t
Definition: TGLScene.h:48
virtual void RenderOpaque(TGLRnrCtx &rnrCtx)
Render opaque elements.
Definition: TGLScene.cxx:613
LogicalShapeMap_t::value_type LogicalShapeMapValueType_t
Definition: TGLScene.h:42
TGLScene & operator=(const TGLScene &)
std::vector< DrawElement_t * > DrawElementPtrVec_t
Definition: TGLScene.h:68
std::map< TObject *, TGLLogicalShape * > LogicalShapeMap_t
Definition: TGLScene.h:41
virtual Bool_t ResolveSelectRecord(TGLSelectRecord &rec, Int_t curIdx)
Process selection record rec.
Definition: TGLScene.cxx:950
ShapeVec_t::iterator ShapeVec_i
Definition: TGLScene.h:73
virtual void UpdatePhysioLogical(TObject *logid, Double_t *trans, UChar_t *col)
Reposition/recolor physical for given logical (assume TGLObject and a single physical).
Definition: TGLScene.cxx:1352
virtual void RenderSelOpaqueForHighlight(TGLRnrCtx &rnrCtx)
Render selected opaque elements for highlight.
Definition: TGLScene.cxx:653
virtual Bool_t DestroyPhysical(UInt_t phid)
Destroy physical shape defined by unique 'ID'.
Definition: TGLScene.cxx:1159
static void RGBAFromColorIdx(Float_t rgba[4], Color_t ci, Char_t transp=0)
Fill rgba color from ROOT color-index ci and transparency (0->100).
Definition: TGLScene.cxx:1532
virtual void RebuildSceneInfo(TGLRnrCtx &rnrCtx)
Major change in scene, need to rebuild all-element draw-vector and sort it.
Definition: TGLScene.cxx:382
virtual Int_t DestroyLogicals()
Destroy all logical shapes in scene.
Definition: TGLScene.cxx:1073
TGLLogicalShape * FindLogicalSmartRefresh(TObject *ID) const
Find and return logical shape identified by unique 'ID' in refresh-cache.
Definition: TGLScene.cxx:1455
virtual void LodifySceneInfo(TGLRnrCtx &rnrCtx)
Setup LOD-dependant values in scene-info.
Definition: TGLScene.cxx:544
virtual void UpdateSceneInfo(TGLRnrCtx &rnrCtx)
Fill scene-info with information needed for rendering, take into account the render-context (viewer s...
Definition: TGLScene.cxx:426
virtual void RenderElements(TGLRnrCtx &rnrCtx, DrawElementPtrVec_t &elVec, Bool_t check_timeout, const TGLPlaneSet_t *clipPlanes=0)
Render DrawElements in elementVec with given timeout.
Definition: TGLScene.cxx:893
LogicalShapeMap_t & RefLogicalShapes()
Definition: TGLScene.h:216
virtual ~TGLScene()
Destroy scene objects.
Definition: TGLScene.cxx:292
std::vector< DrawElement_t * >::iterator DrawElementPtrVec_i
Definition: TGLScene.h:69
virtual void UpdateLogical(TObject *logid)
Drop display-lists for the logical (assume TGLObject/direct rendering).
Definition: TGLScene.cxx:1283
virtual void RenderSelTranspForHighlight(TGLRnrCtx &rnrCtx)
Render selected transparent elements for highlight.
Definition: TGLScene.cxx:663
TGLContextIdentity * fGLCtxIdentity
Definition: TGLScene.h:131
void DumpMapSizes() const
Print sizes of logical and physical-shape maps.
Definition: TGLScene.cxx:1523
virtual void UpdatePhysical(UInt_t phid, Double_t *trans, UChar_t *col)
Reposition/recolor physical shape.
Definition: TGLScene.cxx:1304
virtual TGLLogicalShape * FindLogical(TObject *logid) const
Find and return logical shape identified by unique logid.
Definition: TGLScene.cxx:1107
virtual UInt_t GetMaxPhysicalID()
Returns the maximum used physical id.
Definition: TGLScene.cxx:1231
UInt_t BeginSmartRefresh()
Moves logicals that support smart-refresh to intermediate cache.
Definition: TGLScene.cxx:1416
virtual void CalcBoundingBox() const
Encapsulates all physical shapes bounding box with axes aligned box.
Definition: TGLScene.cxx:977
static Bool_t ComparePhysicalDiagonals(const TGLPhysicalShape *shape1, const TGLPhysicalShape *shape2)
Compare 'shape1' and 'shape2' bounding box volumes - return kTRUE if 'shape1' bigger than 'shape2'.
Definition: TGLScene.cxx:366
Standard selection record including information about containing scene and details ob out selected ob...
Base class for GL viewers.
Definition: TGLViewerBase.h:37
Mother of all ROOT objects.
Definition: TObject.h:37
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition: fillpatterns.C:1
const TGLPhysicalShape * fPhysical
Definition: TGLScene.h:55
DrawElement_t(const TGLPhysicalShape *pshp=0)
Definition: TGLScene.h:61
Definition: civetweb.c:1856