31#include "TGLIncludes.h"
67 static char null[] = {
"" };
159 if (surfPos + 4 <
option.Length() && isdigit(
option[surfPos + 4])) {
160 switch (
option[surfPos + 4] -
'0') {
217 gROOT->ProcessLineFast(
Form(
"((TGLPlotPainter *)0x%zx)->Paint()", (
size_t)
this));
222 Info(
"ProcessEvent",
"Switch to true color to use box cut");
235 glEnable(GL_LIGHTING);
237 glEnable(GL_DEPTH_TEST);
238 glDisable(GL_CULL_FACE);
239 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,
GL_TRUE);
247 glDisable(GL_LIGHTING);
248 glDisable(GL_LIGHT0);
249 glDisable(GL_DEPTH_TEST);
250 glDisable(GL_CULL_FACE);
251 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,
GL_FALSE);
271 for (
Int_t i = 0; i < nX - 1; ++i) {
272 for (
Int_t j = 0; j < nY - 1; ++j) {
287 for (
Int_t i = 0; i < nX; ++i) {
288 for (
Int_t j = 0; j < nY; ++j) {
298 if (!norm.
X() && !norm.
Y() && !norm.
Z())
311 Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.35f};
315 c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);
317 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffColor);
318 const Float_t specColor[] = {1.f, 1.f, 1.f, 1.f};
319 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specColor);
320 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 70.f);
340 glEnable(GL_POLYGON_OFFSET_FILL);
341 glPolygonOffset(1.f, 1.f);
347 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
364 Int_t i = 0, firstJ = 0;
365 const Int_t addI = frontPoint == 2 || frontPoint == 1 ? i = 0, 1 : (i = nX - 2, -1);
366 const Int_t addJ = frontPoint == 2 || frontPoint == 3 ? firstJ = 0, 1 : (firstJ = nY - 2, -1);
371 for (; addI > 0 ? i < nX - 1 : i >= 0; i += addI) {
372 for (
Int_t j = firstJ; addJ > 0 ? j < nY - 1 : j >= 0; j += addJ) {
416 glDisable(GL_POLYGON_OFFSET_FILL);
434 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
435 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
437 glColor4d(0., 0., 0., 0.5);
439 for (i = 0; i < nX - 1; ++i) {
440 for (
Int_t j = 0; j < nY - 1; ++j) {
452 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
461 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
463 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
466 glColor4d(1.f, 0.f, 0.4f, 0.6f);
468 for (i = 0; i < nX; ++i)
469 glVertex3dv(
fMesh[i][0].CArr());
470 for (
Int_t j = 0; j < nY; ++j)
471 glVertex3dv(
fMesh[nX - 1][j].CArr());
472 for (i = nX - 1; i >= 0; --i)
473 glVertex3dv(
fMesh[i][nY - 1].CArr());
474 for (
Int_t j = nY - 1; j >= 0; --j)
475 glVertex3dv(
fMesh[0][j].CArr());
503 fMesh.resize(nX * nY);
578 fMesh.resize(nX * nY);
644 fMesh.resize(nX * nY);
648 if (legoR > 1. || legoR < 0.)
717 fMesh.resize(nX * nY);
721 if (legoR > 1. || legoR < 0.)
779 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
783 typedef std::list<Projection_t>::const_iterator CLI_t;
784 for (CLI_t begin =
fXOZProj.begin(), end =
fXOZProj.end(); begin != end; ++begin) {
790 glVertex3dv(proj.
fVertices[i * 3].CArr());
791 glVertex3dv(proj.
fVertices[i * 3 + 1].CArr());
792 glVertex3dv(proj.
fVertices[i * 3 + 2].CArr());
799 glVertex3d(
v1.X(),
y,
v1.Z());
801 glVertex3d(
v2.X(),
y,
v2.Z());
803 glVertex3d(
v3.X(),
y,
v3.Z());
808 for (CLI_t begin =
fYOZProj.begin(), end =
fYOZProj.end(); begin != end; ++begin) {
814 glVertex3dv(proj.
fVertices[i * 3].CArr());
815 glVertex3dv(proj.
fVertices[i * 3 + 1].CArr());
816 glVertex3dv(proj.
fVertices[i * 3 + 2].CArr());
824 glVertex3d(
x,
v1.Y(),
v1.Z());
826 glVertex3d(
x,
v2.Y(),
v2.Z());
828 glVertex3d(
x,
v3.Y(),
v3.Z());
833 for (CLI_t begin =
fXOYProj.begin(), end =
fXOYProj.end(); begin != end; ++begin) {
839 glVertex3dv(proj.
fVertices[i * 2].CArr());
840 glVertex3dv(proj.
fVertices[i * 2 + 1].CArr());
879 glColor3d(1., 0., 0.);
929 glColor3d(1., 0., 0.);
975 glColor3d(1., 0., 0.);
979 for (
Int_t i = 0; i < nX - 1; ++i) {
980 for (
Int_t j = 0; j < nY - 1; ++j) {
1002 glVertex3dv(intersection[0].CArr());
1003 glVertex3dv(intersection[1].CArr());
1030 glVertex3dv(intersection[0].CArr());
1031 glVertex3dv(intersection[1].CArr());
1065 zVal = frame[0].
Z();
1071 if (zVal > frame[4].Z())
1072 zVal = frame[4].
Z();
1073 else if (zVal < frame[0].Z())
1074 zVal = frame[0].
Z();
1086 Int_t k = selected / 2;
1090 const Bool_t odd = selected & 1;
1098 glGetDoublev(GL_MODELVIEW_MATRIX, mvMatrix);
1100 glGetDoublev(GL_PROJECTION_MATRIX, prMatrix);
1101 Int_t viewport[4] = {0};
1102 glGetIntegerv(GL_VIEWPORT, viewport);
1104 gluProject(
v1.X(),
v1.Y(),
v1.Z(), mvMatrix, prMatrix, viewport, &winV1.
X(), &winV1.
Y(), &winV1.
Z());
1105 gluProject(
v2.X(),
v2.Y(),
v2.Z(), mvMatrix, prMatrix, viewport, &winV2.
X(), &winV2.
Y(), &winV2.
Z());
1106 gluProject(
v3.X(),
v3.Y(),
v3.Z(), mvMatrix, prMatrix, viewport, &winV3.
X(), &winV3.
Y(), &winV3.
Z());
1110 planeABCD[3] = - winV1.
X() * planeABCD[0] - winV1.
Y() * planeABCD[1] - winV1.
Z() * planeABCD[2];
1111 Double_t pz = (-planeABCD[3] - planeABCD[0] * px - planeABCD[1] * py) / planeABCD[2];
1114 gluUnProject(px, py, pz, mvMatrix, prMatrix, viewport, rez, rez + 1, rez + 2);
1179 static const Float_t whiteDiffuse[] = {0.8f, 0.8f, 0.8f, 0.65f};
1180 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, whiteDiffuse);
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
std::pair< Bool_t, TGLLine3 > Intersection(const TGLPlane &p1, const TGLPlane &p2)
Find 3D line interestion of this plane with 'other'.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint angle
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 GetBinCenter(Int_t bin) const
Return center of bin.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low 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 SetRowLen(Int_t len)
void MoveBox(Int_t px, Int_t py, Int_t axisID)
Move box cut along selected direction.
Bool_t IsInCut(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax) const
Check, if box defined by xmin/xmax etc. is in cut.
void DrawBox(Bool_t selectionPass, Int_t selected) const
Draw cut as a semi-transparent box.
void TurnOnOff()
Turn the box cut on/off.
void StartMovement(Int_t px, Int_t py)
Start cut's movement.
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.
3D space, fixed length, line class, with direction / length 'vector', passing through point 'vertex'.
3D plane class - of format Ax + By + Cz + D = 0
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 SetCoordType(EGLCoordType type)
If coord type was changed, plot must reset sections (if any), set fModified.
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.
Int_t GetLastYBin() const
Int_t GetNYBins() const
Number of Y bins.
Int_t GetLastXBin() const
EGLCoordType GetCoordType() const
Get coordinates type.
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
Implements painting of TH2 with "SURF" option.
char * GetPlotInfo(Int_t px, Int_t py) override
Coords for point on surface under cursor.
char * WindowPointTo3DPoint(Int_t px, Int_t py) const
Find 3d coords using mouse cursor coords.
void Pan(Int_t px, Int_t py) override
User's moving mouse cursor, with middle mouse button pressed (for pad).
void InitGL() const override
Initialize some OpenGL state variables.
TGL2DArray< Double_t > fTexMap
void ProcessEvent(Int_t event, Int_t px, Int_t py) override
Remove all profiles/sections.
Bool_t InitGeometryPolar()
Find bin ranges for X and Y axes, axes ranges for X, Y and Z.
void AddOption(const TString &stringOption) override
Additional options for surfaces.
void DrawProjections() const
Draw projections.
Bool_t HasProjections() const
Any projection exists.
Bool_t Textured() const
Checks, if surf requires texture.
void DrawSectionXOY() const override
Draw section Z.
std::list< Projection_t > fXOYProj
void DrawPalette() const
Draw.
TGL2DArray< TGLVector3 > fAverageNormals
void SetSurfaceColor() const
Set color for surface.
void DrawPaletteAxis() const override
Draw. Palette. Axis.
void DrawSectionXOZ() const override
Draw section X.
void DrawPlot() const override
Draw surf/surf1/surf2/surf4.
void DeInitGL() const override
Initialize some OpenGL state variables.
void DrawSectionYOZ() const override
Draw section Y.
TGL2DArray< std::pair< TGLVector3, TGLVector3 > > fFaceNormals
void DrawContoursProjection() const
Draw flat textured surface.
std::list< Projection_t > fXOZProj
Bool_t InitGeometrySpherical()
Find bin ranges for X and Y axes, axes ranges for X, Y and Z.
TGLSurfacePainter(TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord)
Constructor.
void ClampZ(Double_t &zVal) const
Clamp z value.
TGL2DArray< TGLVertex3 > fMesh
Bool_t InitGeometryCartesian()
Find bin ranges for X and Y axes, axes ranges for X, Y and Z.
Bool_t PreparePalette() const
Generate palette.
Bool_t InitGeometry() override
Set mesh, normals.
static TRandom * fgRandom
void GenTexMap() const
Find texture coordinates.
void SetNormals()
One normal per vertex; this normal is average of neighbouring triangles normals.
void StartPan(Int_t px, Int_t py) override
User clicks right mouse button (in a pad).
Bool_t InitGeometryCylindrical()
Find bin ranges for X and Y axes, axes ranges for X, Y and Z.
std::list< Projection_t > fYOZProj
Bool_t HasSections() const
Any section exists.
3 component (x/y/z) vector class.
3 component (x/y/z) vertex class.
const Double_t * CArr() const
TH1 is the base class of all histogram classes in ROOT.
@ kUserContour
User specified contour levels.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
This is the base class for the ROOT Random number generators.
virtual UInt_t Integer(UInt_t imax)
Returns a random integer uniformly distributed on the interval [ 0, imax-1 ].
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 DrawFaceTextured(const TGLVertex3 &v1, const TGLVertex3 &v2, const TGLVertex3 &v3, Double_t t1, Double_t t2, Double_t t3, const TGLVector3 &norm1, const TGLVector3 &norm2, const TGLVector3 &norm3)
Draw textured triangle.
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 DrawQuadOutline(const TGLVertex3 &v1, const TGLVertex3 &v2, const TGLVertex3 &v3, const TGLVertex3 &v4)
Draw quad outline.
void DrawSmoothFace(const TGLVertex3 &v1, const TGLVertex3 &v2, const TGLVertex3 &v3, const TGLVector3 &norm1, const TGLVector3 &norm2, const TGLVector3 &norm3)
Draws triangle face, each vertex has its own averaged normal.
T * Normal2Plane(const T v1[3], const T v2[3], const T v3[3], T normal[3])
Calculates a normal vector of a plane.
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()
void Swap(Projection_t &rhs)
Constructor.
std::vector< TGLVertex3 > fVertices