ROOT  6.06/09
Reference Guide
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Friends | List of all members
TGLLogicalShape Class Referenceabstract

Abstract logical shape - a GL 'drawable' - base for all shapes - faceset sphere etc.

Logical shapes are a unique piece of geometry, described in it's local frame - e.g if we have three spheres in :

Spheres A and C can share a common logical sphere of radius r1 - and place them with two physicals with translations of v1 & v2. Sphere B requires a different logical (radius r2), placed with physical with translation v2.

Physical shapes know about and can share logicals. Logicals do not about (aside from reference counting) physicals or share them.

This sharing of logical shapes greatly reduces memory consumption and scene (re)build times in typical detector geometries which have many repeated objects placements.

TGLLogicalShapes have reference counting, performed by the client physical shapes which are using it.

Display list information is also stored here, possibly per LOD level. Most classes do not support LOD (only sphere and tube) and therefore reasonable defaults are encoded in the following virtual functions:

Int_t DLCacheSize() { return 1; }
UInt_t DLOffset(lod); // Transform lod into DL offset.
Short_t QuantizeShapeLOD(); // Quantize lod.

Classes that have per-LOD display-lists than override these functions. 'UShort_t fDLValid' is used as a bit-field determining validity of each quantized LOD-level; hopefully one will not have more than 16 LOD levels per class. See also: TGLPhysicalShape::CalculateShapeLOD() where LOD is calculated.

See base/src/TVirtualViewer3D for description of common external 3D viewer architecture and how external viewer clients use it.

Definition at line 31 of file TGLLogicalShape.h.

Public Types

enum  ELODAxes {
  kLODAxesNone = 0, kLODAxesX = 1 << 0, kLODAxesY = 1 << 1, kLODAxesZ = 1 << 2,
  kLODAxesAll = kLODAxesX | kLODAxesY | kLODAxesZ
}
 

Public Member Functions

 TGLLogicalShape ()
 Constructor. More...
 
 TGLLogicalShape (TObject *obj)
 Constructor with external object. More...
 
 TGLLogicalShape (const TBuffer3D &buffer)
 Constructor from TBuffer3D. More...
 
virtual ~TGLLogicalShape ()
 Destroy logical shape. More...
 
UInt_t Ref () const
 
void AddRef (TGLPhysicalShape *phys) const
 Add reference to given physical shape. More...
 
void SubRef (TGLPhysicalShape *phys) const
 Remove reference to given physical shape, potentially deleting this object when hitting zero ref-count (if fRefStrong is true). More...
 
void StrongRef (Bool_t strong) const
 
void DestroyPhysicals ()
 Destroy all physicals attached to this logical. More...
 
UInt_t UnrefFirstPhysical ()
 Unreferenced first physical in the list, returning its id and making it fit for destruction somewhere else. More...
 
const TGLPhysicalShapeGetFirstPhysical () const
 
TObjectID () const
 
TObjectGetExternal () const
 
TGLSceneGetScene () const
 
const TGLBoundingBoxBoundingBox () const
 
virtual void UpdateBoundingBox ()
 
void UpdateBoundingBoxesOfPhysicals ()
 Update bounding-boxed of all dependent physicals. More...
 
Bool_t SetDLCache (Bool_t cached)
 Modify capture of draws into display list cache kTRUE - capture, kFALSE direct draw. More...
 
virtual Bool_t ShouldDLCache (const TGLRnrCtx &rnrCtx) const
 Returns kTRUE if draws should be display list cached kFALSE otherwise. More...
 
virtual UInt_t DLOffset (Short_t) const
 
virtual void DLCacheClear ()
 Clear all entries for all LODs for this drawable from the display list cache but keeping the reserved ids from GL context. More...
 
virtual void DLCacheDrop ()
 Drop all entries for all LODs for this drawable from the display list cache, WITHOUT returning the reserved ids to GL context. More...
 
virtual void DLCachePurge ()
 Purge all entries for all LODs for this drawable from the display list cache, returning the reserved ids to GL context. More...
 
virtual ELODAxes SupportedLODAxes () const
 
virtual Short_t QuantizeShapeLOD (Short_t shapeLOD, Short_t combiLOD) const
 Logical shapes usually support only discreet LOD values, especially in view of display-list caching. More...
 
