TGLSceneInfo.h

Go to the documentation of this file.
00001 // @(#)root/gl:$Id: TGLSceneInfo.h 29676 2009-08-04 16:18:07Z 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_TGLSceneInfo_H
00013 #define ROOT_TGLSceneInfo_H
00014 
00015 #include "Rtypes.h"
00016 
00017 #include "TGLBoundingBox.h"
00018 #include "TGLUtil.h"
00019 
00020 class TGLViewerBase;
00021 class TGLSceneBase;
00022 class TGLClip;
00023 class TGLRenderContext;
00024 class TGLCamera;
00025 
00026 class TGLSceneInfo
00027 {
00028    friend class TGLSceneBase;
00029 
00030 public:
00031    enum EClipTest { kClipNone, kClipOutside, kClipInside };
00032 
00033 private:
00034    TGLSceneInfo(const TGLSceneInfo&);            // Not implemented
00035    TGLSceneInfo& operator=(const TGLSceneInfo&); // Not implemented
00036 
00037 protected:
00038    TGLViewerBase  * fViewer;
00039    TGLSceneBase   * fScene;
00040    Bool_t           fActive;      // Show fScene in fViewer
00041 
00042    Short_t          fLOD;         // Optional override of scene lod
00043    Short_t          fStyle;       // Optional override of scene style
00044    Float_t          fWFLineW;     // Optional override of scene wire-frame line-width
00045    Float_t          fOLLineW;     // Optional override of scene outline line-width
00046    TGLClip        * fClip;        // Optional override of clipping-plane
00047 
00048    Short_t          fLastLOD;     // Last combined viewer/scene lod   (set in scene::lodify-scene-info).
00049    Short_t          fLastStyle;   // Last combined viewer/scene style (set in scene::pre-draw).
00050    Float_t          fLastWFLineW; // Last combined viewer/scene wire-frame line-width (set in scene::pre-draw).
00051    Float_t          fLastOLLineW; // Last combined viewer/scene outline line-width (set in scene::pre-draw).
00052    TGLClip        * fLastClip;    // Last combined viewer/scene clip  (set in scene::update)
00053    TGLCamera      * fLastCamera;  // Last camera used.
00054 
00055    UInt_t           fSceneStamp;  // Scene's time-stamp on last update.
00056    UInt_t           fClipStamp;   // Clip's time-stamp on last update.
00057    UInt_t           fCameraStamp; // Camera's time-stamp on last update.
00058    Bool_t           fUpdateTimeouted; // Set if update was interrupted.
00059 
00060    // Eventually we will allow additional per-scene transforamtion.
00061    // TGLMatrix  fSceneTrans;
00062    // Also needed:
00063    // *) transformed clipping planes of the camera
00064    // *) transformed bounding-box of the scene
00065    TGLBoundingBox   fTransformedBBox;
00066 
00067    Bool_t           fViewCheck;     // Viewer side check if render is necessary.
00068    Bool_t           fInFrustum;     // Is scene intersecting view-frustum.
00069    Bool_t           fInClip;        // Is scene contained within clipping-volume.
00070    Char_t           fClipMode;      // Clipping mode, can be disbled.
00071    TGLPlaneSet_t    fFrustumPlanes; // Clipping planes defined by frustum; only those intersecting the scene volume are kept.
00072    TGLPlaneSet_t    fClipPlanes;    // Clipping planes from clip-object; which planes are kept depends on inside/outside mode.
00073 
00074    // Additional stuff (scene-class specific) can be added by sub-classing.
00075    // For TGLScene these data include draw-lists after clipping.
00076 
00077 public:
00078    TGLSceneInfo(TGLViewerBase* view=0, TGLSceneBase* scene=0);
00079    virtual ~TGLSceneInfo() {}
00080 
00081    TGLViewerBase * GetViewer() const { return  fViewer; }
00082    TGLViewerBase & RefViewer() const { return *fViewer; }
00083    TGLSceneBase  * GetScene()  const { return  fScene;  }
00084    TGLSceneBase  & RefScene()  const { return *fScene;  }
00085 
00086    Bool_t GetActive() const { return fActive; }
00087    void   SetActive(Bool_t a);
00088 
00089    void  SetupTransformsAndBBox();
00090 
00091    const TGLBoundingBox& GetTransformedBBox() { return fTransformedBBox; }
00092 
00093    virtual void SetSceneTrans(TGLMatrix&) { ResetSceneStamp(); }
00094 
00095    Bool_t   ViewCheck() const   { return fViewCheck; }
00096    void     ViewCheck(Bool_t c) { fViewCheck = c;    }
00097    Bool_t   IsInFrustum() const { return fInFrustum; }
00098    void     InFrustum(Bool_t f) { fInFrustum = f;    }
00099    Bool_t   IsInClip()    const { return fInClip;    }
00100    void     InClip(Bool_t c)    { fInClip = c;       }
00101    Char_t   ClipMode()    const { return fClipMode;  }
00102    void     ClipMode(Char_t m)  { fClipMode = m;     }
00103 
00104    Bool_t   ShouldClip()  const { return fClipMode != kClipNone; }
00105    Bool_t   IsVisible()   const { return fInFrustum && fInClip;  }
00106 
00107    std::vector<TGLPlane>& FrustumPlanes() { return fFrustumPlanes; }
00108    std::vector<TGLPlane>& ClipPlanes()    { return fClipPlanes;    }
00109 
00110    Short_t  LOD()          const { return fLOD; }
00111    void     SetLOD(Short_t lod)  { fLOD = lod;  }
00112 
00113    Short_t  Style()        const { return fStyle; }
00114    void     SetStyle(Short_t st) { fStyle = st;   }
00115 
00116    Float_t  WFLineW()       const { return fWFLineW; }
00117    void     SetWFLineW(Float_t w) { fWFLineW = w;    }
00118    Float_t  OLLineW()       const { return fOLLineW; }
00119    void     SetOLLineW(Float_t w) { fOLLineW = w;    }
00120 
00121    TGLClip* Clip()         const { return fClip; }
00122    void     SetClip(TGLClip *p)  { fClip = p;    }
00123 
00124    Short_t  LastLOD()        const { return fLastLOD; }
00125    void     SetLastLOD(Short_t ld) { fLastLOD = ld;   }
00126 
00127    Short_t  LastStyle()      const   { return fLastStyle; }
00128    void     SetLastStyle(Short_t st) { fLastStyle = st;   }
00129 
00130    Float_t  LastWFLineW()       const { return fLastWFLineW; }
00131    void     SetLastWFLineW(Float_t w) { fLastWFLineW = w;    }
00132    Float_t  LastOLLineW()       const { return fLastOLLineW; }
00133    void     SetLastOLLineW(Float_t w) { fLastOLLineW = w;    }
00134 
00135    TGLClip* LastClip()         const { return fLastClip; }
00136    void     SetLastClip(TGLClip *p)  { fLastClip = p;    }
00137 
00138    TGLCamera* LastCamera()        const { return fLastCamera; }
00139    void     SetLastCamera(TGLCamera *p) { fLastCamera = p;    }
00140 
00141    UInt_t   SceneStamp()       const { return fSceneStamp; }
00142    void     SetSceneStamp(UInt_t ts) { fSceneStamp = ts;   }
00143    void     ResetSceneStamp()        { fSceneStamp = 0;    }
00144 
00145    UInt_t   ClipStamp()       const { return fClipStamp; }
00146    void     SetClipStamp(UInt_t ts) { fClipStamp = ts;   }
00147    void     ResetClipStamp()        { fClipStamp = 0;    }
00148 
00149    UInt_t   CameraStamp()       const { return fCameraStamp; }
00150    void     SetCameraStamp(UInt_t ts) { fCameraStamp = ts;   }
00151    void     ResetCameraStamp()        { fCameraStamp = 0;    }
00152 
00153    Bool_t   HasUpdateTimeouted() const { return fUpdateTimeouted;   }
00154    void     UpdateTimeouted()          { fUpdateTimeouted = kTRUE;  }
00155    void     ResetUpdateTimeouted()     { fUpdateTimeouted = kFALSE; }
00156 
00157    ClassDef(TGLSceneInfo, 0) // Data about a scene within a viewer context.
00158 }; // endclass TGLSceneInfo
00159 
00160 
00161 #endif

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