Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TGLRnrCtx.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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_TGLRnrCtx
0013 #define ROOT_TGLRnrCtx
0014 
0015 #include "Rtypes.h"
0016 #include "TGLStopwatch.h"
0017 
0018 #include <list>
0019 
0020 class TGLViewerBase;
0021 class TGLCamera;
0022 class TGLSceneBase;
0023 class TGLSceneInfo;
0024 
0025 class TGLColorSet;
0026 class TGLFont;
0027 class TGLContextIdentity;
0028 
0029 class TGLClip;
0030 class TGLSelectBuffer;
0031 
0032 class TGLRect;
0033 
0034 class GLUquadric;
0035 
0036 /**************************************************************************/
0037 // TGLRnrCtx
0038 /**************************************************************************/
0039 
0040 class TGLRnrCtx
0041 {
0042 public:
0043    enum EStyle
0044    {
0045       kStyleUndef     =  -1,
0046       kFill,
0047       kOutline,
0048       kWireFrame
0049    };
0050    static const char* StyleName(Short_t style);
0051 
0052    enum EPass
0053    {
0054       kPassUndef      =  -1,
0055       kPassFill,
0056       kPassOutlineFill,
0057       kPassOutlineLine,
0058       kPassWireFrame
0059    };
0060 
0061    enum ELODPresets
0062    {
0063       kLODUndef       =  -1,
0064       kLODPixel       =   0, // Projected size pixel or less
0065       kLODLow         =  20,
0066       kLODMed         =  50,
0067       kLODHigh        = 100
0068    };
0069 
0070    enum EShapeSelectionLevel
0071    {
0072       kSSLNotSelected,
0073       kSSLSelected,
0074       kSSLImpliedSelected,
0075       kSSLHighlighted,
0076       kSSLImpliedHighlighted,
0077       kSSLEnd
0078    };
0079 
0080    enum ESelectabilityOfTransparents
0081    {
0082       kIfNoOpaques = 0,
0083       kIfClosest,
0084       kNever
0085    };
0086 
0087 private:
0088    TGLRnrCtx(const TGLRnrCtx&) = delete;
0089    TGLRnrCtx& operator=(const TGLRnrCtx&) = delete;
0090 
0091    typedef std::list<TGLColorSet*> lpTGLColorSet_t;
0092 
0093 protected:
0094    TGLViewerBase  *fViewer;
0095    TGLCamera      *fCamera;
0096    TGLSceneInfo   *fSceneInfo;
0097 
0098    Short_t         fViewerLOD;
0099    Short_t         fSceneLOD;
0100    Short_t         fCombiLOD;     // Combined viewer/scene lod.
0101    Short_t         fShapeLOD;     // LOD calculated for current shape.
0102    Float_t         fShapePixSize; // Only relevant when not using display lists.
0103 
0104    Short_t         fViewerStyle;
0105    Short_t         fSceneStyle;
0106 
0107    Float_t         fViewerWFLineW;
0108    Float_t         fSceneWFLineW;
0109    Float_t         fViewerOLLineW;
0110    Float_t         fSceneOLLineW;
0111 
0112    TGLClip        *fViewerClip;
0113    TGLClip        *fSceneClip;
0114    TGLClip        *fClip;
0115 
0116    Short_t         fDrawPass;
0117 
0118    TGLStopwatch    fStopwatch;
0119    Double_t        fRenderTimeOut;
0120    Bool_t          fIsRunning;
0121    Bool_t          fHasTimedOut;
0122 
0123    // Highlight / Selection stuff
0124    Bool_t          fHighlight;        // True when in highlight.
0125    Bool_t          fHighlightOutline; // True when in highlight-outline.
0126    Bool_t          fSelection;        // True when in selection.
0127    Bool_t          fSecSelection;     // True when in secondary selection.
0128    Short_t         fSelectTransparents;
0129    Int_t           fPickRadius;
0130    TGLRect        *fPickRectangle;
0131    TGLSelectBuffer*fSelectBuffer;
0132 
0133    lpTGLColorSet_t*fColorSetStack;
0134    Float_t         fRenderScale;
0135 
0136    UInt_t          fEventKeySym;
0137 
0138    // GL state
0139    Bool_t              fDLCaptureOpen; //! DL-capture currently open
0140    TGLContextIdentity *fGLCtxIdentity; //! Current GL context identity
0141 
0142    GLUquadric         *fQuadric;
0143 
0144    // Picture grabbing
0145    Bool_t           fGrabImage;    // Set to true to store the image.
0146    Int_t            fGrabBuffer;   // Which buffer to grab after render.
0147    UChar_t         *fGrabbedImage; // Buffer where image was stored after rendering.
0148 
0149 public:
0150    TGLRnrCtx(TGLViewerBase* viewer);
0151    virtual ~TGLRnrCtx();
0152 
0153    // Central objects
0154    TGLViewerBase * GetViewer() { return  fViewer; }
0155    TGLViewerBase & RefViewer() { return *fViewer; }
0156    TGLCamera     * GetCamera() { return  fCamera; }
0157    TGLCamera     & RefCamera() { return *fCamera; }
0158    TGLSceneInfo  * GetSceneInfo()  { return  fSceneInfo; }
0159    TGLSceneInfo  & RefSceneInfo()  { return *fSceneInfo; }
0160    TGLSceneBase  * GetScene();
0161    TGLSceneBase  & RefScene();
0162 
0163    const TGLCamera & RefCamera() const { return *fCamera; }
0164    const TGLCamera * GetCamera() const { return  fCamera; }
0165 
0166    // void SetViewer   (TGLViewerBase* v) { fViewer = v; }
0167    void SetCamera   (TGLCamera*     c) { fCamera = c; }
0168    void SetSceneInfo(TGLSceneInfo* si) { fSceneInfo = si; }
0169 
0170    // Draw LOD, style, clip, rnr-pass
0171    Short_t ViewerLOD()   const         { return fViewerLOD; }
0172    void    SetViewerLOD(Short_t LOD)   { fViewerLOD = LOD;  }
0173    Short_t SceneLOD()    const         { return fSceneLOD; }
0174    void    SetSceneLOD(Short_t LOD)    { fSceneLOD = LOD;  }
0175    Short_t CombiLOD()    const         { return fCombiLOD; }
0176    void    SetCombiLOD(Short_t LOD)    { fCombiLOD = LOD;  }
0177    Short_t ShapeLOD()    const         { return fShapeLOD; }
0178    void    SetShapeLOD(Short_t LOD)    { fShapeLOD = LOD;  }
0179    Float_t ShapePixSize() const        { return fShapePixSize; }
0180    void    SetShapePixSize(Float_t ps) { fShapePixSize = ps; }
0181 
0182    Short_t ViewerStyle() const         { return fViewerStyle; }
0183    void    SetViewerStyle(Short_t sty) { fViewerStyle = sty;  }
0184    Short_t SceneStyle()  const         { return fSceneStyle; }
0185    void    SetSceneStyle(Short_t sty)  { fSceneStyle = sty;  }
0186 
0187    Float_t ViewerWFLineW()       const { return fViewerWFLineW; }
0188    void    SetViewerWFLineW(Float_t w) { fViewerWFLineW = w;    }
0189    Float_t SceneWFLineW()        const { return fSceneWFLineW;  }
0190    void    SetSceneWFLineW(Float_t w)  { fSceneWFLineW = w;     }
0191    Float_t ViewerOLLineW()       const { return fViewerOLLineW; }
0192    void    SetViewerOLLineW(Float_t w) { fViewerOLLineW = w;    }
0193    Float_t SceneOLLineW()        const { return fSceneOLLineW;  }
0194    void    SetSceneOLLineW(Float_t w)  { fSceneOLLineW = w;     }
0195 
0196    TGLClip* ViewerClip()         const { return fViewerClip; }
0197    void     SetViewerClip(TGLClip *p)  { fViewerClip = p;    }
0198    TGLClip* SceneClip()          const { return fSceneClip;  }
0199    void     SetSceneClip(TGLClip *p)   { fSceneClip = p;     }
0200    TGLClip* Clip()               const { return  fClip;      }
0201    void     SetClip(TGLClip *p)        { fClip = p;          }
0202    Bool_t   HasClip()            const { return  fClip != nullptr; }
0203 
0204    Short_t DrawPass()    const         { return fDrawPass;  }
0205    void    SetDrawPass(Short_t dpass)  { fDrawPass = dpass; }
0206    Bool_t  IsDrawPassFilled() const;
0207    Bool_t  IsDrawPassOutlineLine() const { return fDrawPass == kPassOutlineLine; }
0208 
0209    // Render time-out
0210    Double_t RenderTimeOut()           const { return fRenderTimeOut; }
0211    void     SetRenderTimeOut(Double_t tout) { fRenderTimeOut = tout; }
0212    void     StartStopwatch();
0213    void     StopStopwatch();
0214    Bool_t   IsStopwatchRunning() const { return fIsRunning; }
0215    Bool_t   HasStopwatchTimedOut();
0216 
0217    // Highlight / Selection state during rendering
0218    Bool_t  Highlight()    const           { return fHighlight;      }
0219    void    SetHighlight(Bool_t hil)       { fHighlight = hil;       }
0220    Bool_t  HighlightOutline() const       { return fHighlightOutline; }
0221    void    SetHighlightOutline(Bool_t ho) { fHighlightOutline = ho;   }
0222    Bool_t  Selection()    const           { return fSelection;      }
0223    void    SetSelection(Bool_t sel)       { fSelection = sel;       }
0224    Bool_t  SecSelection() const           { return fSecSelection;   }
0225    void    SetSecSelection(Bool_t secSel) { fSecSelection = secSel; }
0226    // Highlight / selection parameters
0227    Short_t SelectTransparents()        const { return fSelectTransparents; }
0228    void    SetSelectTransparents(Short_t st) { fSelectTransparents = st;   }
0229    TGLRect         * GetPickRectangle();
0230    Int_t             GetPickRadius();
0231    TGLSelectBuffer * GetSelectBuffer() const { return fSelectBuffer; }
0232    // Selection setup / end
0233    void    BeginSelection(Int_t x, Int_t y, Int_t r=3);
0234    void    EndSelection  (Int_t glResult);
0235 
0236    void         PushColorSet();
0237    TGLColorSet& ColorSet();
0238    void         PopColorSet();
0239    TGLColorSet* ChangeBaseColorSet(TGLColorSet* set);
0240    TGLColorSet* GetBaseColorSet();
0241 
0242    void         ColorOrForeground(Color_t col);
0243 
0244    Float_t GetRenderScale()    const { return fRenderScale; }
0245    void    SetRenderScale(Float_t s) { fRenderScale = s; }
0246 
0247    UInt_t GetEventKeySym()   const { return fEventKeySym; }
0248    void   SetEventKeySym(UInt_t k) { fEventKeySym = k; }
0249 
0250    Bool_t IsDLCaptureOpen() const  { return fDLCaptureOpen; }
0251    void   OpenDLCapture();
0252    void   CloseDLCapture();
0253 
0254    TGLContextIdentity* GetGLCtxIdentity()   const { return fGLCtxIdentity; }
0255    void SetGLCtxIdentity(TGLContextIdentity* cid) { fGLCtxIdentity = cid; }
0256 
0257    void  RegisterFont(Int_t size, Int_t file, Int_t mode, TGLFont& out);
0258    void  RegisterFont(Int_t size, const char* name, Int_t mode, TGLFont& out);
0259    void  RegisterFontNoScale(Int_t size, Int_t file, Int_t mode, TGLFont& out);
0260    void  RegisterFontNoScale(Int_t size, const char* name, Int_t mode, TGLFont& out);
0261    void  ReleaseFont(TGLFont& font);
0262 
0263    GLUquadric* GetGluQuadric();
0264 
0265    // Picture grabbing
0266    void     SetGrabImage(Bool_t gi) { fGrabImage = gi;   }
0267    Bool_t   GetGrabImage()    const { return fGrabImage; }
0268 
0269    // Matrix manipulation helpers
0270    void ProjectionMatrixPushIdentity();
0271    void ProjectionMatrixPop();
0272 
0273    ClassDef(TGLRnrCtx, 0); // Collection of objects and data passes along all rendering calls.
0274 };
0275 
0276 
0277 #endif