219 if(contour<zmin || contour>zmax) {
220 Error(
"GetContourList",
"Contour level (%g) outside the Z scope [%g,%g]",
242 std::vector<Double_t> xs0(
fNdt);
243 std::vector<Double_t> ys0(
fNdt);
244 std::vector<Double_t> xs1(
fNdt);
245 std::vector<Double_t> ys1(
fNdt);
259 for(it=0; it<
fNdt; it++) {
268 z0 =
fZ[p0]; z2 =
fZ[p0];
273 if (
fZ[p1]<=z0) {z0=
fZ[p1]; x0=
fX[p1]; y0=
fY[p1]; i0=1;}
275 if (
fZ[p2]<=z0) {z0=
fZ[p2]; x0=
fX[p2]; y0=
fY[p2]; i0=2;}
277 if (i0==0 && i2==0) {
278 Error(
"GetContourList",
"wrong vertices ordering");
293 if(contour >= z0 && contour <=z2) {
294 r20 = (contour-z0)/(z2-z0);
295 xs0c = r20*(
x2-x0)+x0;
296 ys0c = r20*(
y2-y0)+y0;
297 if(contour >= z1 && contour <=z2) {
298 r21 = (contour-z1)/(z2-z1);
302 r10 = (contour-z0)/(z1-z0);
303 xs1c = r10*(
x1-x0)+x0;
304 ys1c = r10*(
y1-y0)+y0;
307 if(xs0c != xs1c || ys0c != ys1c) {
324 x0 =
fX[p[0]];
x2 =
fX[p[0]];
325 y0 =
fY[p[0]];
y2 =
fY[p[0]];
326 z0 =
fZ[p[0]]; z2 =
fZ[p[0]];
331 if (
fZ[p[1]]<=z0) {z0=
fZ[p[1]]; x0=
fX[p[1]]; y0=
fY[p[1]]; i0=1;}
332 if (
fZ[p[1]]>z2) {z2=
fZ[p[1]];
x2=
fX[p[1]];
y2=
fY[p[1]]; i2=1;}
333 if (
fZ[p[2]]<=z0) {z0=
fZ[p[2]]; x0=
fX[p[2]]; y0=
fY[p[2]]; i0=2;}
334 if (
fZ[p[2]]>z2) {z2=
fZ[p[2]];
x2=
fX[p[2]];
y2=
fY[p[2]]; i2=2;}
335 if (i0==0 && i2==0) {
336 Error(
"GetContourList",
"wrong vertices ordering");
351 if(contour >= z0 && contour <=z2) {
352 r20 = (contour-z0)/(z2-z0);
353 xs0c = r20*(
x2-x0)+x0;
354 ys0c = r20*(
y2-y0)+y0;
355 if(contour >= z1 && contour <=z2) {
356 r21 = (contour-z1)/(z2-z1);
360 r10 = (contour-z0)/(z1-z0);
361 xs1c = r10*(
x1-x0)+x0;
362 ys1c = r10*(
y1-y0)+y0;
365 if(xs0c != xs1c || ys0c != ys1c) {
378 std::vector<Bool_t> segUsed(
fNdt);
389 for (is=0; is<nbSeg; is++) {
390 if (segUsed[is])
continue;
395 for (js=0; js<nbSeg; js++) {
396 if (is==js)
continue;
397 if (xs0[is]==xs0[js] && ys0[is]==ys0[js])
s0 =
kTRUE;
398 if (xs0[is]==xs1[js] && ys0[is]==ys1[js])
s0 =
kTRUE;
399 if (xs1[is]==xs0[js] && ys1[is]==ys0[js])
s1 =
kTRUE;
400 if (xs1[is]==xs1[js] && ys1[is]==ys1[js])
s1 =
kTRUE;
407 graph->SetPoint(npg,xs0[is],ys0[is]); npg++;
408 graph->SetPoint(npg,xs1[is],ys1[is]); npg++;
410 list->Add(
graph); npg = 0;
419 if (
s0) {xc = xs0[is]; yc = ys0[is]; xnc = xs1[is]; ync = ys1[is];}
420 if (
s1) {xc = xs1[is]; yc = ys1[is]; xnc = xs0[is]; ync = ys0[is];}
421 graph->SetPoint(npg,xnc,ync); npg++;
426 if (js < nbSeg && segUsed[js]) {
429 }
else if (xc==xs0[js] && yc==ys0[js]) {
433 }
else if (xc==xs1[js] && yc==ys1[js]) {
440 graph->SetPoint(npg,xc,yc); npg++;
445 if (js<nbSeg)
goto L01;
446 list->Add(
graph); npg = 0;
453 for (is=0; is<nbSeg; is++) {
454 if (segUsed[is])
continue;
462 graph->SetPoint(npg,xc,yc); npg++;
465 if (js < nbSeg && segUsed[js]) {
468 }
else if (xc==xs0[js] && yc==ys0[js]) {
472 }
else if (xc==xs1[js] && yc==ys1[js]) {
479 graph->SetPoint(npg,xc,yc); npg++;
484 if (js<nbSeg)
goto L02;
486 graph->SetPoint(npg,xs0[is],ys0[is]); npg++;
487 list->Add(
graph); npg = 0;
562 ndiv =
gStyle->GetNumberContours();
570 for (
Int_t k=0; k<ndiv; k++) {
574 while (
auto obj = next()) {
577 g->SetLineWidth(
fGraph2D->GetLineWidth());
578 g->SetLineStyle(
fGraph2D->GetLineStyle());
580 g->SetLineColor(
gStyle->GetColorPalette(theColor));
584 if (
l) {
l->Delete();
delete l; }
598 Error(
"PaintErrors",
"No TView in current pad");
618 temp1[0] =
fX[it]-err;
628 view->
WCtoNDC(temp1, &temp2[0]);
633 temp1[0] =
fX[it]+err;
636 view->
WCtoNDC(temp1, &temp2[0]);
639 gPad->PaintPolyLine(2,xm,ym);
644 temp1[1] =
fY[it]-err;
653 view->
WCtoNDC(temp1, &temp2[0]);
658 temp1[1] =
fY[it]+err;
661 view->
WCtoNDC(temp1, &temp2[0]);
664 gPad->PaintPolyLine(2,xm,ym);
670 temp1[2] =
fZ[it]-err;
678 view->
WCtoNDC(temp1, &temp2[0]);
683 temp1[2] =
fZ[it]+err;
687 view->
WCtoNDC(temp1, &temp2[0]);
690 gPad->PaintPolyLine(2,xm,ym);
704 Int_t i, fillColor, ncolors, theColor0, theColor2;
724 if (zmin==-1111 && zmax==-1111) {
732 Int_t i0=0, i1=0, i2=0;
733 if (
fZ[p[1]]<=z0) {z0=
fZ[p[1]]; x0=
x[1]; y0=
y[1]; i0=1;}
734 if (
fZ[p[1]]>z2) {z2=
fZ[p[1]];
x2=
x[1];
y2=
y[1]; i2=1;}
735 if (
fZ[p[2]]<=z0) {z0=
fZ[p[2]]; x0=
x[2]; y0=
y[2]; i0=2;}
736 if (
fZ[p[2]]>z2) {z2=
fZ[p[2]];
x2=
x[2];
y2=
y[2]; i2=2;}
742 if (z0>zmax) z0 = zmax;
743 if (z2>zmax) z2 = zmax;
744 if (z0<zmin) z0 = zmin;
745 if (z2<zmin) z2 = zmin;
746 if (z1>zmax) z1 = zmax;
747 if (z1<zmin) z1 = zmin;
765 ncolors =
gStyle->GetNumberOfColors();
766 theColor0 = (
Int_t)( ((z0-zmin)/(zmax-zmin))*(ncolors-1) );
767 theColor2 = (
Int_t)( ((z2-zmin)/(zmax-zmin))*(ncolors-1) );
780 fillColor =
fGraph2D->GetFillColor();
784 if(theColor0 == theColor2) {
787 gPad->PaintFillArea(3,
x,
y);
791 for(ci=theColor0; ci<=theColor2; ci++) {
795 zi = (((ci+1)*(zmax-zmin))/(ncolors-1))+zmin;
798 rl = (zi-z0)/(z2-z0);
799 xp[1] = rl*(
x2-x0)+x0;
800 yp[1] = rl*(
y2-y0)+y0;
801 if (zi>=z1 || z0==z1) {
802 rs = (zi-z1)/(z2-z1);
809 rs = (zi-z0)/(z1-z0);
810 xp[2] = rs*(
x1-x0)+x0;
811 yp[2] = rs*(
y1-y0)+y0;
814 }
else if (ci==theColor2) {
819 if (zi<z1 || z2==z1) {
829 zi = (((ci+1)*(zmax-zmin))/(ncolors-1))+zmin;
832 rl = (zi-z0)/(z2-z0);
833 xp[1] = rl*(
x2-x0)+x0;
834 yp[1] = rl*(
y2-y0)+y0;
835 if ( zi>=z1 && zip<=z1) {
847 rs = (zi-z0)/(z1-z0);
848 xp[2] = rs*(
x1-x0)+x0;
849 yp[2] = rs*(
y1-y0)+y0;
851 rs = (zi-z1)/(z2-z1);
858 gPad->PaintFillArea(npf,xp,yp);
868 for(
i=0;
i<nblev;
i++){
870 if(zl >= z0 && zl <=z2) {
874 xl[0]=r20*(
x2-x0)+x0;
875 yl[0]=r20*(
y2-y0)+y0;
876 if(zl >= z1 && zl <=z2) {
880 xl[1]=r10*(
x1-x0)+x0;
881 yl[1]=r10*(
y1-y0)+y0;
883 gPad->PaintPolyLine(2,xl,yl);
901 Error(
"PaintPolyMarker",
"No TView in current pad");
916 ndiv =
gStyle->GetNumberContours();
931 if (hzmincol==-1111 && hzmaxcol==-1111) {
943 Double_t Zeps = (hzmax-hzmin)*0.0001;
951 if(hzmin -
fZ[it] > Zeps ||
fZ[it] - hzmax > Zeps)
continue;
962 view->
WCtoNDC(temp1, &temp2[0]);
972 for (it=0; it<npd; it++) {
973 theColor = (
Int_t)( ((zm[it]-hzmincol)/(hzmaxcol-hzmincol))*(ncolors-1) );
976 gPad->PaintPolyMarker(1,xm.data()+it,ym.data()+it);
984 gPad->PaintPolyMarker(npd,xm.data(),ym.data());
998 Error(
"PaintPolyLine",
"No TView in current pad");
1006 std::vector<Double_t> xm(
fNpoints);
1007 std::vector<Double_t> ym(
fNpoints);
1026 view->
WCtoNDC(temp1, &temp2[0]);
1027 xm[npd - 1] = temp2[0];
1028 ym[npd - 1] = temp2[1];
1034 gPad->PaintPolyLine(npd,xm.data(),ym.data());
1050 gPad->PaintPolyMarker(1,&
x[
i],&
y[
i]);
1054 gPad->PaintPolyMarker(1,&
x[
i],&
y[
i]);
1079 std::vector<Int_t> order;
1080 std::vector<Double_t> dist;
1084 Error(
"PaintTriangles",
"No TView in current pad");
1099 std::vector<Double_t> glev;
1100 if (!tri1 && !tri2 && !wire) {
1103 Double_t binLow = 0, binHigh = 0, binWidth = 0;
1108 if (!r0 || !r1)
return;
1112 binLow, binHigh, nbins, binWidth,
" ");
1117 binWidth = (binHigh-binLow)/nbins;
1122 for (
Int_t i = 0;
i < nblev; ++
i) glev[
i] = binLow+
i*binWidth;
1129 ndiv =
gStyle->GetNumberContours();
1146 for (it=0; it<
fNdt; it++) {
1152 if ((cp >= 0) && (sp >= 0.)) {
1154 }
else if ((cp <= 0) && (sp >= 0.)) {
1157 }
else if ((cp <= 0) && (sp <= 0.)) {
1173 int lst =
fGraph2D->GetLineStyle();
1176 for (it=0; it<
fNdt; it++) {
1180 for (
Int_t k=0; k<3; k++) {
1183 if(
fZ[t[k]-1] < zmin ||
fZ[t[k]-1] > zmax)
goto endloop;
1184 temp1[0] =
fX[t[k]-1];
1185 temp1[1] =
fY[t[k]-1];
1186 temp1[2] =
fZ[t[k]-1];
1194 view->
WCtoNDC(temp1, &temp2[0]);
1201 if (!tri1 && !tri2 && !wire) {
1202 gPad->PaintFillArea(3,
x,
y);
1205 if (!tri2)
gPad->PaintPolyLine(4,
x,
y);
1214 gPad->PaintPolyMarker(3,
x,
y);
1238 Error(
"PaintTriangles",
"No TView in current pad");
1253 std::vector<Double_t> glev;
1254 if (!tri1 && !tri2 && !wire) {
1257 Double_t binLow = 0, binHigh = 0, binWidth = 0;
1262 if (!r0 || !r1)
return;
1266 binLow, binHigh, nbins, binWidth,
" ");
1271 binWidth = (binHigh-binLow)/nbins;
1276 for (
Int_t i = 0;
i < nblev; ++
i) glev[
i] = binLow+
i*binWidth;
1283 ndiv =
gStyle->GetNumberContours();
1299 if ((cp >= 0) && (sp >= 0.)) {
1301 }
else if ((cp <= 0) && (sp >= 0.)) {
1304 }
else if ((cp <= 0) && (sp <= 0.)) {
1311 typedef std::pair<Double_t, TGraphDelaunay2D::Triangles::const_iterator> DistEntry;
1312 std::vector<DistEntry> dist;
1315 Double_t xd = (face.x[0] + face.x[1] + face.x[2]) / 3;
1316 Double_t yd = (face.y[0] + face.y[1] + face.y[2]) / 3;
1318 dist.emplace_back(fDist(xd, yd), it);
1321 std::sort(dist.begin(), dist.end(),
1322 [&](
const DistEntry &
a,
const DistEntry &
b){ return !reverse ? (a.first < b.first) : (b.first < a .first); });
1331 int lst =
fGraph2D->GetLineStyle();
1334 for (
const auto & it : dist) {
1335 p[0] = it.second->idx[0];
1336 p[1] = it.second->idx[1];
1337 p[2] = it.second->idx[2];
1338 for (
Int_t k=0; k<3; k++) {
1341 if(
fZ[p[k]] < zmin ||
fZ[p[k]] > zmax)
goto endloop;
1342 temp1[0] =
fX[p[k]];
1343 temp1[1] =
fY[p[k]];
1344 temp1[2] =
fZ[p[k]];
1352 view->
WCtoNDC(temp1, &temp2[0]);
1359 if (!tri1 && !tri2 && !wire) {
1360 gPad->PaintFillArea(3,
x,
y);
1363 if (!tri2)
gPad->PaintPolyLine(4,
x,
y);
1372 gPad->PaintPolyMarker(3,
x,
y);
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize fs
Option_t Option_t TPoint TPoint const char y1
R__EXTERN TH1 * gCurrentHist
R__EXTERN Hoption_t Hoption
R__EXTERN TStyle * gStyle
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.
The TGraphDelaunay painting class.
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.
A TGraph is an object made of two arrays X and Y with npoints each.
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.