27#include "TGLIncludes.h"
42 fLegoType(kColorSimple),
64 fBinInfo.
Form(
"(binx = %d; biny = %d; binc = %f)", binI, binJ,
67 fBinInfo =
"Switch to true-color mode to obtain correct info";
117 if (
fXEdges[i].second > frame[1].
X())
121 if (
fXEdges[i].second < frame[0].
X())
129 if (
fXEdges[i].second > frame[1].
X())
133 if (
fXEdges[i].second < frame[0].
X())
147 if (
fYEdges[j].second > frame[2].Y())
151 if (
fYEdges[j].second < frame[0].Y())
159 if (
fYEdges[j].second > frame[2].Y())
160 fYEdges[j].second = frame[2].Y();
163 if (
fYEdges[j].second < frame[0].Y())
164 fYEdges[j].second = frame[0].Y();
438 if (legoPos + 4 <
option.Length() && isdigit(
option[legoPos + 4])) {
439 switch (
option[legoPos + 4] -
'0') {
457 if (ePos == legoPos + 1)
458 ePos =
option.Index(
"e", legoPos + 4);
469 glEnable(GL_DEPTH_TEST);
470 glEnable(GL_LIGHTING);
473 glEnable(GL_CULL_FACE);
476 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,
GL_TRUE);
484 glDisable(GL_DEPTH_TEST);
485 glDisable(GL_LIGHTING);
486 glDisable(GL_LIGHT0);
487 glDisable(GL_CULL_FACE);
488 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,
GL_FALSE);
526 glEnable(GL_POLYGON_OFFSET_FILL);
527 glPolygonOffset(1.f, 1.f);
532 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
543 const Int_t addI = frontPoint == 2 || frontPoint == 1 ? 1 : (iInit = nX - 1, irInit =
fCoord->
GetLastXBin(), -1);
544 const Int_t addJ = frontPoint == 2 || frontPoint == 3 ? 1 : (jInit = nY - 1, jrInit =
fCoord->
GetLastYBin(), -1);
557 for(
Int_t i = iInit, ir = irInit; addI > 0 ? i < nX : i >= 0; i += addI, ir += addI) {
558 for(
Int_t j = jInit, jr = jrInit; addJ > 0 ? j < nY : j >= 0; j += addJ, jr += addJ) {
592 glDisable(GL_POLYGON_OFFSET_FILL);
595 glColor3d(0., 0., 0.);
597 glColor4d(0., 0., 0., 0.4);
598 glPolygonMode(GL_FRONT, GL_LINE);
601 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
603 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
605 for(
Int_t i = iInit, ir = irInit; addI > 0 ? i < nX : i >= 0; i += addI, ir += addI) {
606 for(
Int_t j = jInit, jr = jrInit; addJ > 0 ? j < nY : j >= 0; j += addJ, jr += addJ) {
618 fYEdges[j].second, zMax, errorZMax);
623 glPolygonMode(GL_FRONT, GL_FILL);
640 glEnable(GL_POLYGON_OFFSET_FILL);
641 glPolygonOffset(1.f, 1.f);
694 glDisable(GL_POLYGON_OFFSET_FILL);
696 glColor3d(0., 0., 0.);
697 glPolygonMode(GL_FRONT, GL_LINE);
699 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
701 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
720 glPolygonMode(GL_FRONT, GL_FILL);
735 if (legoR > 1. || legoR < 0.)
741 glEnable(GL_POLYGON_OFFSET_FILL);
742 glPolygonOffset(1.f, 1.f);
765 std::swap(zMin, zMax);
799 glDisable(GL_POLYGON_OFFSET_FILL);
801 glColor3d(0., 0., 0.);
802 glPolygonMode(GL_FRONT, GL_LINE);
805 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
807 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
814 std::swap(zMin, zMax);
828 glPolygonMode(GL_FRONT, GL_FILL);
844 if (legoR > 1. || legoR < 0.)
849 glEnable(GL_POLYGON_OFFSET_FILL);
850 glPolygonOffset(1.f, 1.f);
872 std::swap(zMin, zMax);
921 glDisable(GL_POLYGON_OFFSET_FILL);
923 glColor3d(0., 0., 0.);
924 glPolygonMode(GL_FRONT, GL_LINE);
926 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
928 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
935 std::swap(zMin, zMax);
965 glPolygonMode(GL_FRONT, GL_FILL);
977 Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.15f};
981 c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);
983 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffColor);
984 const Float_t specColor[] = {1.f, 1.f, 1.f, 1.f};
985 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specColor);
986 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 70.f);
1005 glColor3d(1., 0., 0.);
1041 glColor3d(1., 0., 0.);
1081 gROOT->ProcessLineFast(
Form(
"((TGLPlotPainter *)0x%zx)->Paint()", (
size_t)
this));
1085 Info(
"ProcessEvent",
"Box cut does not exist for lego");
1104 if (zVal > frame[4].Z())
1105 zVal = frame[4].
Z();
1106 else if (zVal < frame[0].Z())
1107 zVal = frame[0].
Z();
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
R__EXTERN TStyle * gStyle
virtual Color_t GetFillColor() const
Return the fill area color.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
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",...
void MoveBox(Int_t px, Int_t py, Int_t axisID)
Move box cut along selected direction.
void TurnOnOff()
Turn the box cut on/off.
void StartMovement(Int_t px, Int_t py)
Start cut's movement.
Plot-painter implementing LEGO rendering of TH2 histograms in cartesian, polar, cylindrical and spher...
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.
void DisableTexture() const
Disable 1D texture.
Double_t GetTexCoord(Double_t z) const
Get tex coordinate.
Bool_t GeneratePalette(UInt_t paletteSize, const Rgl::Range_t &zRange, Bool_t checkSize=kTRUE)
Try to find colors for palette.
void EnableTexture(Int_t mode) const
Enable 1D texture.
void SetPlotBox(const Rgl::Range_t &xRange, const Rgl::Range_t &yRange, const Rgl::Range_t &zRange)
Set up a frame box.
const TGLVertex3 * Get3DBox() const
Get 3D box.
void DrawBox(Int_t selectedPart, Bool_t selectionPass, const std::vector< Double_t > &zLevels, Bool_t highColor) const
Draw back box for a plot.
Int_t GetFrontPoint() const
The nearest point.
Camera for TGLPlotPainter and sub-classes.
void StartPan(Int_t px, Int_t py)
User clicks somewhere (px, py).
void Apply(Double_t phi, Double_t theta) const
Applies rotations and translations before drawing.
void SetCamera() const
Viewport and projection.
void Pan(Int_t px, Int_t py)
Pan camera.
Int_t GetHeight() const
viewport[3]
void SetViewVolume(const TGLVertex3 *box)
'box' is the TGLPlotPainter's back box's coordinates.
Helper class for plot-painters holding information about axis ranges, numbers of bins and flags if ce...
Double_t GetZLength() const
Z length.
Bool_t SetRanges(const TH1 *hist, Bool_t errors=kFALSE, Bool_t zBins=kFALSE)
Set bin ranges, ranges.
Double_t GetYScale() const
const Rgl::Range_t & GetXRangeScaled() const
Scaled range.
Bool_t GetXLog() const
Get X log.
Int_t GetFirstXBin() const
Int_t GetFirstYBin() const
const Rgl::Range_t & GetZRange() const
Z range.
const Rgl::Range_t & GetYRangeScaled() const
Scaled range.
void ResetModified()
Reset modified.
Bool_t GetYLog() const
Get Y log.
Bool_t GetZLog() const
Get Z log.
Bool_t Modified() const
Modified.
Double_t GetXScale() const
Double_t GetZScale() const
Int_t GetNXBins() const
Number of X bins.
const Rgl::Range_t & GetZRangeScaled() const
Scaled range.
const Rgl::Range_t & GetYRange() const
Y range.
Int_t GetLastYBin() const
Int_t GetNYBins() const
Number of Y bins.
Int_t GetLastXBin() const
EGLCoordType GetCoordType() const
Get coordinates type.
Double_t GetYLength() const
Y length.
Double_t GetFactor() const
Get factor.
Base class for plot-painters that provide GL rendering of various 2D and 3D histograms,...
void DrawSections() const
Draw sections (if any).
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.
virtual Float_t GetBarWidth() const
virtual Float_t GetBarOffset() const
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
@ kUserContour
User specified contour levels.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
const char * GetName() const override
Returns name of object.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
const char * Data() const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Float_t GetLegoInnerR() const
Int_t GetNumberContours() 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()