virtual void Draw (TGLRnrCtx &rnrCtx) const
 Draw the GL drawable, using draw flags. More...
 
virtual void DirectDraw (TGLRnrCtx &rnrCtx) const =0
 
virtual void DrawHighlight (TGLRnrCtx &rnrCtx, const TGLPhysicalShape *pshp, Int_t lvl=-1) const
 Draw the logical shape in highlight mode. More...
 
virtual Bool_t IgnoreSizeForOfInterest () const
 Return true if size of this shape should be ignored when determining if the object should be drawn. More...
 
virtual Bool_t KeepDuringSmartRefresh () const
 
virtual Bool_t SupportsSecondarySelect () const
 
virtual Bool_t AlwaysSecondarySelect () const
 
virtual void ProcessSelection (TGLRnrCtx &rnrCtx, TGLSelectRecord &rec)
 Virtual method called-back after a secondary selection hit is recorded (see TGLViewer::HandleButton(), Ctrl-Button1). More...
 
void InvokeContextMenu (TContextMenu &menu, UInt_t x, UInt_t y) const
 Invoke popup menu or our bound external TObject (if any), using passed 'menu' object, at location 'x' 'y'. More...
 

Static Public Member Functions

static Bool_t GetIgnoreSizeForCameraInterest ()
 Get state of static fgIgnoreSizeForCameraInterest flag. More...
 
static void SetIgnoreSizeForCameraInterest (Bool_t isfci)
 Set state of static fgIgnoreSizeForCameraInterest flag. More...
 

Protected Member Functions

void PurgeDLRange (UInt_t base, Int_t size) const
 External object is a fake. More...
 

Protected Attributes

UInt_t fRef
 
TGLPhysicalShapefFirstPhysical
 physical instance ref counting More...
 
TObjectfExternalObj
 first replica More...
 
TGLBoundingBox fBoundingBox
 Also plays the role of ID. More...
 
TGLScenefScene
 Shape's bounding box. More...
 
UInt_t fDLBase
 scene where object is stored (can be zero!) More...
 
Int_t fDLSize
 display-list id base More...
 
UShort_t fDLValid
 display-list size for different LODs More...
 
Bool_t fDLCache
 display-list validity bit-field More...
 
Bool_t fRefStrong
 use display list caching More...
 
Bool_t fOwnExtObj
 Strong ref (delete on 0 ref); not in scene. More...
 

Static Protected Attributes

static Bool_t fgIgnoreSizeForCameraInterest = kFALSE
 

Private Member Functions

 TGLLogicalShape (const TGLLogicalShape &)
 
TGLLogicalShapeoperator= (const TGLLogicalShape &)
 

Friends

class TGLScene
 

#include <TGLLogicalShape.h>

+ Inheritance diagram for TGLLogicalShape:
+ Collaboration diagram for TGLLogicalShape:

Member Enumeration Documentation

Enumerator
kLODAxesNone 
kLODAxesX 
kLODAxesY 
kLODAxesZ 
kLODAxesAll 

Definition at line 40 of file TGLLogicalShape.h.

Constructor & Destructor Documentation

TGLLogicalShape::TGLLogicalShape ( const TGLLogicalShape )
private
TGLLogicalShape::TGLLogicalShape ( )

Constructor.

Definition at line 70 of file TGLLogicalShape.cxx.

TGLLogicalShape::TGLLogicalShape ( TObject obj)

Constructor with external object.

Definition at line 87 of file TGLLogicalShape.cxx.

TGLLogicalShape::TGLLogicalShape ( const TBuffer3D buffer)

Constructor from TBuffer3D.

Definition at line 104 of file TGLLogicalShape.cxx.

TGLLogicalShape::~TGLLogicalShape ( )
virtual

Destroy logical shape.

Definition at line 136 of file TGLLogicalShape.cxx.

Member Function Documentation

void TGLLogicalShape::AddRef ( TGLPhysicalShape phys) const

Add reference to given physical shape.

Definition at line 159 of file TGLLogicalShape.cxx.

Referenced by TGLPhysicalShape::TGLPhysicalShape().

virtual Bool_t TGLLogicalShape::AlwaysSecondarySelect ( ) const
inlinevirtual
const TGLBoundingBox& TGLLogicalShape::BoundingBox ( ) const
inline
void TGLLogicalShape::DestroyPhysicals ( )

