17#include "TGLIncludes.h"
140 assert(ref !=
nullptr);
151 assert(ref !=
nullptr);
159 while ((shp2 = shp1->
fNextPSRef) !=
nullptr) {
171 Error(
"TGLPhysicalShape::RemoveReference",
"Attempt to un-ref an unregistered shape-ref.");
229 for (
UInt_t i = 0; i < 17; i++) {
255 for (
Int_t i=0; i<4; ++i)
265 for (
Int_t i=0; i<4; ++i)
266 fColor[i] = rgba[i]/255.0f;
282 fColor[3] = 1.0f - 0.01*transparency;
293 if (color ==
nullptr) color =
fColor;
311 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color);
312 glMaterialfv(GL_FRONT, GL_AMBIENT, color + 4);
313 glMaterialfv(GL_FRONT, GL_SPECULAR, color + 8);
314 glMaterialfv(GL_FRONT, GL_EMISSION, color + 12);
315 glMaterialf(GL_FRONT, GL_SHININESS, color[16]);
341 Info(
"TGLPhysicalShape::Draw",
"this %zd (class %s) LOD %d",
342 (
size_t)
this,
IsA()->GetName(), rnrCtx.
ShapeLOD());
360 Info(
"TGLPhysicalShape::Draw",
"this %zd (class %s) LOD %d",
361 (
size_t)
this,
IsA()->GetName(), rnrCtx.
ShapeLOD());
370 glPushAttrib(GL_LIGHTING_BIT | GL_DEPTH_BUFFER_BIT);
372 glDisable(GL_LIGHTING);
373 glDisable(GL_DEPTH_TEST);
377 static const Int_t offsets[20][2] =
378 { {-1,-1}, { 1,-1}, { 1, 1}, {-1, 1},
379 { 1, 0}, { 0, 1}, {-1, 0}, { 0,-1},
380 { 0,-2}, { 2, 0}, { 0, 2}, {-2, 0},
381 {-2,-2}, { 2,-2}, { 2, 2}, {-2, 2},
382 { 0,-3}, { 3, 0}, { 0, 3}, {-3, 0} };
383 static const Int_t max_off =
388 for (
int i = 0; i < max_off; ++i)
390 glViewport(vp.
X() + offsets[i][0], vp.
Y() + offsets[i][1], vp.
Width(), vp.
Height());
444 std::vector <Double_t> boxViewportDiags;
470 Error(
"TGLPhysicalShape::CalcPhysicalLOD",
"LOD calculation for single axis not implemented presently");
477 for (
UInt_t i = 0; i < boxViewportDiags.size(); i++) {
478 if (boxViewportDiags[i] > largestDiagonal) {
479 largestDiagonal = boxViewportDiags[i];
482 pixSize = largestDiagonal;
484 if (largestDiagonal <= 1.0) {
490 UInt_t lodApp =
static_cast<UInt_t>(std::pow(largestDiagonal,0.4) * 100.0 / std::pow(2000.0,0.4));
491 if (lodApp > 1000) lodApp = 1000;
502 quantLOD =
fLogicalShape->QuantizeShapeLOD(shapeLOD, combiLOD);
int Int_t
Signed integer 4 bytes (int).
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
short Short_t
Signed Short integer 2 bytes (short).
double Double_t
Double 8 bytes.
short Color_t
Color number (short).
float Float_t
Float 4 bytes (float).
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
TGLRect ViewportRect(const TGLBoundingBox &box, TGLBoundingBox::EFace face) const
Calculate viewport rectangle which just contains projection of single 'face' of world frame bounding ...
16 component (4x4) transform matrix - column MAJOR as per GL.
Base class for references to TGLPysicalShape that need to be notified when the shape is destroyed.
TGLPShapeRef * fNextPSRef
virtual void PShapeModified()
This is called from physical shape when it is modified.
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.
void SetupGLColors(TGLRnrCtx &rnrCtx, const Float_t *color=nullptr) const
Setup colors - avoid setting things not required for current draw flags.
TGLPhysicalShape * fNextPhysical
! pointer to next replica
const TGLLogicalShape * fLogicalShape
! the associated logical shape
Bool_t fModified
! has been modified - retain across scene rebuilds
const TGLBoundingBox & BoundingBox() const
UChar_t fSelected
! selected state
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
! permitted manipulation bitflags - see EManip
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
! unique physical ID within containing scene
Bool_t fIsScaleForRnr
! cache
virtual TClass * IsA() 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...
void AddReference(TGLPShapeRef *ref)
Add reference ref.
Bool_t fInvertedWind
! face winding TODO: can get directly from fTransform?
void SetDiffuseColor(const Float_t rgba[4])
Set color from ROOT color index and transparency [0,100].
TGLPhysicalShape(const TGLPhysicalShape &)=delete
TGLBoundingBox fBoundingBox
! bounding box of the physical (transformed)
TGLMatrix fTransform
! transform (placement) of physical instance
TGLPShapeRef * fFirstPSRef
! pointer to first reference
Float_t fColor[17]
! GL color array
void UpdateBoundingBox()
Update our internal bounding box (in global frame).
friend class TGLLogicalShape
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw physical shape, using LOD flags, potential from display list cache.
Viewport (pixel base) 2D rectangle class.
Int_t Diagonal() const
Return the diagonal of the rectangle.
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
TGLColorSet & ColorSet()
Return reference to current color-set (top of the stack).
Bool_t HighlightOutline() const
Bool_t IsDrawPassOutlineLine() const
static UInt_t LockColor()
Prevent further color changes.
static UInt_t UnlockColor()
Allow color changes.
static Float_t GetScreenScalingFactor()
Returns scaling factor between screen points and GL viewport pixels.
static void ColorAlpha(const TGLColor &color, UChar_t alpha)
Set color from TGLColor and alpha value.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)