27#include "TGLIncludes.h"
63 fBinInfo.Form(
"(binx = %d; biny = %d; binc = %f)", binI, binJ,
64 fHist->GetBinContent(binI, binJ));
66 fBinInfo =
"Switch to true-color mode to obtain correct info";
78 switch (
fCoord->GetCoordType()) {
111 for (
Int_t i = 0, ir =
fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
116 if (
fXEdges[i].second > frame[1].
X())
118 if (
fXEdges[i].first < frame[0].
X())
120 if (
fXEdges[i].second < frame[0].
X())
124 for (
Int_t i = 0, ir =
fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
128 if (
fXEdges[i].second > frame[1].
X())
130 if (
fXEdges[i].first < frame[0].
X())
132 if (
fXEdges[i].second < frame[0].
X())
141 for (
Int_t j = 0, jr =
fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
146 if (
fYEdges[j].second > frame[2].Y())
148 if (
fYEdges[j].first < frame[0].Y())
150 if (
fYEdges[j].second < frame[0].Y())
154 for (
Int_t j = 0, jr =
fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
158 if (
fYEdges[j].second > frame[2].Y())
160 if (
fYEdges[j].first < frame[0].Y())
162 if (
fYEdges[j].second < frame[0].Y())
184 for (
Int_t j =
fCoord->GetFirstYBin(), e1 =
fCoord->GetLastYBin(); j <= e1; ++j) {
215 for (
Int_t j = 0, jr =
fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
227 for (
Int_t i = 0, ir =
fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
244 for (
Int_t j =
fCoord->GetFirstYBin(), e1 =
fCoord->GetLastYBin(); j <= e1; ++j) {
271 for (
Int_t j = 0, jr =
fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
276 for (
Int_t j = 0, jr =
fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
287 for (
Int_t i = 0, ir =
fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
310 for (
Int_t j =
fCoord->GetFirstYBin(), e1 =
fCoord->GetLastYBin(); j <= e1; ++j) {
335 for (
Int_t j = 0, jr =
fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
336 angle = (
fYAxis->GetBinLowEdge(jr) - thetaLow) / fullTheta *
TMath::Pi();
349 for (
Int_t i = 0, ir =
fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
367 for (
Int_t j =
fCoord->GetFirstYBin(), e1 =
fCoord->GetLastYBin(); j <= e1; ++j) {
406 py =
fCamera->GetHeight() - py;
436 if (legoPos + 4 < option.
Length() && isdigit(option[legoPos + 4])) {
437 switch (option[legoPos + 4] -
'0') {
455 if (ePos == legoPos + 1)
456 ePos = option.
Index(
"e", legoPos + 4);
467 glEnable(GL_DEPTH_TEST);
468 glEnable(GL_LIGHTING);
471 glEnable(GL_CULL_FACE);
474 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
482 glDisable(GL_DEPTH_TEST);
483 glDisable(GL_LIGHTING);
484 glDisable(GL_LIGHT0);
485 glDisable(GL_CULL_FACE);
486 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
497 switch (
fCoord->GetCoordType()) {
524 glEnable(GL_POLYGON_OFFSET_FILL);
525 glPolygonOffset(1.f, 1.f);
530 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
540 Int_t iInit = 0, jInit = 0, irInit =
fCoord->GetFirstXBin(), jrInit =
fCoord->GetFirstYBin();
541 const Int_t addI = frontPoint == 2 || frontPoint == 1 ? 1 : (iInit = nX - 1, irInit =
fCoord->GetLastXBin(), -1);
542 const Int_t addJ = frontPoint == 2 || frontPoint == 3 ? 1 : (jInit = nY - 1, jrInit =
fCoord->GetLastYBin(), -1);
549 fPalette.EnableTexture(GL_MODULATE);
555 for(
Int_t i = iInit, ir = irInit; addI > 0 ? i < nX : i >= 0; i += addI, ir += addI) {
556 for(
Int_t j = jInit, jr = jrInit; addJ > 0 ? j < nY : j >= 0; j += addJ, jr += addJ) {
574 fPalette.GetTexCoord(zMax), frontPoint);
590 glDisable(GL_POLYGON_OFFSET_FILL);
593 glColor3d(0., 0., 0.);
595 glColor4d(0., 0., 0., 0.4);
596 glPolygonMode(GL_FRONT, GL_LINE);
599 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
601 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
603 for(
Int_t i = iInit, ir = irInit; addI > 0 ? i < nX : i >= 0; i += addI, ir += addI) {
604 for(
Int_t j = jInit, jr = jrInit; addJ > 0 ? j < nY : j >= 0; j += addJ, jr += addJ) {
616 fYEdges[j].second, zMax, errorZMax);
621 glPolygonMode(GL_FRONT, GL_FILL);
638 glEnable(GL_POLYGON_OFFSET_FILL);
639 glPolygonOffset(1.f, 1.f);
649 fPalette.EnableTexture(GL_MODULATE);
655 for(
Int_t i = 0, ir =
fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
656 for(
Int_t j = 0, jr =
fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
692 glDisable(GL_POLYGON_OFFSET_FILL);
694 glColor3d(0., 0., 0.);
695 glPolygonMode(GL_FRONT, GL_LINE);
697 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
699 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
701 for(
Int_t i = 0, ir =
fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
702 for(
Int_t j = 0, jr =
fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
718 glPolygonMode(GL_FRONT, GL_FILL);
733 if (legoR > 1. || legoR < 0.)
739 glEnable(GL_POLYGON_OFFSET_FILL);
740 glPolygonOffset(1.f, 1.f);
745 legoR *=
fCoord->GetXScale();
752 fPalette.EnableTexture(GL_MODULATE);
758 for(
Int_t i = 0, ir =
fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
759 for(
Int_t j = 0, jr =
fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
761 Double_t zMax = legoR + (
fHist->GetBinContent(ir, jr) -
fCoord->GetZRange().first) / rRange * sc;
763 std::swap(zMin, zMax);
797 glDisable(GL_POLYGON_OFFSET_FILL);
799 glColor3d(0., 0., 0.);
800 glPolygonMode(GL_FRONT, GL_LINE);
803 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
805 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
807 for(
Int_t i = 0, ir =
fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
808 for(
Int_t j = 0, jr =
fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
810 Double_t zMax = legoR + (
fHist->GetBinContent(ir, jr) -
fCoord->GetZRange().first) / rRange * sc;
812 std::swap(zMin, zMax);
826 glPolygonMode(GL_FRONT, GL_FILL);
842 if (legoR > 1. || legoR < 0.)
847 glEnable(GL_POLYGON_OFFSET_FILL);
848 glPolygonOffset(1.f, 1.f);
859 fPalette.EnableTexture(GL_MODULATE);
865 for(
Int_t i = 0, ir =
fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
866 for(
Int_t j = 0, jr =
fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
868 Double_t zMax = legoR + (
fHist->GetBinContent(ir, jr) -
fCoord->GetZRange().first) / rRange * sc;
870 std::swap(zMin, zMax);
919 glDisable(GL_POLYGON_OFFSET_FILL);
921 glColor3d(0., 0., 0.);
922 glPolygonMode(GL_FRONT, GL_LINE);
924 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
926 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
928 for(
Int_t i = 0, ir =
fCoord->GetFirstXBin(); i < nX; ++i, ++ir) {
929 for(
Int_t j = 0, jr =
fCoord->GetFirstYBin(); j < nY; ++j, ++jr) {
931 Double_t zMax = legoR + (
fHist->GetBinContent(ir, jr) -
fCoord->GetZRange().first) / rRange * sc;
933 std::swap(zMin, zMax);
963 glPolygonMode(GL_FRONT, GL_FILL);
975 Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.15f};
979 c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);
981 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffColor);
982 const Float_t specColor[] = {1.f, 1.f, 1.f, 1.f};
983 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specColor);
984 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 70.f);
1002 binY +=
fCoord->GetFirstYBin();
1003 glColor3d(1., 0., 0.);
1011 glBegin(GL_LINE_LOOP);
1038 binX +=
fCoord->GetFirstXBin();
1039 glColor3d(1., 0., 0.);
1047 glBegin(GL_LINE_LOOP);
1079 gROOT->ProcessLineFast(
Form(
"((TGLPlotPainter *)0x%zx)->Paint()", (
size_t)
this));
1083 Info(
"ProcessEvent",
"Box cut does not exist for lego");
1098 zVal *=
fCoord->GetZScale();
1102 if (zVal > frame[4].Z())
1103 zVal = frame[4].
Z();
1104 else if (zVal < frame[0].Z())
1105 zVal = frame[0].
Z();
int Int_t
Signed integer 4 bytes (int).
int Ssiz_t
String size (currently int).
char Char_t
Character 1 byte (char).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
float Float_t
Float 4 bytes (float).
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Bool_t InitGeometryCartesian()
Geometry for lego in cartesian coords.
Bool_t PreparePalette() const
Initialize color palette.
void DrawSectionXOZ() const override
XOZ plane parallel section.
void DrawSectionXOY() const override
Empty. No such sections for lego.
void DrawLegoSpherical() const
Lego in spherical system.
std::vector< Rgl::Range_t > fXEdges
void StartPan(Int_t px, Int_t py) override
User clicks on a lego with middle mouse button (middle for pad).
Bool_t InitGeometryCylindrical()
Geometry for lego in cylindrical coords.
void AddOption(const TString &stringOption) override
Parse additional options.
void InitGL() const override
Initialize some gl state variables.
char * GetPlotInfo(Int_t px, Int_t py) override
Obtain bin's info (i, j, value).
void DrawLegoPolar() const
Lego in polar system.
void DrawSectionYOZ() const override
YOZ plane parallel section.
void Pan(Int_t px, Int_t py) override
Move lego or section.
Bool_t ClampZ(Double_t &zVal) const
Clamp z value.
Bool_t InitGeometrySpherical()
Geometry for lego in spherical coords.
void DrawPlot() const override
Select method corresponding to coordinate system.
TGLLegoPainter(const TGLLegoPainter &)
void DrawPalette() const
Draw.
void DrawLegoCartesian() const
Lego in cartesian system.
void SetLegoColor() const
Set lego's color.
std::vector< Rgl::Range_t > fYEdges
std::vector< CosSin_t > fCosSinTableX
void DeInitGL() const override
Return some gl states to original values.
void DrawLegoCylindrical() const
Lego in cylindrical system.
std::vector< CosSin_t > fCosSinTableY
Bool_t InitGeometryPolar()
Geometry for lego in polar coords.
void ProcessEvent(Int_t event, Int_t px, Int_t py) override
Remove all sections and repaint.
Bool_t InitGeometry() override
Select method.
void DrawPaletteAxis() const override
Draw. Palette. Axis.
Camera for TGLPlotPainter and sub-classes.
Helper class for plot-painters holding information about axis ranges, numbers of bins and flags if ce...
void DrawSections() const
Draw sections (if any).
TGLPlotPainter(TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord, Bool_t xoySelectable, Bool_t xozSelectable, Bool_t yozSelectable)
TGLPlotPainter's ctor.
std::vector< Double_t > fZLevels
void RestoreModelviewMatrix() const
TGLPlotCoordinates * fCoord
void Paint() override
Draw lego/surf/whatever you can.
void SaveProjectionMatrix() const
void SaveModelviewMatrix() const
void MoveSection(Int_t px, Int_t py)
Create dynamic profile using selected plane.
void RestoreProjectionMatrix() const
3 component (x/y/z) vertex class.
TH1 is the base class of all histogram classes in ROOT.
@ kUserContour
User specified contour levels.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
void DrawTrapezoid(const Double_t ver[][2], Double_t zMin, Double_t zMax, Bool_t color=kTRUE)
void DrawTrapezoidTextured(const Double_t ver[][2], Double_t zMin, Double_t zMax, Double_t tMin, Double_t tMax)
In polar coordinates, box became trapezoid.
const Float_t gNullEmission[]
void ObjectIDToColor(Int_t objectID, Bool_t highColor)
Object id encoded as rgb triplet.
void SetZLevels(TAxis *zAxis, Double_t zMin, Double_t zMax, Double_t zScale, std::vector< Double_t > &zLevels)
void DrawPalette(const TGLPlotCamera *camera, const TGLLevelPalette &palette)
Draw. Palette.
void DrawPaletteAxis(const TGLPlotCamera *camera, const Range_t &minMax, Bool_t logZ)
void DrawTrapezoidTextured2(const Double_t ver[][2], Double_t zMin, Double_t zMax, Double_t tMin, Double_t tMax)
In polar coordinates, box became trapezoid.
void DrawCylinder(TGLQuadric *quadric, Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
Cylinder for lego3.
void DrawError(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
std::pair< Double_t, Double_t > Range_t
void DrawBoxFront(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax, Int_t fp)
Draws lego's bar as a 3d box.
void DrawBoxFrontTextured(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax, Double_t tMin, Double_t tMax, Int_t front)
Draws lego's bar as a 3d box LULULULU.
const Float_t gOrangeEmission[]
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
constexpr Double_t TwoPi()