Destroy all physicals attached to this logical.

Definition at line 202 of file TGLLogicalShape.cxx.

Referenced by TGLScene::DestroyPhysicals(), and ~TGLLogicalShape().

virtual void TGLLogicalShape::DirectDraw ( TGLRnrCtx rnrCtx) const
pure virtual
void TGLLogicalShape::DLCacheClear ( )
virtual

Clear all entries for all LODs for this drawable from the display list cache but keeping the reserved ids from GL context.

Reimplemented in TEveJetConeGL.

Definition at line 299 of file TGLLogicalShape.cxx.

Referenced by TEveJetConeGL::DLCacheClear(), TGLScene::FindLogicalSmartRefresh(), TEveSceneList::ProcessSceneChanges(), and TGLScene::UpdateLogical().

void TGLLogicalShape::DLCacheDrop ( )
virtual

Drop all entries for all LODs for this drawable from the display list cache, WITHOUT returning the reserved ids to GL context.

This is called by scene if it realized that the GL context was destroyed.

Reimplemented in TEveCaloLegoGL, and TEveBoxSetGL.

Definition at line 311 of file TGLLogicalShape.cxx.

Referenced by TEveBoxSetGL::DLCacheDrop(), and TEveCaloLegoGL::DLCacheDrop().

void TGLLogicalShape::DLCachePurge ( )
virtual

Purge all entries for all LODs for this drawable from the display list cache, returning the reserved ids to GL context.

If you override this function:

  1. call the base-class version from it;
  2. call it from the destructor of the derived class!

Reimplemented in TEveCaloLegoGL, and TEveBoxSetGL.

Definition at line 325 of file TGLLogicalShape.cxx.

Referenced by TEveBoxSetGL::DLCachePurge(), TEveCaloLegoGL::DLCachePurge(), SetDLCache(), and ~TGLLogicalShape().

virtual UInt_t TGLLogicalShape::DLOffset ( Short_t  ) const
inlinevirtual

Reimplemented in TGLCylinder, and TGLSphere.

Definition at line 92 of file TGLLogicalShape.h.

Referenced by Draw().

void TGLLogicalShape::Draw ( TGLRnrCtx rnrCtx) const
virtual

Draw the GL drawable, using draw flags.

If DL caching is enabled (see SetDLCache) then attempt to draw from the cache, if not found attempt to capture the draw - done by DirectDraw() - into a new cache entry. If not cached just call DirectDraw() for normal non DL cached drawing.

Reimplemented in TEveBoxProjectedGL, TEveJetConeProjectedGL, TEveJetConeGL, TEvePolygonSetProjectedGL, TEveBoxGL, TEveProjectionAxesGL, TEveStraightLineSetGL, and TPointSet3DGL.

Definition at line 370 of file TGLLogicalShape.cxx.

Referenced by TGLCylinder::DirectDraw(), TPointSet3DGL::Draw(), TEveStraightLineSetGL::Draw(), TEveProjectionAxesGL::Draw(), TEveBoxGL::Draw(), TEvePolygonSetProjectedGL::Draw(), TEveJetConeGL::Draw(), TEveJetConeProjectedGL::Draw(), TEveBoxProjectedGL::Draw(), TGLPhysicalShape::Draw(), and DrawHighlight().

void TGLLogicalShape::DrawHighlight ( TGLRnrCtx rnrCtx,
const TGLPhysicalShape pshp,
Int_t  lvl = -1 
) const
virtual

Draw the logical shape in highlight mode.

If lvl argument is less than 0 (-1 by default), the index into color-set is taken from the physical shape itself.

Reimplemented in TEveCaloLegoGL, TEveCalo2DGL, TEvePolygonSetProjectedGL, TEveCalo3DGL, and TEveDigitSetGL.

Definition at line 424 of file TGLLogicalShape.cxx.

Referenced by TGLPhysicalShape::Draw(), and TEveDigitSetGL::DrawHighlight().

TObject* TGLLogicalShape::GetExternal ( ) const
inline
const TGLPhysicalShape* TGLLogicalShape::GetFirstPhysical ( ) const
inline
Bool_t TGLLogicalShape::GetIgnoreSizeForCameraInterest ( )
static

