50 fRGBA[0] = rhs.fRGBA[0], fRGBA[1] = rhs.fRGBA[1], fRGBA[2] = rhs.fRGBA[2], fRGBA[3] = rhs.fRGBA[3];
51 fVertices.swap(rhs.fVertices);
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 SetZLevels(TAxis *zAxis, Double_t zMin, Double_t zMax, Double_t zScale, std::vector< Double_t > &zLevels)
void SetRowLen(Int_t len)
Camera for TGLPlotPainter and sub-classes.
Bool_t InitGeometryCylindrical()
Find bin ranges for X and Y axes, axes ranges for X, Y and Z.
void SetSurfaceColor() const
Set color for surface.
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 GetNXBins() const
Number of X bins.
const Rgl::Range_t & GetZRangeScaled() const
Scaled range.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
void MoveBox(Int_t px, Int_t py, Int_t axisID)
Move box cut along selected direction.
TGL2DArray< TGLVector3 > fAverageNormals
void DrawSectionXOZ() const
Draw section X.
Int_t GetLastXBin() const
R__EXTERN TStyle * gStyle
const Double_t * CArr() const
void DrawPaletteAxis() const
Draw. Palette. Axis.
void StartPan(Int_t px, Int_t py)
User clicks somewhere (px, py).
TGL2DArray< Double_t > fTexMap
void ProcessEvent(Int_t event, Int_t px, Int_t py)
Remove all profiles/sections.
Int_t GetNumberContours() const
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
const Rgl::Range_t & GetYRangeScaled() const
Scaled range.
Short_t Min(Short_t a, Short_t b)
void TurnOnOff()
Turn the box cut on/off.
void DrawPalette(const TGLPlotCamera *camera, const TGLLevelPalette &palette)
Draw. Palette.
void DrawPaletteAxis(const TGLPlotCamera *camera, const Range_t &minMax, Bool_t logZ)
TGL2DArray< TGLVertex3 > fMesh
Implements painting of TH2 with "SURF" option.
Double_t GetZScale() const
Int_t GetFirstXBin() const
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])
TGLViewer::ECameraType camera
Float_t GetLegoInnerR() const
void DrawQuadOutline(const TGLVertex3 &v1, const TGLVertex3 &v2, const TGLVertex3 &v3, const TGLVertex3 &v4)
Draw quad outline.
Double_t GetZLength() const
Z length.
std::vector< TGLVertex3 > fVertices
const char * Data() const
void EnableTexture(Int_t mode) const
Enable 1D texture.
void SetNormals()
One normal per vertex; this normal is average of neighbouring triangles normals.
void SaveProjectionMatrix() const
Bool_t InitGeometry()
Set mesh, normals.
void DisableTexture() const
Disable 1D texture.
void ClampZ(Double_t &zVal) const
Clamp z value.
3 component (x/y/z) vertex class.
void DeInitGL() const
Initialize some OpenGL state variables.
void DrawSectionXOY() const
Draw section Z.
Double_t Log10(Double_t x)
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,...)
Bool_t PreparePalette() const
Generate palette.
3 component (x/y/z) vector class.
static TRandom * fgRandom
Double_t GetXScale() const
void Apply(Double_t phi, Double_t theta) const
Applies rotations and translations before drawing.
void SetViewVolume(const TGLVertex3 *box)
'box' is the TGLPlotPainter's back box's coordinates.
Bool_t InitGeometrySpherical()
Find bin ranges for X and Y axes, axes ranges for X, Y and Z.
Bool_t GetZLog() const
Get Z log.
void RestoreProjectionMatrix() const
void ObjectIDToColor(Int_t objectID, Bool_t highColor)
Object id encoded as rgb triplet.
Bool_t GetYLog() const
Get Y log.
void DrawContoursProjection() const
Draw flat textured surface.
char * WindowPointTo3DPoint(Int_t px, Int_t py) const
Find 3d coords using mouse cursor coords.
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 DrawBox(Bool_t selectionPass, Int_t selected) const
Draw cut as a semi-transparent box.
void Pan(Int_t px, Int_t py)
User's moving mouse cursor, with middle mouse button pressed (for pad).
Double_t GetTexCoord(Double_t z) const
Get tex coordinate.
void DrawSections() const
Draw sections (if any).
virtual Color_t GetFillColor() const
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.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t TestBit(UInt_t f) const
char * Form(const char *fmt,...)
void SaveModelviewMatrix() const
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.
Bool_t HasSections() const
Any section exists.
std::vector< Double_t > fZLevels
void GenTexMap() const
Find texture coordinates.
void RestoreModelviewMatrix() const
std::list< Projection_t > fXOYProj
char * GetPlotInfo(Int_t px, Int_t py)
Coords for point on surface under cursor.
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 SetCoordType(EGLCoordType type)
If coord type was changed, plot must reset sections (if any), set fModified.
Int_t GetFirstYBin() const
static RooMathCoreReg dummy
Int_t GetNYBins() const
Number of Y bins.
void DrawProjections() const
Draw projections.
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 DrawSectionYOZ() const
Draw section Y.
const TGLVertex3 * Get3DBox() const
Get 3D box.
Int_t GetFrontPoint() const
The nearest point.
void AddOption(const TString &stringOption)
Additional options for surfaces.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
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.
EGLCoordType GetCoordType() const
Get coordinates type.
const Rgl::Range_t & GetXRangeScaled() const
Scaled range.
Bool_t GetXLog() const
Get X log.
Double_t GetYScale() const
void StartMovement(Int_t px, Int_t py)
Start cut's movement.
void DrawPalette() const
Draw.
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.
Bool_t Modified() const
Modified.
Int_t GetLastYBin() const
void DrawPlot() const
Draw surf/surf1/surf2/surf4.
TGLSurfacePainter(TH1 *hist, TGLPlotCamera *camera, TGLPlotCoordinates *coord)
Constructor.
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.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
std::complex< float_v > Z
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
void SetCamera() const
Viewport and projection.
Bool_t HasProjections() const
Any projection exists.
Int_t GetHeight() const
viewport[3]
Bool_t Textured() const
Checks, if surf requires texture.
void InitGL() const
Initialize some OpenGL state variables.
const Rgl::Range_t & GetZRange() const
Z range.
std::pair< Bool_t, TGLLine3 > Intersection(const TGLPlane &p1, const TGLPlane &p2)
Find 3D line interestion of this plane with 'other'.