12 #ifndef ROOT_TGLScene_H
13 #define ROOT_TGLScene_H
23 class TGLLogicalShape;
24 class TGLPhysicalShape;
26 class TGLContextIdentity;
28 class TGLScene :
public TGLSceneBase
31 TGLScene(
const TGLScene&);
32 TGLScene& operator=(
const TGLScene&);
35 static Bool_t ComparePhysicalVolumes(
const TGLPhysicalShape* shape1,
36 const TGLPhysicalShape* shape2);
37 static Bool_t ComparePhysicalDiagonals(
const TGLPhysicalShape* shape1,
38 const TGLPhysicalShape* shape2);
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;
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;
55 const TGLPhysicalShape* fPhysical;
61 DrawElement_t(
const TGLPhysicalShape* pshp=0) :
62 fPhysical(pshp), fPixelSize(0), fPixelLOD(0), fFinalLOD(0) {}
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;
72 typedef std::vector<const TGLPhysicalShape*> ShapeVec_t;
73 typedef ShapeVec_t::iterator ShapeVec_i;
78 class TSceneInfo :
public TGLSceneInfo
81 Bool_t CmpDrawElements(
const DrawElement_t& de1,
const DrawElement_t& de2);
84 void ClearDrawElementVec(DrawElementVec_t& vec, Int_t maxSize);
85 void ClearDrawElementPtrVec(DrawElementPtrVec_t& vec, Int_t maxSize);
88 ShapeVec_t fShapesOfInterest;
90 DrawElementVec_t fVisibleElements;
93 DrawElementPtrVec_t fOpaqueElements;
94 DrawElementPtrVec_t fTranspElements;
95 DrawElementPtrVec_t fSelOpaqueElements;
96 DrawElementPtrVec_t fSelTranspElements;
98 TSceneInfo(TGLViewerBase* view=0, TGLScene* scene=0);
99 virtual ~TSceneInfo();
101 void ClearAfterRebuild();
102 void ClearAfterUpdate();
104 void Lodify(TGLRnrCtx& ctx);
115 std::map<TClass*, UInt_t> fByShapeCnt;
117 void ResetDrawStats();
118 void UpdateDrawStats(
const TGLPhysicalShape& shape, Short_t lod);
119 void DumpDrawStats();
121 friend class TSceneInfo;
125 LogicalShapeMap_t fLogicalShapes;
126 PhysicalShapeMap_t fPhysicalShapes;
128 virtual void DestroyPhysicalInternal(PhysicalShapeMapIt_t pit);
131 TGLContextIdentity * fGLCtxIdentity;
132 void ReleaseGLCtxIdentity();
135 Bool_t fInSmartRefresh;
136 mutable LogicalShapeMap_t fSmartRefreshCache;
139 Float_t fLastPointSizeScale;
140 Float_t fLastLineWidthScale;
149 virtual void CalcBoundingBox()
const;
151 virtual TSceneInfo* CreateSceneInfo(TGLViewerBase* view);
152 virtual void RebuildSceneInfo(TGLRnrCtx& rnrCtx);
153 virtual void UpdateSceneInfo(TGLRnrCtx& rnrCtx);
154 virtual void LodifySceneInfo(TGLRnrCtx& rnrCtx);
158 virtual void PreDraw (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);
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);
185 virtual Bool_t ResolveSelectRecord(TGLSelectRecord& rec, Int_t curIdx);
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;
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();
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);
216 LogicalShapeMap_t& RefLogicalShapes() {
return fLogicalShapes; }
222 UInt_t BeginSmartRefresh();
223 void EndSmartRefresh();
224 TGLLogicalShape* FindLogicalSmartRefresh(TObject* ID)
const;
230 TGLContextIdentity* GetGLCtxIdentity()
const {
return fGLCtxIdentity; }
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);