218 if(contour<zmin || contour>zmax) {
219 Error(
"GetContourList",
"Contour level (%g) outside the Z scope [%g,%g]",
236 Int_t t[3],i,it,i0,i1,i2;
241 std::vector<Double_t> xs0(
fNdt);
242 std::vector<Double_t> ys0(
fNdt);
243 std::vector<Double_t> xs1(
fNdt);
244 std::vector<Double_t> ys1(
fNdt);
245 for (i=0;i<
fNdt;i++) {
258 for(it=0; it<
fNdt; it++) {
265 x0 =
fX[p0]; x2 =
fX[p0];
266 y0 =
fY[p0]; y2 =
fY[p0];
267 z0 =
fZ[p0]; z2 =
fZ[p0];
272 if (
fZ[p1]<=z0) {z0=
fZ[p1]; x0=
fX[p1]; y0=
fY[p1]; i0=1;}
273 if (
fZ[p1]>z2) {z2=
fZ[p1]; x2=
fX[p1]; y2=
fY[p1]; i2=1;}
274 if (
fZ[p2]<=z0) {z0=
fZ[p2]; x0=
fX[p2]; y0=
fY[p2]; i0=2;}
275 if (
fZ[p2]>z2) {z2=
fZ[p2]; x2=
fX[p2]; y2=
fY[p2]; i2=2;}
276 if (i0==0 && i2==0) {
277 Error(
"GetContourList",
"wrong vertices ordering");
292 if(contour >= z0 && contour <=z2) {
293 r20 = (contour-z0)/(z2-z0);
294 xs0c = r20*(x2-x0)+x0;
295 ys0c = r20*(y2-y0)+y0;
296 if(contour >= z1 && contour <=z2) {
297 r21 = (contour-z1)/(z2-z1);
298 xs1c = r21*(x2-x1)+x1;
299 ys1c = r21*(y2-y1)+y1;
301 r10 = (contour-z0)/(z1-z0);
302 xs1c = r10*(x1-x0)+x0;
303 ys1c = r10*(y1-y0)+y0;
306 if(xs0c != xs1c || ys0c != ys1c) {
323 x0 =
fX[p[0]]; x2 =
fX[p[0]];
324 y0 =
fY[p[0]]; y2 =
fY[p[0]];
325 z0 =
fZ[p[0]]; z2 =
fZ[p[0]];
330 if (
fZ[p[1]]<=z0) {z0=
fZ[p[1]]; x0=
fX[p[1]]; y0=
fY[p[1]]; i0=1;}
331 if (
fZ[p[1]]>z2) {z2=
fZ[p[1]]; x2=
fX[p[1]]; y2=
fY[p[1]]; i2=1;}
332 if (
fZ[p[2]]<=z0) {z0=
fZ[p[2]]; x0=
fX[p[2]]; y0=
fY[p[2]]; i0=2;}
333 if (
fZ[p[2]]>z2) {z2=
fZ[p[2]]; x2=
fX[p[2]]; y2=
fY[p[2]]; i2=2;}
334 if (i0==0 && i2==0) {
335 Error(
"GetContourList",
"wrong vertices ordering");
350 if(contour >= z0 && contour <=z2) {
351 r20 = (contour-z0)/(z2-z0);
352 xs0c = r20*(x2-x0)+x0;
353 ys0c = r20*(y2-y0)+y0;
354 if(contour >= z1 && contour <=z2) {
355 r21 = (contour-z1)/(z2-z1);
356 xs1c = r21*(x2-x1)+x1;
357 ys1c = r21*(y2-y1)+y1;
359 r10 = (contour-z0)/(z1-z0);
360 xs1c = r10*(x1-x0)+x0;
361 ys1c = r10*(y1-y0)+y0;
364 if(xs0c != xs1c || ys0c != ys1c) {
377 std::vector<Bool_t> segUsed(
fNdt);
388 for (is=0; is<nbSeg; is++) {
389 if (segUsed[is])
continue;
394 for (js=0; js<nbSeg; js++) {
395 if (is==js)
continue;
396 if (xs0[is]==xs0[js] && ys0[is]==ys0[js])
s0 =
kTRUE;
397 if (xs0[is]==xs1[js] && ys0[is]==ys1[js])
s0 =
kTRUE;
398 if (xs1[is]==xs0[js] && ys1[is]==ys0[js])
s1 =
kTRUE;
399 if (xs1[is]==xs1[js] && ys1[is]==ys1[js])
s1 =
kTRUE;
406 graph->
SetPoint(npg,xs0[is],ys0[is]); npg++;
407 graph->
SetPoint(npg,xs1[is],ys1[is]); npg++;
409 list->Add(graph); npg = 0;
418 if (
s0) {xc = xs0[is]; yc = ys0[is]; xnc = xs1[is]; ync = ys1[is];}
419 if (
s1) {xc = xs1[is]; yc = ys1[is]; xnc = xs0[is]; ync = ys0[is];}
420 graph->
SetPoint(npg,xnc,ync); npg++;
425 if (js < nbSeg && segUsed[js]) {
428 }
else if (xc==xs0[js] && yc==ys0[js]) {
432 }
else if (xc==xs1[js] && yc==ys1[js]) {
444 if (js<nbSeg)
goto L01;
445 list->Add(graph); npg = 0;
452 for (is=0; is<nbSeg; is++) {
453 if (segUsed[is])
continue;
464 if (js < nbSeg && segUsed[js]) {
467 }
else if (xc==xs0[js] && yc==ys0[js]) {
471 }
else if (xc==xs1[js] && yc==ys1[js]) {
483 if (js<nbSeg)
goto L02;
485 graph->
SetPoint(npg,xs0[is],ys0[is]); npg++;
486 list->Add(graph); npg = 0;
561 ndiv =
gStyle->GetNumberContours();
569 for (
Int_t k=0; k<ndiv; k++) {
573 while (
auto obj = next()) {
576 g->SetLineWidth(
fGraph2D->GetLineWidth());
577 g->SetLineStyle(
fGraph2D->GetLineStyle());
579 g->SetLineColor(
gStyle->GetColorPalette(theColor));
583 if (
l) {
l->Delete();
delete l; }
597 Error(
"PaintErrors",
"No TView in current pad");
617 temp1[0] =
fX[it]-
err;
627 view->
WCtoNDC(temp1, &temp2[0]);
632 temp1[0] =
fX[it]+
err;
635 view->
WCtoNDC(temp1, &temp2[0]);
638 gPad->PaintPolyLine(2,xm,ym);
643 temp1[1] =
fY[it]-
err;
652 view->
WCtoNDC(temp1, &temp2[0]);
657 temp1[1] =
fY[it]+
err;
660 view->
WCtoNDC(temp1, &temp2[0]);
663 gPad->PaintPolyLine(2,xm,ym);
669 temp1[2] =
fZ[it]-
err;
677 view->
WCtoNDC(temp1, &temp2[0]);
682 temp1[2] =
fZ[it]+
err;
686 view->
WCtoNDC(temp1, &temp2[0]);
689 gPad->PaintPolyLine(2,xm,ym);
703 Int_t i, fillColor, ncolors, theColor0, theColor2;
723 if (zmin==-1111 && zmax==-1111) {
731 Int_t i0=0, i1=0, i2=0;
732 if (
fZ[p[1]]<=z0) {z0=
fZ[p[1]]; x0=
x[1]; y0=
y[1]; i0=1;}
733 if (
fZ[p[1]]>z2) {z2=
fZ[p[1]]; x2=
x[1]; y2=
y[1]; i2=1;}
734 if (
fZ[p[2]]<=z0) {z0=
fZ[p[2]]; x0=
x[2]; y0=
y[2]; i0=2;}
735 if (
fZ[p[2]]>z2) {z2=
fZ[p[2]]; x2=
x[2]; y2=
y[2]; i2=2;}
741 if (z0>zmax) z0 = zmax;
742 if (z2>zmax) z2 = zmax;
743 if (z0<zmin) z0 = zmin;
744 if (z2<zmin) z2 = zmin;
745 if (z1>zmax) z1 = zmax;
746 if (z1<zmin) z1 = zmin;
764 ncolors =
gStyle->GetNumberOfColors();
765 theColor0 = (
Int_t)( ((z0-zmin)/(zmax-zmin))*(ncolors-1) );
766 theColor2 = (
Int_t)( ((z2-zmin)/(zmax-zmin))*(ncolors-1) );
779 fillColor =
fGraph2D->GetFillColor();
783 if(theColor0 == theColor2) {
786 gPad->PaintFillArea(3,
x,
y);
790 for(ci=theColor0; ci<=theColor2; ci++) {
794 zi = (((ci+1)*(zmax-zmin))/(ncolors-1))+zmin;
797 rl = (zi-z0)/(z2-z0);
798 xp[1] = rl*(x2-x0)+x0;
799 yp[1] = rl*(y2-y0)+y0;
800 if (zi>=z1 || z0==z1) {
801 rs = (zi-z1)/(z2-z1);
802 xp[2] = rs*(x2-x1)+x1;
803 yp[2] = rs*(y2-y1)+y1;
808 rs = (zi-z0)/(z1-z0);
809 xp[2] = rs*(x1-x0)+x0;
810 yp[2] = rs*(y1-y0)+y0;
813 }
else if (ci==theColor2) {
818 if (zi<z1 || z2==z1) {
828 zi = (((ci+1)*(zmax-zmin))/(ncolors-1))+zmin;
831 rl = (zi-z0)/(z2-z0);
832 xp[1] = rl*(x2-x0)+x0;
833 yp[1] = rl*(y2-y0)+y0;
834 if ( zi>=z1 && zip<=z1) {
846 rs = (zi-z0)/(z1-z0);
847 xp[2] = rs*(x1-x0)+x0;
848 yp[2] = rs*(y1-y0)+y0;
850 rs = (zi-z1)/(z2-z1);
851 xp[2] = rs*(x2-x1)+x1;
852 yp[2] = rs*(y2-y1)+y1;
857 gPad->PaintFillArea(npf,xp,yp);
867 for(i=0; i<nblev; i++){
869 if(zl >= z0 && zl <=z2) {
873 xl[0]=r20*(x2-x0)+x0;
874 yl[0]=r20*(y2-y0)+y0;
875 if(zl >= z1 && zl <=z2) {
876 xl[1]=r21*(x2-x1)+x1;
877 yl[1]=r21*(y2-y1)+y1;
879 xl[1]=r10*(x1-x0)+x0;
880 yl[1]=r10*(y1-y0)+y0;
882 gPad->PaintPolyLine(2,xl,yl);
900 Error(
"PaintPolyMarker",
"No TView in current pad");
915 ndiv =
gStyle->GetNumberContours();
930 if (hzmincol==-1111 && hzmaxcol==-1111) {
942 Double_t Zeps = (hzmax-hzmin)*0.0001;
950 if(hzmin -
fZ[it] > Zeps ||
fZ[it] - hzmax > Zeps)
continue;
961 view->
WCtoNDC(temp1, &temp2[0]);
971 for (it=0; it<npd; it++) {
972 theColor = (
Int_t)( ((zm[it]-hzmincol)/(hzmaxcol-hzmincol))*(ncolors-1) );
975 gPad->PaintPolyMarker(1,xm.data()+it,ym.data()+it);
983 gPad->PaintPolyMarker(npd,xm.data(),ym.data());
997 Error(
"PaintPolyLine",
"No TView in current pad");
1005 std::vector<Double_t> xm(
fNpoints);
1006 std::vector<Double_t> ym(
fNpoints);
1025 view->
WCtoNDC(temp1, &temp2[0]);
1026 xm[npd - 1] = temp2[0];
1027 ym[npd - 1] = temp2[1];
1033 gPad->PaintPolyLine(npd,xm.data(),ym.data());
1045 for (
Int_t i=0; i<
n; i++) {
1049 gPad->PaintPolyMarker(1,&
x[i],&
y[i]);
1053 gPad->PaintPolyMarker(1,&
x[i],&
y[i]);
1078 std::vector<Int_t> order;
1079 std::vector<Double_t> dist;
1083 Error(
"PaintTriangles",
"No TView in current pad");
1098 std::vector<Double_t> glev;
1099 if (!tri1 && !tri2 && !wire) {
1102 Double_t binLow = 0, binHigh = 0, binWidth = 0;
1107 if (!r0 || !r1)
return;
1111 binLow, binHigh, nbins, binWidth,
" ");
1116 binWidth = (binHigh-binLow)/nbins;
1121 for (
Int_t i = 0; i < nblev; ++i) glev[i] = binLow+i*binWidth;
1128 ndiv =
gStyle->GetNumberContours();
1145 for (it=0; it<
fNdt; it++) {
1151 if ((cp >= 0) && (sp >= 0.)) {
1153 }
else if ((cp <= 0) && (sp >= 0.)) {
1156 }
else if ((cp <= 0) && (sp <= 0.)) {
1172 int lst =
fGraph2D->GetLineStyle();
1175 for (it=0; it<
fNdt; it++) {
1179 for (
Int_t k=0; k<3; k++) {
1182 if(
fZ[t[k]-1] < zmin ||
fZ[t[k]-1] > zmax)
goto endloop;
1183 temp1[0] =
fX[t[k]-1];
1184 temp1[1] =
fY[t[k]-1];
1185 temp1[2] =
fZ[t[k]-1];
1193 view->
WCtoNDC(temp1, &temp2[0]);
1200 if (!tri1 && !tri2 && !wire) {
1201 gPad->PaintFillArea(3,
x,
y);
1204 if (!tri2)
gPad->PaintPolyLine(4,
x,
y);
1213 gPad->PaintPolyMarker(3,
x,
y);
1237 Error(
"PaintTriangles",
"No TView in current pad");
1252 std::vector<Double_t> glev;
1253 if (!tri1 && !tri2 && !wire) {
1256 Double_t binLow = 0, binHigh = 0, binWidth = 0;
1261 if (!r0 || !r1)
return;
1265 binLow, binHigh, nbins, binWidth,
" ");
1270 binWidth = (binHigh-binLow)/nbins;
1275 for (
Int_t i = 0; i < nblev; ++i) glev[i] = binLow+i*binWidth;
1282 ndiv =
gStyle->GetNumberContours();
1298 if ((cp >= 0) && (sp >= 0.)) {
1300 }
else if ((cp <= 0) && (sp >= 0.)) {
1303 }
else if ((cp <= 0) && (sp <= 0.)) {
1310 typedef std::pair<Double_t, TGraphDelaunay2D::Triangles::const_iterator> DistEntry;
1311 std::vector<DistEntry> dist;
1314 Double_t xd = (face.x[0] + face.x[1] + face.x[2]) / 3;
1315 Double_t yd = (face.y[0] + face.y[1] + face.y[2]) / 3;
1317 dist.emplace_back(fDist(xd, yd), it);
1320 std::sort(dist.begin(), dist.end(),
1321 [&](
const DistEntry &
a,
const DistEntry &
b){ return !reverse ? (a.first < b.first) : (b.first < a .first); });
1330 int lst =
fGraph2D->GetLineStyle();
1333 for (
const auto & it : dist) {
1334 p[0] = it.second->idx[0];
1335 p[1] = it.second->idx[1];
1336 p[2] = it.second->idx[2];
1337 for (
Int_t k=0; k<3; k++) {
1340 if(
fZ[p[k]] < zmin ||
fZ[p[k]] > zmax)
goto endloop;
1341 temp1[0] =
fX[p[k]];
1342 temp1[1] =
fY[p[k]];
1343 temp1[2] =
fZ[p[k]];
1351 view->
WCtoNDC(temp1, &temp2[0]);
1358 if (!tri1 && !tri2 && !wire) {
1359 gPad->PaintFillArea(3,
x,
y);
1362 if (!tri2)
gPad->PaintPolyLine(4,
x,
y);
1371 gPad->PaintPolyMarker(3,
x,
y);
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
const char Option_t
Option string (const char).
Class to manage histogram axis.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
virtual Int_t FindFixBin(Double_t x) const
Find bin number corresponding to abscissa x.
Int_t GetLast() const
Return last bin on the axis i.e.
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Int_t GetFirst() const
Return first bin on the axis i.e.
void PaintContour(Option_t *option)
Paints the 2D graph as a contour plot.
Int_t * fNTried
! Pointer to fDelaunay->fNTried
Double_t * fYN
! Pointer to fDelaunay->fYN
TGraphDelaunay * fDelaunay
! Pointer to the TGraphDelaunay2D to be painted
void Paint(Option_t *option) override
Paint a TGraphDelaunay according to the value of "option":
Double_t fYmin
! fGraph2D->fHistogram Ymin
Double_t * fZ
! Pointer to fGraph2D->fZ
void PaintLevels(Int_t *v, Double_t *x, Double_t *y, Int_t nblev=0, Double_t *glev=nullptr)
Paints one triangle.
TGraphDelaunay2D * fDelaunay2D
! Pointer to the TGraphDelaunay2D to be painted
TGraph2D * fGraph2D
! Pointer to the TGraph2D in fDelaunay
void PaintErrors(Option_t *option)
Paints the 2D graph as error bars.
Double_t * fXN
! Pointer to fDelaunay->fXN
Int_t * fMTried
! Pointer to fDelaunay->fMTried
void FindTriangles()
Find triangles in fDelaunay and initialise the TGraph2DPainter values needed to paint triangles or fi...
Int_t * fPTried
! Pointer to fDelaunay->fPTried
Double_t fXNmin
! Equal to fDelaunay->fXNmin
Double_t fXmax
! fGraph2D->fHistogram Xmax
Double_t * fEZhigh
! Pointer to fGraph2D->fZEhigh
Int_t fNpoints
! Equal to fGraph2D->fNpoints
Double_t fZmin
! fGraph2D->fHistogram Zmin
Int_t fNdt
! Equal to fDelaunay->fNdt
Double_t * fEYlow
! Pointer to fGraph2D->fYElow
TList * GetContourList(Double_t contour)
Returns the X and Y graphs building a contour.
Double_t * fX
! Pointer to fGraph2D->fX
Double_t fYmax
! fGraph2D->fHistogram Ymax
Double_t * fEXhigh
! Pointer to fGraph2D->fXEhigh
void PaintPolyMarker0(Int_t n, Double_t *x, Double_t *y)
Paints a circle at each vertex. Each circle background is white.
void PaintTriangles(Option_t *option)
Paints the 2D graph as triangles.
void PaintPolyMarker(Option_t *option)
Paints the 2D graph as PaintPolyMarker.
Double_t * fY
! Pointer to fGraph2D->fY
Double_t fYNmin
! Equal to fDelaunay->fYNmin
Double_t * fEXlow
! Pointer to fGraph2D->fXElow
void PaintPolyLine(Option_t *option)
Paints the 2D graph as PaintPolyLine.
Double_t * fEYhigh
! Pointer to fGraph2D->fYEhigh
TGraph2DPainter()
TGraph2DPainter default constructor.
Double_t fZmax
! fGraph2D->fHistogram Zmax
void PaintTriangles_old(Option_t *option)
Paints the 2D graph as triangles (old implementation).
void GetGraph2dProperties()
Protected method to get all TGraph2D properties.
~TGraph2DPainter() override
TGraph2DPainter destructor.
Double_t fYNmax
! Equal to fDelaunay->fYNmax
Double_t * fEZlow
! Pointer to fGraph2D->fZElow
Double_t fXmin
! fGraph2D->fHistogram Xmin
Double_t fXNmax
! Equal to fDelaunay->fXNmax
void PaintTriangles_new(Option_t *option)
Paints the 2D graph as triangles (new implementation).
TGraphDelaunay2D generates a Delaunay triangulation of a TGraph2D.
TGraphDelaunay generates a Delaunay triangulation of a TGraph2D.
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
TH1 is the base class of all histogram classes in ROOT.
@ kUserContour
User specified contour levels.
static void Optimize(Double_t A1, Double_t A2, Int_t nold, Double_t &BinLow, Double_t &BinHigh, Int_t &nbins, Double_t &BWID, Option_t *option="")
Static function to compute reasonable axis limits.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
void ToLower()
Change string to lower-case.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual Double_t * GetRmax()=0
virtual Double_t * GetRmin()=0
virtual Double_t GetLongitude()=0
virtual void WCtoNDC(const Float_t *pw, Float_t *pn)=0
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.
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Sort the n elements of the array a of generic templated type Element.
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Histograms' drawing options structure.