TGLScene provides management and rendering of ROOT's default 3D /object representation as logical and physical shapes.
A GL scene is the container for all the viewable objects (shapes) loaded into the viewer. It consists of two main stl::maps containing the TGLLogicalShape and TGLPhysicalShape collections, and interface functions enabling viewers to manage objects in these. The physical shapes defined the placement of copies of the logical shapes - see TGLLogicalShape/TGLPhysicalShape for more information on relationship
The scene can be drawn by owning viewer, passing camera, draw style & quality (LOD), clipping etc - see Draw(). The scene can also be drawn for selection in similar fashion - see Select(). The scene keeps track of a single selected physical - which can be modified by viewers.
The scene maintains a lazy calculated bounding box for the total scene extents, axis aligned round TGLPhysicalShape shapes.
Currently a scene is owned exclusively by one viewer - however it is intended that it could easily be shared by multiple viewers - for efficiency and synchronisation reasons. Hence viewer variant objects camera, clips etc being owned by viewer and passed at draw/select
Definition at line 28 of file TGLScene.h.
Classes | |
struct | DrawElement_t |
class | TSceneInfo |
Public Types | |
typedef std::vector< DrawElement_t * >::iterator | DrawElementPtrVec_i |
typedef std::vector< DrawElement_t * > | DrawElementPtrVec_t |
typedef std::vector< DrawElement_t >::iterator | DrawElementVec_i |
typedef std::vector< DrawElement_t > | DrawElementVec_t |
typedef std::map< TObject *, TGLLogicalShape * > | LogicalShapeMap_t |
typedef LogicalShapeMap_t::const_iterator | LogicalShapeMapCIt_t |
typedef LogicalShapeMap_t::iterator | LogicalShapeMapIt_t |
typedef LogicalShapeMap_t::value_type | LogicalShapeMapValueType_t |
typedef std::map< UInt_t, TGLPhysicalShape * > | PhysicalShapeMap_t |
typedef PhysicalShapeMap_t::const_iterator | PhysicalShapeMapCIt_t |
typedef PhysicalShapeMap_t::iterator | PhysicalShapeMapIt_t |
typedef PhysicalShapeMap_t::value_type | PhysicalShapeMapValueType_t |
typedef ShapeVec_t::iterator | ShapeVec_i |
typedef std::vector< const TGLPhysicalShape * > | ShapeVec_t |
Public Types inherited from TGLLockable | |
enum | ELock { kUnlocked , kDrawLock , kSelectLock , kModifyLock } |
Public Member Functions | |
TGLScene () | |
~TGLScene () override | |
Destroy scene objects. | |
virtual void | AdoptLogical (TGLLogicalShape &shape) |
Adopt dynamically created logical 'shape' - add to internal map and take responsibility for deleting. | |
virtual void | AdoptPhysical (TGLPhysicalShape &shape) |
Adopt dynamically created physical 'shape' - add to internal map and take responsibility for deleting. | |
UInt_t | BeginSmartRefresh () |
Moves logicals that support smart-refresh to intermediate cache. | |
virtual Bool_t | BeginUpdate () |
Put scene in update mode, return true if lock acquired. | |
void | CalcBoundingBox () const override |
Encapsulates all physical shapes bounding box with axes aligned box. | |
TSceneInfo * | CreateSceneInfo (TGLViewerBase *view) override |
Create a scene-info instance appropriate for this scene class. | |
virtual Bool_t | DestroyLogical (TObject *logid, Bool_t mustFind=kTRUE) |
Destroy logical shape defined by unique 'ID'. | |
virtual Int_t | DestroyLogicals () |
Destroy all logical shapes in scene. | |
virtual Bool_t | DestroyPhysical (UInt_t phid) |
Destroy physical shape defined by unique 'ID'. | |
virtual Int_t | DestroyPhysicals () |
Destroy physical shapes. | |
void | DumpMapSizes () const |
Print sizes of logical and physical-shape maps. | |
void | EndSmartRefresh () |
Wipes logicals in refresh-cache. | |
virtual void | EndUpdate (Bool_t minorChange=kTRUE, Bool_t sceneChanged=kTRUE, Bool_t updateViewers=kTRUE) |
Exit scene update mode. | |
TGLLogicalShape * | FindLogical (TObject *logid) const override |
Find and return logical shape identified by unique logid. | |
TGLLogicalShape * | FindLogicalSmartRefresh (TObject *ID) const |
Find and return logical shape identified by unique 'ID' in refresh-cache. | |
virtual TGLPhysicalShape * | FindPhysical (UInt_t phid) const |
Find and return physical shape identified by unique 'ID'. | |
TGLContextIdentity * | GetGLCtxIdentity () const |
virtual UInt_t | GetMaxPhysicalID () |
Returns the maximum used physical id. | |
TClass * | IsA () const override |
void | LodifySceneInfo (TGLRnrCtx &rnrCtx) override |
Setup LOD-dependant values in scene-info. | |
void | PostDraw (TGLRnrCtx &rnrCtx) override |
Called after the rendering is finished. | |
void | PreDraw (TGLRnrCtx &rnrCtx) override |
Initialize rendering. | |
void | RebuildSceneInfo (TGLRnrCtx &rnrCtx) override |
Major change in scene, need to rebuild all-element draw-vector and sort it. | |
LogicalShapeMap_t & | RefLogicalShapes () |
virtual void | RenderAllPasses (TGLRnrCtx &rnrCtx, DrawElementPtrVec_t &elVec, Bool_t check_timeout) |
Do full rendering of scene. | |
virtual void | RenderElements (TGLRnrCtx &rnrCtx, DrawElementPtrVec_t &elVec, Bool_t check_timeout, const TGLPlaneSet_t *clipPlanes=nullptr) |
Render DrawElements in elementVec with given timeout. | |
virtual void | RenderHighlight (TGLRnrCtx &rnrCtx, DrawElementPtrVec_t &elVec) |
void | RenderOpaque (TGLRnrCtx &rnrCtx) override |
Render opaque elements. | |
void | RenderSelOpaque (TGLRnrCtx &rnrCtx) override |
Render selected opaque elements. | |
void | RenderSelOpaqueForHighlight (TGLRnrCtx &rnrCtx) override |
Render selected opaque elements for highlight. | |
void | RenderSelTransp (TGLRnrCtx &rnrCtx) override |
Render selected transparent elements. | |
void | RenderSelTranspForHighlight (TGLRnrCtx &rnrCtx) override |
Render selected transparent elements for highlight. | |
void | RenderTransp (TGLRnrCtx &rnrCtx) override |
Render transparent elements. | |
Bool_t | ResolveSelectRecord (TGLSelectRecord &rec, Int_t curIdx) override |
Process selection record rec. | |
UInt_t | SizeOfScene () const |
Return memory cost of scene. | |
void | Streamer (TBuffer &) override |
void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
virtual void | UpdateLogical (TObject *logid) |
Drop display-lists for the logical (assume TGLObject/direct rendering). | |
virtual void | UpdatePhysical (UInt_t phid, Double_t *trans, Color_t cidx=-1, UChar_t transp=0) |
Reposition/recolor physical shape. | |
virtual void | UpdatePhysical (UInt_t phid, Double_t *trans, UChar_t *col) |
Reposition/recolor physical shape. | |
virtual void | UpdatePhysioLogical (TObject *logid, Double_t *trans, Color_t cidx, UChar_t transp) |
Reposition/recolor physical for given logical (assume TGLObject and a single physical). | |
virtual void | UpdatePhysioLogical (TObject *logid, Double_t *trans, UChar_t *col) |
Reposition/recolor physical for given logical (assume TGLObject and a single physical). | |
void | UpdateSceneInfo (TGLRnrCtx &rnrCtx) override |
Fill scene-info with information needed for rendering, take into account the render-context (viewer state, camera, clipping). | |
Public Member Functions inherited from TGLSceneBase | |
TGLSceneBase () | |
~TGLSceneBase () override | |
Destructor. | |
void | AddViewer (TGLViewerBase *viewer) |
Add viewer to the list. | |
const TGLBoundingBox & | BoundingBox () const |
TGLClip * | Clip () const |
Bool_t | GetAutoDestruct () const |
UInt_t | GetMinorStamp () const |
virtual const char * | GetName () const |
Bool_t | GetSelectable () const |
UInt_t | GetTimeStamp () const |
virtual const char * | GetTitle () const |
void | IncMinorStamp () |
void | IncTimeStamp () |
void | InvalidateBoundingBox () |
TClass * | IsA () const override |
const char * | LockIdStr () const override |
Name printed on locking info messages. | |
Short_t | LOD () const |
virtual void | PostRender (TGLRnrCtx &rnrCtx) |
Perform post-render clean-up. | |
virtual void | PreRender (TGLRnrCtx &rnrCtx) |
Perform pre-render initialization - fill rnrCtx with values stored during PreDraw(). | |
void | RemoveViewer (TGLViewerBase *viewer) |
Remove viewer from the list. | |
virtual void | Render (TGLRnrCtx &rnrCtx) |
This function does rendering of all stages, the shapes are rendered in the following order: opaque, transparent, selected-opaque, selected-transparent. | |
void | SetAutoDestruct (Bool_t a) |
void | SetClip (TGLClip *p) |
void | SetLOD (Short_t lod) |
virtual void | SetName (const char *name) |
virtual void | SetNameTitle (const char *name, const char *title) |
void | SetSelectable (Bool_t a) |
void | SetStyle (Short_t st) |
virtual void | SetTitle (const char *title) |
void | Streamer (TBuffer &) override |
void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
Short_t | Style () const |
void | TagViewersChanged () |
Tag all viewers as changed. | |
Public Member Functions inherited from TGLLockable | |
TGLLockable () | |
virtual | ~TGLLockable () |
ELock | CurrentLock () const |
Bool_t | IsDrawOrSelectLock () const |
Bool_t | IsLocked () const |
Bool_t | ReleaseLock (ELock lock) const |
Release current lock, make sure it the same as the 'lock' argument. | |
void | StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b) |
Bool_t | TakeLock (ELock lock) const |
Lock the object in mode 'lock'. | |
Static Public Member Functions | |
static TClass * | Class () |
static const char * | Class_Name () |
static constexpr Version_t | Class_Version () |
static const char * | DeclFileName () |
static Bool_t | IsOutside (const TGLBoundingBox &box, const TGLPlaneSet_t &planes) |
Check if box is outside of all planes. | |
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). | |
Static Public Member Functions inherited from TGLSceneBase | |
static TClass * | Class () |
static const char * | Class_Name () |
static constexpr Version_t | Class_Version () |
static const char * | DeclFileName () |
Static Public Member Functions inherited from TGLLockable | |
static TClass * | Class () |
static const char * | Class_Name () |
static constexpr Version_t | Class_Version () |
static const char * | DeclFileName () |
static const char * | LockName (ELock lock) |
Return name-string for given lock-type. | |
static Bool_t | LockValid (ELock lock) |
Test if lock is a valid type to take/release. | |
Protected Member Functions | |
virtual void | DestroyPhysicalInternal (PhysicalShapeMapIt_t pit) |
Virtual function to destroy a physical. | |
void | ReleaseGLCtxIdentity () |
Release all GL resources for current context identity. | |
Protected Attributes | |
TGLContextIdentity * | fGLCtxIdentity |
Bool_t | fInSmartRefresh |
Float_t | fLastLineWidthScale |
Float_t | fLastPointSizeScale |
LogicalShapeMap_t | fLogicalShapes |
PhysicalShapeMap_t | fPhysicalShapes |
LogicalShapeMap_t | fSmartRefreshCache |
Protected Attributes inherited from TGLSceneBase | |
Bool_t | fAutoDestruct |
TGLBoundingBox | fBoundingBox |
Bool_t | fBoundingBoxValid |
TGLClip * | fClip |
Bool_t | fDoClipCheck |
Bool_t | fDoFrustumCheck |
Short_t | fLOD |
UInt_t | fMinorStamp |
TString | fName |
Float_t | fOLLineW |
UInt_t | fSceneID |
Bool_t | fSelectable |
Short_t | fStyle |
UInt_t | fTimeStamp |
TString | fTitle |
ViewerList_t | fViewers |
Float_t | fWFLineW |
Protected Attributes inherited from TGLLockable | |
ELock | fLock |
Private Member Functions | |
TGLScene (const TGLScene &)=delete | |
TGLScene & | operator= (const TGLScene &)=delete |
Static Private Member Functions | |
static Bool_t | ComparePhysicalDiagonals (const TGLPhysicalShape *shape1, const TGLPhysicalShape *shape2) |
Compare 'shape1' and 'shape2' bounding box volumes - return kTRUE if 'shape1' bigger than 'shape2'. | |
static Bool_t | ComparePhysicalVolumes (const TGLPhysicalShape *shape1, const TGLPhysicalShape *shape2) |
Compare 'shape1' and 'shape2' bounding box volumes - return kTRUE if 'shape1' bigger than 'shape2'. | |
Friends | |
class | TSceneInfo |
Additional Inherited Members | |
Protected Types inherited from TGLSceneBase | |
typedef std::list< TGLViewerBase * >::iterator | ViewerList_i |
typedef std::list< TGLViewerBase * > | ViewerList_t |
#include <TGLScene.h>
typedef std::vector<DrawElement_t*>::iterator TGLScene::DrawElementPtrVec_i |
Definition at line 69 of file TGLScene.h.
typedef std::vector<DrawElement_t*> TGLScene::DrawElementPtrVec_t |
Definition at line 68 of file TGLScene.h.
typedef std::vector<DrawElement_t>::iterator TGLScene::DrawElementVec_i |
Definition at line 66 of file TGLScene.h.
typedef std::vector<DrawElement_t> TGLScene::DrawElementVec_t |
Definition at line 65 of file TGLScene.h.
typedef std::map<TObject*, TGLLogicalShape*> TGLScene::LogicalShapeMap_t |
Definition at line 41 of file TGLScene.h.
typedef LogicalShapeMap_t::const_iterator TGLScene::LogicalShapeMapCIt_t |
Definition at line 44 of file TGLScene.h.
typedef LogicalShapeMap_t::iterator TGLScene::LogicalShapeMapIt_t |
Definition at line 43 of file TGLScene.h.
typedef LogicalShapeMap_t::value_type TGLScene::LogicalShapeMapValueType_t |
Definition at line 42 of file TGLScene.h.
typedef std::map<UInt_t, TGLPhysicalShape*> TGLScene::PhysicalShapeMap_t |
Definition at line 47 of file TGLScene.h.
typedef PhysicalShapeMap_t::const_iterator TGLScene::PhysicalShapeMapCIt_t |
Definition at line 50 of file TGLScene.h.
typedef PhysicalShapeMap_t::iterator TGLScene::PhysicalShapeMapIt_t |
Definition at line 49 of file TGLScene.h.
typedef PhysicalShapeMap_t::value_type TGLScene::PhysicalShapeMapValueType_t |
Definition at line 48 of file TGLScene.h.
typedef ShapeVec_t::iterator TGLScene::ShapeVec_i |
Definition at line 73 of file TGLScene.h.
typedef std::vector<const TGLPhysicalShape*> TGLScene::ShapeVec_t |
Definition at line 72 of file TGLScene.h.
|
privatedelete |
TGLScene::TGLScene | ( | ) |
Definition at line 278 of file TGLScene.cxx.
|
override |
Destroy scene objects.
Definition at line 292 of file TGLScene.cxx.
|
virtual |
Adopt dynamically created logical 'shape' - add to internal map and take responsibility for deleting.
Definition at line 1018 of file TGLScene.cxx.
|
virtual |
Adopt dynamically created physical 'shape' - add to internal map and take responsibility for deleting.
Definition at line 1129 of file TGLScene.cxx.
UInt_t TGLScene::BeginSmartRefresh | ( | ) |
Moves logicals that support smart-refresh to intermediate cache.
Destroys the others and returns the number of destroyed ones.
Definition at line 1416 of file TGLScene.cxx.
|
virtual |
Put scene in update mode, return true if lock acquired.
Definition at line 1245 of file TGLScene.cxx.
|
overridevirtual |
Encapsulates all physical shapes bounding box with axes aligned box.
Validity checked in the base-class.
Implements TGLSceneBase.
Definition at line 977 of file TGLScene.cxx.
|
static |
|
inlinestaticconstexpr |
Definition at line 244 of file TGLScene.h.
|
inlinestaticprivate |
Compare 'shape1' and 'shape2' bounding box volumes - return kTRUE if 'shape1' bigger than 'shape2'.
Definition at line 366 of file TGLScene.cxx.
|
inlinestaticprivate |
Compare 'shape1' and 'shape2' bounding box volumes - return kTRUE if 'shape1' bigger than 'shape2'.
Definition at line 356 of file TGLScene.cxx.
|
overridevirtual |
Create a scene-info instance appropriate for this scene class.
Here we instantiate the inner class TSceneInfo that includes camera/clipping specific draw-list containers.
Reimplemented from TGLSceneBase.
Definition at line 347 of file TGLScene.cxx.
|
inlinestatic |
Definition at line 244 of file TGLScene.h.
Destroy logical shape defined by unique 'ID'.
Returns kTRUE if found/destroyed - kFALSE otherwise.
If mustFind is true, an error is reported if the logical is not found.
Definition at line 1036 of file TGLScene.cxx.
|
virtual |
Destroy all logical shapes in scene.
Return number of destroyed logicals.
Definition at line 1073 of file TGLScene.cxx.
Destroy physical shape defined by unique 'ID'.
Returns kTRUE if found/destroyed - kFALSE otherwise.
Definition at line 1159 of file TGLScene.cxx.
|
protectedvirtual |
Virtual function to destroy a physical.
Sub-classes might have special checks to perform. Caller should also invalidate the draw-list.
Definition at line 1149 of file TGLScene.cxx.
|
virtual |
Destroy physical shapes.
Definition at line 1183 of file TGLScene.cxx.
void TGLScene::DumpMapSizes | ( | ) | const |
Print sizes of logical and physical-shape maps.
Definition at line 1523 of file TGLScene.cxx.
void TGLScene::EndSmartRefresh | ( | ) |
Wipes logicals in refresh-cache.
Definition at line 1439 of file TGLScene.cxx.
|
virtual |
Exit scene update mode.
If sceneChanged is true (default), the scene timestamp is increased and basic draw-lists etc will be rebuild on next draw request. If you only changed colors or some other visual parameters that do not affect object bounding-box or transformation matrix, you can set it to false.
If updateViewers is true (default), the viewers using this scene will be tagged as changed. If sceneChanged is true the updateViewers should be true as well, unless you take care of the viewers elsewhere or in some other way.
Definition at line 1265 of file TGLScene.cxx.
|
overridevirtual |
Find and return logical shape identified by unique logid.
Returns 0 if not found.
Reimplemented from TGLSceneBase.
Definition at line 1107 of file TGLScene.cxx.
TGLLogicalShape * TGLScene::FindLogicalSmartRefresh | ( | TObject * | ID | ) | const |
Find and return logical shape identified by unique 'ID' in refresh-cache.
Returns 0 if not found.
Definition at line 1455 of file TGLScene.cxx.
|
virtual |
Find and return physical shape identified by unique 'ID'.
Returns 0 if not found.
Definition at line 1221 of file TGLScene.cxx.
|
inline |
Definition at line 230 of file TGLScene.h.
|
virtual |
Returns the maximum used physical id.
Returns 0 if empty.
Definition at line 1231 of file TGLScene.cxx.
|
inlineoverridevirtual |
Reimplemented from TGLLockable.
Reimplemented in TGLScenePad.
Definition at line 244 of file TGLScene.h.
|
static |
Check if box is outside of all planes.
Definition at line 1543 of file TGLScene.cxx.
|
overridevirtual |
Setup LOD-dependant values in scene-info.
We have to perform LOD quantization for all draw-elements.
Reimplemented from TGLSceneBase.
Definition at line 544 of file TGLScene.cxx.
|
overridevirtual |
Called after the rendering is finished.
In debug mode draw statistics is dumped. Parent's PostDraw is called for GL cleanup.
Reimplemented from TGLSceneBase.
Definition at line 707 of file TGLScene.cxx.
|
overridevirtual |
Initialize rendering.
Pass to base-class where most work is done. Check if GL-ctx is shared with the previous one; if not wipe display-lists of all logicals.
Reimplemented from TGLSceneBase.
Definition at line 568 of file TGLScene.cxx.
|
overridevirtual |
Major change in scene, need to rebuild all-element draw-vector and sort it.
Sort the TGLPhysical draw list by shape bounding box diagonal, from large to small. This makes dropout of shapes with time limited Draw() calls must less noticeable. As this does not use projected size it only needs to be done after a scene content change - not every time scene drawn (potential camera/projection change).
Reimplemented from TGLSceneBase.
Definition at line 382 of file TGLScene.cxx.
|
inline |
Definition at line 216 of file TGLScene.h.
|
protected |
Release all GL resources for current context identity.
Requires iteration over all logical shapes.
Definition at line 311 of file TGLScene.cxx.
|
virtual |
Do full rendering of scene.
First draw the opaques, then the transparents. For each we do the number of passes required by draw mode and clipping setup.
Definition at line 725 of file TGLScene.cxx.
|
virtual |
Render DrawElements in elementVec with given timeout.
If clipPlanes is non-zero, test each element against its clipping planes.
Definition at line 893 of file TGLScene.cxx.
|
virtual |
Definition at line 672 of file TGLScene.cxx.
|
overridevirtual |
Render opaque elements.
Reimplemented from TGLSceneBase.
Definition at line 613 of file TGLScene.cxx.
|
overridevirtual |
Render selected opaque elements.
Reimplemented from TGLSceneBase.
Definition at line 633 of file TGLScene.cxx.
|
overridevirtual |
Render selected opaque elements for highlight.
Reimplemented from TGLSceneBase.
Definition at line 653 of file TGLScene.cxx.
|
overridevirtual |
Render selected transparent elements.
Reimplemented from TGLSceneBase.
Definition at line 643 of file TGLScene.cxx.
|
overridevirtual |
Render selected transparent elements for highlight.
Reimplemented from TGLSceneBase.
Definition at line 663 of file TGLScene.cxx.
|
overridevirtual |
Render transparent elements.
Reimplemented from TGLSceneBase.
Definition at line 623 of file TGLScene.cxx.
|
overridevirtual |
Process selection record rec.
'curIdx' is the item position where the scene should start its processing. Return TRUE if an object has been identified or FALSE otherwise. The scene-info member of the record is already set by the caller.
Reimplemented from TGLSceneBase.
Definition at line 950 of file TGLScene.cxx.
Fill rgba color from ROOT color-index ci and transparency (0->100).
Definition at line 1532 of file TGLScene.cxx.
UInt_t TGLScene::SizeOfScene | ( | ) | const |
Return memory cost of scene.
Warning: NOT CORRECT at present - doesn't correctly calculate size. of logical shapes with dynamic internal contents.
Definition at line 1491 of file TGLScene.cxx.
|
overridevirtual |
Reimplemented from TGLLockable.
Reimplemented in TGLScenePad.
|
inline |
Definition at line 244 of file TGLScene.h.
|
virtual |
Drop display-lists for the logical (assume TGLObject/direct rendering).
Re-calculate the bounding box (also for all physicals).
Definition at line 1283 of file TGLScene.cxx.
|
virtual |
Reposition/recolor physical shape.
Definition at line 1325 of file TGLScene.cxx.
Reposition/recolor physical shape.
Definition at line 1304 of file TGLScene.cxx.
|
virtual |
Reposition/recolor physical for given logical (assume TGLObject and a single physical).
Definition at line 1379 of file TGLScene.cxx.
Reposition/recolor physical for given logical (assume TGLObject and a single physical).
Definition at line 1352 of file TGLScene.cxx.
|
overridevirtual |
Fill scene-info with information needed for rendering, take into account the render-context (viewer state, camera, clipping).
Here we have to iterate over all the physical shapes and select the visible ones. While at it, opaque and transparent shapes are divided into two groups.
Reimplemented from TGLSceneBase.
Definition at line 426 of file TGLScene.cxx.
|
friend |
Definition at line 121 of file TGLScene.h.
|
protected |
Definition at line 131 of file TGLScene.h.
|
protected |
Definition at line 135 of file TGLScene.h.
|
protected |
Definition at line 140 of file TGLScene.h.
|
protected |
Definition at line 139 of file TGLScene.h.
|
protected |
Definition at line 125 of file TGLScene.h.
|
protected |
Definition at line 126 of file TGLScene.h.
|
mutableprotected |
Definition at line 136 of file TGLScene.h.