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, 0
x1, 0
x1);
683 glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
684 glClear(GL_STENCIL_BUFFER_BIT);
686 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
690 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
692 glStencilFunc(GL_NOTEQUAL, 0
x1, 0
x1);
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");
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 SetAligned(const TGLVertex3 &lowVertex, const TGLVertex3 &highVertex)
Set ALIGNED box from two low/high vertices.
DrawElementPtrVec_t fTranspElements
ShapeVec_t::iterator ShapeVec_i
Bool_t ShouldClip() const
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
std::vector< DrawElement_t > DrawElementVec_t
static Bool_t ComparePhysicalVolumes(const TGLPhysicalShape *shape1, const TGLPhysicalShape *shape2)
Compare 'shape1' and 'shape2' bounding box volumes - return kTRUE if 'shape1' bigger than 'shape2'...
virtual void EndUpdate(Bool_t minorChange=kTRUE, Bool_t sceneChanged=kTRUE, Bool_t updateViewers=kTRUE)
Exit scene update mode.
virtual void UpdatePhysioLogical(TObject *logid, Double_t *trans, UChar_t *col)
Reposition/recolor physical for given logical (assume TGLObject and a single physical).
virtual TGLLogicalShape * FindLogical(TObject *logid) const
Find and return logical shape identified by unique logid.
std::map< TObject *, TGLLogicalShape * > LogicalShapeMap_t
static constexpr double pi
TObject * GetExternal() const
virtual ~TGLScene()
Destroy scene objects.
const Double_t * CArr() const
virtual Bool_t IgnoreSizeForOfInterest() const
Return true if size of this shape should be ignored when determining if the object should be drawn...
LogicalShapeMap_t::iterator LogicalShapeMapIt_t
PhysicalShapeMap_t::value_type PhysicalShapeMapValueType_t
virtual void RenderTransp(TGLRnrCtx &rnrCtx)
Render transparent elements.
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...
static Bool_t ComparePhysicalDiagonals(const TGLPhysicalShape *shape1, const TGLPhysicalShape *shape2)
Compare 'shape1' and 'shape2' bounding box volumes - return kTRUE if 'shape1' bigger than 'shape2'...
const TGLBoundingBox & BoundingBox() const
virtual ~TSceneInfo()
Destructor.
Identifier of a shared GL-context.
void SetPhysShape(TGLPhysicalShape *pshp)
UInt_t SizeOfScene() const
Return memory cost of scene.
std::vector< TGLPlane >::const_iterator TGLPlaneSet_ci
virtual TGLPhysicalShape * FindPhysical(UInt_t phid) const
Find and return physical shape identified by unique 'ID'.
virtual void RenderSelOpaqueForHighlight(TGLRnrCtx &rnrCtx)
Render selected opaque elements for highlight.
Scene base-class – provides basic interface expected by the TGLViewer or its sub-classes: ...
void ResetUpdateTimeouted()
virtual void UpdateLogical(TObject *logid)
Drop display-lists for the logical (assume TGLObject/direct rendering).
virtual void RenderOpaque(TGLRnrCtx &rnrCtx)
Render opaque elements.
static void SetEnvDefaults()
PhysicalShapeMap_t::const_iterator PhysicalShapeMapCIt_t
void DestroyPhysicals()
Destroy all physicals attached to this logical.
TGLSceneInfo * GetSceneInfo()
LogicalShapeMap_t fSmartRefreshCache
LogicalShapeMap_t::value_type LogicalShapeMapValueType_t
virtual UInt_t GetMaxPhysicalID()
Returns the maximum used physical id.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
TGLBoundingBox fBoundingBox
virtual Bool_t ResolveSelectRecord(TGLSelectRecord &rec, Int_t curIdx)
Process selection record rec.
void SetShapeLOD(Short_t LOD)
void ClearAfterUpdate()
Clear DrawElementPtrVectors and optionally resize them so that they don't take more space then requir...
LogicalShapeMap_t fLogicalShapes
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...
Base class for GL viewers.
Concrete physical shape - a GL drawable.
PhysicalShapeMap_t::iterator PhysicalShapeMapIt_t
virtual void RenderSelTranspForHighlight(TGLRnrCtx &rnrCtx)
Render selected transparent elements for highlight.
virtual TSceneInfo * CreateSceneInfo(TGLViewerBase *view)
Create a scene-info instance appropriate for this scene class.
const char * Data() const
TGLScene * fScene
Shape's bounding box.
virtual void AdoptPhysical(TGLPhysicalShape &shape)
Adopt dynamically created physical 'shape' - add to internal map and take responsibility for deleting...
void SetTransparent(Bool_t t)
std::vector< TGLPlane > & FrustumPlanes()
std::vector< TGLPlane > & ClipPlanes()
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw physical shape, using LOD flags, potential from display list cache.
Double_t Diagonal() const
3 component (x/y/z) vertex class.
static Float_t GetPointSizeScale()
Get global point-size scale.
virtual void UpdatePhysical(UInt_t phid, Double_t *trans, UChar_t *col)
Reposition/recolor physical shape.
UInt_t BeginSmartRefresh()
Moves logicals that support smart-refresh to intermediate cache.
const TGLLogicalShape * GetLogical() const
void PostDraw()
Clean-up after drawing, nothing to be done here.
Short_t SceneStyle() const
virtual void UpdateSceneInfo(TGLRnrCtx &ctx)
Fill scene-info with information needed for rendering, take into account the render-context (viewer s...
TGLContextIdentity * GetGLCtxIdentity() const
void Info(const char *location, const char *msgfmt,...)
void UpdateDrawStats(const TGLPhysicalShape &shape, Short_t lod)
Update draw stats, for newly drawn 'shape'.
void DumpMapSizes() const
Print sizes of logical and physical-shape maps.
Float_t SceneWFLineW() const
static const char * StyleName(Short_t style)
Return string describing the style.
Float_t fLastLineWidthScale
PhysicalShapeMap_t fPhysicalShapes
TGLContextIdentity * fGLCtxIdentity
virtual Bool_t DestroyLogical(TObject *logid, Bool_t mustFind=kTRUE)
Destroy logical shape defined by unique 'ID'.
void Error(const char *location, const char *msgfmt,...)
void ClearAfterRebuild()
Clear DrawElementVector fVisibleElement and optionally resize it so that it doesn't take more space t...
void DumpDrawStats()
Output draw stats to Info stream.
DrawElementPtrVec_t fSelTranspElements
Float_t SceneOLLineW() const
Short_t ViewerLOD() const
virtual void RebuildSceneInfo(TGLRnrCtx &ctx)
Fill scene-info with very basic information that is practically view independent. ...
void SetShapePixSize(Float_t ps)
void SetHighlightOutline(Bool_t ho)
TGLPhysicalShape * fFirstPhysical
physical instance ref counting
TGLLogicalShape * FindLogicalSmartRefresh(TObject *ID) const
Find and return logical shape identified by unique 'ID' in refresh-cache.
Standard selection record including information about containing scene and details ob out selected ob...
virtual void GetRGB(Float_t &r, Float_t &g, Float_t &b) const
UInt_t UnrefFirstPhysical()
Unreferenced first physical in the list, returning its id and making it fit for destruction somewhere...
virtual void CalcBoundingBox() const
Encapsulates all physical shapes bounding box with axes aligned box.
virtual Bool_t DestroyPhysical(UInt_t phid)
Destroy physical shape defined by unique 'ID'.
std::vector< DrawElement_t * > DrawElementPtrVec_t
char * Form(const char *fmt,...)
static TClass * GetGLRenderer(TClass *isa)
Return direct-rendering GL class for class isa.
void SetObject(TObject *obj)
The ROOT global object gROOT contains a list of all defined classes.
Bool_t ReleaseLock(ELock lock) const
Release current lock, make sure it the same as the 'lock' argument.
virtual void LodifySceneInfo(TGLRnrCtx &ctx)
Setup LOD-dependant values in scene-info.
void Warning(const char *location, const char *msgfmt,...)
void InvalidateBoundingBox()
virtual void RenderHighlight(TGLRnrCtx &rnrCtx, DrawElementPtrVec_t &elVec)
Bool_t IsTransparent() const
Abstract logical shape - a GL 'drawable' - base for all shapes - faceset sphere etc.
void Lodify(TGLRnrCtx &ctx)
Quantize LODs for given render-context.
void EndSmartRefresh()
Wipes logicals in refresh-cache.
static const double x1[5]
Float_t fLastPointSizeScale
std::vector< TGLPlane > TGLPlaneSet_t
virtual Int_t DestroyPhysicals()
Destroy physical shapes.
TGLSceneBase * GetScene() const
virtual void RenderElements(TGLRnrCtx &rnrCtx, DrawElementPtrVec_t &elVec, Bool_t check_timeout, const TGLPlaneSet_t *clipPlanes=0)
Render DrawElements in elementVec with given timeout.
void Negate()
Negate the plane.
UInt_t GetItem(Int_t i) const
virtual void DestroyPhysicalInternal(PhysicalShapeMapIt_t pit)
Virtual function to destroy a physical.
std::vector< const TGLPhysicalShape * > ShapeVec_t
void SetTransform(const TGLMatrix &transform)
virtual void UpdateBoundingBox()
virtual void RenderSelOpaque(TGLRnrCtx &rnrCtx)
Render selected opaque elements.
virtual void PostDraw(TGLRnrCtx &rnrCtx)
Called after the rendering is finished.
void PreDraw()
Prepare for drawing - fill DrawElementPtrVectors from the contents of fVisibleElements if there was s...
The color creation and management class.
virtual void RenderSelTransp(TGLRnrCtx &rnrCtx)
Render selected transparent elements.
Bool_t TakeLock(ELock lock) const
Lock the object in mode 'lock'.
void SetLogShape(TGLLogicalShape *lshp)
void SetDrawPass(Short_t dpass)
Rgl::EOverlap Overlap(const TGLPlane &plane) const
Find overlap (Inside, Outside, Partial) of plane c.f. bounding box.
Mother of all ROOT objects.
virtual void RebuildSceneInfo(TGLRnrCtx &rnrCtx)
Major change in scene, need to rebuild all-element draw-vector and sort it.
Concrete class describing an orientated (free) or axis aligned box of 8 vertices. ...
void ReleaseGLCtxIdentity()
Release all GL resources for current context identity.
static Bool_t IsOutside(const TGLBoundingBox &box, const TGLPlaneSet_t &planes)
Check if box is outside of all planes.
DrawElementPtrVec_t fOpaqueElements
static Float_t GetLineWidthScale()
Returns global line-width scale.
TGLScene provides management and rendering of ROOT's default 3D /object representation as logical and...
UInt_t GetMinorStamp() const
virtual void RenderAllPasses(TGLRnrCtx &rnrCtx, DrawElementPtrVec_t &elVec, Bool_t check_timeout)
Do full rendering of scene.
Bool_t HasStopwatchTimedOut()
Check if the stopwatch went beyond the render time limit.
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...
DrawElementPtrVec_t fSelOpaqueElements
Base class for extended scene context.
virtual void UpdateSceneInfo(TGLRnrCtx &rnrCtx)
Fill scene-info with information needed for rendering, take into account the render-context (viewer s...
virtual Bool_t BeginUpdate()
Put scene in update mode, return true if lock acquired.
void TagViewersChanged()
Tag all viewers as changed.
static Float_t LineWidth()
Get the line-width, taking the global scaling into account.
virtual void PreDraw(TGLRnrCtx &rnrCtx)
Perform basic pre-render initialization:
Bool_t IsStopwatchRunning() const
virtual void AdoptLogical(TGLLogicalShape &shape)
Adopt dynamically created logical 'shape' - add to internal map and take responsibility for deleting...
std::vector< DrawElement_t >::iterator DrawElementVec_i
TSceneInfo(TGLViewerBase *view=0, TGLScene *scene=0)
Constructor.
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).
DrawElementVec_t fVisibleElements
void SetSpecific(void *spec)
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...
std::vector< DrawElement_t * >::iterator DrawElementPtrVec_i
3D plane class - of format Ax + By + Cz + D = 0
virtual Int_t DestroyLogicals()
Destroy all logical shapes in scene.
LogicalShapeMap_t::const_iterator LogicalShapeMapCIt_t
virtual void LodifySceneInfo(TGLRnrCtx &rnrCtx)
Setup LOD-dependant values in scene-info.
void ResetDrawStats()
Reset draw statistics.
virtual void PreDraw(TGLRnrCtx &rnrCtx)
Initialize rendering.
void SetDiffuseColor(const Float_t rgba[4])
Set color from ROOT color index and transparency [0,100].
virtual void PostDraw(TGLRnrCtx &rnrCtx)
Finalize drawing.
ShapeVec_t fShapesOfInterest
virtual void DLCacheClear()
Clear all entries for all LODs for this drawable from the display list cache but keeping the reserved...