17#include "TGLIncludes.h"
69 fLogicalShape (&logicalShape),
73 fTransform (transform),
76 fInvertedWind (invertedWind),
98 fLogicalShape (&logicalShape),
102 fTransform (transform),
105 fInvertedWind (invertedWind),
172 Error(
"TGLPhysicalShape::RemoveReference",
"Attempt to un-ref an unregistered shape-ref.");
230 for (
UInt_t i = 0; i < 17; i++) {
256 for (
Int_t i=0; i<4; ++i)
266 for (
Int_t i=0; i<4; ++i)
267 fColor[i] = rgba[i]/255.0f;
283 fColor[3] = 1.0f - 0.01*transparency;
294 if (color == 0) color =
fColor;
312 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color);
313 glMaterialfv(GL_FRONT, GL_AMBIENT, color + 4);
314 glMaterialfv(GL_FRONT, GL_SPECULAR, color + 8);
315 glMaterialfv(GL_FRONT, GL_EMISSION, color + 12);
316 glMaterialf(GL_FRONT, GL_SHININESS, color[16]);
342 Info(
"TGLPhysicalShape::Draw",
"this %zd (class %s) LOD %d",
343 (
size_t)
this,
IsA()->GetName(), rnrCtx.
ShapeLOD());
361 Info(
"TGLPhysicalShape::Draw",
"this %zd (class %s) LOD %d",
362 (
size_t)
this,
IsA()->GetName(), rnrCtx.
ShapeLOD());
371 glPushAttrib(GL_LIGHTING_BIT | GL_DEPTH_BUFFER_BIT);
373 glDisable(GL_LIGHTING);
374 glDisable(GL_DEPTH_TEST);
378 static const Int_t offsets[20][2] =
379 { {-1,-1}, { 1,-1}, { 1, 1}, {-1, 1},
380 { 1, 0}, { 0, 1}, {-1, 0}, { 0,-1},
381 { 0,-2}, { 2, 0}, { 0, 2}, {-2, 0},
382 {-2,-2}, { 2,-2}, { 2, 2}, {-2, 2},
383 { 0,-3}, { 3, 0}, { 0, 3}, {-3, 0} };
384 static const Int_t max_off =
389 for (
int i = 0; i < max_off; ++i)
391 glViewport(vp.
X() + offsets[i][0], vp.
Y() + offsets[i][1], vp.
Width(), vp.
Height());
445 std::vector <Double_t> boxViewportDiags;
471 Error(
"TGLPhysicalShape::CalcPhysicalLOD",
"LOD calculation for single axis not implemented presently");
478 for (
UInt_t i = 0; i < boxViewportDiags.size(); i++) {
479 if (boxViewportDiags[i] > largestDiagonal) {
480 largestDiagonal = boxViewportDiags[i];
483 pixSize = largestDiagonal;
485 if (largestDiagonal <= 1.0) {
491 UInt_t lodApp =
static_cast<UInt_t>(std::pow(largestDiagonal,0.4) * 100.0 / std::pow(2000.0,0.4));
492 if (lodApp > 1000) lodApp = 1000;
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
The color creation and management class.
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
void Set(const TGLVertex3 vertex[8])
Set a bounding box from provided 8 vertices.
void Transform(const TGLMatrix &matrix)
Transform all vertices with matrix.
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 ...
Abstract logical shape - a GL 'drawable' - base for all shapes - faceset sphere etc.
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw the GL drawable, using draw flags.
virtual void DrawHighlight(TGLRnrCtx &rnrCtx, const TGLPhysicalShape *pshp, Int_t lvl=-1) const
Draw the logical shape in highlight mode.
void SubRef(TGLPhysicalShape *phys) const
Remove reference to given physical shape, potentially deleting this object when hitting zero ref-coun...
virtual Short_t QuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD) const
Logical shapes usually support only discreet LOD values, especially in view of display-list caching.
virtual ELODAxes SupportedLODAxes() const
const TGLBoundingBox & BoundingBox() const
void AddRef(TGLPhysicalShape *phys) const
Add reference to given physical shape.
void InvokeContextMenu(TContextMenu &menu, UInt_t x, UInt_t y) const
Invoke popup menu or our bound external TObject (if any), using passed 'menu' object,...
TGLScene * GetScene() const
const TGLPhysicalShape * GetFirstPhysical() const
16 component (4x4) transform matrix - column MAJOR as per GL.
void Transpose3x3()
Transpose the top left 3x3 matrix component along major diagonal Supported as currently incompatibili...
const Double_t * CArr() const
Bool_t IsScalingForRender() const
Return true if matrix is to be considered a scaling matrix for rendering.
Base class for references to TGLPysicalShape that need to be notified when the shape is destroyed.
virtual void SetPShape(TGLPhysicalShape *shape)
Set the shape.
TGLPShapeRef * fNextPSRef
virtual void PShapeModified()
This is called from physical shape when it is modified.
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.
void SetupGLColors(TGLRnrCtx &rnrCtx, const Float_t *color=nullptr) const
Setup colors - avoid setting things not required for current draw flags.
TGLPhysicalShape * fNextPhysical
the associated logical shape
const TGLLogicalShape * fLogicalShape
Bool_t fModified
face winding TODO: can get directly from fTransform?
TGLPhysicalShape(const TGLPhysicalShape &)
const TGLBoundingBox & BoundingBox() const
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.
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.
Bool_t fIsScaleForRnr
has been modified - retain across scene rebuilds
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
selected state
void SetDiffuseColor(const Float_t rgba[4])
Set color from ROOT color index and transparency [0,100].
TGLBoundingBox fBoundingBox
transform (placement) of physical instance
TGLMatrix fTransform
unique physical ID within containing scene
TGLPShapeRef * fFirstPSRef
pointer to next replica
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.
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
void InvalidateBoundingBox()
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)