70 static char null[] = {
"" };
163 if (surfPos + 4 < option.
Length() && isdigit(option[surfPos + 4])) {
164 switch (option[surfPos + 4] -
'0') {
221 gROOT->ProcessLineFast(
Form(
"((TGLPlotPainter *)0x%lx)->Paint()", (
ULong_t)
this));
226 Info(
"ProcessEvent",
"Switch to true color to use box cut");
239 glEnable(GL_LIGHTING);
241 glEnable(GL_DEPTH_TEST);
242 glDisable(GL_CULL_FACE);
243 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
251 glDisable(GL_LIGHTING);
252 glDisable(GL_LIGHT0);
253 glDisable(GL_DEPTH_TEST);
254 glDisable(GL_CULL_FACE);
255 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
275 for (
Int_t i = 0; i < nX - 1; ++i) {
276 for (
Int_t j = 0; j < nY - 1; ++j) {
291 for (
Int_t i = 0; i < nX; ++i) {
292 for (
Int_t j = 0; j < nY; ++j) {
302 if (!norm.
X() && !norm.
Y() && !norm.
Z())
315 Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.35f};
319 c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);
321 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffColor);
322 const Float_t specColor[] = {1.f, 1.f, 1.f, 1.f};
323 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specColor);
324 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 70.
f);
344 glEnable(GL_POLYGON_OFFSET_FILL);
345 glPolygonOffset(1.
f, 1.
f);
351 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
368 Int_t i = 0, firstJ = 0;
369 const Int_t addI = frontPoint == 2 || frontPoint == 1 ? i = 0, 1 : (i = nX - 2, -1);
370 const Int_t addJ = frontPoint == 2 || frontPoint == 3 ? firstJ = 0, 1 : (firstJ = nY - 2, -1);
375 for (; addI > 0 ? i < nX - 1 : i >= 0; i += addI) {
376 for (
Int_t j = firstJ; addJ > 0 ? j < nY - 1 : j >= 0; j += addJ) {
420 glDisable(GL_POLYGON_OFFSET_FILL);
436 glDepthMask(GL_FALSE);
438 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
439 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
441 glColor4d(0., 0., 0., 0.5);
443 for (i = 0; i < nX - 1; ++i) {
444 for (
Int_t j = 0; j < nY - 1; ++j) {
449 glDepthMask(GL_TRUE);
456 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
465 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
467 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
470 glColor4d(1.
f, 0.
f, 0.4
f, 0.6
f);
471 glBegin(GL_LINE_STRIP);
472 for (i = 0; i < nX; ++i)
473 glVertex3dv(
fMesh[i][0].CArr());
474 for (
Int_t j = 0; j < nY; ++j)
475 glVertex3dv(
fMesh[nX - 1][j].CArr());
476 for (i = nX - 1; i >= 0; --i)
477 glVertex3dv(
fMesh[i][nY - 1].CArr());
478 for (
Int_t j = nY - 1; j >= 0; --j)
479 glVertex3dv(
fMesh[0][j].CArr());
507 fMesh.resize(nX * nY);
582 fMesh.resize(nX * nY);
648 fMesh.resize(nX * nY);
652 if (legoR > 1. || legoR < 0.)
721 fMesh.resize(nX * nY);
725 if (legoR > 1. || legoR < 0.)
783 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
784 glDepthMask(GL_FALSE);
787 typedef std::list<Projection_t>::const_iterator CLI_t;
788 for (CLI_t begin =
fXOZProj.begin(), end =
fXOZProj.end(); begin != end; ++begin) {
793 glBegin(GL_LINE_STRIP);
794 glVertex3dv(proj.
fVertices[i * 3].CArr());
795 glVertex3dv(proj.
fVertices[i * 3 + 1].CArr());
796 glVertex3dv(proj.
fVertices[i * 3 + 2].CArr());
801 glBegin(GL_LINE_STRIP);
803 glVertex3d(v1.
X(),
y, v1.
Z());
805 glVertex3d(v2.X(),
y, v2.Z());
807 glVertex3d(v3.X(),
y, v3.Z());
812 for (CLI_t begin =
fYOZProj.begin(), end =
fYOZProj.end(); begin != end; ++begin) {
817 glBegin(GL_LINE_STRIP);
818 glVertex3dv(proj.
fVertices[i * 3].CArr());
819 glVertex3dv(proj.
fVertices[i * 3 + 1].CArr());
820 glVertex3dv(proj.
fVertices[i * 3 + 2].CArr());
826 glBegin(GL_LINE_STRIP);
828 glVertex3d(x, v1.
Y(), v1.
Z());
830 glVertex3d(x, v2.Y(), v2.Z());
832 glVertex3d(x, v3.Y(), v3.Z());
837 for (CLI_t begin =
fXOYProj.begin(), end =
fXOYProj.end(); begin != end; ++begin) {
843 glVertex3dv(proj.
fVertices[i * 2].CArr());
844 glVertex3dv(proj.
fVertices[i * 2 + 1].CArr());
860 glDepthMask(GL_TRUE);
884 glColor3d(1., 0., 0.);
888 glBegin(GL_LINE_STRIP);
935 glColor3d(1., 0., 0.);
938 glBegin(GL_LINE_STRIP);
982 glColor3d(1., 0., 0.);
986 for (
Int_t i = 0; i < nX - 1; ++i) {
987 for (
Int_t j = 0; j < nY - 1; ++j) {
1009 glVertex3dv(intersection[0].CArr());
1010 glVertex3dv(intersection[1].CArr());
1020 if (zMin < fXOYSectionPos && zMax > fXOYSectionPos) {
1037 glVertex3dv(intersection[0].CArr());
1038 glVertex3dv(intersection[1].CArr());
1072 zVal = frame[0].
Z();
1078 if (zVal > frame[4].
Z())
1079 zVal = frame[4].
Z();
1080 else if (zVal < frame[0].
Z())
1081 zVal = frame[0].
Z();
1093 Int_t k = selected / 2;
1097 const Bool_t odd = selected & 1;
1105 glGetDoublev(GL_MODELVIEW_MATRIX, mvMatrix);
1107 glGetDoublev(GL_PROJECTION_MATRIX, prMatrix);
1108 Int_t viewport[4] = {0};
1109 glGetIntegerv(GL_VIEWPORT, viewport);
1111 gluProject(v1.
X(), v1.
Y(), v1.
Z(), mvMatrix, prMatrix, viewport, &winV1.
X(), &winV1.
Y(), &winV1.
Z());
1112 gluProject(v2.
X(), v2.
Y(), v2.
Z(), mvMatrix, prMatrix, viewport, &winV2.
X(), &winV2.
Y(), &winV2.
Z());
1113 gluProject(v3.
X(), v3.
Y(), v3.
Z(), mvMatrix, prMatrix, viewport, &winV3.
X(), &winV3.
Y(), &winV3.
Z());
1117 planeABCD[3] = - winV1.
X() * planeABCD[0] - winV1.
Y() * planeABCD[1] - winV1.
Z() * planeABCD[2];
1118 Double_t pz = (-planeABCD[3] - planeABCD[0] * px - planeABCD[1] * py) / planeABCD[2];
1121 gluUnProject(px, py, pz, mvMatrix, prMatrix, viewport, rez, rez + 1, rez + 2);
1186 static const Float_t whiteDiffuse[] = {0.8f, 0.8f, 0.8f, 0.65f};
1187 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, whiteDiffuse);
void ClampZ(Double_t &zVal) const
Clamp z value.
void DrawBox(Bool_t selectionPass, Int_t selected) const
Draw cut as a semi-transparent box.
void SetZLevels(TAxis *zAxis, Double_t zMin, Double_t zMax, Double_t zScale, std::vector< Double_t > &zLevels)
Int_t GetFrontPoint() const
The nearest point.
void SetRowLen(Int_t len)
void RestoreModelviewMatrix() const
Camera for TGLPlotPainter and sub-classes.
Bool_t InitGeometryCylindrical()
Find bin ranges for X and Y axes, axes ranges for X, Y and Z.
Int_t GetFirstXBin() 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.
Int_t GetNYBins() const
Number of Y bins.
void MoveBox(Int_t px, Int_t py, Int_t axisID)
Move box cut along selected direction.
void DrawSectionXOZ() const
Draw section X.
Int_t GetNumberContours() const
void DrawContoursProjection() const
Draw flat textured surface.
Bool_t GetZLog() const
Get Z log.
TGL2DArray< TGLVector3 > fAverageNormals
void DrawProjections() const
Draw projections.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
constexpr Double_t TwoPi()
R__EXTERN TStyle * gStyle
EGLCoordType GetCoordType() const
Get coordinates type.
Bool_t TestBit(UInt_t f) const
void DrawSections() const
Draw sections (if any).
Bool_t HasSections() const
Any section exists.
void StartPan(Int_t px, Int_t py)
User clicks somewhere (px, py).
TGL2DArray< Double_t > fTexMap
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Double_t GetTexCoord(Double_t z) const
Get tex coordinate.
const TGLVertex3 * Get3DBox() const
Get 3D box.
void ProcessEvent(Int_t event, Int_t px, Int_t py)
Remove all profiles/sections.
void DrawPalette() const
Draw.
Double_t GetZLength() const
Z length.
void InitGL() const
Initialize some OpenGL state variables.
const Rgl::Range_t & GetZRange() const
Z range.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Int_t GetNXBins() const
Number of X bins.
Short_t Min(Short_t a, Short_t b)
void TurnOnOff()
Turn the box cut on/off.
Bool_t GetYLog() const
Get Y log.
void DrawPalette(const TGLPlotCamera *camera, const TGLLevelPalette &palette)
Draw. Palette.
void DrawPaletteAxis(const TGLPlotCamera *camera, const Range_t &minMax, Bool_t logZ)
void GenTexMap() const
Find texture coordinates.
TGL2DArray< TGLVertex3 > fMesh
Implements painting of TH2 with "SURF" option.
void StartPan(Int_t px, Int_t py)
User clicks right mouse button (in a pad).
Bool_t InitGeometryPolar()
Find bin ranges for X and Y axes, axes ranges for X, Y and Z.
T * Normal2Plane(const T v1[3], const T v2[3], const T v3[3], T normal[3])
void DrawQuadOutline(const TGLVertex3 &v1, const TGLVertex3 &v2, const TGLVertex3 &v3, const TGLVertex3 &v4)
Draw quad outline.
void DrawSectionYOZ() const
Draw section Y.
std::vector< TGLVertex3 > fVertices
void DrawPaletteAxis() const
Draw. Palette. Axis.
void Apply(Double_t phi, Double_t theta) const
Applies rotations and translations before drawing.
void SetNormals()
One normal per vertex; this normal is average of neighbouring triangles normals.
void DrawSectionXOY() const
Draw section Z.
Bool_t InitGeometry()
Set mesh, normals.
This is the base class for the ROOT Random number generators.
3 component (x/y/z) vertex class.
void EnableTexture(Int_t mode) const
Enable 1D texture.
Double_t Log10(Double_t x)
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
virtual UInt_t Integer(UInt_t imax)
Returns a random integer on [ 0, imax-1 ].
TGL2DArray< std::pair< TGLVector3, TGLVector3 > > fFaceNormals
void Info(const char *location, const char *msgfmt,...)
void SetCamera() const
Viewport and projection.
Int_t GetFirstYBin() const
3 component (x/y/z) vector class.
char * WindowPointTo3DPoint(Int_t px, Int_t py) const
Find 3d coords using mouse cursor coords.
user specified contour levels
void SetViewVolume(const TGLVertex3 *box)
'box' is the TGLPlotPainter's back box's coordinates.
Bool_t GetXLog() const
Get X log.
Bool_t InitGeometrySpherical()
Find bin ranges for X and Y axes, axes ranges for X, Y and Z.
void ObjectIDToColor(Int_t objectID, Bool_t highColor)
Object id encoded as rgb triplet.
const Rgl::Range_t & GetZRangeScaled() const
Scaled range.
Float_t GetLegoInnerR() const
void RestoreProjectionMatrix() const
Int_t GetLastYBin() const
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.
void Pan(Int_t px, Int_t py)
User's moving mouse cursor, with middle mouse button pressed (for pad).
Bool_t Textured() const
Checks, if surf requires texture.
Helper class for plot-painters holding information about axis ranges, numbers of bins and flags if ce...
void ResetModified()
Reset modified.
void Pan(Int_t px, Int_t py)
Pan camera.
Bool_t HasProjections() const
Any projection exists.
char * Form(const char *fmt,...)
3D space, fixed length, line class, with direction / length 'vector', passing through point 'vertex'...
Base class for plot-painters that provide GL rendering of various 2D and 3D histograms, functions and parametric surfaces.
std::vector< Double_t > fZLevels
void DrawBox(Int_t selectedPart, Bool_t selectionPass, const std::vector< Double_t > &zLevels, Bool_t highColor) const
Draw back box for a plot.
void DrawPlot() const
Draw surf/surf1/surf2/surf4.
Double_t GetYScale() const
void Swap(Projection_t &rhs)
Constructor.
std::list< Projection_t > fXOYProj
char * GetPlotInfo(Int_t px, Int_t py)
Coords for point on surface under cursor.
void SetCoordType(EGLCoordType type)
If coord type was changed, plot must reset sections (if any), set fModified.
Bool_t Modified() const
Modified.
static RooMathCoreReg dummy
void SetSurfaceColor() const
Set color for surface.
virtual Color_t GetFillColor() const
Return the fill area color.
void SaveProjectionMatrix() const
static TRandom * fgRandom
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
The color creation and management class.
Bool_t SetRanges(const TH1 *hist, Bool_t errors=kFALSE, Bool_t zBins=kFALSE)
Set bin ranges, ranges.
void DisableTexture() const
Disable 1D texture.
const Rgl::Range_t & GetYRangeScaled() const
Scaled range.
void AddOption(const TString &stringOption)
Additional options for surfaces.
Int_t GetLastXBin() const
you should not use this method at all Int_t Int_t z
const Double_t * CArr() const
Bool_t PreparePalette() const
Generate palette.
void StartMovement(Int_t px, Int_t py)
Start cut's movement.
void MoveSection(Int_t px, Int_t py)
Create dynamic profile using selected plane.
Short_t Max(Short_t a, Short_t b)
void SetPlotBox(const Rgl::Range_t &xRange, const Rgl::Range_t &yRange, const Rgl::Range_t &zRange)
Set up a frame box.
TGLSurfacePainter(TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord)
Constructor.
const Rgl::Range_t & GetXRangeScaled() const
Scaled range.
std::list< Projection_t > fXOZProj
std::list< Projection_t > fYOZProj
Bool_t InitGeometryCartesian()
Find bin ranges for X and Y axes, axes ranges for X, Y and Z.
Int_t GetHeight() const
viewport[3]
void SaveModelviewMatrix() const
Bool_t GeneratePalette(UInt_t paletteSize, const Rgl::Range_t &zRange, Bool_t checkSize=kTRUE)
Try to find colors for palette.
TGLPlotCoordinates * fCoord
virtual void Paint()
Draw lego/surf/whatever you can.
double norm(double *x, double *p)
3D plane class - of format Ax + By + Cz + D = 0
Double_t GetZScale() const
void DeInitGL() const
Initialize some OpenGL state variables.
Double_t GetXScale() const
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.
std::pair< Bool_t, TGLLine3 > Intersection(const TGLPlane &p1, const TGLPlane &p2)
Find 3D line interestion of this plane with 'other'.