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.4f, 0.6f);
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());
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);
static RooMathCoreReg dummy
void Info(const char *location, const char *msgfmt,...)
std::pair< Bool_t, TGLLine3 > Intersection(const TGLPlane &p1, const TGLPlane &p2)
Find 3D line interestion of this plane with 'other'.
char * Form(const char *fmt,...)
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.
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
virtual void Paint()
Draw lego/surf/whatever you can.
TGLPlotCoordinates * fCoord
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 * WindowPointTo3DPoint(Int_t px, Int_t py) const
Find 3d coords using mouse cursor coords.
void DrawPlot() const
Draw surf/surf1/surf2/surf4.
TGL2DArray< Double_t > fTexMap
Bool_t InitGeometryPolar()
Find bin ranges for X and Y axes, axes ranges for X, Y and Z.
void DrawSectionXOY() const
Draw section Z.
void DeInitGL() const
Initialize some OpenGL state variables.
void DrawProjections() const
Draw projections.
Bool_t HasProjections() const
Any projection exists.
Bool_t Textured() const
Checks, if surf requires texture.
std::list< Projection_t > fXOYProj
Bool_t InitGeometry()
Set mesh, normals.
void DrawPalette() const
Draw.
TGL2DArray< TGLVector3 > fAverageNormals
void StartPan(Int_t px, Int_t py)
User clicks right mouse button (in a pad).
void SetSurfaceColor() const
Set color for surface.
char * GetPlotInfo(Int_t px, Int_t py)
Coords for point on surface under cursor.
TGL2DArray< std::pair< TGLVector3, TGLVector3 > > fFaceNormals
void DrawContoursProjection() const
Draw flat textured surface.
void InitGL() const
Initialize some OpenGL state variables.
std::list< Projection_t > fXOZProj
void ProcessEvent(Int_t event, Int_t px, Int_t py)
Remove all profiles/sections.
void DrawSectionYOZ() const
Draw section Y.
Bool_t InitGeometrySpherical()
Find bin ranges for X and Y axes, axes ranges for X, Y and Z.
void AddOption(const TString &stringOption)
Additional options for surfaces.
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.
void Pan(Int_t px, Int_t py)
User's moving mouse cursor, with middle mouse button pressed (for pad).
static TRandom * fgRandom
void GenTexMap() const
Find texture coordinates.
void DrawSectionXOZ() const
Draw section X.
void SetNormals()
One normal per vertex; this normal is average of neighbouring triangles normals.
Bool_t InitGeometryCylindrical()
Find bin ranges for X and Y axes, axes ranges for X, Y and Z.
std::list< Projection_t > fYOZProj
void DrawPaletteAxis() const
Draw. Palette. Axis.
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
@ 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.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
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.
static constexpr double second
T * Normal2Plane(const T v1[3], const T v2[3], const T v3[3], T normal[3])
Calculate a normal vector of a plane.
Short_t Max(Short_t a, Short_t b)
Short_t Min(Short_t a, Short_t b)
Double_t Log10(Double_t x)
constexpr Double_t TwoPi()
void Swap(Projection_t &rhs)
Constructor.
std::vector< TGLVertex3 > fVertices