Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TGLPhysicalShape.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:  Richard Maunder  25/05/2005
0003 // Parts taken from original TGLSceneObject Timur Pocheptsov
0004 
0005 /*************************************************************************
0006  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
0007  * All rights reserved.                                                  *
0008  *                                                                       *
0009  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0010  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0011  *************************************************************************/
0012 
0013 #ifndef ROOT_TGLPhysicalShape
0014 #define ROOT_TGLPhysicalShape
0015 
0016 //#ifndef ROOT_TGLLogicalShape
0017 //#include "TGLLogicalShape.h"
0018 //#endif
0019 #include "TGLBoundingBox.h"
0020 #ifndef ROOT_TGLUtil
0021 #include "TGLUtil.h" // For TGLMatrix
0022 #endif
0023 
0024 class TGLPShapeRef;
0025 class TGLLogicalShape;
0026 class TGLRnrCtx;
0027 
0028 class TContextMenu;
0029 
0030 
0031 class TGLPhysicalShape
0032 {
0033    friend class TGLLogicalShape; // for replica-list management
0034 
0035 private:
0036    TGLPhysicalShape(const TGLPhysicalShape&) = delete;
0037    TGLPhysicalShape& operator=(const TGLPhysicalShape&) = delete;
0038 
0039 public:
0040    // Flags for permitted manipulation of object
0041    enum EManip  { kTranslateX   = 1 << 0,
0042                   kTranslateY   = 1 << 1,
0043                   kTranslateZ   = 1 << 2,
0044                   kTranslateAll = kTranslateX | kTranslateY | kTranslateZ,
0045                   kScaleX       = 1 << 3,
0046                   kScaleY       = 1 << 4,
0047                   kScaleZ       = 1 << 5,
0048                   kScaleAll     = kScaleX | kScaleY | kScaleZ,
0049                   kRotateX      = 1 << 6,
0050                   kRotateY      = 1 << 7,
0051                   kRotateZ      = 1 << 8,
0052                   kRotateAll    = kRotateX | kRotateY | kRotateZ,
0053                   kManipAll     = kTranslateAll | kScaleAll | kRotateAll
0054                 };
0055 private:
0056    // Fields
0057    const TGLLogicalShape * fLogicalShape; //! the associated logical shape
0058          TGLPhysicalShape* fNextPhysical; //! pointer to next replica
0059          TGLPShapeRef    * fFirstPSRef;   //! pointer to first reference
0060 
0061    UInt_t                  fID;           //! unique physical ID within containing scene
0062    TGLMatrix               fTransform;    //! transform (placement) of physical instance
0063    TGLBoundingBox          fBoundingBox;  //! bounding box of the physical (transformed)
0064    Float_t                 fColor[17];    //! GL color array
0065    EManip                  fManip;        //! permitted manipulation bitflags - see EManip
0066    UChar_t                 fSelected;     //! selected state
0067    Bool_t                  fInvertedWind; //! face winding TODO: can get directly from fTransform?
0068    Bool_t                  fModified;     //! has been modified - retain across scene rebuilds
0069    Bool_t                  fIsScaleForRnr;//! cache
0070 
0071    // Methods
0072    void            UpdateBoundingBox();
0073    void            InitColor(const Float_t rgba[4]);
0074 
0075 public:
0076    TGLPhysicalShape(UInt_t ID, const TGLLogicalShape & logicalShape,
0077                     const TGLMatrix & transform, Bool_t invertedWind,
0078                     const Float_t rgba[4]);
0079    TGLPhysicalShape(UInt_t ID, const TGLLogicalShape & logicalShape,
0080                     const Double_t * transform, Bool_t invertedWind,
0081                     const Float_t rgba[4]);
0082    virtual ~TGLPhysicalShape();
0083 
0084    void   AddReference   (TGLPShapeRef* ref);
0085    void   RemoveReference(TGLPShapeRef* ref);
0086 
0087    UInt_t                 ID()          const { return fID; }
0088    const TGLBoundingBox & BoundingBox() const { return fBoundingBox; }
0089 
0090    virtual void CalculateShapeLOD(TGLRnrCtx & rnrCtx, Float_t& pixSize, Short_t& shapeLOD) const;
0091    virtual void QuantizeShapeLOD (Short_t shapeLOD, Short_t combiLOD, Short_t& quantLOD) const;
0092 
0093    void SetupGLColors(TGLRnrCtx & rnrCtx, const Float_t* color = nullptr) const;
0094    virtual void Draw(TGLRnrCtx & rnrCtx) const;
0095 
0096    const TGLLogicalShape  * GetLogical()      const { return fLogicalShape; }
0097    const TGLPhysicalShape * GetNextPhysical() const { return fNextPhysical; }
0098 
0099    // Modification and manipulation
0100    EManip  GetManip()   const      { return fManip;  }
0101    void    SetManip(EManip manip)  { fManip = manip; }
0102 
0103    // Modified - treated as temporary modification
0104    void    Modified();
0105    Bool_t  IsModified() const      { return fModified; }
0106 
0107    // Selection
0108    Bool_t  IsSelected()  const    { return fSelected != 0; }
0109    UChar_t GetSelected() const    { return fSelected; }
0110    void    Select(UChar_t select) { fSelected = select; }
0111 
0112    // Color
0113    const Float_t  * Color() const                      { return fColor; }
0114    Bool_t           IsTransparent() const              { return fColor[3] < 1.f; }
0115    Bool_t           IsInvisible() const                { return fColor[3] == 0.f; }
0116    void             SetColor(const Float_t rgba[17]);
0117    void             SetColorOnFamily(const Float_t rgba[17]);
0118    void             SetDiffuseColor(const Float_t rgba[4]);
0119    void             SetDiffuseColor(const UChar_t rgba[4]);
0120    void             SetDiffuseColor(Color_t ci, UChar_t transparency);
0121 
0122    // Geometry
0123    TGLVector3       GetScale() const;
0124    TGLVertex3       GetTranslation() const;
0125 
0126    void             SetTransform(const TGLMatrix & transform);
0127    void             SetTransform(const Double_t vals[16]);
0128    void             SetTranslation(const TGLVertex3 & translation);
0129    void             Translate(const TGLVector3 & vect);
0130    void             Scale(const TGLVector3 & scale);
0131    void             Rotate(const TGLVertex3 & pivot, const TGLVector3 & axis, Double_t angle);
0132 
0133    // Context menu
0134    void             InvokeContextMenu(TContextMenu & menu, UInt_t x, UInt_t y) const;
0135 
0136    ClassDef(TGLPhysicalShape,0) // a physical (placed, global frame) drawable object
0137 };
0138 
0139 
0140 //______________________________________________________________________________
0141 inline TGLVector3 TGLPhysicalShape::GetScale() const
0142 {
0143    return fTransform.GetScale();
0144 }
0145 
0146 //______________________________________________________________________________
0147 inline TGLVertex3 TGLPhysicalShape::GetTranslation() const
0148 {
0149    return fTransform.GetTranslation();
0150 }
0151 
0152 //______________________________________________________________________________
0153 inline void TGLPhysicalShape::SetTransform(const TGLMatrix & transform)
0154 {
0155    fTransform = transform;
0156    UpdateBoundingBox();
0157    Modified();
0158 }
0159 
0160 //______________________________________________________________________________
0161 inline void TGLPhysicalShape::SetTransform(const Double_t vals[16])
0162 {
0163    fTransform.Set(vals);
0164    UpdateBoundingBox();
0165    Modified();
0166 }
0167 
0168 //______________________________________________________________________________
0169 inline void TGLPhysicalShape::SetTranslation(const TGLVertex3 & translation)
0170 {
0171    fTransform.SetTranslation(translation);
0172    UpdateBoundingBox();
0173    Modified();
0174 }
0175 
0176 //______________________________________________________________________________
0177 inline void TGLPhysicalShape::Translate(const TGLVector3 & vect)
0178 {
0179    fTransform.Translate(vect);
0180    UpdateBoundingBox();
0181    Modified();
0182 }
0183 
0184 //______________________________________________________________________________
0185 inline void TGLPhysicalShape::Scale(const TGLVector3 & scale)
0186 {
0187    TGLVertex3 origCenter = fBoundingBox.Center();
0188    fTransform.Scale(scale);
0189    UpdateBoundingBox();
0190    TGLVector3 shift = fBoundingBox.Center() - origCenter;
0191    Translate(-shift);
0192    UpdateBoundingBox();
0193    Modified();
0194 }
0195 
0196 //______________________________________________________________________________
0197 inline void TGLPhysicalShape::Rotate(const TGLVertex3 & pivot, const TGLVector3 & axis, Double_t angle)
0198 {
0199    TGLVertex3 c = BoundingBox().Center();
0200    fTransform.Rotate(pivot, axis, angle);
0201    UpdateBoundingBox();
0202    Modified();
0203 }
0204 
0205 #endif // ROOT_TGLPhysicalShape