17#include "TGLIncludes.h"
141 assert(ref !=
nullptr);
152 assert(ref !=
nullptr);
160 while ((shp2 = shp1->
fNextPSRef) !=
nullptr) {
172 Error(
"TGLPhysicalShape::RemoveReference",
"Attempt to un-ref an unregistered shape-ref.");
283 fColor[3] = 1.0f - 0.01*transparency;
294 if (color ==
nullptr) 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;
503 quantLOD =
fLogicalShape->QuantizeShapeLOD(shapeLOD, combiLOD);
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.
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.
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?
const TGLBoundingBox & BoundingBox() 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 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
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].
TGLPhysicalShape(const TGLPhysicalShape &)=delete
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
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)