71 if (vec.capacity() > (
size_t) maxSize) {
73 foo.reserve((
size_t) maxSize);
87 if (vec.capacity() > (
size_t) maxSize) {
89 foo.reserve((
size_t) maxSize);
103 Int_t maxSize = (
Int_t) fShapesOfInterest.size();
105 ClearDrawElementVec(fVisibleElements, maxSize);
115 Int_t maxSize = (
Int_t) fShapesOfInterest.size();
117 ClearDrawElementPtrVec(fOpaqueElements, maxSize);
118 ClearDrawElementPtrVec(fTranspElements, maxSize);
119 ClearDrawElementPtrVec(fSelOpaqueElements, maxSize);
120 ClearDrawElementPtrVec(fSelTranspElements, maxSize);
130 for (
DrawElementVec_i i = fVisibleElements.begin(); i != fVisibleElements.end(); ++i)
131 i->fPhysical->QuantizeShapeLOD(i->fPixelLOD, ctx.
CombiLOD(), i->fFinalLOD);
142 fOpaqueElements.clear();
143 fTranspElements.clear();
144 fSelOpaqueElements.clear();
145 fSelTranspElements.clear();
147 for (
DrawElementVec_i i = fVisibleElements.begin(); i != fVisibleElements.end(); ++i)
149 if (i->fPhysical->IsSelected())
151 if (i->fPhysical->IsTransparent())
152 fSelTranspElements.push_back(&*i);
154 fSelOpaqueElements.push_back(&*i);
156 if (i->fPhysical->IsTransparent())
157 fTranspElements.push_back(&*i);
159 fOpaqueElements.push_back(&*i);
205 std::map<TClass*, UInt_t>::iterator it = fByShapeCnt.find(logIsA);
206 if (it == fByShapeCnt.end()) {
208 it = fByShapeCnt.insert(std::make_pair(logIsA, 0u)).first;
224 out +=
Form(
"Drew scene (%s / %i LOD) - %i (Op %i Trans %i) %i pixel\n",
226 fOpaqueCnt + fTranspCnt, fOpaqueCnt, fTranspCnt, fAsPixelCnt);
227 out +=
Form(
"\tInner phys nums: physicals=%d, of_interest=%lu, visible=%lu, op=%lu, trans=%lu",
229 (
ULong_t)fShapesOfInterest.size(), (
ULong_t)fVisibleElements.size(),
230 (
ULong_t)fOpaqueElements.size(), (
ULong_t)fTranspElements.size());
235 out +=
"\n\tStatistics by shape:\n";
236 std::map<TClass*, UInt_t>::const_iterator it = fByShapeCnt.begin();
237 while (it != fByShapeCnt.end()) {
238 out +=
Form(
"\t%-20s %u\n", it->first->GetName(), it->second);
242 Info(
"TGLScene::DumpDrawStats()",
"%s",out.
Data());
320 lit->second->DLCachePurge();
329 lit->second->DLCacheDrop();
385 if (sinfo == 0 || sinfo->
GetScene() !=
this) {
386 Error(
"TGLScene::RebuildSceneInfo",
"Scene mismatch.");
429 if (sinfo == 0 || sinfo->
GetScene() !=
this) {
430 Error(
"TGLScene::UpdateSceneInfo",
"Scene mismatch.");
445 Int_t checkCount = 0;
451 ++phys, ++checkCount)
468 std::vector<TGLPlane>::iterator
pi = sinfo->
ClipPlanes().begin();
482 std::vector<TGLPlane>::iterator
pi = sinfo->
ClipPlanes().begin();
527 Warning(
"TGLScene::UpdateSceneInfo",
528 "Timeout reached, not all elements processed.");
547 if (sinfo == 0 || sinfo->
GetScene() !=
this) {
548 Error(
"TGLScene::LodifySceneInfo",
"Scene mismatch.");
571 if (sinfo == 0 || sinfo->
GetScene() !=
this) {
573 Error(
"TGLScene::PreDraw",
"%s",
Form(
"SceneInfo mismatch (0x%lx, '%s').",
574 (
ULong_t)si, si ? si->IsA()->GetName() :
"<>"));
596 lit->second->DLCacheClear();
677 glEnable(GL_STENCIL_TEST);
682 glStencilFunc(GL_ALWAYS, 0x1, 0x1);
683 glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
684 glClear(GL_STENCIL_BUFFER_BIT);
692 glStencilFunc(GL_NOTEQUAL, 0x1, 0x1);
693 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
699 glDisable(GL_STENCIL_TEST);
745 glEnable(GL_LIGHTING);
749 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,
GL_TRUE);
750 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
751 glDisable(GL_CULL_FACE);
770 glDisable(GL_LIGHTING);
771 glDisable(GL_CULL_FACE);
772 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
781 for (
Int_t i = 0; i < reqPasses; ++i)
792 glEnable(GL_POLYGON_OFFSET_FILL);
793 glPolygonOffset(0.5f, 0.5f);
799 glDisable(GL_POLYGON_OFFSET_FILL);
800 glDisable(GL_LIGHTING);
808 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
827 Info(
"TGLScene::RenderAllPasses()",
828 "%ld active clip planes", (
Long_t)planeSet.size());
832 glGetIntegerv(GL_MAX_CLIP_PLANES, &maxGLPlanes);
833 UInt_t maxPlanes = maxGLPlanes;
835 if (planeSet.size() < maxPlanes) {
836 maxPlanes = planeSet.size();
843 for (
UInt_t ii=0; ii<maxPlanes; ii++) {
844 glClipPlane(GL_CLIP_PLANE0+ii, planeSet[ii].CArr());
845 glEnable(GL_CLIP_PLANE0+ii);
857 std::vector<TGLPlane> activePlanes;
858 for (planeInd=0; planeInd<maxPlanes; planeInd++)
860 activePlanes.push_back(planeSet[planeInd]);
863 glClipPlane(GL_CLIP_PLANE0+planeInd, p.
CArr());
864 glEnable(GL_CLIP_PLANE0+planeInd);
871 glClipPlane(GL_CLIP_PLANE0+planeInd, p.
CArr());
875 for (planeInd=0; planeInd<maxPlanes; planeInd++) {
876 glDisable(GL_CLIP_PLANE0+planeInd);
882 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,
GL_FALSE);
883 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
884 glEnable(GL_CULL_FACE);
885 glEnable(GL_LIGHTING);
918 glPushName(drawShape->
ID());
919 drawShape->
Draw(rnrCtx);
927 if (check_timeout && (drawCount % 2000) == 0 &&
931 Warning(
"TGLScene::RenderElements",
932 "Timeout reached, not all elements rendered.");
952 if (curIdx >= rec.
GetN())
979 Double_t xMin, xMax, yMin, yMax, zMin, zMax;
980 xMin = xMax = yMin = yMax = zMin = zMax = 0.0;
985 physicalShape = physicalShapeIt->second;
993 xMin =
box.XMin(); xMax =
box.XMax();
994 yMin =
box.YMin(); yMax =
box.YMax();
995 zMin =
box.ZMin(); zMax =
box.ZMax();
997 if (
box.XMin() < xMin) { xMin =
box.XMin(); }
998 if (
box.XMax() > xMax) { xMax =
box.XMax(); }
999 if (
box.YMin() < yMin) { yMin =
box.YMin(); }
1000 if (
box.YMax() > yMax) { yMax =
box.YMax(); }
1001 if (
box.ZMin() < zMin) { zMin =
box.ZMin(); }
1002 if (
box.ZMax() > zMax) { zMax =
box.ZMax(); }
1021 Error(
"TGLScene::AdoptLogical",
"expected ModifyLock");
1039 Error(
"TGLScene::DestroyLogical",
"expected ModifyLock");
1047 Error(
"TGLScene::DestroyLogical",
"logical not found in map.");
1059 Warning(
"TGLScene::DestroyLogical",
"an attached physical not found in map.");
1061 assert(logical->
Ref() == 0);
1076 Error(
"TGLScene::DestroyLogicals",
"expected ModifyLock");
1084 logicalShape = logicalShapeIt->second;
1086 if (logicalShape->
Ref() == 0) {
1088 delete logicalShape;
1132 Error(
"TGLScene::AdoptPhysical",
"expected ModifyLock");
1162 Error(
"TGLScene::DestroyPhysical",
"expected ModifyLock.");
1169 Error(
"TGLScene::DestroyPhysical::UpdatePhysical",
"physical not found.");
1186 Error(
"TGLScene::DestroyPhysicals",
"expected ModifyLock");
1198 if (lshp && lshp->
Ref() != 0)
1200 count += lshp->
Ref();
1286 Error(
"TGLScene::UpdateLogical",
"expected ModifyLock");
1293 Error(
"TGLScene::UpdateLogical",
"logical not found");
1297 log->DLCacheClear();
1298 log->UpdateBoundingBox();
1307 Error(
"TGLScene::UpdatePhysical",
"expected ModifyLock");
1314 Error(
"TGLScene::UpdatePhysical",
"physical not found");
1328 Error(
"TGLScene::UpdatePhysical",
"expected ModifyLock");
1335 Error(
"TGLScene::UpdatePhysical",
"physical not found");
1355 Error(
"TGLScene::UpdatePhysioLogical",
"expected ModifyLock");
1362 Error(
"TGLScene::UpdatePhysioLogical",
"logical not found");
1366 if (
log->Ref() != 1) {
1367 Warning(
"TGLScene::UpdatePhysioLogical",
"expecting a single physical (%d).",
log->Ref());
1382 Error(
"TGLScene::UpdatePhysioLogical",
"expected ModifyLock");
1389 Error(
"TGLScene::UpdatePhysioLogical",
"logical not found");
1393 if (
log->Ref() != 1) {
1394 Warning(
"TGLScene::UpdatePhysioLogical",
"expecting a single physical (%d).",
log->Ref());
1423 if (i->second->KeepDuringSmartRefresh() ==
kFALSE) {
1464 Warning(
"TGLScene::FindLogicalSmartRefresh",
"Wrong renderer-type found in cache.");
1493 UInt_t size =
sizeof(*this);
1495 printf(
"Size: Scene Only %u\n", size);
1500 logicalShape = logicalShapeIt->second;
1501 size +=
sizeof(*logicalShape);
1505 printf(
"Size: Scene + Logical Shapes %u\n", size);
1510 physicalShape = physicalShapeIt->second;
1511 size +=
sizeof(*physicalShape);
1515 printf(
"Size: Scene + Logical Shapes + Physical Shapes %u\n", size);
1525 printf(
"Scene: %u Logicals / %u Physicals\n",
1535 if(
c)
c->GetRGB(rgba[0], rgba[1], rgba[2]);
1536 else rgba[0] = rgba[1] = rgba[2] = 0.5;
1537 rgba[3] = 1.0f - transp/100.0f;
void Info(const char *location, const char *msgfmt,...)
void Error(const char *location, const char *msgfmt,...)
void Warning(const char *location, const char *msgfmt,...)
std::vector< TGLPlane > TGLPlaneSet_t
std::vector< TGLPlane >::const_iterator TGLPlaneSet_ci
char * Form(const char *fmt,...)
TClass instances represent classes, structs and namespaces in the ROOT type system.
The color creation and management class.
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
Double_t Diagonal() const
void SetAligned(const TGLVertex3 &lowVertex, const TGLVertex3 &highVertex)
Set ALIGNED box from two low/high vertices.
Rgl::EOverlap Overlap(const TGLPlane &plane) const
Find overlap (Inside, Outside, Partial) of plane c.f. bounding box.
Bool_t OfInterest(const TGLBoundingBox &box, Bool_t ignoreSize) const
Calculate if the an object defined by world frame bounding box is 'of interest' to the camera.
Identifier of a shared GL-context.
Bool_t TakeLock(ELock lock) const
Lock the object in mode 'lock'.
Bool_t ReleaseLock(ELock lock) const
Release current lock, make sure it the same as the 'lock' argument.
Abstract logical shape - a GL 'drawable' - base for all shapes - faceset sphere etc.
UInt_t UnrefFirstPhysical()
Unreferenced first physical in the list, returning its id and making it fit for destruction somewhere...
TObject * GetExternal() const
void DestroyPhysicals()
Destroy all physicals attached to this logical.
static void SetEnvDefaults()
virtual void UpdateBoundingBox()
TGLScene * fScene
Shape's bounding box.
virtual void DLCacheClear()
Clear all entries for all LODs for this drawable from the display list cache but keeping the reserved...
virtual Bool_t IgnoreSizeForOfInterest() const
Return true if size of this shape should be ignored when determining if the object should be drawn.
static TClass * GetGLRenderer(TClass *isa)
Return direct-rendering GL class for class isa.
Concrete physical shape - a GL drawable.
void SetTransform(const TGLMatrix &transform)
const TGLBoundingBox & BoundingBox() const
const TGLLogicalShape * GetLogical() const
virtual void CalculateShapeLOD(TGLRnrCtx &rnrCtx, Float_t &pixSize, Short_t &shapeLOD) const
Calculate shape-lod, suitable for use under projection defined by 'rnrCtx', taking account of which l...
void SetDiffuseColor(const Float_t rgba[4])
Set color from ROOT color index and transparency [0,100].
Bool_t IsTransparent() const
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw physical shape, using LOD flags, potential from display list cache.
3D plane class - of format Ax + By + Cz + D = 0
void Negate()
Negate the plane.
const Double_t * CArr() const
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
void SetShapeLOD(Short_t LOD)
Short_t SceneStyle() const
Float_t SceneOLLineW() const
void SetShapePixSize(Float_t ps)
void SetHighlightOutline(Bool_t ho)
Bool_t IsStopwatchRunning() const
Short_t ViewerLOD() const
Bool_t HasStopwatchTimedOut()
Check if the stopwatch went beyond the render time limit.
void SetDrawPass(Short_t dpass)
Float_t SceneWFLineW() const
static const char * StyleName(Short_t style)
Return string describing the style.
TGLSceneInfo * GetSceneInfo()
TGLContextIdentity * GetGLCtxIdentity() const
Scene base-class – provides basic interface expected by the TGLViewer or its sub-classes:
virtual void PostDraw(TGLRnrCtx &rnrCtx)
Finalize drawing.
TGLBoundingBox fBoundingBox
virtual void LodifySceneInfo(TGLRnrCtx &ctx)
Setup LOD-dependant values in scene-info.
UInt_t GetMinorStamp() const
void InvalidateBoundingBox()
virtual void PreDraw(TGLRnrCtx &rnrCtx)
Perform basic pre-render initialization:
virtual void RebuildSceneInfo(TGLRnrCtx &ctx)
Fill scene-info with very basic information that is practically view independent.
virtual void UpdateSceneInfo(TGLRnrCtx &ctx)
Fill scene-info with information needed for rendering, take into account the render-context (viewer s...
void TagViewersChanged()
Tag all viewers as changed.
Base class for extended scene context.
Bool_t ShouldClip() const
std::vector< TGLPlane > & ClipPlanes()
std::vector< TGLPlane > & FrustumPlanes()
void ResetUpdateTimeouted()
TGLSceneBase * GetScene() const
DrawElementPtrVec_t fSelTranspElements
void PostDraw()
Clean-up after drawing, nothing to be done here.
DrawElementPtrVec_t fTranspElements
void ClearAfterRebuild()
Clear DrawElementVector fVisibleElement and optionally resize it so that it doesn't take more space t...
void ResetDrawStats()
Reset draw statistics.
void DumpDrawStats()
Output draw stats to Info stream.
TSceneInfo(TGLViewerBase *view=0, TGLScene *scene=0)
Constructor.
DrawElementVec_t fVisibleElements
void PreDraw()
Prepare for drawing - fill DrawElementPtrVectors from the contents of fVisibleElements if there was s...
virtual ~TSceneInfo()
Destructor.
DrawElementPtrVec_t fOpaqueElements
ShapeVec_t fShapesOfInterest
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.
void UpdateDrawStats(const TGLPhysicalShape &shape, Short_t lod)
Update draw stats, for newly drawn 'shape'.
DrawElementPtrVec_t fSelOpaqueElements
void ClearAfterUpdate()
Clear DrawElementPtrVectors and optionally resize them so that they don't take more space then requir...
void Lodify(TGLRnrCtx &ctx)
Quantize LODs for given render-context.
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.
TGLScene provides management and rendering of ROOT's default 3D /object representation as logical and...
Float_t fLastLineWidthScale
virtual void RenderSelOpaque(TGLRnrCtx &rnrCtx)
Render selected opaque elements.
std::vector< DrawElement_t > DrawElementVec_t
virtual TGLPhysicalShape * FindPhysical(UInt_t phid) const
Find and return physical shape identified by unique 'ID'.
PhysicalShapeMap_t::const_iterator PhysicalShapeMapCIt_t
virtual TSceneInfo * CreateSceneInfo(TGLViewerBase *view)
Create a scene-info instance appropriate for this scene class.
virtual void DestroyPhysicalInternal(PhysicalShapeMapIt_t pit)
Virtual function to destroy a physical.
virtual Bool_t BeginUpdate()
Put scene in update mode, return true if lock acquired.
virtual void AdoptPhysical(TGLPhysicalShape &shape)
Adopt dynamically created physical 'shape' - add to internal map and take responsibility for deleting...
void ReleaseGLCtxIdentity()
Release all GL resources for current context identity.
LogicalShapeMap_t::const_iterator LogicalShapeMapCIt_t
virtual void RenderSelTransp(TGLRnrCtx &rnrCtx)
Render selected transparent elements.
virtual void EndUpdate(Bool_t minorChange=kTRUE, Bool_t sceneChanged=kTRUE, Bool_t updateViewers=kTRUE)
Exit scene update mode.
Float_t fLastPointSizeScale
static Bool_t ComparePhysicalVolumes(const TGLPhysicalShape *shape1, const TGLPhysicalShape *shape2)
Compare 'shape1' and 'shape2' bounding box volumes - return kTRUE if 'shape1' bigger than 'shape2'.
LogicalShapeMap_t fLogicalShapes
virtual void PreDraw(TGLRnrCtx &rnrCtx)
Initialize rendering.
virtual Int_t DestroyPhysicals()
Destroy physical shapes.
virtual void RenderAllPasses(TGLRnrCtx &rnrCtx, DrawElementPtrVec_t &elVec, Bool_t check_timeout)
Do full rendering of scene.
virtual void AdoptLogical(TGLLogicalShape &shape)
Adopt dynamically created logical 'shape' - add to internal map and take responsibility for deleting.
virtual void RenderTransp(TGLRnrCtx &rnrCtx)
Render transparent elements.
static Bool_t IsOutside(const TGLBoundingBox &box, const TGLPlaneSet_t &planes)
Check if box is outside of all planes.
virtual void PostDraw(TGLRnrCtx &rnrCtx)
Called after the rendering is finished.
void EndSmartRefresh()
Wipes logicals in refresh-cache.
virtual Bool_t DestroyLogical(TObject *logid, Bool_t mustFind=kTRUE)
Destroy logical shape defined by unique 'ID'.
std::vector< const TGLPhysicalShape * > ShapeVec_t
UInt_t SizeOfScene() const
Return memory cost of scene.
PhysicalShapeMap_t::iterator PhysicalShapeMapIt_t
LogicalShapeMap_t fSmartRefreshCache
virtual void RenderHighlight(TGLRnrCtx &rnrCtx, DrawElementPtrVec_t &elVec)
PhysicalShapeMap_t fPhysicalShapes
std::vector< DrawElement_t >::iterator DrawElementVec_i
LogicalShapeMap_t::iterator LogicalShapeMapIt_t
PhysicalShapeMap_t::value_type PhysicalShapeMapValueType_t
virtual void RenderOpaque(TGLRnrCtx &rnrCtx)
Render opaque elements.
LogicalShapeMap_t::value_type LogicalShapeMapValueType_t
std::vector< DrawElement_t * > DrawElementPtrVec_t
std::map< TObject *, TGLLogicalShape * > LogicalShapeMap_t
virtual Bool_t ResolveSelectRecord(TGLSelectRecord &rec, Int_t curIdx)
Process selection record rec.
ShapeVec_t::iterator ShapeVec_i
virtual void UpdatePhysioLogical(TObject *logid, Double_t *trans, UChar_t *col)
Reposition/recolor physical for given logical (assume TGLObject and a single physical).
virtual void RenderSelOpaqueForHighlight(TGLRnrCtx &rnrCtx)
Render selected opaque elements for highlight.
virtual Bool_t DestroyPhysical(UInt_t phid)
Destroy physical shape defined by unique 'ID'.
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).
virtual void RebuildSceneInfo(TGLRnrCtx &rnrCtx)
Major change in scene, need to rebuild all-element draw-vector and sort it.
virtual Int_t DestroyLogicals()
Destroy all logical shapes in scene.
TGLLogicalShape * FindLogicalSmartRefresh(TObject *ID) const
Find and return logical shape identified by unique 'ID' in refresh-cache.
virtual void LodifySceneInfo(TGLRnrCtx &rnrCtx)
Setup LOD-dependant values in scene-info.
virtual void UpdateSceneInfo(TGLRnrCtx &rnrCtx)
Fill scene-info with information needed for rendering, take into account the render-context (viewer s...
virtual void RenderElements(TGLRnrCtx &rnrCtx, DrawElementPtrVec_t &elVec, Bool_t check_timeout, const TGLPlaneSet_t *clipPlanes=0)
Render DrawElements in elementVec with given timeout.
virtual ~TGLScene()
Destroy scene objects.
std::vector< DrawElement_t * >::iterator DrawElementPtrVec_i
virtual void UpdateLogical(TObject *logid)
Drop display-lists for the logical (assume TGLObject/direct rendering).
virtual void RenderSelTranspForHighlight(TGLRnrCtx &rnrCtx)
Render selected transparent elements for highlight.
TGLContextIdentity * fGLCtxIdentity
void DumpMapSizes() const
Print sizes of logical and physical-shape maps.
virtual void UpdatePhysical(UInt_t phid, Double_t *trans, UChar_t *col)
Reposition/recolor physical shape.
virtual TGLLogicalShape * FindLogical(TObject *logid) const
Find and return logical shape identified by unique logid.
virtual UInt_t GetMaxPhysicalID()
Returns the maximum used physical id.
UInt_t BeginSmartRefresh()
Moves logicals that support smart-refresh to intermediate cache.
virtual void CalcBoundingBox() const
Encapsulates all physical shapes bounding box with axes aligned box.
static Bool_t ComparePhysicalDiagonals(const TGLPhysicalShape *shape1, const TGLPhysicalShape *shape2)
Compare 'shape1' and 'shape2' bounding box volumes - return kTRUE if 'shape1' bigger than 'shape2'.
UInt_t GetItem(Int_t i) const
Standard selection record including information about containing scene and details ob out selected ob...
void SetSpecific(void *spec)
void SetTransparent(Bool_t t)
void SetPhysShape(TGLPhysicalShape *pshp)
void SetObject(TObject *obj)
void SetLogShape(TGLLogicalShape *lshp)
static Float_t GetPointSizeScale()
Get global point-size scale.
static Float_t GetLineWidthScale()
Returns global line-width scale.
static Float_t LineWidth()
Get the line-width, taking the global scaling into account.
3 component (x/y/z) vertex class.
Base class for GL viewers.
Mother of all ROOT objects.
const char * Data() const
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
static constexpr double pi