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);
131 i->fPhysical->QuantizeShapeLOD(i->fPixelLOD, ctx.
CombiLOD(), i->fFinalLOD);
149 if (i->fPhysical->IsSelected())
151 if (i->fPhysical->IsTransparent())
156 if (i->fPhysical->IsTransparent())
205 std::map<TClass*, UInt_t>::iterator it =
fByShapeCnt.find(logIsA);
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",
227 out +=
Form(
"\tInner phys nums: physicals=%d, of_interest=%lu, visible=%lu, op=%lu, trans=%lu",
235 out +=
"\n\tStatistics by shape:\n";
236 std::map<TClass*, UInt_t>::const_iterator it =
fByShapeCnt.begin();
238 out +=
Form(
"\t%-20s %u\n", it->first->GetName(), it->second);
242 Info(
"TGLScene::DumpDrawStats()",
"%s",out.
Data());
317 lit->second->DLCachePurge();
326 lit->second->DLCacheDrop();
382 if (sinfo == 0 || sinfo->
GetScene() !=
this) {
383 Error(
"TGLScene::RebuildSceneInfo",
"Scene mismatch.");
426 if (sinfo == 0 || sinfo->
GetScene() !=
this) {
427 Error(
"TGLScene::UpdateSceneInfo",
"Scene mismatch.");
442 Int_t checkCount = 0;
448 ++phys, ++checkCount)
465 std::vector<TGLPlane>::iterator
pi = sinfo->
ClipPlanes().begin();
479 std::vector<TGLPlane>::iterator
pi = sinfo->
ClipPlanes().begin();
524 Warning(
"TGLScene::UpdateSceneInfo",
525 "Timeout reached, not all elements processed.");
544 if (sinfo == 0 || sinfo->
GetScene() !=
this) {
545 Error(
"TGLScene::LodifySceneInfo",
"Scene mismatch.");
568 if (sinfo == 0 || sinfo->
GetScene() !=
this) {
570 Error(
"TGLScene::PreDraw",
"%s",
Form(
"SceneInfo mismatch (0x%lx, '%s').",
571 (
ULong_t)si, si ? si->IsA()->GetName() :
"<>"));
593 lit->second->DLCacheClear();
674 glEnable(GL_STENCIL_TEST);
679 glStencilFunc(GL_ALWAYS, 0
x1, 0
x1);
680 glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
681 glClear(GL_STENCIL_BUFFER_BIT);
683 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
687 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
689 glStencilFunc(GL_NOTEQUAL, 0
x1, 0
x1);
690 glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
696 glDisable(GL_STENCIL_TEST);
742 glEnable(GL_LIGHTING);
746 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
747 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
748 glDisable(GL_CULL_FACE);
767 glDisable(GL_LIGHTING);
768 glDisable(GL_CULL_FACE);
769 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
778 for (
Int_t i = 0; i < reqPasses; ++i)
789 glEnable(GL_POLYGON_OFFSET_FILL);
790 glPolygonOffset(0.5
f, 0.5
f);
796 glDisable(GL_POLYGON_OFFSET_FILL);
797 glDisable(GL_LIGHTING);
805 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
824 Info(
"TGLScene::RenderAllPasses()",
825 "%ld active clip planes", (
Long_t)planeSet.size());
829 glGetIntegerv(GL_MAX_CLIP_PLANES, &maxGLPlanes);
830 UInt_t maxPlanes = maxGLPlanes;
832 if (planeSet.size() < maxPlanes) {
833 maxPlanes = planeSet.size();
840 for (
UInt_t ii=0; ii<maxPlanes; ii++) {
841 glClipPlane(GL_CLIP_PLANE0+ii, planeSet[ii].CArr());
842 glEnable(GL_CLIP_PLANE0+ii);
854 std::vector<TGLPlane> activePlanes;
855 for (planeInd=0; planeInd<maxPlanes; planeInd++)
857 activePlanes.push_back(planeSet[planeInd]);
860 glClipPlane(GL_CLIP_PLANE0+planeInd, p.
CArr());
861 glEnable(GL_CLIP_PLANE0+planeInd);
868 glClipPlane(GL_CLIP_PLANE0+planeInd, p.
CArr());
872 for (planeInd=0; planeInd<maxPlanes; planeInd++) {
873 glDisable(GL_CLIP_PLANE0+planeInd);
879 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
880 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
881 glEnable(GL_CULL_FACE);
882 glEnable(GL_LIGHTING);
915 glPushName(drawShape->
ID());
916 drawShape->
Draw(rnrCtx);
924 if (check_timeout && (drawCount % 2000) == 0 &&
928 Warning(
"TGLScene::RenderElements",
929 "Timeout reached, not all elements rendered.");
949 if (curIdx >= rec.
GetN())
976 Double_t xMin, xMax, yMin, yMax, zMin, zMax;
977 xMin = xMax = yMin = yMax = zMin = zMax = 0.0;
982 physicalShape = physicalShapeIt->second;
990 xMin = box.
XMin(); xMax = box.
XMax();
991 yMin = box.
YMin(); yMax = box.
YMax();
992 zMin = box.
ZMin(); zMax = box.
ZMax();
994 if (box.
XMin() < xMin) { xMin = box.
XMin(); }
995 if (box.
XMax() > xMax) { xMax = box.
XMax(); }
996 if (box.
YMin() < yMin) { yMin = box.
YMin(); }
997 if (box.
YMax() > yMax) { yMax = box.
YMax(); }
998 if (box.
ZMin() < zMin) { zMin = box.
ZMin(); }
999 if (box.
ZMax() > zMax) { zMax = box.
ZMax(); }
1018 Error(
"TGLScene::AdoptLogical",
"expected ModifyLock");
1036 Error(
"TGLScene::DestroyLogical",
"expected ModifyLock");
1044 Error(
"TGLScene::DestroyLogical",
"logical not found in map.");
1056 Warning(
"TGLScene::DestroyLogical",
"an attached physical not found in map.");
1058 assert(logical->
Ref() == 0);
1073 Error(
"TGLScene::DestroyLogicals",
"expected ModifyLock");
1081 logicalShape = logicalShapeIt->second;
1083 if (logicalShape->
Ref() == 0) {
1085 delete logicalShape;
1129 Error(
"TGLScene::AdoptPhysical",
"expected ModifyLock");
1159 Error(
"TGLScene::DestroyPhysical",
"expected ModifyLock.");
1166 Error(
"TGLScene::DestroyPhysical::UpdatePhysical",
"physical not found.");
1183 Error(
"TGLScene::DestroyPhysicals",
"expected ModifyLock");
1195 if (lshp && lshp->
Ref() != 0)
1197 count += lshp->
Ref();
1283 Error(
"TGLScene::UpdateLogical",
"expected ModifyLock");
1290 Error(
"TGLScene::UpdateLogical",
"logical not found");
1304 Error(
"TGLScene::UpdatePhysical",
"expected ModifyLock");
1311 Error(
"TGLScene::UpdatePhysical",
"physical not found");
1325 Error(
"TGLScene::UpdatePhysical",
"expected ModifyLock");
1332 Error(
"TGLScene::UpdatePhysical",
"physical not found");
1352 Error(
"TGLScene::UpdatePhysioLogical",
"expected ModifyLock");
1359 Error(
"TGLScene::UpdatePhysioLogical",
"logical not found");
1363 if (log->
Ref() != 1) {
1364 Warning(
"TGLScene::UpdatePhysioLogical",
"expecting a single physical (%d).", log->
Ref());
1369 if (col) phys->SetDiffuseColor(col);
1379 Error(
"TGLScene::UpdatePhysioLogical",
"expected ModifyLock");
1386 Error(
"TGLScene::UpdatePhysioLogical",
"logical not found");
1390 if (log->
Ref() != 1) {
1391 Warning(
"TGLScene::UpdatePhysioLogical",
"expecting a single physical (%d).", log->
Ref());
1400 phys->SetDiffuseColor(rgba);
1420 if (i->second->KeepDuringSmartRefresh() ==
kFALSE) {
1461 Warning(
"TGLScene::FindLogicalSmartRefresh",
"Wrong renderer-type found in cache.");
1490 UInt_t size =
sizeof(*this);
1492 printf(
"Size: Scene Only %u\n", size);
1497 logicalShape = logicalShapeIt->second;
1498 size +=
sizeof(*logicalShape);
1502 printf(
"Size: Scene + Logical Shapes %u\n", size);
1507 physicalShape = physicalShapeIt->second;
1508 size +=
sizeof(*physicalShape);
1512 printf(
"Size: Scene + Logical Shapes + Physical Shapes %u\n", size);
1522 printf(
"Scene: %u Logicals / %u Physicals\n",
1532 if(c) c->
GetRGB(rgba[0], rgba[1], rgba[2]);
1533 else rgba[0] = rgba[1] = rgba[2] = 0.5;
1534 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
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).
std::map< TObject *, TGLLogicalShape * > LogicalShapeMap_t
Bool_t ReleaseLock(ELock lock) const
Release current lock, make sure it the same as the 'lock' argument.
TGLLogicalShape * FindLogicalSmartRefresh(TObject *ID) const
Find and return logical shape identified by unique 'ID' in refresh-cache.
virtual ~TGLScene()
Destroy scene objects.
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'...
virtual ~TSceneInfo()
Destructor.
Identifier of a shared GL-context.
void SetPhysShape(TGLPhysicalShape *pshp)
std::vector< TGLPlane >::const_iterator TGLPlaneSet_ci
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.
TGLSceneBase * GetScene() const
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
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...
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)
virtual void GetRGB(Float_t &r, Float_t &g, Float_t &b) const
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...
TGLContextIdentity * GetGLCtxIdentity() const
LogicalShapeMap_t fLogicalShapes
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.
TGLScene * fScene
Shape's bounding box.
virtual TGLLogicalShape * FindLogical(TObject *logid) const
Find and return logical shape identified by unique logid.
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 CalcBoundingBox() const
Encapsulates all physical shapes bounding box with axes aligned box.
3 component (x/y/z) vertex class.
static Float_t GetPointSizeScale()
Get global point-size scale.
const TGLBoundingBox & BoundingBox() const
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.
void PostDraw()
Clean-up after drawing, nothing to be done here.
Bool_t IsTransparent() const
virtual void UpdateSceneInfo(TGLRnrCtx &ctx)
Fill scene-info with information needed for rendering, take into account the render-context (viewer s...
void DumpMapSizes() const
Print sizes of logical and physical-shape maps.
void Info(const char *location, const char *msgfmt,...)
std::map< TClass *, UInt_t > fByShapeCnt
void UpdateDrawStats(const TGLPhysicalShape &shape, Short_t lod)
Update draw stats, for newly drawn 'shape'.
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
const Double_t * CArr() const
Double_t Diagonal() const
TObject * GetExternal() const
virtual void RebuildSceneInfo(TGLRnrCtx &ctx)
Fill scene-info with very basic information that is practically view independent. ...
void SetShapePixSize(Float_t ps)
Short_t SceneStyle() const
void SetHighlightOutline(Bool_t ho)
virtual TGLPhysicalShape * FindPhysical(UInt_t phid) const
Find and return physical shape identified by unique 'ID'.
TGLPhysicalShape * fFirstPhysical
physical instance ref counting
Standard selection record including information about containing scene and details ob out selected ob...
UInt_t UnrefFirstPhysical()
Unreferenced first physical in the list, returning its id and making it fit for destruction somewhere...
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.
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)
Abstract logical shape - a GL 'drawable' - base for all shapes - faceset sphere etc.
void Lodify(TGLRnrCtx &ctx)
Quantize LODs for given render-context.
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw physical shape, using LOD flags, potential from display list cache.
Bool_t IsStopwatchRunning() const
Short_t LastStyle() const
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.
Float_t SceneOLLineW() 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 SizeOfScene() const
Return memory cost of scene.
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.
void SetLogShape(TGLLogicalShape *lshp)
void SetDrawPass(Short_t dpass)
UInt_t GetMinorStamp() const
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.
static Float_t GetLineWidthScale()
Returns global line-width scale.
DrawElementPtrVec_t fOpaqueElements
TGLScene provides management and rendering of ROOT's default 3D /object representation as logical and...
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.
Bool_t TakeLock(ELock lock) const
Lock the object in mode 'lock'.
void TagViewersChanged()
Tag all viewers as changed.
static Float_t LineWidth()
Get the line-width, taking the global scaling into account.
Bool_t ShouldClip() const
virtual Bool_t IgnoreSizeForOfInterest() const
Return true if size of this shape should be ignored when determining if the object should be drawn...
virtual void PreDraw(TGLRnrCtx &rnrCtx)
Perform basic pre-render initialization:
Rgl::EOverlap Overlap(const TGLPlane &plane) const
Find overlap (Inside, Outside, Partial) of plane c.f. bounding box.
virtual void AdoptLogical(TGLLogicalShape &shape)
Adopt dynamically created logical 'shape' - add to internal map and take responsibility for deleting...
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...
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)
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
Short_t ViewerLOD() const
virtual void LodifySceneInfo(TGLRnrCtx &rnrCtx)
Setup LOD-dependant values in scene-info.
const TGLLogicalShape * GetLogical() const
void ResetDrawStats()
Reset draw statistics.
Float_t SceneWFLineW() const
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...
const char * Data() const