31#include "TGLIncludes.h" 
   67   static char null[] = { 
"" };
 
  160   if (surfPos + 4 < 
option.Length() && isdigit(
option[surfPos + 4])) {
 
  161      switch (
option[surfPos + 4] - 
'0') {
 
  218         gROOT->ProcessLineFast(
Form(
"((TGLPlotPainter *)0x%zx)->Paint()", (
size_t)
this));
 
  223         Info(
"ProcessEvent", 
"Switch to true color to use box cut");
 
  236   glEnable(GL_LIGHTING);
 
  238   glEnable(GL_DEPTH_TEST);
 
  239   glDisable(GL_CULL_FACE);
 
  240   glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 
GL_TRUE);
 
  248   glDisable(GL_LIGHTING);
 
  249   glDisable(GL_LIGHT0);
 
  250   glDisable(GL_DEPTH_TEST);
 
  251   glDisable(GL_CULL_FACE);
 
  252   glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 
GL_FALSE);
 
  272   for (
Int_t i = 0; i < nX - 1; ++i) {
 
  273      for (
Int_t j = 0; j < nY - 1; ++j) {
 
  288   for (
Int_t i = 0; i < nX; ++i) {
 
  289      for (
Int_t j = 0; j < nY; ++j) {
 
  299         if (!norm.
X() && !norm.
Y() && !norm.
Z())
 
  312   Float_t diffColor[] = {0.8f, 0.8f, 0.8f, 0.35f};
 
  316         c->GetRGB(diffColor[0], diffColor[1], diffColor[2]);
 
  318   glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffColor);
 
  319   const Float_t specColor[] = {1.f, 1.f, 1.f, 1.f};
 
  320   glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specColor);
 
  321   glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 70.f);
 
  341      glEnable(GL_POLYGON_OFFSET_FILL);
 
  342      glPolygonOffset(1.f, 1.f);
 
  348         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
  365   Int_t i = 0, firstJ = 0;
 
  366   const Int_t addI = frontPoint == 2 || frontPoint == 1 ? i = 0, 1 : (i = nX - 2, -1);
 
  367   const Int_t addJ = frontPoint == 2 || frontPoint == 3 ? firstJ = 0, 1 : (firstJ = nY - 2, -1);
 
  372   for (; addI > 0 ? i < nX - 1 : i >= 0; i += addI) {
 
  373      for (
Int_t j = firstJ; addJ > 0 ? j < nY - 1 : j >= 0; j += addJ) {
 
  417      glDisable(GL_POLYGON_OFFSET_FILL);
 
  435         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
  436         glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
 
  438         glColor4d(0., 0., 0., 0.5);
 
  440         for (i = 0; i < nX - 1; ++i) {
 
  441            for (
Int_t j = 0; j < nY - 1; ++j) {
 
  453      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
  462      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
  464      glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
 
  467      glColor4d(1.f, 0.f, 0.4f, 0.6f);
 
  469      for (i = 0; i < nX; ++i)
 
  470         glVertex3dv(
fMesh[i][0].CArr());
 
  471      for (
Int_t j = 0; j < nY; ++j)
 
  472         glVertex3dv(
fMesh[nX - 1][j].CArr());
 
  473      for (i = nX - 1; i >= 0; --i)
 
  474         glVertex3dv(
fMesh[i][nY - 1].CArr());
 
  475      for (
Int_t j = nY - 1; j >= 0; --j)
 
  476         glVertex3dv(
fMesh[0][j].CArr());
 
  504   fMesh.resize(nX * nY);
 
  579   fMesh.resize(nX * nY);
 
  645   fMesh.resize(nX * nY);
 
  649   if (legoR > 1. || legoR < 0.)
 
  718   fMesh.resize(nX * nY);
 
  722   if (legoR > 1. || legoR < 0.)
 
  780   glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
 
  784   typedef std::list<Projection_t>::const_iterator CLI_t;
 
  785   for (CLI_t begin = 
fXOZProj.begin(), end = 
fXOZProj.end(); begin != end; ++begin) {
 
  791         glVertex3dv(proj.
fVertices[i * 3].CArr());
 
  792         glVertex3dv(proj.
fVertices[i * 3 + 1].CArr());
 
  793         glVertex3dv(proj.
fVertices[i * 3 + 2].CArr());
 
  800         glVertex3d(
v1.X(), 
y, 
v1.Z());
 
  802         glVertex3d(
v2.X(), 
y, 
v2.Z());
 
  804         glVertex3d(
v3.X(), 
y, 
v3.Z());
 
  809   for (CLI_t begin = 
fYOZProj.begin(), end = 
fYOZProj.end(); begin != end; ++begin) {
 
  815         glVertex3dv(proj.
fVertices[i * 3].CArr());
 
  816         glVertex3dv(proj.
fVertices[i * 3 + 1].CArr());
 
  817         glVertex3dv(proj.
fVertices[i * 3 + 2].CArr());
 
  825         glVertex3d(
x, 
v1.Y(), 
v1.Z());
 
  827         glVertex3d(
x, 
v2.Y(), 
v2.Z());
 
  829         glVertex3d(
x, 
v3.Y(), 
v3.Z());
 
  834   for (CLI_t begin = 
fXOYProj.begin(), end = 
fXOYProj.end(); begin != end; ++begin) {
 
  840         glVertex3dv(proj.
fVertices[i * 2].CArr());
 
  841         glVertex3dv(proj.
fVertices[i * 2 + 1].CArr());
 
  881         glColor3d(1., 0., 0.);
 
  932         glColor3d(1., 0., 0.);
 
  979      glColor3d(1., 0., 0.);
 
  983   for (
Int_t i = 0; i < nX - 1; ++i) {
 
  984      for (
Int_t j = 0; j < nY - 1; ++j) {
 
 1006                  glVertex3dv(intersection[0].CArr());
 
 1007                  glVertex3dv(intersection[1].CArr());
 
 1034                  glVertex3dv(intersection[0].CArr());
 
 1035                  glVertex3dv(intersection[1].CArr());
 
 1069         zVal = frame[0].
Z();
 
 1075   if (zVal > frame[4].Z())
 
 1076      zVal = frame[4].
Z();
 
 1077   else if (zVal < frame[0].Z())
 
 1078      zVal = frame[0].
Z();
 
 1090   Int_t k = selected / 2;
 
 1094   const Bool_t odd = selected & 1;
 
 1102   glGetDoublev(GL_MODELVIEW_MATRIX, mvMatrix);
 
 1104   glGetDoublev(GL_PROJECTION_MATRIX, prMatrix);
 
 1105   Int_t viewport[4] = {0};
 
 1106   glGetIntegerv(GL_VIEWPORT, viewport);
 
 1108   gluProject(
v1.X(), 
v1.Y(), 
v1.Z(), mvMatrix, prMatrix, viewport, &winV1.
X(), &winV1.
Y(), &winV1.
Z());
 
 1109   gluProject(
v2.X(), 
v2.Y(), 
v2.Z(), mvMatrix, prMatrix, viewport, &winV2.
X(), &winV2.
Y(), &winV2.
Z());
 
 1110   gluProject(
v3.X(), 
v3.Y(), 
v3.Z(), mvMatrix, prMatrix, viewport, &winV3.
X(), &winV3.
Y(), &winV3.
Z());
 
 1114   planeABCD[3] = - winV1.
X() * planeABCD[0] - winV1.
Y() * planeABCD[1] - winV1.
Z() * planeABCD[2];
 
 1115   Double_t pz = (-planeABCD[3] - planeABCD[0] * px - planeABCD[1] * py) / planeABCD[2];
 
 1118   gluUnProject(px, py, pz, mvMatrix, prMatrix, viewport, rez, rez + 1, rez + 2);
 
 1183   static const Float_t whiteDiffuse[] = {0.8f, 0.8f, 0.8f, 0.65f};
 
 1184   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
 
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
 
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