Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/gl:$Id$
0002 // Author:  Matevz Tadel, Feb 2007
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_TGLSceneBase_H
0013 #define ROOT_TGLSceneBase_H
0014 
0015 #include "TGLLockable.h"
0016 #include "TGLBoundingBox.h"
0017 
0018 #include <TString.h>
0019 
0020 #include <list>
0021 
0022 class TGLViewerBase;
0023 class TGLSceneInfo;
0024 class TGLClip;
0025 class TGLRnrCtx;
0026 class TGLLogicalShape;
0027 class TGLSelectRecord;
0028 
0029 // Avoid TObject inheritance due to clash with TObject::Draw as well
0030 // as possible inheritance of TGLPadScene from VierualViewer3D.
0031 
0032 class TGLSceneBase : public TGLLockable // : public TObject / TNamed
0033 {
0034 private:
0035    TGLSceneBase(const TGLSceneBase&) = delete;
0036    TGLSceneBase& operator=(const TGLSceneBase&) = delete;
0037 
0038    static UInt_t fgSceneIDSrc;
0039 
0040 protected:
0041    UInt_t             fSceneID;     // Unique scene id.
0042    TString            fName;        // Object identifier.
0043    TString            fTitle;       // Object title.
0044 
0045    UInt_t             fTimeStamp;   // Counter increased on every update.
0046    UInt_t             fMinorStamp;  // Counter increased on minimal update.
0047    Short_t            fLOD;         // Scene-lod.
0048    Short_t            fStyle;       // Scene-style.
0049    Float_t            fWFLineW;     // Scene wire-frame line-width.
0050    Float_t            fOLLineW;     // Scene outline line-width.
0051    TGLClip          * fClip;        // Scene clipping-plane.
0052    Bool_t             fSelectable;  // Objects in the scene are selectable.
0053 
0054    // BoundingBox
0055    mutable TGLBoundingBox fBoundingBox;      // bounding box for scene (axis aligned) - lazy update - use BoundingBox() to access
0056    mutable Bool_t         fBoundingBoxValid; // bounding box valid?
0057 
0058    Bool_t  fDoFrustumCheck;  // Perform global frustum-check in UpdateSceneInfo()
0059    Bool_t  fDoClipCheck;     // Perform global clip-plane-check in UpdateSceneInfo()
0060 
0061    // Interface to other components
0062    typedef std::list<TGLViewerBase*>           ViewerList_t;
0063    typedef std::list<TGLViewerBase*>::iterator ViewerList_i;
0064 
0065    ViewerList_t       fViewers;
0066    Bool_t             fAutoDestruct;
0067 
0068    // Possible future extensions
0069    // TGLMatrix fGlobalTrans;
0070 
0071 public:
0072    TGLSceneBase();
0073    ~TGLSceneBase() override;
0074 
0075    void AddViewer(TGLViewerBase* viewer);
0076    void RemoveViewer(TGLViewerBase* viewer);
0077    void TagViewersChanged();
0078 
0079    const char* LockIdStr() const override;
0080 
0081    virtual const char  *GetName()  const { return fName; }
0082    virtual const char  *GetTitle() const { return fTitle; }
0083    virtual void  SetName (const char *name)  { fName = name; }
0084    virtual void  SetTitle(const char *title) { fTitle = title; }
0085    virtual void  SetNameTitle(const char *name, const char *title) { SetName(name); SetTitle(title); }
0086 
0087    virtual TGLSceneInfo* CreateSceneInfo(TGLViewerBase* view);
0088    virtual void          RebuildSceneInfo(TGLRnrCtx& ctx);
0089    virtual void          UpdateSceneInfo(TGLRnrCtx& ctx);
0090    virtual void          LodifySceneInfo(TGLRnrCtx& ctx);
0091 
0092    // Rendering
0093    virtual void PreDraw   (TGLRnrCtx& rnrCtx);
0094    virtual void PreRender (TGLRnrCtx& rnrCtx);
0095    virtual void Render    (TGLRnrCtx& rnrCtx);
0096    virtual void RenderOpaque   (TGLRnrCtx& rnrCtx);
0097    virtual void RenderTransp   (TGLRnrCtx& rnrCtx);
0098    virtual void RenderSelOpaque(TGLRnrCtx& rnrCtx);
0099    virtual void RenderSelTransp(TGLRnrCtx& rnrCtx);
0100    virtual void RenderSelOpaqueForHighlight(TGLRnrCtx& rnrCtx);
0101    virtual void RenderSelTranspForHighlight(TGLRnrCtx& rnrCtx);
0102    virtual void PostRender(TGLRnrCtx& rnrCtx);
0103    virtual void PostDraw  (TGLRnrCtx& rnrCtx);
0104 
0105    virtual TGLLogicalShape* FindLogical(TObject*) const { return nullptr; }
0106 
0107    // Selection interface
0108    virtual Bool_t ResolveSelectRecord(TGLSelectRecord& rec, Int_t curIdx);
0109 
0110 
0111    // Getters & setters
0112 
0113    UInt_t GetTimeStamp() const { return fTimeStamp; }
0114    void   IncTimeStamp()       { ++fTimeStamp; fMinorStamp = 1; }
0115 
0116    UInt_t GetMinorStamp() const { return fMinorStamp; }
0117    void   IncMinorStamp()       { ++fMinorStamp;      }
0118 
0119    Short_t  LOD()          const { return fLOD; }
0120    void     SetLOD(Short_t lod)  { fLOD = lod;  }
0121 
0122    Short_t  Style()        const { return fStyle; }
0123    void     SetStyle(Short_t st) { fStyle = st;   }
0124 
0125    TGLClip* Clip()         const { return fClip; }
0126    void     SetClip(TGLClip *p)  { fClip = p;    }
0127 
0128    Bool_t   GetSelectable()   const { return fSelectable; }
0129    void     SetSelectable(Bool_t a) { fSelectable = a;    }
0130 
0131    Bool_t   GetAutoDestruct()   const { return fAutoDestruct; }
0132    void     SetAutoDestruct(Bool_t a) { fAutoDestruct = a;    }
0133 
0134    // BoundingBox
0135 
0136    virtual void CalcBoundingBox() const = 0;
0137    void         InvalidateBoundingBox() { fBoundingBoxValid = kFALSE; }
0138    const TGLBoundingBox& BoundingBox() const
0139    { if (!fBoundingBoxValid) CalcBoundingBox(); return fBoundingBox; }
0140 
0141 
0142    ClassDefOverride(TGLSceneBase, 0) // Base-class for OpenGL scenes.
0143 }; // endclass TGLSceneBase
0144 
0145 
0146 #endif