Logo ROOT   6.16/01
Reference Guide
TGLPhysicalShape.h
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Richard Maunder 25/05/2005
3// Parts taken from original TGLSceneObject Timur Pocheptsov
4
5/*************************************************************************
6 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#ifndef ROOT_TGLPhysicalShape
14#define ROOT_TGLPhysicalShape
15
16//#ifndef ROOT_TGLLogicalShape
17//#include "TGLLogicalShape.h"
18//#endif
19#include "TGLBoundingBox.h"
20#ifndef ROOT_TGLUtil
21#include "TGLUtil.h" // For TGLMatrix
22#endif
23
24class TGLPShapeRef;
25class TGLLogicalShape;
26class TGLRnrCtx;
27
28class TContextMenu;
29
30
32{
33 friend class TGLLogicalShape; // for replica-list management
34
35private:
36 TGLPhysicalShape(const TGLPhysicalShape&); // Not implemented
37 TGLPhysicalShape& operator=(const TGLPhysicalShape&); // Not implemented
38
39public:
40 // Flags for permitted manipulation of object
41 enum EManip { kTranslateX = 1 << 0,
42 kTranslateY = 1 << 1,
43 kTranslateZ = 1 << 2,
45 kScaleX = 1 << 3,
46 kScaleY = 1 << 4,
47 kScaleZ = 1 << 5,
49 kRotateX = 1 << 6,
50 kRotateY = 1 << 7,
51 kRotateZ = 1 << 8,
54 };
55private:
56 // Fields
57 const TGLLogicalShape * fLogicalShape; //! the associated logical shape
58 TGLPhysicalShape* fNextPhysical; //! pointer to next replica
59 TGLPShapeRef * fFirstPSRef; //! pointer to first reference
60
61 UInt_t fID; //! unique physical ID within containing scene
62 TGLMatrix fTransform; //! transform (placement) of physical instance
63 TGLBoundingBox fBoundingBox; //! bounding box of the physical (transformed)
64 Float_t fColor[17]; //! GL color array
65 EManip fManip; //! permitted manipulation bitflags - see EManip
66 UChar_t fSelected; //! selected state
67 Bool_t fInvertedWind; //! face winding TODO: can get directly from fTransform?
68 Bool_t fModified; //! has been modified - retain across scene rebuilds
70
71 // Methods
72 void UpdateBoundingBox();
73 void InitColor(const Float_t rgba[4]);
74
75public:
76 TGLPhysicalShape(UInt_t ID, const TGLLogicalShape & logicalShape,
77 const TGLMatrix & transform, Bool_t invertedWind,
78 const Float_t rgba[4]);
79 TGLPhysicalShape(UInt_t ID, const TGLLogicalShape & logicalShape,
80 const double * transform, Bool_t invertedWind,
81 const Float_t rgba[4]);
82 virtual ~TGLPhysicalShape();
83
84 void AddReference (TGLPShapeRef* ref);
86
87 UInt_t ID() const { return fID; }
88 const TGLBoundingBox & BoundingBox() const { return fBoundingBox; }
89
90 virtual void CalculateShapeLOD(TGLRnrCtx & rnrCtx, Float_t& pixSize, Short_t& shapeLOD) const;
91 virtual void QuantizeShapeLOD (Short_t shapeLOD, Short_t combiLOD, Short_t& quantLOD) const;
92
93 void SetupGLColors(TGLRnrCtx & rnrCtx, const Float_t* color=0) const;
94 virtual void Draw(TGLRnrCtx & rnrCtx) const;
95
96 const TGLLogicalShape * GetLogical() const { return fLogicalShape; }
98
99 // Modification and manipulation
100 EManip GetManip() const { return fManip; }
101 void SetManip(EManip manip) { fManip = manip; }
102
103 // Modified - treated as temporary modification
104 void Modified();
105 Bool_t IsModified() const { return fModified; }
106
107 // Selection
108 Bool_t IsSelected() const { return fSelected != 0; }
109 UChar_t GetSelected() const { return fSelected; }
110 void Select(UChar_t select) { fSelected = select; }
111
112 // Color
113 const Float_t * Color() const { return fColor; }
114 Bool_t IsTransparent() const { return fColor[3] < 1.f; }
115 Bool_t IsInvisible() const { return fColor[3] == 0.f; }
116 void SetColor(const Float_t rgba[17]);
117 void SetColorOnFamily(const Float_t rgba[17]);
118 void SetDiffuseColor(const Float_t rgba[4]);
119 void SetDiffuseColor(const UChar_t rgba[4]);
120 void SetDiffuseColor(Color_t ci, UChar_t transparency);
121
122 // Geometry
123 TGLVector3 GetScale() const;
125
126 void SetTransform(const TGLMatrix & transform);
127 void SetTransform(const Double_t vals[16]);
128 void SetTranslation(const TGLVertex3 & translation);
129 void Translate(const TGLVector3 & vect);
130 void Scale(const TGLVector3 & scale);
131 void Rotate(const TGLVertex3 & pivot, const TGLVector3 & axis, Double_t angle);
132
133 // Context menu
134 void InvokeContextMenu(TContextMenu & menu, UInt_t x, UInt_t y) const;
135
136 ClassDef(TGLPhysicalShape,0) // a physical (placed, global frame) drawable object
137};
138
139
140//______________________________________________________________________________
142{
143 return fTransform.GetScale();
144}
145
146//______________________________________________________________________________
148{
149 return fTransform.GetTranslation();
150}
151
152//______________________________________________________________________________
153inline void TGLPhysicalShape::SetTransform(const TGLMatrix & transform)
154{
155 fTransform = transform;
157 Modified();
158}
159
160//______________________________________________________________________________
161inline void TGLPhysicalShape::SetTransform(const Double_t vals[16])
162{
163 fTransform.Set(vals);
165 Modified();
166}
167
168//______________________________________________________________________________
169inline void TGLPhysicalShape::SetTranslation(const TGLVertex3 & translation)
170{
171 fTransform.SetTranslation(translation);
173 Modified();
174}
175
176//______________________________________________________________________________
178{
179 fTransform.Translate(vect);
181 Modified();
182}
183
184//______________________________________________________________________________
185inline void TGLPhysicalShape::Scale(const TGLVector3 & scale)
186{
187 TGLVertex3 origCenter = fBoundingBox.Center();
188 fTransform.Scale(scale);
190 TGLVector3 shift = fBoundingBox.Center() - origCenter;
191 Translate(-shift);
193 Modified();
194}
195
196//______________________________________________________________________________
197inline void TGLPhysicalShape::Rotate(const TGLVertex3 & pivot, const TGLVector3 & axis, Double_t angle)
198{
200 fTransform.Rotate(pivot, axis, angle);
202 Modified();
203}
204
205#endif // ROOT_TGLPhysicalShape
#define c(i)
Definition: RSha256.hxx:101
unsigned char UChar_t
Definition: RtypesCore.h:34
unsigned int UInt_t
Definition: RtypesCore.h:42
bool Bool_t
Definition: RtypesCore.h:59
short Short_t
Definition: RtypesCore.h:35
double Double_t
Definition: RtypesCore.h:55
short Color_t
Definition: RtypesCore.h:79
float Float_t
Definition: RtypesCore.h:53
#define ClassDef(name, id)
Definition: Rtypes.h:324
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:40
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
TGLVertex3 Center() const
Abstract logical shape - a GL 'drawable' - base for all shapes - faceset sphere etc.
16 component (4x4) transform matrix - column MAJOR as per GL.
Definition: TGLUtil.h:597
void Scale(const TGLVector3 &scale)
Set matrix axis scales to 'scale'.
Definition: TGLUtil.cxx:862
void Set(const TGLVertex3 &origin, const TGLVector3 &zAxis, const TGLVector3 &xAxis=0)
Set matrix which when applied puts local origin at 'origin' and the local Z axis in direction 'z'.
Definition: TGLUtil.cxx:764
void Rotate(const TGLVertex3 &pivot, const TGLVector3 &axis, Double_t angle)
Update matrix so resulting transform has been rotated about 'pivot' (in parent frame),...
Definition: TGLUtil.cxx:898
TGLVector3 GetTranslation() const
Return the translation component of matrix.
Definition: TGLUtil.cxx:822
TGLVector3 GetScale() const
Get local axis scaling factors.
Definition: TGLUtil.cxx:1127
void SetTranslation(Double_t x, Double_t y, Double_t z)
Set matrix translation components x,y,z.
Definition: TGLUtil.cxx:804
void Translate(const TGLVector3 &vect)
Shift matrix translation components by 'vect' in parent frame.
Definition: TGLUtil.cxx:830
Base class for references to TGLPysicalShape that need to be notified when the shape is destroyed.
Definition: TGLPShapeRef.h:20
Concrete physical shape - a GL drawable.
void Modified()
Call this after modifying the physical so that the information can be propagated to the object refere...
void InvokeContextMenu(TContextMenu &menu, UInt_t x, UInt_t y) const
Request creation of context menu on shape, attached to 'menu' at screen position 'x' 'y'.
virtual ~TGLPhysicalShape()
Destroy the physical shape.
TGLPhysicalShape * fNextPhysical
the associated logical shape
UInt_t ID() const
const TGLLogicalShape * fLogicalShape
void Scale(const TGLVector3 &scale)
const Float_t * Color() const
Bool_t fModified
face winding TODO: can get directly from fTransform?
const TGLPhysicalShape * GetNextPhysical() const
void SetTransform(const TGLMatrix &transform)
TGLPhysicalShape(const TGLPhysicalShape &)
const TGLBoundingBox & BoundingBox() const
Bool_t IsInvisible() const
UChar_t fSelected
permitted manipulation bitflags - see EManip
virtual void QuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD, Short_t &quantLOD) const
Factor in scene/vierer LOD and Quantize ... forward to logical shape.
void RemoveReference(TGLPShapeRef *ref)
Remove reference ref.
EManip fManip
GL color array.
void Rotate(const TGLVertex3 &pivot, const TGLVector3 &axis, Double_t angle)
void SetManip(EManip manip)
TGLVector3 GetScale() const
void SetupGLColors(TGLRnrCtx &rnrCtx, const Float_t *color=0) const
Setup colors - avoid setting things not required for current draw flags.
const TGLLogicalShape * GetLogical() const
void InitColor(const Float_t rgba[4])
Initialise the colors, using basic RGBA diffuse material color supplied.
void SetColor(const Float_t rgba[17])
Set full color attributes - see OpenGL material documentation for full description.
UInt_t fID
pointer to first reference
Bool_t fIsScaleForRnr
has been modified - retain across scene rebuilds
TGLVertex3 GetTranslation() const
void SetColorOnFamily(const Float_t rgba[17])
Set full color attributes to all physicals sharing the same logical with this object.
virtual void CalculateShapeLOD(TGLRnrCtx &rnrCtx, Float_t &pixSize, Short_t &shapeLOD) const
Calculate shape-lod, suitable for use under projection defined by 'rnrCtx', taking account of which l...
Bool_t IsSelected() const
void AddReference(TGLPShapeRef *ref)
Add reference ref.
Bool_t fInvertedWind
selected state
void SetTranslation(const TGLVertex3 &translation)
void SetDiffuseColor(const Float_t rgba[4])
Set color from ROOT color index and transparency [0,100].
Bool_t IsModified() const
TGLBoundingBox fBoundingBox
transform (placement) of physical instance
TGLMatrix fTransform
unique physical ID within containing scene
UChar_t GetSelected() const
TGLPShapeRef * fFirstPSRef
pointer to next replica
void Select(UChar_t select)
Bool_t IsTransparent() const
Float_t fColor[17]
bounding box of the physical (transformed)
void UpdateBoundingBox()
cache
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw physical shape, using LOD flags, potential from display list cache.
void Translate(const TGLVector3 &vect)
EManip GetManip() const
TGLPhysicalShape & operator=(const TGLPhysicalShape &)
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:41
3 component (x/y/z) vector class.
Definition: TGLUtil.h:247
3 component (x/y/z) vertex class.
Definition: TGLUtil.h:83
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17