Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:00

0001 // @(#)root/gl:$Id$
0002 // Author:  Richard Maunder  25/05/2005
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TGLLogicalShape
0013 #define ROOT_TGLLogicalShape
0014 
0015 #include "TGLBoundingBox.h"
0016 
0017 class TBuffer3D;
0018 class TObject;
0019 class TContextMenu;
0020 
0021 class TGLPhysicalShape;
0022 class TGLRnrCtx;
0023 class TGLSelectRecord;
0024 class TGLViewer;
0025 class TGLSceneBase;
0026 class TGLScene;
0027 
0028 
0029 class TGLLogicalShape
0030 {
0031    friend class TGLScene;
0032 
0033 private:
0034    TGLLogicalShape(const TGLLogicalShape&) = delete;
0035    TGLLogicalShape& operator=(const TGLLogicalShape&) = delete;
0036 
0037 public:
0038    enum ELODAxes  { kLODAxesNone = 0,  // LOD will be set to high or pixel.
0039                     kLODAxesX    = 1 << 0,
0040                     kLODAxesY    = 1 << 1,
0041                     kLODAxesZ    = 1 << 2,
0042                     kLODAxesAll  = kLODAxesX | kLODAxesY | kLODAxesZ
0043                   };
0044 
0045 protected:
0046    mutable UInt_t             fRef;           //! physical instance ref counting
0047    mutable TGLPhysicalShape  *fFirstPhysical; //! first replica
0048 
0049    TObject           *fExternalObj; //! Also plays the role of ID.
0050    TGLBoundingBox     fBoundingBox; //! Shape's bounding box.
0051    mutable TGLScene  *fScene;       //! scene where object is stored (can be zero!)
0052    mutable UInt_t     fDLBase;      //! display-list id base
0053    mutable Int_t      fDLSize;      //! display-list size for different LODs
0054    mutable UShort_t   fDLValid;     //! display-list validity bit-field
0055    mutable Bool_t     fDLCache;     //! use display list caching
0056    mutable Bool_t     fRefStrong;   //! Strong ref (delete on 0 ref); not in scene
0057    mutable Bool_t     fOwnExtObj;   //! External object is a fake
0058 
0059    void PurgeDLRange(UInt_t base, Int_t size) const;
0060 
0061    static  Bool_t     fgIgnoreSizeForCameraInterest;
0062 
0063    static  Bool_t     fgUseDLs;            //! global flag for usage of display-lists
0064    static  Bool_t     fgUseDLsForVertArrs; //! global flag for usage of display-lists in shapes that use vertex arrays
0065 
0066 public:
0067    TGLLogicalShape();
0068    TGLLogicalShape(TObject* obj);
0069    TGLLogicalShape(const TBuffer3D & buffer);
0070    virtual ~TGLLogicalShape();
0071 
0072    // Physical shape reference-counting, replica management
0073    UInt_t Ref() const { return fRef; }
0074    void   AddRef(TGLPhysicalShape* phys) const;
0075    void   SubRef(TGLPhysicalShape* phys) const;
0076    void   StrongRef(Bool_t strong) const { fRefStrong = strong; }
0077    void   DestroyPhysicals();
0078    UInt_t UnrefFirstPhysical();
0079 
0080    const TGLPhysicalShape* GetFirstPhysical() const { return fFirstPhysical; }
0081 
0082    TObject*  ID()          const { return fExternalObj; }
0083    TObject*  GetExternal() const { return fExternalObj; }
0084    TGLScene* GetScene()    const { return fScene; }
0085 
0086    const TGLBoundingBox& BoundingBox() const { return fBoundingBox; }
0087    virtual void          UpdateBoundingBox() {}
0088    void                  UpdateBoundingBoxesOfPhysicals();
0089 
0090    // Display List Caching
0091            Bool_t SetDLCache(Bool_t cached);
0092    virtual Bool_t ShouldDLCache(const TGLRnrCtx & rnrCtx) const;
0093    virtual UInt_t DLOffset(Short_t /*lod*/) const { return 0; }
0094    virtual void   DLCacheClear();
0095    virtual void   DLCacheDrop();
0096    virtual void   DLCachePurge();
0097 
0098    virtual ELODAxes SupportedLODAxes() const { return kLODAxesNone; }
0099    virtual Short_t  QuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD) const;
0100    virtual void     Draw(TGLRnrCtx& rnrCtx) const;
0101    virtual void     DirectDraw(TGLRnrCtx& rnrCtx) const = 0; // Actual draw method (non DL cached)
0102 
0103    virtual void     DrawHighlight(TGLRnrCtx& rnrCtx, const TGLPhysicalShape* pshp, Int_t lvl=-1) const;
0104 
0105    virtual Bool_t IgnoreSizeForOfInterest() const;
0106 
0107    // Override in sub-classes that do direct object rendering (e.g. TGLObject).
0108    virtual Bool_t KeepDuringSmartRefresh() const { return kFALSE; }
0109    // Override in sub-classes that support secondary selection (e.g. TPointSet3DGL).
0110    virtual Bool_t SupportsSecondarySelect() const { return kFALSE; }
0111    virtual Bool_t AlwaysSecondarySelect()   const { return kFALSE; }
0112    virtual void   ProcessSelection(TGLRnrCtx& rnrCtx, TGLSelectRecord& rec);
0113 
0114    void InvokeContextMenu(TContextMenu & menu, UInt_t x, UInt_t y) const;
0115 
0116    static Bool_t GetIgnoreSizeForCameraInterest();
0117    static void   SetIgnoreSizeForCameraInterest(Bool_t isfci);
0118 
0119    static void   SetEnvDefaults();
0120 
0121    ClassDef(TGLLogicalShape,0) // a logical (non-placed, local frame) drawable object
0122 };
0123 
0124 
0125 #endif // ROOT_TGLLogicalShape