43 void ReplaceUVNames(
TString &equation)
51 for (
Ssiz_t i = 0; i < len;) {
52 const char c = equation[i];
58 if (
c ==
'u' ||
c ==
'v') {
61 if (i == len || (!isalpha(equation[i]) && !isdigit(equation[i]) && equation[i] !=
'_')) {
63 equation[i - 1] =
c ==
'u' ?
'x' : (++vFound,
'y');
67 while (i < len && (isalpha(equation[i]) || isdigit(equation[i]) || equation[i] ==
'_'))
71 while (i < len && (isalpha(equation[i]) || isdigit(equation[i]) || equation[i] ==
'_'))
137 Error(
"TGLParametricEquation",
"One of string expressions is empty");
144 ReplaceUVNames(equation);
154 ReplaceUVNames(equation);
164 ReplaceUVNames(equation);
184 Error(
"TGLParametricEquation",
"Function ptr is null");
259 return fPainter->DistancetoPrimitive(px, py);
269 return fPainter->ExecuteEvent(event, px, py);
277 static char mess[] = {
"parametric surface" };
348 using namespace TMath;
354 min.
X() =
Min(min.
X(), newVert.
X());
355 max.X() =
Max(max.X(), newVert.
X());
356 min.
Y() =
Min(min.
Y(), newVert.
Y());
357 max.Y() =
Max(max.Y(), newVert.
Y());
358 min.
Z() =
Min(min.
Z(), newVert.
Z());
359 max.Z() =
Max(max.Z(), newVert.
Z());
361 fMesh[i][j].fPos = newVert;
368 TH3F hist(
"tmp",
"tmp", 2, -1., 1., 2, -1., 1., 2, -1., 1.);
459 static char mess[] = {
"parametric surface" };
479 gROOT->ProcessLineFast(
Form(
"((TGLPlotPainter *)0x%lx)->Paint()", (
ULong_t)
this));
485 Info(
"ProcessEvent",
"Switch to true color to use box cut");
508 glEnable(GL_DEPTH_TEST);
509 glEnable(GL_LIGHTING);
511 glDisable(GL_CULL_FACE);
512 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,
GL_TRUE);
520 glDisable(GL_DEPTH_TEST);
521 glDisable(GL_LIGHTING);
522 glDisable(GL_LIGHT0);
523 glDisable(GL_CULL_FACE);
524 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,
GL_FALSE);
538 glEnable(GL_POLYGON_OFFSET_FILL);
539 glPolygonOffset(1.f, 1.f);
563 glNormal3dv(
fMesh[i + 1][j + 1].fNormal.CArr());
565 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE,
fMesh[i + 1][j + 1].fRGBA);
566 glVertex3dv(
fMesh[i + 1][j + 1].fPos.CArr());
568 glNormal3dv(
fMesh[i][j + 1].fNormal.CArr());
570 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE,
fMesh[i][j + 1].fRGBA);
571 glVertex3dv(
fMesh[i][j + 1].fPos.CArr());
573 glNormal3dv(
fMesh[i][j].fNormal.CArr());
575 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE,
fMesh[i][j].fRGBA);
576 glVertex3dv(
fMesh[i][j].fPos.CArr());
578 glNormal3dv(
fMesh[i + 1][j].fNormal.CArr());
580 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE,
fMesh[i + 1][j].fRGBA);
581 glVertex3dv(
fMesh[i + 1][j].fPos.CArr());
583 glNormal3dv(
fMesh[i + 1][j + 1].fNormal.CArr());
585 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE,
fMesh[i + 1][j + 1].fRGBA);
586 glVertex3dv(
fMesh[i + 1][j + 1].fPos.CArr());
588 glNormal3dv(
fMesh[i][j].fNormal.CArr());
590 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE,
fMesh[i][j].fRGBA);
591 glVertex3dv(
fMesh[i][j].fPos.CArr());
598 glDisable(GL_POLYGON_OFFSET_FILL);
603 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
604 glColor4d(0., 0., 0., 0.5);
605 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
623 glVertex3dv(
fMesh[i][j].fPos.CArr());
624 glVertex3dv(
fMesh[i][j + 1].fPos.CArr());
625 glVertex3dv(
fMesh[i + 1][j + 1].fPos.CArr());
626 glVertex3dv(
fMesh[i + 1][j].fPos.CArr());
631 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
686 const Float_t specular[] = {1.f, 1.f, 1.f, 1.f};
687 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
688 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 20.f);
691 const Float_t outerDiff[] = {0.5f, 0.42f, 0.f, 1.f};
692 glMaterialfv(GL_FRONT, GL_DIFFUSE, outerDiff);
693 const Float_t innerDiff[] = {0.5f, 0.2f, 0.f, 1.f};
694 glMaterialfv(GL_BACK, GL_DIFFUSE, innerDiff);
void Info(const char *location, const char *msgfmt,...)
void(* ParametricEquation_t)(TGLVertex3 &, Double_t u, Double_t v)
char * Form(const char *fmt,...)
virtual void Set(Int_t nbins, Double_t xmin, Double_t xmax)
Initialize axis with fix bins.
virtual void Copy(TObject &axis) const
Copy axis structure to another axis.
A 2-Dim function with parameters.
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.
The histogram painter class using OpenGL.
A parametric surface is a surface defined by a parametric equation, involving two parameters (u,...
Rgl::Range_t GetVRange() const
[vMin, vMax]
ParametricEquation_t fEquation
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Pass event to painter.
void Paint(Option_t *option)
Delegate paint.
Bool_t IsModified() const
Something was changed in parametric equation (or constrained option was changed).
TGLParametricEquation(const TString &name, const TString &xEquation, const TString &yEquation, const TString &zEquation, Double_t uMin, Double_t uMax, Double_t vMin, Double_t vMax)
Surface is defined by three strings.
char * GetObjectInfo(Int_t px, Int_t py) const
No object info yet.
Rgl::Range_t GetURange() const
[uMin, uMax]
Bool_t IsConstrained() const
Check is constrained.
Int_t DistancetoPrimitive(Int_t px, Int_t py)
Check, if parametric surface is under cursor.
void EvalVertex(TGLVertex3 &newVertex, Double_t u, Double_t v) const
Calculate vertex.
void SetConstrained(Bool_t c)
Set constrained.
void SetModified(Bool_t m)
Set modified.
TGLParametricPlot(TGLParametricEquation *equation, TGLPlotCamera *camera)
Constructor.
void InitColors()
Calculate colors for vertices, using one of 20 color themes.
void DeInitGL() const
Initialize gl state.
Bool_t InitGeometry()
Build mesh.
void AddOption(const TString &option)
No additional options for parametric surfaces.
void InitGL() const
Initialize gl state.
void DrawSectionXOY() const
No such sections.
void DrawSectionYOZ() const
No such sections.
void ProcessEvent(Int_t event, Int_t px, Int_t py)
Change color/mesh size or switch on/off mesh/box cut.
char * GetPlotInfo(Int_t px, Int_t py)
No object info yet.
void Pan(Int_t px, Int_t py)
User's moving mouse cursor, with middle mouse button pressed (for pad).
void DrawPlot() const
Draw parametric surface.
void SetSurfaceColor() const
Set material properties.
TGLPlotCoordinates fCartesianCoord
TGLParametricEquation * fEquation
TGL2DArray< Vertex_t > fMesh
void StartPan(Int_t px, Int_t py)
User clicks right mouse button (in a pad).
void DrawSectionXOZ() const
No such sections.
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.
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.
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.
const Rgl::Range_t & GetYRangeScaled() const
Scaled range.
Double_t GetXScale() const
Double_t GetZScale() const
const Rgl::Range_t & GetZRangeScaled() const
Scaled range.
Base class for plot-painters that provide GL rendering of various 2D and 3D histograms,...
void RestoreModelviewMatrix() const
virtual void Paint()
Draw lego/surf/whatever you can.
TGLPlotCoordinates * fCoord
void SaveProjectionMatrix() const
void SaveModelviewMatrix() const
void RestoreProjectionMatrix() const
3 component (x/y/z) vertex class.
const Double_t * CArr() const
virtual void SetDirectory(TDirectory *dir)
By default when an histogram is created, it is added to the list of histogram objects in the current ...
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
3-D histogram with a float per channel (see TH1 documentation)}
The TNamed class is the base class for all named ROOT classes.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
R__ALWAYS_INLINE Bool_t IsZombie() const
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
void ToLower()
Change string to lower-case.
const char * Data() const
void ObjectIDToColor(Int_t objectID, Bool_t highColor)
Object id encoded as rgb triplet.
void GetColor(Float_t v, Float_t vmin, Float_t vmax, Int_t type, Float_t *rgba)
This function creates color for parametric surface's vertex, using its 'u' value.
std::pair< Double_t, Double_t > Range_t
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)