Get state of static fgIgnoreSizeForCameraInterest flag.

When this is true all objects, also very small, will be drawn by GL.

Definition at line 477 of file TGLLogicalShape.cxx.

TGLScene* TGLLogicalShape::GetScene ( ) const
inline
TObject* TGLLogicalShape::ID ( ) const
inline
Bool_t TGLLogicalShape::IgnoreSizeForOfInterest ( ) const
virtual

Return true if size of this shape should be ignored when determining if the object should be drawn.

In this base-class we simply return state of static flag fgIgnoreSizeForCameraInterest.

Several sub-classes override this virtual function.

Reimplemented in TEveBoxProjectedGL, TEvePolygonSetProjectedGL, TEveBoxGL, TEveProjectionAxesGL, TEveStraightLineSetGL, TGLPolyMarker, TEveQuadSetGL, and TPointSet3DGL.

Definition at line 468 of file TGLLogicalShape.cxx.

Referenced by TGLScene::RebuildSceneInfo().

void TGLLogicalShape::InvokeContextMenu ( TContextMenu menu,
UInt_t  x,
UInt_t  y 
) const

Invoke popup menu or our bound external TObject (if any), using passed 'menu' object, at location 'x' 'y'.

Definition at line 454 of file TGLLogicalShape.cxx.

Referenced by TGLPhysicalShape::InvokeContextMenu().

virtual Bool_t TGLLogicalShape::KeepDuringSmartRefresh ( ) const
inlinevirtual

Reimplemented in TGLObject, TGLPlot3D, TF2GL, TGLParametricEquationGL, and TEvePlot3DGL.

Definition at line 107 of file TGLLogicalShape.h.

TGLLogicalShape& TGLLogicalShape::operator= ( const TGLLogicalShape )
private
void TGLLogicalShape::ProcessSelection ( TGLRnrCtx rnrCtx,
TGLSelectRecord rec 
)
virtual

Virtual method called-back after a secondary selection hit is recorded (see TGLViewer::HandleButton(), Ctrl-Button1).

The ptr argument holds the GL pick-record of the closest hit.

This base-class implementation simply prints out the result.

Reimplemented in TEveCaloLegoGL, TEveCalo2DGL, TEveCalo3DGL, TEveDigitSetGL, TEveStraightLineSetGL, TEveTrackGL, and TPointSet3DGL.

Definition at line 441 of file TGLLogicalShape.cxx.

Referenced by TGLEventHandler::SelectForClicked(), and TGLEventHandler::SelectForMouseOver().

void TGLLogicalShape::PurgeDLRange ( UInt_t  base,
Int_t  size 
) const
protected

External object is a fake.

Purge given display-list range.

Utility function.

Definition at line 339 of file TGLLogicalShape.cxx.

Referenced by TEveBoxSetGL::DLCachePurge(), DLCachePurge(), and TEveCaloLegoGL::DLCachePurge().

Short_t TGLLogicalShape::QuantizeShapeLOD ( Short_t  shapeLOD,
Short_t  combiLOD 
) const
virtual

Logical shapes usually support only discreet LOD values, especially in view of display-list caching.

This function should be overriden to perform the desired quantization. See TGLSphere.

Reimplemented in TGLCylinder, and TGLSphere.

Definition at line 358 of file TGLLogicalShape.cxx.

Referenced by TGLPhysicalShape::QuantizeShapeLOD().

UInt_t TGLLogicalShape::Ref ( ) const
inline
Bool_t TGLLogicalShape::SetDLCache ( Bool_t  cache)

Modify capture of draws into display list cache kTRUE - capture, kFALSE direct draw.

Return kTRUE is state changed, kFALSE if not.

Definition at line 261 of file TGLLogicalShape.cxx.

void TGLLogicalShape::SetIgnoreSizeForCameraInterest ( Bool_t  isfci)
static

Set state of static fgIgnoreSizeForCameraInterest flag.

Definition at line 485 of file TGLLogicalShape.cxx.

Bool_t TGLLogicalShape::ShouldDLCache ( const TGLRnrCtx rnrCtx) const
virtual

Returns kTRUE if draws should be display list cached kFALSE otherwise.

