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
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef ROOT_TGLPhysicalShape
0014 #define ROOT_TGLPhysicalShape
0015
0016
0017
0018
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;
0034
0035 private:
0036 TGLPhysicalShape(const TGLPhysicalShape&) = delete;
0037 TGLPhysicalShape& operator=(const TGLPhysicalShape&) = delete;
0038
0039 public:
0040
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
0057 const TGLLogicalShape * fLogicalShape;
0058 TGLPhysicalShape* fNextPhysical;
0059 TGLPShapeRef * fFirstPSRef;
0060
0061 UInt_t fID;
0062 TGLMatrix fTransform;
0063 TGLBoundingBox fBoundingBox;
0064 Float_t fColor[17];
0065 EManip fManip;
0066 UChar_t fSelected;
0067 Bool_t fInvertedWind;
0068 Bool_t fModified;
0069 Bool_t fIsScaleForRnr;
0070
0071
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
0100 EManip GetManip() const { return fManip; }
0101 void SetManip(EManip manip) { fManip = manip; }
0102
0103
0104 void Modified();
0105 Bool_t IsModified() const { return fModified; }
0106
0107
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
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
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
0134 void InvokeContextMenu(TContextMenu & menu, UInt_t x, UInt_t y) const;
0135
0136 ClassDef(TGLPhysicalShape,0)
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