TGLLogicalShape.h

Go to the documentation of this file.
00001 // @(#)root/gl:$Id: TGLLogicalShape.h 33124 2010-04-21 20:04:42Z matevz $
00002 // Author:  Richard Maunder  25/05/2005
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGLLogicalShape
00013 #define ROOT_TGLLogicalShape
00014 
00015 #ifndef ROOT_TGLBoundingBox
00016 #include "TGLBoundingBox.h"
00017 #endif
00018 
00019 class TBuffer3D;
00020 class TObject;
00021 class TContextMenu;
00022 
00023 class TGLPhysicalShape;
00024 class TGLRnrCtx;
00025 class TGLSelectRecord;
00026 class TGLViewer;
00027 class TGLSceneBase;
00028 class TGLScene;
00029 
00030 
00031 class TGLLogicalShape
00032 {
00033    friend class TGLScene;
00034 
00035 private:
00036    TGLLogicalShape(const TGLLogicalShape&);            // Not implemented.
00037    TGLLogicalShape& operator=(const TGLLogicalShape&); // Not implemented.
00038 
00039 public:
00040    enum ELODAxes  { kLODAxesNone = 0,  // LOD will be set to high or pixel.
00041                     kLODAxesX    = 1 << 0,
00042                     kLODAxesY    = 1 << 1,
00043                     kLODAxesZ    = 1 << 2,
00044                     kLODAxesAll  = kLODAxesX | kLODAxesY | kLODAxesZ
00045                   };
00046 
00047 protected:
00048    mutable UInt_t             fRef;           //! physical instance ref counting
00049    mutable TGLPhysicalShape  *fFirstPhysical; //! first replica
00050 
00051    TObject           *fExternalObj; //! Also plays the role of ID.
00052    TGLBoundingBox     fBoundingBox; //! Shape's bounding box.
00053    mutable TGLScene  *fScene;       //! scene where object is stored (can be zero!)
00054    mutable UInt_t     fDLBase;      //! display-list id base
00055    mutable Int_t      fDLSize;      //! display-list size for different LODs
00056    mutable UShort_t   fDLValid;     //! display-list validity bit-field
00057    mutable Bool_t     fDLCache;     //! use display list caching
00058    mutable Bool_t     fRefStrong;   //! Strong ref (delete on 0 ref); not in scene
00059    mutable Bool_t     fOwnExtObj;   //! External object is a fake
00060 
00061    void PurgeDLRange(UInt_t base, Int_t size) const;
00062 
00063 public:
00064    TGLLogicalShape();
00065    TGLLogicalShape(TObject* obj);
00066    TGLLogicalShape(const TBuffer3D & buffer);
00067    virtual ~TGLLogicalShape();
00068 
00069    // Physical shape reference-counting, replica management
00070    UInt_t Ref() const { return fRef; }
00071    void   AddRef(TGLPhysicalShape* phys) const;
00072    void   SubRef(TGLPhysicalShape* phys) const;
00073    void   StrongRef(Bool_t strong) const { fRefStrong = strong; }
00074    void   DestroyPhysicals();
00075    UInt_t UnrefFirstPhysical();
00076 
00077    const TGLPhysicalShape* GetFirstPhysical() const { return fFirstPhysical; }
00078 
00079    TObject*  ID()          const { return fExternalObj; }
00080    TObject*  GetExternal() const { return fExternalObj; }
00081    TGLScene* GetScene()    const { return fScene; }
00082 
00083    const TGLBoundingBox& BoundingBox() const { return fBoundingBox; }
00084    virtual void          UpdateBoundingBox() {}
00085    void                  UpdateBoundingBoxesOfPhysicals();
00086 
00087    // Display List Caching
00088            Bool_t SetDLCache(Bool_t cached);
00089    virtual Bool_t ShouldDLCache(const TGLRnrCtx & rnrCtx) const;
00090    virtual UInt_t DLOffset(Short_t /*lod*/) const { return 0; }
00091    virtual void   DLCacheClear();
00092    virtual void   DLCacheDrop();
00093    virtual void   DLCachePurge();
00094 
00095    virtual ELODAxes SupportedLODAxes() const { return kLODAxesNone; }
00096    virtual Short_t  QuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD) const;
00097    virtual void     Draw(TGLRnrCtx& rnrCtx) const;
00098    virtual void     DirectDraw(TGLRnrCtx& rnrCtx) const = 0; // Actual draw method (non DL cached)
00099 
00100    virtual void     DrawHighlight(TGLRnrCtx& rnrCtx, const TGLPhysicalShape* pshp, Int_t lvl=-1) const;
00101 
00102    virtual Bool_t IgnoreSizeForOfInterest() const { return kFALSE; }
00103 
00104    // Override in sub-classes that do direct object rendering (e.g. TGLObject).
00105    virtual Bool_t KeepDuringSmartRefresh() const { return kFALSE; }
00106    // Override in sub-classes that support secondary selection (e.g. TPointSet3DGL).
00107    virtual Bool_t SupportsSecondarySelect() const { return kFALSE; }
00108    virtual Bool_t AlwaysSecondarySelect()   const { return kFALSE; }
00109    virtual void   ProcessSelection(TGLRnrCtx& rnrCtx, TGLSelectRecord& rec);
00110 
00111    void InvokeContextMenu(TContextMenu & menu, UInt_t x, UInt_t y) const;
00112 
00113    ClassDef(TGLLogicalShape,0) // a logical (non-placed, local frame) drawable object
00114 };
00115 
00116 
00117 #endif // ROOT_TGLLogicalShape

Generated on Tue Jul 5 14:16:47 2011 for ROOT_528-00b_version by  doxygen 1.5.1