Here we check that: a) fScene is set (Scene manages link to GL-context); b) secondary selection is not in progress as different render-path is usually taken in this case.

Otherwise we return internal bool.

Override this in sub-class if different behaviour is required.

Reimplemented in TGLObject, TEveCalo3DGL, TEveStraightLineSetGL, TEveBoxSetGL, and TPointSet3DGL.

Definition at line 285 of file TGLLogicalShape.cxx.

Referenced by Draw().

void TGLLogicalShape::StrongRef ( Bool_t  strong) const
inline

Definition at line 75 of file TGLLogicalShape.h.

Referenced by TGLClip::TGLClip().

void TGLLogicalShape::SubRef ( TGLPhysicalShape phys) const

Remove reference to given physical shape, potentially deleting this object when hitting zero ref-count (if fRefStrong is true).

Definition at line 171 of file TGLLogicalShape.cxx.

Referenced by TGLPhysicalShape::~TGLPhysicalShape().

virtual ELODAxes TGLLogicalShape::SupportedLODAxes ( ) const
inlinevirtual

Reimplemented in TGLCylinder, and TGLSphere.

Definition at line 97 of file TGLLogicalShape.h.

Referenced by TGLPhysicalShape::CalculateShapeLOD().

virtual Bool_t TGLLogicalShape::SupportsSecondarySelect ( ) const
inlinevirtual
UInt_t TGLLogicalShape::UnrefFirstPhysical ( )

Unreferenced first physical in the list, returning its id and making it fit for destruction somewhere else.

Returns 0 if there are no replicas attached.

Definition at line 222 of file TGLLogicalShape.cxx.

Referenced by TGLScene::DestroyLogical().

virtual void TGLLogicalShape::UpdateBoundingBox ( )
inlinevirtual
void TGLLogicalShape::UpdateBoundingBoxesOfPhysicals ( )

Update bounding-boxed of all dependent physicals.

Definition at line 242 of file TGLLogicalShape.cxx.

Referenced by TEveTextGL::DirectDraw(), and TGLObject::UpdateBoundingBox().

Friends And Related Function Documentation

friend class TGLScene
friend

Definition at line 33 of file TGLLogicalShape.h.

Member Data Documentation

TGLBoundingBox TGLLogicalShape::fBoundingBox
protected
UInt_t TGLLogicalShape::fDLBase
mutableprotected

scene where object is stored (can be zero!)

Definition at line 54 of file TGLLogicalShape.h.

Referenced by DLCacheDrop(), DLCachePurge(), and Draw().

Bool_t TGLLogicalShape::fDLCache
mutableprotected
Int_t TGLLogicalShape::fDLSize
mutableprotected

display-list id base

Definition at line 55 of file TGLLogicalShape.h.

Referenced by DLCachePurge(), Draw(), TGLCylinder::TGLCylinder(), and TGLSphere::TGLSphere().

UShort_t TGLLogicalShape::fDLValid
mutableprotected

display-list size for different LODs

Definition at line 56 of file TGLLogicalShape.h.

Referenced by DLCacheClear(), DLCacheDrop(), DLCachePurge(), and Draw().

TObject* TGLLogicalShape::fExternalObj
protected
TGLPhysicalShape* TGLLogicalShape::fFirstPhysical
mutableprotected
Bool_t TGLLogicalShape::fgIgnoreSizeForCameraInterest = kFALSE
staticprotected
Bool_t TGLLogicalShape::fOwnExtObj
mutableprotected

Strong ref (delete on 0 ref); not in scene.

Definition at line 59 of file TGLLogicalShape.h.

Referenced by TGLLogicalShape(), and ~TGLLogicalShape().

UInt_t TGLLogicalShape::fRef
mutableprotected
Bool_t TGLLogicalShape::fRefStrong
mutableprotected

use display list caching

Definition at line 58 of file TGLLogicalShape.h.

Referenced by SubRef().

TGLScene* TGLLogicalShape::fScene
mutableprotected

Shape's bounding box.

Definition at line 53 of file TGLLogicalShape.h.

Referenced by TGLScene::AdoptLogical(), GetScene(), PurgeDLRange(), TGLObject::ShouldDLCache(), and ShouldDLCache().


The documentation for this class was generated from the following files: