ROOT logo
ROOT » GRAF3D » GL » TGLLogicalShape

class TGLLogicalShape


 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 :
 Sphere A - Radius r1, center v1
 Sphere B - Radius r2, center v2
 Sphere C - Radius r1, center v3

 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 does not support LOD (only sphere and tube) and
 therefore reasonable defaults are encoded in the following virtual
 functions:

 * ELODAxes SupportedLODAxes()  { return kLODAxesNone; }
 * 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.

Function Members (Methods)

 
    This is an abstract class, constructors will not be documented.
    Look at the header to check for available constructors.

public:
virtual~TGLLogicalShape()
voidAddRef(TGLPhysicalShape* phys) const
const TGLBoundingBox&BoundingBox() const
static TClass*Class()
voidDestroyPhysicals()
virtual voidDirectDraw(TGLRnrCtx& rnrCtx) const
virtual voidDLCacheClear()
virtual voidDLCacheDrop()
virtual voidDLCachePurge()
virtual UInt_tDLOffset(Short_t) const
virtual voidDraw(TGLRnrCtx& rnrCtx) const
TObject*GetExternal() const
const TGLPhysicalShape*GetFirstPhysical() const
TGLScene*GetScene() const
TObject*ID() const
virtual Bool_tIgnoreSizeForOfInterest() const
voidInvokeContextMenu(TContextMenu& menu, UInt_t x, UInt_t y) const
virtual TClass*IsA() const
virtual Bool_tKeepDuringSmartRefresh() const
virtual voidProcessSelection(TGLRnrCtx& rnrCtx, TGLSelectRecord& rec)
virtual Short_tQuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD) const
UInt_tRef() const
Bool_tSetDLCache(Bool_t cached)
virtual Bool_tShouldDLCache(const TGLRnrCtx& rnrCtx) const
virtual voidShowMembers(TMemberInspector& insp, char* parent)
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
voidStrongRef(Bool_t strong) const
voidSubRef(TGLPhysicalShape* phys) const
virtual TGLLogicalShape::ELODAxesSupportedLODAxes() const
virtual Bool_tSupportsSecondarySelect() const
UInt_tUnrefFirstPhysical()
virtual voidUpdateBoundingBox()
voidUpdateBoundingBoxesOfPhysicals()
protected:
voidPurgeDLRange(UInt_t base, Int_t size) const

Data Members

private:
enum ELODAxes { kLODAxesNone
kLODAxesX
kLODAxesY
kLODAxesZ
kLODAxesAll
};
protected:
TGLBoundingBoxfBoundingBox! Shape's bounding box.
UInt_tfDLBase! display-list id base
Bool_tfDLCache! use display list caching
Int_tfDLSize! display-list size for different LODs
UShort_tfDLValid! display-list validity bit-field
TObject*fExternalObj! Also plays the role of ID.
TGLPhysicalShape*fFirstPhysical! first replica
Bool_tfOwnExtObj! External object is a fake
UInt_tfRef! physical instance ref counting
Bool_tfRefStrong! Strong ref (delete on 0 ref); not in scene
TGLScene*fScene! scene where object is stored (can be zero!)

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

~TGLLogicalShape()
 Destroy logical shape.
void AddRef(TGLPhysicalShape* phys) const
 Add reference to given physical shape.
void SubRef(TGLPhysicalShape* phys) const
 Remove reference to given physical shape, potentially deleting
 *this* object when hitting zero ref-count (if fRefStrong is
 true).
void DestroyPhysicals()
 Destroy all physicals attached to this logical.
UInt_t UnrefFirstPhysical()
 Unreference first physical in the list, returning its id and
 making it fit for destruction somewhere else.
 Returns 0 if there are no replicas attached.
void UpdateBoundingBoxesOfPhysicals()
 Update bounding-boxed of all dependent physicals.
Bool_t SetDLCache(Bool_t cached)
 Modify capture of draws into display list cache kTRUE - capture,
 kFALSE direct draw. Return kTRUE is state changed, kFALSE if not.
Bool_t ShouldDLCache(const TGLRnrCtx& rnrCtx) const
 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.
void DLCacheClear()
 Clear all entries for all LODs for this drawable from the
 display list cache but keeping the reserved ids from GL context.
void DLCacheDrop()
 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.
void DLCachePurge()
 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!
void PurgeDLRange(UInt_t base, Int_t size) const
 Purge given display-list range.
 Utility function.
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.
 This function should be overriden to perform the desired quantization.
 See TGLSphere.
void Draw(TGLRnrCtx& rnrCtx) const
 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.
void ProcessSelection(TGLRnrCtx& rnrCtx, TGLSelectRecord& rec)
 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.
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'
TGLLogicalShape& operator=(const TGLLogicalShape& )
UInt_t Ref() const
 Physical shape reference-counting, replica management
{ return fRef; }
void StrongRef(Bool_t strong) const
{ fRefStrong = strong; }
const TGLPhysicalShape * GetFirstPhysical() const
{ return fFirstPhysical; }
TObject * ID() const
{ return fExternalObj; }
TObject * GetExternal() const
{ return fExternalObj; }
TGLScene * GetScene() const
{ return fScene; }
void UpdateBoundingBox()
{}
UInt_t DLOffset(Short_t ) const
{ return 0; }
ELODAxes SupportedLODAxes() const
{ return kLODAxesNone; }
void DirectDraw(TGLRnrCtx& rnrCtx) const
Bool_t IgnoreSizeForOfInterest() const
{ return kFALSE; }
Bool_t KeepDuringSmartRefresh() const
 Override in sub-classes that do direct object rendering (e.g. TGLObject).
{ return kFALSE; }
Bool_t SupportsSecondarySelect() const
{ return kFALSE; }