26#include "TGLIncludes.h"
82 fPlotInfo.Form(
"(binx = %d; biny = %d; binz = %d; binc = %f)", binI, binJ, binK,
83 fHist->GetBinContent(binI, binJ, binK));
85 fPlotInfo =
"Switch to true color mode to get correct info";
109 for (
Int_t ir =
fCoord->GetFirstXBin(); ir <= fCoord->GetLastXBin(); ++ir) {
110 for (
Int_t jr =
fCoord->GetFirstYBin(); jr <= fCoord->GetLastYBin(); ++jr) {
111 for (
Int_t kr =
fCoord->GetFirstZBin(); kr <= fCoord->GetLastZBin(); ++kr) {
128 for (
unsigned i = 0; i <
fPMPoints.size(); i += 3) {
176 py =
fCamera->GetHeight() - py;
209 if (boxPos + 3 < option.
Length() && isdigit(option[boxPos + 3]))
228 gROOT->ProcessLineFast(
Form(
"((TGLPlotPainter *)0x%zx)->Paint()", (
size_t)
this));
233 Info(
"ProcessEvent",
"Switch to true color mode to use box cut");
246 glEnable(GL_DEPTH_TEST);
247 glEnable(GL_LIGHTING);
250 glEnable(GL_CULL_FACE);
253 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
261 glDisable(GL_DEPTH_TEST);
262 glDisable(GL_LIGHTING);
263 glDisable(GL_LIGHT0);
264 glDisable(GL_CULL_FACE);
265 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
279 const Double_t ratio = onSphere ? 0.4 : 0.15;
280 const Double_t leftX = xMin + ratio * (xMax - xMin), rightX = xMax - ratio * (xMax - xMin);
281 const Double_t leftY = yMin + ratio * (yMax - yMin), rightY = yMax - ratio * (yMax - yMin);
282 const Double_t lowZ = zMin / 2. + zMax / 2. - 0.1 * (zMax - zMin);
283 const Double_t upZ = zMin / 2. + zMax / 2. + 0.1 * (zMax - zMin);
286 const Double_t minusVerts[][3] = {{xMin, leftY, lowZ}, {xMin, leftY, upZ}, {xMin, rightY, upZ}, {xMin, rightY, lowZ},
287 {leftX, yMin, lowZ}, {rightX, yMin, lowZ}, {rightX, yMin, upZ}, {leftX, yMin, upZ},
288 {xMax, leftY, lowZ}, {xMax, rightY, lowZ}, {xMax, rightY, upZ}, {xMax, leftY, upZ},
289 {rightX, yMax, lowZ}, {leftX, yMax, lowZ}, {leftX, yMax, upZ}, {rightX, yMax, upZ}};
290 const Int_t minusQuads[][4] = {{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}, {12, 13, 14, 15}};
294 glColor3d(1., 0., 0.);
296 const Int_t frontPlanes[][2] = {{0, 1}, {1, 2}, {2, 3}, {3, 0}};
297 const Int_t *verts = minusQuads[frontPlanes[fp][0]];
300 glVertex3dv(minusVerts[verts[0]]);
301 glVertex3dv(minusVerts[verts[1]]);
302 glVertex3dv(minusVerts[verts[2]]);
303 glVertex3dv(minusVerts[verts[3]]);
306 verts = minusQuads[frontPlanes[fp][1]];
309 glVertex3dv(minusVerts[verts[0]]);
310 glVertex3dv(minusVerts[verts[1]]);
311 glVertex3dv(minusVerts[verts[2]]);
312 glVertex3dv(minusVerts[verts[3]]);
315 const Float_t nullEmission[] = {0.f, 0.f, 0.f, 1.f};
316 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, nullEmission);
317 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, nullEmission);
319 glColor4d(0., 0., 0., 0.25);
320 glPolygonMode(GL_FRONT, GL_LINE);
324 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
327 glEnable(GL_LINE_SMOOTH);
328 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
330 verts = minusQuads[frontPlanes[fp][0]];
333 glVertex3dv(minusVerts[verts[0]]);
334 glVertex3dv(minusVerts[verts[1]]);
335 glVertex3dv(minusVerts[verts[2]]);
336 glVertex3dv(minusVerts[verts[3]]);
339 verts = minusQuads[frontPlanes[fp][1]];
342 glVertex3dv(minusVerts[verts[0]]);
343 glVertex3dv(minusVerts[verts[1]]);
344 glVertex3dv(minusVerts[verts[2]]);
345 glVertex3dv(minusVerts[verts[3]]);
348 glPolygonMode(GL_FRONT, GL_FILL);
369 glDisable(GL_CULL_FACE);
371 glEnable(GL_CULL_FACE);
374 glEnable(GL_POLYGON_OFFSET_FILL);
375 glPolygonOffset(1.f, 1.f);
380 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
394 const Int_t addI = frontPoint == 2 || frontPoint == 1 ? 1 : (iInit = nX - 1, irInit =
fCoord->GetLastXBin(), -1);
395 const Int_t addJ = frontPoint == 2 || frontPoint == 3 ? 1 : (jInit = nY - 1, jrInit =
fCoord->GetLastYBin(), -1);
397 : (kInit = nZ - 1, krInit =
fCoord->GetLastZBin(),-1);
417 for(
Int_t ir = irInit, i = iInit; addI > 0 ? i < nX : i >= 0; ir += addI, i += addI) {
418 for(
Int_t jr = jrInit, j = jInit; addJ > 0 ? j < nY : j >= 0; jr += addJ, j += addJ) {
419 for(
Int_t kr = krInit, k = kInit; addK > 0 ? k < nZ : k >= 0; kr += addK, k += addK) {
420 binContent =
fHist->GetBinContent(ir, jr, kr);
421 if (binContent < wmin)
continue;
422 if (binContent > wmax) binContent = wmax;
435 if (
fBoxCut.IsActive() &&
fBoxCut.IsInCut(xMin, xMax, yMin, yMax, zMin, zMax))
464 glDisable(GL_POLYGON_OFFSET_FILL);
466 glColor4d(0., 0., 0., 0.25);
467 glPolygonMode(GL_FRONT, GL_LINE);
470 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
472 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
474 for(
Int_t ir = irInit, i = iInit; addI > 0 ? i < nX : i >= 0; ir += addI, i += addI) {
475 for(
Int_t jr = jrInit, j = jInit; addJ > 0 ? j < nY : j >= 0; jr += addJ, j += addJ) {
476 for(
Int_t kr = krInit, k = kInit; addK > 0 ? k < nZ : k >= 0; kr += addK, k += addK) {
477 binContent =
fHist->GetBinContent(ir, jr, kr);
478 if (binContent < wmin)
continue;
479 if (binContent > wmax) binContent = wmax;
491 if (
fBoxCut.IsActive() &&
fBoxCut.IsInCut(xMin, xMax, yMin, yMax, zMin, zMax))
499 glPolygonMode(GL_FRONT, GL_FILL);
520 glDisable(GL_LIGHTING);
523 const Double_t dX = (bb[1].
X() - bb[0].
X()) / 40.;
524 const Double_t dY = (bb[3].
Y() - bb[0].Y()) / 40.;
525 const Double_t dZ = (bb[4].
Z() - bb[0].Z()) / 40.;
529 glEnable(GL_LIGHTING);
537 Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.05f};
546 c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);
549 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffColor);
550 const Float_t specColor[] = {1.f, 1.f, 1.f, 1.f};
551 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specColor);
552 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 70.f);
int Int_t
Signed integer 4 bytes (int).
int Ssiz_t
String size (currently int).
char Char_t
Character 1 byte (char).
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.
Class to manage histogram axis.
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.
const TPolyMarker3D * fPolymarker
void DrawPlot() const override
Bool_t HasSections() const
Check, if any section exists.
void DrawSectionYOZ() const override
Draw YOZ parallel section.
Bool_t InitGeometry() override
Set ranges, find min and max bin content.
void Pan(Int_t px, Int_t py) override
User's moving mouse cursor, with middle mouse button pressed (for pad).
void DeInitGL() const override
Return back some gl state variables.
void AddOption(const TString &stringOption) override
Box1 == spheres.
void DrawSectionXOZ() const override
Draw XOZ parallel section.
void InitGL() const override
Initialize some gl state variables.
void StartPan(Int_t px, Int_t py) override
User clicks right mouse button (in a pad).
std::vector< Double_t > fPMPoints
void DrawPaletteAxis() const override
Draw. Palette. Axis.
void SetPlotColor() const
Set boxes color.
TGLBoxPainter(const TGLBoxPainter &)
void DrawCloud() const
Draw a frame and a polymarker inside.
void DrawSectionXOY() const override
Draw XOY parallel section.
void ProcessEvent(Int_t event, Int_t px, Int_t py) override
Remove sections.
void DrawPalette() const
Draw.
char * GetPlotInfo(Int_t px, Int_t py) override
Show box info (i, j, k, binContent).
Int_t GetPaletteSize() const
Get. Palette. Size.
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).
const Float_t * fPhysicalShapeColor
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
static void RenderPolyMarkers(const TAttMarker &marker, Char_t transp, Float_t *p, Int_t n, Int_t pick_radius=0, Bool_t selection=kFALSE, Bool_t sec_selection=kFALSE)
Render polymarkers at points specified by p-array.
3 component (x/y/z) vertex class.
TH1 is the base class of all histogram classes in ROOT.
The 3-D histogram classes derived from the 1-D histogram classes.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
const Float_t gNullEmission[]
void ObjectIDToColor(Int_t objectID, Bool_t highColor)
Object id encoded as rgb triplet.
void DrawPalette(const TGLPlotCamera *camera, const TGLLevelPalette &palette)
Draw. Palette.
void DrawPaletteAxis(const TGLPlotCamera *camera, const Range_t &minMax, Bool_t logZ)
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 DrawSphere(TGLQuadric *quadric, Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
Cylinder for lego3.
const Float_t gOrangeEmission[]
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.