Back to home page

EIC code displayed by LXR

 
 

    


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

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_TGLViewerBase
0013 #define ROOT_TGLViewerBase
0014 
0015 #include <TObject.h>
0016 
0017 #include "TGLLockable.h"
0018 #include <TGLBoundingBox.h>
0019 #include "TGLOverlay.h"
0020 
0021 #include <list>
0022 #include <vector>
0023 
0024 class TGLSceneBase;
0025 class TGLSceneInfo;
0026 class TGLCamera;
0027 class TGLClip;
0028 class TGLRnrCtx;
0029 class TGLLogicalShape;
0030 class TGLSelectRecord;
0031 class TGLOvlSelectRecord;
0032 class TGLOverlayElement;
0033 
0034 // Avoid TObject inheritance due to clash with TVirtualViewer3D.
0035 
0036 class TGLViewerBase : public TGLLockable // : public TObject
0037 {
0038 private:
0039    TGLViewerBase(const TGLViewerBase&) = delete;
0040    TGLViewerBase& operator=(const TGLViewerBase&) = delete;
0041 
0042 protected:
0043    typedef std::list<TGLSceneInfo*>             SceneInfoList_t;
0044    typedef SceneInfoList_t::iterator            SceneInfoList_i;
0045 
0046    typedef std::vector<TGLSceneInfo*>           SceneInfoVec_t;
0047    typedef SceneInfoVec_t::iterator             SceneInfoVec_i;
0048 
0049    typedef std::vector<TGLOverlayElement*>      OverlayElmVec_t;
0050    typedef OverlayElmVec_t::iterator            OverlayElmVec_i;
0051 
0052    SceneInfoList_i FindScene(TGLSceneBase* scene);
0053 
0054    typedef void (TGLSceneBase::* SubRender_foo) (TGLRnrCtx &);
0055 
0056    void SubRenderScenes(SubRender_foo render_foo);
0057 
0058    virtual void SetupClipObject();
0059 
0060    // Members
0061 
0062    TGLRnrCtx         *fRnrCtx;
0063 
0064    TGLCamera         *fCamera;      // Camera for rendering.
0065    TGLClip           *fClip;        // Viewer clipping-plane.
0066    Short_t            fLOD;         // Viewer-lod for rendering.
0067    Short_t            fStyle;       // Viewer-style for rendering.
0068    Float_t            fWFLineW;     // Optional override of scene wire-frame line-width
0069    Float_t            fOLLineW;     // Optional override of scene outline line-width
0070 
0071    Bool_t             fResetSceneInfosOnRender; // Request rebuild of view-specific scene data.
0072    Bool_t             fChanged;                 // Change requiring redraw is pending.
0073 
0074    SceneInfoList_t    fScenes;                  // Registered scenes.
0075    SceneInfoVec_t     fVisScenes;               // Visible scenes.
0076 
0077    TGLBoundingBox     fOverallBoundingBox;      // Axis-aligned union of scene bboxes.
0078 
0079    OverlayElmVec_t    fOverlay;
0080 
0081    // ================================================================
0082 
0083 public:
0084 
0085    TGLViewerBase();
0086    ~TGLViewerBase() override;
0087 
0088    const char* LockIdStr() const override;
0089 
0090    TGLSceneInfo* AddScene(TGLSceneBase* scene);
0091    void          RemoveScene(TGLSceneBase* scene);
0092    void          RemoveAllScenes();
0093    void          SceneDestructing(TGLSceneBase* scene);
0094 
0095    TGLSceneInfo* GetSceneInfo(TGLSceneBase* scene);
0096 
0097    TGLLogicalShape* FindLogicalInScenes(TObject* id);
0098 
0099    virtual void AddOverlayElement(TGLOverlayElement* el);
0100    virtual void RemoveOverlayElement(TGLOverlayElement* el);
0101    virtual void DeleteOverlayAnnotations();
0102    virtual void DeleteOverlayElements(TGLOverlayElement::ERole r);
0103 
0104    TGLClip* Clip()         const { return fClip; }
0105    void     SetClip(TGLClip *p)  { fClip = p;    }
0106 
0107    Short_t  LOD()          const { return fLOD; }
0108    void     SetLOD(Short_t lod)  { fLOD = lod;  }
0109 
0110    Short_t  Style()        const { return fStyle; }
0111    void     SetStyle(Short_t st) { fStyle = st;   }
0112 
0113    Float_t  WFLineW()       const { return fWFLineW; }
0114    void     SetWFLineW(Float_t w) { fWFLineW = w;    }
0115    Float_t  OLLineW()       const { return fOLLineW; }
0116    void     SetOLLineW(Float_t w) { fOLLineW = w;    }
0117 
0118    // ================================================================
0119 
0120    virtual void   ResetSceneInfos();
0121    virtual void   Changed() { fChanged = kTRUE; }
0122    virtual Bool_t IsChanged() const { return fChanged; }
0123 
0124    virtual void   MergeSceneBBoxes(TGLBoundingBox& bbox);
0125 
0126    const TGLBoundingBox& RefOverallBoundingBox() const { return fOverallBoundingBox; }
0127 
0128    // ================================================================
0129 
0130    // Low-level methods
0131    virtual void PreRender();
0132    virtual void Render();
0133    virtual void RenderNonSelected();
0134    virtual void RenderSelected();
0135    virtual void RenderSelectedForHighlight();
0136    virtual void RenderOpaque(Bool_t rnr_non_selected=kTRUE, Bool_t rnr_selected=kTRUE);
0137    virtual void RenderTransparent(Bool_t rnr_non_selected=kTRUE, Bool_t rnr_selected=kTRUE);
0138    virtual void RenderOverlay(Int_t state, Bool_t selection);
0139    virtual void PostRender();
0140 
0141    virtual void PreRenderOverlaySelection();
0142    virtual void PostRenderOverlaySelection();
0143 
0144    // High-level methods
0145    // virtual void Draw();
0146    // virtual void Select();
0147    // virtual void SelectOverlay();
0148 
0149    // Demangle select buffer
0150    Bool_t ResolveSelectRecord(TGLSelectRecord& rec, Int_t recIdx);
0151    // Slightly higher-level search in select-buffer
0152    Bool_t FindClosestRecord      (TGLSelectRecord& rec, Int_t& recIdx);
0153    Bool_t FindClosestOpaqueRecord(TGLSelectRecord& rec, Int_t& recIdx);
0154 
0155    // Demangle overlay select buffer
0156    Bool_t FindClosestOverlayRecord(TGLOvlSelectRecord& rec, Int_t& recIdx);
0157 
0158    TGLRnrCtx* GetRnrCtx() const { return  fRnrCtx; }
0159    TGLRnrCtx& RnrCtx() const    { return *fRnrCtx; }
0160 
0161    ClassDefOverride(TGLViewerBase, 0); // GL Viewer base-class.
0162 };
0163 
0164 
0165 #endif