TGLRnrCtx.h

Go to the documentation of this file.
00001 // @(#)root/gl:$Id: TGLRnrCtx.h 36675 2010-11-15 20:33:58Z matevz $
00002 // Author:  Matevz Tadel, Feb 2007
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_TGLRnrCtx
00013 #define ROOT_TGLRnrCtx
00014 
00015 #include "Rtypes.h"
00016 #include "TGLStopwatch.h"
00017 
00018 class TGLViewerBase;
00019 class TGLCamera;
00020 class TGLSceneBase;
00021 class TGLSceneInfo;
00022 
00023 class TGLColorSet;
00024 class TGLFont;
00025 class TGLContextIdentity;
00026 
00027 class TGLClip;
00028 class TGLSelectBuffer;
00029 
00030 class TGLRect;
00031 
00032 class GLUquadric;
00033 
00034 namespace std
00035 {
00036    template<typename _Tp> class allocator;
00037    template<typename _Tp, typename _Alc> class list;
00038 }
00039 
00040 /**************************************************************************/
00041 // TGLRnrCtx
00042 /**************************************************************************/
00043 
00044 class TGLRnrCtx
00045 {
00046 public:
00047    enum EStyle
00048    {
00049       kStyleUndef     =  -1,
00050       kFill,
00051       kOutline,
00052       kWireFrame
00053    };
00054    static const char* StyleName(Short_t style);
00055 
00056    enum EPass
00057    {
00058       kPassUndef      =  -1,
00059       kPassFill,
00060       kPassOutlineFill,
00061       kPassOutlineLine,
00062       kPassWireFrame
00063    };
00064 
00065    enum ELODPresets
00066    {
00067       kLODUndef       =  -1,
00068       kLODPixel       =   0, // Projected size pixel or less
00069       kLODLow         =  20,
00070       kLODMed         =  50,
00071       kLODHigh        = 100
00072    };
00073 
00074    enum EShapeSelectionLevel
00075    {
00076       kSSLNotSelected,
00077       kSSLSelected,
00078       kSSLImpliedSelected,
00079       kSSLHighlighted,
00080       kSSLImpliedHighlighted,
00081       kSSLEnd
00082    };
00083 
00084 private:
00085    TGLRnrCtx(const TGLRnrCtx&);            // Not implemented
00086    TGLRnrCtx& operator=(const TGLRnrCtx&); // Not implemented
00087 
00088    typedef std::list<TGLColorSet*, std::allocator<TGLColorSet*> > lpTGLColorSet_t;
00089 
00090 protected:
00091    TGLViewerBase  *fViewer;
00092    TGLCamera      *fCamera;
00093    TGLSceneInfo   *fSceneInfo;
00094 
00095    Short_t         fViewerLOD;
00096    Short_t         fSceneLOD;
00097    Short_t         fCombiLOD;     // Combined viewer/scene lod.
00098    Short_t         fShapeLOD;     // LOD calculated for current shape.
00099    Float_t         fShapePixSize; // Only relevant when not using display lists.
00100 
00101    Short_t         fViewerStyle;
00102    Short_t         fSceneStyle;
00103 
00104    Float_t         fViewerWFLineW;
00105    Float_t         fSceneWFLineW;
00106    Float_t         fViewerOLLineW;
00107    Float_t         fSceneOLLineW;
00108 
00109    TGLClip        *fViewerClip;
00110    TGLClip        *fSceneClip;
00111    TGLClip        *fClip;
00112 
00113    Short_t         fDrawPass;
00114 
00115    TGLStopwatch    fStopwatch;
00116    Double_t        fRenderTimeOut;
00117    Bool_t          fIsRunning;
00118    Bool_t          fHasTimedOut;
00119 
00120    // Highlight / Selection stuff
00121    Bool_t          fHighlight;        // True when in highlight.
00122    Bool_t          fHighlightOutline; // True when in highlight-outline.
00123    Bool_t          fSelection;
00124    Bool_t          fSecSelection;
00125    Int_t           fPickRadius;
00126    TGLRect        *fPickRectangle;
00127    TGLSelectBuffer*fSelectBuffer;
00128 
00129    lpTGLColorSet_t*fColorSetStack;
00130    Float_t         fRenderScale;
00131 
00132    UInt_t          fEventKeySym;
00133 
00134    // GL state
00135    Bool_t              fDLCaptureOpen; //! DL-capture currently open
00136    TGLContextIdentity *fGLCtxIdentity; //! Current GL context identity
00137 
00138    GLUquadric         *fQuadric;
00139 
00140    // Picture grabbing
00141    Bool_t           fGrabImage;    // Set to true to store the image.
00142    Int_t            fGrabBuffer;   // Which buffer to grab after render.
00143    UChar_t         *fGrabbedImage; // Buffer where image was stored after rendering.
00144 
00145 public:
00146    TGLRnrCtx(TGLViewerBase* viewer);
00147    virtual ~TGLRnrCtx();
00148 
00149    // Central objects
00150    TGLViewerBase * GetViewer() { return  fViewer; }
00151    TGLViewerBase & RefViewer() { return *fViewer; }
00152    TGLCamera     * GetCamera() { return  fCamera; }
00153    TGLCamera     & RefCamera() { return *fCamera; }
00154    TGLSceneInfo  * GetSceneInfo()  { return  fSceneInfo; }
00155    TGLSceneInfo  & RefSceneInfo()  { return *fSceneInfo; }
00156    TGLSceneBase  * GetScene();
00157    TGLSceneBase  & RefScene();
00158 
00159    const TGLCamera & RefCamera() const { return *fCamera; }
00160    const TGLCamera * GetCamera() const { return  fCamera; }
00161 
00162    // void SetViewer   (TGLViewerBase* v) { fViewer = v; }
00163    void SetCamera   (TGLCamera*     c) { fCamera = c; }
00164    void SetSceneInfo(TGLSceneInfo* si) { fSceneInfo = si; }
00165 
00166 
00167    // Draw LOD, style, clip, rnr-pass
00168    Short_t ViewerLOD()   const         { return fViewerLOD; }
00169    void    SetViewerLOD(Short_t LOD)   { fViewerLOD = LOD;  }
00170    Short_t SceneLOD()    const         { return fSceneLOD; }
00171    void    SetSceneLOD(Short_t LOD)    { fSceneLOD = LOD;  }
00172    Short_t CombiLOD()    const         { return fCombiLOD; }
00173    void    SetCombiLOD(Short_t LOD)    { fCombiLOD = LOD;  }
00174    Short_t ShapeLOD()    const         { return fShapeLOD; }
00175    void    SetShapeLOD(Short_t LOD)    { fShapeLOD = LOD;  }
00176    Float_t ShapePixSize() const        { return fShapePixSize; }
00177    void    SetShapePixSize(Float_t ps) { fShapePixSize = ps; }
00178 
00179    Short_t ViewerStyle() const         { return fViewerStyle; }
00180    void    SetViewerStyle(Short_t sty) { fViewerStyle = sty;  }
00181    Short_t SceneStyle()  const         { return fSceneStyle; }
00182    void    SetSceneStyle(Short_t sty)  { fSceneStyle = sty;  }
00183 
00184    Float_t ViewerWFLineW()       const { return fViewerWFLineW; }
00185    void    SetViewerWFLineW(Float_t w) { fViewerWFLineW = w;    }
00186    Float_t SceneWFLineW()        const { return fSceneWFLineW;  }
00187    void    SetSceneWFLineW(Float_t w)  { fSceneWFLineW = w;     }
00188    Float_t ViewerOLLineW()       const { return fViewerOLLineW; }
00189    void    SetViewerOLLineW(Float_t w) { fViewerOLLineW = w;    }
00190    Float_t SceneOLLineW()        const { return fSceneOLLineW;  }
00191    void    SetSceneOLLineW(Float_t w)  { fSceneOLLineW = w;     }
00192 
00193    TGLClip* ViewerClip()         const { return fViewerClip; }
00194    void     SetViewerClip(TGLClip *p)  { fViewerClip = p;    }
00195    TGLClip* SceneClip()          const { return fSceneClip;  }
00196    void     SetSceneClip(TGLClip *p)   { fSceneClip = p;     }
00197    TGLClip* Clip()               const { return  fClip;      }
00198    void     SetClip(TGLClip *p)        { fClip = p;          }
00199    Bool_t   HasClip()            const { return  fClip != 0; }
00200 
00201    Short_t DrawPass()    const         { return fDrawPass;  }
00202    void    SetDrawPass(Short_t dpass)  { fDrawPass = dpass; }
00203    Bool_t  IsDrawPassFilled() const;
00204    Bool_t  IsDrawPassOutlineLine() const { return fDrawPass == kPassOutlineLine; }
00205 
00206    // Render time-out
00207    Double_t RenderTimeOut()           const { return fRenderTimeOut; }
00208    void     SetRenderTimeOut(Double_t tout) { fRenderTimeOut = tout; }
00209    void     StartStopwatch();
00210    void     StopStopwatch();
00211    Bool_t   IsStopwatchRunning() const { return fIsRunning; }
00212    Bool_t   HasStopwatchTimedOut();
00213 
00214    // Highlight / Selection stuff
00215    Bool_t  Highlight()    const           { return fHighlight;      }
00216    void    SetHighlight(Bool_t hil)       { fHighlight = hil;       }
00217    Bool_t  HighlightOutline() const       { return fHighlightOutline; }
00218    void    SetHighlightOutline(Bool_t ho) { fHighlightOutline = ho;   }
00219 
00220    Bool_t  Selection()    const           { return fSelection;      }
00221    void    SetSelection(Bool_t sel)       { fSelection = sel;       }
00222    Bool_t  SecSelection() const           { return fSecSelection;   }
00223    void    SetSecSelection(Bool_t secSel) { fSecSelection = secSel; }
00224    // Low-level getters
00225    TGLRect         * GetPickRectangle();
00226    Int_t             GetPickRadius();
00227    TGLSelectBuffer * GetSelectBuffer() const { return fSelectBuffer; }
00228    // Composed operations
00229    void      BeginSelection(Int_t x, Int_t y, Int_t r=3);
00230    void      EndSelection  (Int_t glResult);
00231 
00232    void         PushColorSet();
00233    TGLColorSet& ColorSet();
00234    void         PopColorSet();
00235    TGLColorSet* ChangeBaseColorSet(TGLColorSet* set);
00236    TGLColorSet* GetBaseColorSet();
00237 
00238    void         ColorOrForeground(Color_t col);
00239 
00240    Float_t GetRenderScale()    const { return fRenderScale; }
00241    void    SetRenderScale(Float_t s) { fRenderScale = s; }
00242 
00243    UInt_t GetEventKeySym()   const { return fEventKeySym; }
00244    void   SetEventKeySym(UInt_t k) { fEventKeySym = k; }
00245 
00246    Bool_t IsDLCaptureOpen() const  { return fDLCaptureOpen; }
00247    void   OpenDLCapture();
00248    void   CloseDLCapture();
00249 
00250    TGLContextIdentity* GetGLCtxIdentity()   const { return fGLCtxIdentity; }
00251    void SetGLCtxIdentity(TGLContextIdentity* cid) { fGLCtxIdentity = cid; }
00252 
00253    void  RegisterFont(Int_t size, Int_t file, Int_t mode, TGLFont& out);
00254    void  RegisterFont(Int_t size, const char* name, Int_t mode, TGLFont& out);
00255    void  RegisterFontNoScale(Int_t size, Int_t file, Int_t mode, TGLFont& out);
00256    void  RegisterFontNoScale(Int_t size, const char* name, Int_t mode, TGLFont& out);
00257    void  ReleaseFont(TGLFont& font);
00258 
00259    GLUquadric* GetGluQuadric() { return fQuadric; }
00260 
00261    // Picture grabbing
00262    void     SetGrabImage(Bool_t gi) { fGrabImage = gi;   }
00263    Bool_t   GetGrabImage()    const { return fGrabImage; }
00264 
00265    // Matrix manipulation helpers
00266    void ProjectionMatrixPushIdentity();
00267    void ProjectionMatrixPop();
00268 
00269    ClassDef(TGLRnrCtx, 0); // Collection of objects and data passes along all rendering calls.
00270 };
00271 
00272 
00273 #endif

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