62 static Int_t gReadLevel = 0;
64 Int_t TPad::fgMaxPickDistance = 5;
132 fPadPointer =
nullptr;
133 fPrimitives =
nullptr;
139 fCopyGLDevice = kFALSE;
140 fEmbeddedGL = kFALSE;
148 fPadView3D =
nullptr;
149 fMother = (TPad*)gPad;
178 fFixedAspectRatio = kFALSE;
181 fNumPaletteColor = 0;
182 fNextPaletteColor = 0;
183 fCollideGrid =
nullptr;
197 fUxmin = fUymin = fUxmax = fUymax = 0;
212 SetBit(kMustCleanup);
243 TPad::TPad(
const char *name,
const char *title, Double_t xlow,
244 Double_t ylow, Double_t xup, Double_t yup,
245 Color_t color, Short_t bordersize, Short_t bordermode)
246 : TVirtualPad(name,title,xlow,ylow,xup,yup,color,bordersize,bordermode)
250 fBorderSize = bordersize;
251 fBorderMode = bordermode;
252 if (gPad) fCanvas = gPad->GetCanvas();
253 else fCanvas = (TCanvas*)
this;
254 fMother = (TPad*)gPad;
255 fPrimitives =
new TList;
257 fPadPointer =
nullptr;
260 fGridx = gStyle->GetPadGridX();
261 fGridy = gStyle->GetPadGridY();
262 fTickx = gStyle->GetPadTickX();
263 fTicky = gStyle->GetPadTickY();
267 fPadView3D =
nullptr;
269 fCopyGLDevice = kFALSE;
270 fEmbeddedGL = kFALSE;
306 fUxmin = fUymin = fUxmax = fUymax = 0;
307 fLogx = gStyle->GetOptLogx();
308 fLogy = gStyle->GetOptLogy();
309 fLogz = gStyle->GetOptLogz();
311 fFixedAspectRatio = kFALSE;
314 fNumPaletteColor = 0;
315 fNextPaletteColor = 0;
316 fCollideGrid =
nullptr;
322 fGLDevice = fCanvas->GetGLDevice();
330 Error(
"TPad",
"You must create a TCanvas before creating a TPad");
335 TPad *padsav = (TPad*)gPad;
337 if ((xlow < 0) || (xlow > 1) || (ylow < 0) || (ylow > 1)) {
338 Error(
"TPad",
"illegal bottom left position: x=%f, y=%f", xlow, ylow);
341 if ((xup < 0) || (xup > 1) || (yup < 0) || (yup > 1)) {
342 Error(
"TPad",
"illegal top right position: x=%f, y=%f", xup, yup);
346 fLogx = gStyle->GetOptLogx();
347 fLogy = gStyle->GetOptLogy();
348 fLogz = gStyle->GetOptLogz();
350 fUxmin = fUymin = fUxmax = fUymax = 0;
353 SetPad(name, title, xlow, ylow, xup, yup, color, bordersize, bordermode);
355 SetBit(kMustCleanup);
373 if (!TestBit(kNotDeleted))
return;
377 auto primitives = fPrimitives;
383 fPrimitives =
nullptr;
387 if (fCollideGrid)
delete [] fCollideGrid;
390 ROOT::CallRecursiveRemoveIfNeeded(*
this);
434 void TPad::AddExec(
const char *name,
const char*command)
436 if (!fExecs) fExecs =
new TList;
437 TExec *ex =
new TExec(name,command);
444 void TPad::AutoExec()
446 if (GetCrosshair()) DrawCrosshair();
448 if (!fExecs) fExecs =
new TList;
451 while ((exec = (TExec*)next())) {
459 void TPad::Browse(TBrowser *b)
462 if (fPrimitives) fPrimitives->Browse(b);
491 TLegend *TPad::BuildLegend(Double_t x1, Double_t y1, Double_t x2, Double_t y2,
492 const char* title, Option_t *option)
494 TList *lop=GetListOfPrimitives();
501 while( (o=next()) ) {
502 if((o->InheritsFrom(TAttLine::Class()) || o->InheritsFrom(TAttMarker::Class()) ||
503 o->InheritsFrom(TAttFill::Class())) &&
504 ( !(o->InheritsFrom(TFrame::Class())) && !(o->InheritsFrom(TPave::Class())) )) {
505 if (!leg) leg =
new TLegend(x1, y1, x2, y2, title);
506 if (o->InheritsFrom(TNamed::Class()) && strlen(((TNamed *)o)->GetTitle()))
507 mes = ((TNamed *)o)->GetTitle();
508 else if (strlen(o->GetName()))
511 mes = o->ClassName();
512 if (strlen(option)) {
515 if (o->InheritsFrom(TAttLine::Class())) opt +=
"l";
516 if (o->InheritsFrom(TAttMarker::Class())) opt +=
"p";
517 if (o->InheritsFrom(TAttFill::Class())) opt +=
"f";
519 leg->AddEntry(o,mes.Data(),opt.Data());
520 }
else if ( o->InheritsFrom(TMultiGraph::Class() ) ) {
521 if (!leg) leg =
new TLegend(x1, y1, x2, y2, title);
522 TList * grlist = ((TMultiGraph *)o)->GetListOfGraphs();
523 TIter nextgraph(grlist);
526 while ((obj = nextgraph())) {
528 if (strlen(gr->GetTitle())) mes = gr->GetTitle();
529 else if (strlen(gr->GetName())) mes = gr->GetName();
530 else mes = gr->ClassName();
531 if (strlen(option)) opt = option;
533 leg->AddEntry( obj, mes.Data(), opt );
535 }
else if ( o->InheritsFrom(THStack::Class() ) ) {
536 if (!leg) leg =
new TLegend(x1, y1, x2, y2, title);
537 TList * hlist = ((THStack *)o)->GetHists();
538 TIter nexthist(hlist);
541 while ((obj = nexthist())) {
543 if (strlen(hist->GetTitle())) mes = hist->GetTitle();
544 else if (strlen(hist->GetName())) mes = hist->GetName();
545 else mes = hist->ClassName();
546 if (strlen(option)) opt = option;
548 leg->AddEntry( obj, mes.Data(), opt );
553 TVirtualPad *gpadsave;
559 Info(
"BuildLegend(void)",
"No object to build a TLegend.");
591 TVirtualPad *TPad::cd(Int_t subpadnumber)
595 if (!gPad->IsBatch() && GetPainter()) GetPainter()->SelectDrawable(fPixmapID);
600 if (!fPrimitives) fPrimitives =
new TList;
601 TIter next(fPrimitives);
602 while ((obj = next())) {
603 if (obj->InheritsFrom(TPad::Class())) {
604 Int_t n = ((TPad*)obj)->GetNumber();
605 if (n == subpadnumber) {
606 return ((TPad*)obj)->cd();
620 void TPad::Clear(Option_t *option)
622 if (!IsEditable())
return;
624 R__LOCKGUARD(gROOTMutex);
628 if (fPrimitives) fPrimitives->Clear(option);
630 if (fFrame->TestBit(kNotDeleted))
delete fFrame;
634 if (fCanvas) fCanvas->Cleared(
this);
638 if (TestBit(kClearAfterCR)) {
644 if (!gPad->IsBatch()) GetPainter()->ClearDrawable();
645 if (gVirtualPS && gPad == gPad->GetCanvas()) gVirtualPS->NewPage();
647 PaintBorder(GetFillColor(), kTRUE);
649 fNumPaletteColor = 0;
651 delete [] fCollideGrid;
652 fCollideGrid =
nullptr;
656 ResetBit(TGraph::kClipFrame);
670 Int_t TPad::Clip(Float_t *x, Float_t *y, Float_t xclipl, Float_t yclipb, Float_t xclipr, Float_t yclipt)
672 const Float_t kP=10000;
675 for (Int_t i=0;i<2;i++) {
676 if (TMath::Abs(xclipl-x[i]) <= TMath::Abs(xclipr-xclipl)/kP) x[i] = xclipl;
677 if (TMath::Abs(xclipr-x[i]) <= TMath::Abs(xclipr-xclipl)/kP) x[i] = xclipr;
678 if (TMath::Abs(yclipb-y[i]) <= TMath::Abs(yclipt-yclipb)/kP) y[i] = yclipb;
679 if (TMath::Abs(yclipt-y[i]) <= TMath::Abs(yclipt-yclipb)/kP) y[i] = yclipt;
683 Int_t code1 = ClippingCode(x[0],y[0],xclipl,yclipb,xclipr,yclipt);
684 Int_t code2 = ClippingCode(x[1],y[1],xclipl,yclipb,xclipr,yclipt);
688 while(code1 + code2) {
699 if (ic == 0) ic = code2;
701 yt = y[0] + (y[1]-y[0])*(xclipl-x[0])/(x[1]-x[0]);
705 yt = y[0] + (y[1]-y[0])*(xclipr-x[0])/(x[1]-x[0]);
709 xt = x[0] + (x[1]-x[0])*(yclipb-y[0])/(y[1]-y[0]);
713 xt = x[0] + (x[1]-x[0])*(yclipt-y[0])/(y[1]-y[0]);
719 code1 = ClippingCode(xt,yt,xclipl,yclipb,xclipr,yclipt);
723 code2 = ClippingCode(xt,yt,xclipl,yclipb,xclipr,yclipt);
741 Int_t TPad::Clip(Double_t *x, Double_t *y, Double_t xclipl, Double_t yclipb, Double_t xclipr, Double_t yclipt)
743 const Double_t kP=10000;
746 for (Int_t i=0;i<2;i++) {
747 if (TMath::Abs(xclipl-x[i]) <= TMath::Abs(xclipr-xclipl)/kP) x[i] = xclipl;
748 if (TMath::Abs(xclipr-x[i]) <= TMath::Abs(xclipr-xclipl)/kP) x[i] = xclipr;
749 if (TMath::Abs(yclipb-y[i]) <= TMath::Abs(yclipt-yclipb)/kP) y[i] = yclipb;
750 if (TMath::Abs(yclipt-y[i]) <= TMath::Abs(yclipt-yclipb)/kP) y[i] = yclipt;
755 if (x[0] < xclipl) code1 = code1 | 0x1;
756 if (x[0] > xclipr) code1 = code1 | 0x2;
757 if (y[0] < yclipb) code1 = code1 | 0x4;
758 if (y[0] > yclipt) code1 = code1 | 0x8;
760 if (x[1] < xclipl) code2 = code2 | 0x1;
761 if (x[1] > xclipr) code2 = code2 | 0x2;
762 if (y[1] < yclipb) code2 = code2 | 0x4;
763 if (y[1] > yclipt) code2 = code2 | 0x8;
767 while(code1 + code2) {
778 if (ic == 0) ic = code2;
780 yt = y[0] + (y[1]-y[0])*(xclipl-x[0])/(x[1]-x[0]);
784 yt = y[0] + (y[1]-y[0])*(xclipr-x[0])/(x[1]-x[0]);
788 xt = x[0] + (x[1]-x[0])*(yclipb-y[0])/(y[1]-y[0]);
792 xt = x[0] + (x[1]-x[0])*(yclipt-y[0])/(y[1]-y[0]);
798 code1 = ClippingCode(xt,yt,xclipl,yclipb,xclipr,yclipt);
802 code2 = ClippingCode(xt,yt,xclipl,yclipb,xclipr,yclipt);
812 Int_t TPad::ClippingCode(Double_t x, Double_t y, Double_t xcl1, Double_t ycl1, Double_t xcl2, Double_t ycl2)
815 if (x < xcl1) code = code | 0x1;
816 if (x > xcl2) code = code | 0x2;
817 if (y < ycl1) code = code | 0x4;
818 if (y > ycl2) code = code | 0x8;
861 Int_t TPad::ClipPolygon(Int_t n, Double_t *x, Double_t *y, Int_t nn, Double_t *xc, Double_t *yc, Double_t xclipl, Double_t yclipb, Double_t xclipr, Double_t yclipt)
864 Double_t x1, y1, x2, y2, slope;
866 Double_t *xc2 =
new Double_t[nn];
867 Double_t *yc2 =
new Double_t[nn];
870 x1 = x[n-1]; y1 = y[n-1];
873 for (i=0; i<n; i++) {
874 x2 = x[i]; y2 = y[i];
878 slope = (y2-y1)/(x2-x1);
882 xc2[nc2] = xclipl; yc2[nc2++] = slope*(xclipl-x1)+y1;
884 xc2[nc2] = x2; yc2[nc2++] = y2;
888 xc2[nc2] = xclipl; yc2[nc2++] = slope*(xclipl-x1)+y1;
889 xc2[nc2] = x2; yc2[nc2++] = y2;
896 x1 = xc2[nc2-1]; y1 = yc2[nc2-1];
898 for (i=0; i<nc2; i++) {
899 x2 = xc2[i]; y2 = yc2[i];
903 slope = (x2-x1)/(y2-y1);
907 xc[nc] = x1+(yclipt-y1)*slope; yc[nc++] = yclipt;
909 xc[nc] = x2; yc[nc++] = y2;
913 xc[nc] = x1+(yclipt-y1)*slope; yc[nc++] = yclipt;
914 xc[nc] = x2; yc[nc++] = y2;
923 x1 = xc[nc-1]; y1 = yc[nc-1];
925 for (i=0; i<nc; i++) {
926 x2 = xc[i]; y2 = yc[i];
930 slope = (y2-y1)/(x2-x1);
934 xc2[nc2] = xclipr; yc2[nc2++] = slope*(xclipr-x1)+y1;
936 xc2[nc2] = x2; yc2[nc2++] = y2;
940 xc2[nc2] = xclipr; yc2[nc2++] = slope*(xclipr-x1)+y1;
941 xc2[nc2] = x2; yc2[nc2++] = y2;
948 x1 = xc2[nc2-1]; y1 = yc2[nc2-1];
950 for (i=0; i<nc2; i++) {
951 x2 = xc2[i]; y2 = yc2[i];
955 slope = (x2-x1)/(y2-y1);
959 xc[nc] = x1+(yclipb-y1)*slope; yc[nc++] = yclipb;
961 xc[nc] = x2; yc[nc++] = y2;
965 xc[nc] = x1+(yclipb-y1)*slope; yc[nc++] = yclipb;
966 xc[nc] = x2; yc[nc++] = y2;
985 void TPad::Close(Option_t *)
987 if (!TestBit(kNotDeleted))
return;
988 if (!fMother)
return;
989 if (!fMother->TestBit(kNotDeleted))
return;
992 fPrimitives->Clear();
994 if (fView->TestBit(kNotDeleted))
delete fView;
998 if (fFrame->TestBit(kNotDeleted))
delete fFrame;
1003 if (IsA() != TCanvas::Class())
1006 if (fPixmapID != -1) {
1008 if (!gPad->IsBatch())
1009 GetPainter()->DestroyDrawable(fPixmapID);
1013 if (!gROOT->GetListOfCanvases())
return;
1014 if (fMother ==
this) {
1015 gROOT->GetListOfCanvases()->Remove(
this);
1021 if (fMother->GetListOfPrimitives())
1022 fMother->GetListOfPrimitives()->Remove(
this);
1024 if (gPad ==
this) fMother->cd();
1027 if (fCanvas->GetPadSave() ==
this)
1028 fCanvas->ClearPadSave();
1029 if (fCanvas->GetSelectedPad() ==
this)
1030 fCanvas->SetSelectedPad(0);
1031 if (fCanvas->GetClickSelectedPad() ==
this)
1032 fCanvas->SetClickSelectedPad(0);
1036 if (gROOT->GetSelectedPad() ==
this) gROOT->SetSelectedPad(
nullptr);
1042 void TPad::CopyPixmap()
1045 XYtoAbsPixel(fX1, fY2, px, py);
1047 if (fPixmapID != -1)
1048 GetPainter()->CopyDrawable(fPixmapID, px, py);
1050 if (
this == gPad) HighLight(gPad->GetHighLightColor());
1056 void TPad::CopyPixmaps()
1059 if (!fPrimitives) fPrimitives =
new TList;
1060 TIter next(GetListOfPrimitives());
1061 while ((obj = next())) {
1062 if (obj->InheritsFrom(TPad::Class())) {
1063 ((TPad*)obj)->CopyPixmap();
1064 ((TPad*)obj)->CopyPixmaps();
1072 void TPad::DeleteExec(
const char *name)
1074 if (!fExecs) fExecs =
new TList;
1075 TExec *ex = (TExec*)fExecs->FindObject(name);
1088 Int_t TPad::DistancetoPrimitive(Int_t px, Int_t py)
1090 Int_t pxl, pyl, pxt, pyt;
1091 Int_t px1 = gPad->XtoAbsPixel(fX1);
1092 Int_t py1 = gPad->YtoAbsPixel(fY1);
1093 Int_t px2 = gPad->XtoAbsPixel(fX2);
1094 Int_t py2 = gPad->YtoAbsPixel(fY2);
1095 if (px1 < px2) {pxl = px1; pxt = px2;}
1096 else {pxl = px2; pxt = px1;}
1097 if (py1 < py2) {pyl = py1; pyt = py2;}
1098 else {pyl = py2; pyt = py1;}
1102 if ( (px > pxl && px < pxt) && (py > pyl && py < pyt) ) {
1103 if (GetFillStyle())
return 0;
1108 Int_t dxl = TMath::Abs(px - pxl);
1109 if (py < pyl) dxl += pyl - py;
1110 if (py > pyt) dxl += py - pyt;
1111 Int_t dxt = TMath::Abs(px - pxt);
1112 if (py < pyl) dxt += pyl - py;
1113 if (py > pyt) dxt += py - pyt;
1114 Int_t dyl = TMath::Abs(py - pyl);
1115 if (px < pxl) dyl += pxl - px;
1116 if (px > pxt) dyl += px - pxt;
1117 Int_t dyt = TMath::Abs(py - pyt);
1118 if (px < pxl) dyt += pxl - px;
1119 if (px > pxt) dyt += px - pxt;
1121 Int_t distance = dxl;
1122 if (dxt < distance) distance = dxt;
1123 if (dyl < distance) distance = dyl;
1124 if (dyt < distance) distance = dyt;
1126 return distance - Int_t(0.5*fLineWidth);
1163 void TPad::Divide(Int_t nx, Int_t ny, Float_t xmargin, Float_t ymargin, Int_t color)
1165 if (!IsEditable())
return;
1170 arr[1] =
this; arr[2] = (
void*)&nx;arr[3] = (
void*)& ny;
1171 arr[4] = (
void*)&xmargin; arr[5] = (
void *)& ymargin; arr[6] = (
void *)&color;
1172 if ((*gThreadXAR)(
"PDCD", 7, arr, 0))
return;
1175 TPad *padsav = (TPad*)gPad;
1177 if (nx <= 0) nx = 1;
1178 if (ny <= 0) ny = 1;
1180 Double_t x1,y1,x2,y2;
1183 Int_t nchname = strlen(GetName())+6;
1184 Int_t nchtitle = strlen(GetTitle())+6;
1185 char *name =
new char [nchname];
1186 char *title =
new char [nchtitle];
1188 if (color == 0) color = GetFillColor();
1189 if (xmargin > 0 && ymargin > 0) {
1191 dy = 1/Double_t(ny);
1192 dx = 1/Double_t(nx);
1193 for (iy=0;iy<ny;iy++) {
1194 y2 = 1 - iy*dy - ymargin;
1195 y1 = y2 - dy + 2*ymargin;
1197 if (y1 > y2)
continue;
1198 for (ix=0;ix<nx;ix++) {
1199 x1 = ix*dx + xmargin;
1200 x2 = x1 +dx -2*xmargin;
1201 if (x1 > x2)
continue;
1203 snprintf(name,nchname,
"%s_%d",GetName(),n);
1204 pad =
new TPad(name,name,x1,y1,x2,y2,color);
1211 Double_t xl = GetLeftMargin();
1212 Double_t xr = GetRightMargin();
1213 Double_t yb = GetBottomMargin();
1214 Double_t yt = GetTopMargin();
1221 SetBottomMargin(yb);
1226 for (Int_t i=0;i<nx;i++) {
1230 if (i == nx-1) x2 = 1-xr;
1231 for (Int_t j=0;j<ny;j++) {
1232 number = j*nx + i +1;
1235 if (j == 0) y2 = 1-yt;
1236 if (j == ny-1) y1 = 0;
1237 snprintf(name,nchname,
"%s_%d",GetName(),number);
1238 snprintf(title,nchtitle,
"%s_%d",GetTitle(),number);
1239 pad =
new TPad(name,title,x1,y1,x2,y2);
1240 pad->SetNumber(number);
1241 pad->SetBorderMode(0);
1242 if (i == 0) pad->SetLeftMargin(xl*nx);
1243 else pad->SetLeftMargin(0);
1244 pad->SetRightMargin(0);
1245 pad->SetTopMargin(0);
1246 if (j == ny-1) pad->SetBottomMargin(yb*ny);
1247 else pad->SetBottomMargin(0);
1255 if (padsav) padsav->cd();
1262 void TPad::DivideSquare(Int_t n, Float_t xmargin, Float_t ymargin, Int_t color)
1266 if (fCanvas->GetWindowWidth() > fCanvas->GetWindowHeight()) {
1267 w = TMath::Ceil(TMath::Sqrt(n));
1268 h = TMath::Floor(TMath::Sqrt(n));
1271 h = TMath::Ceil(TMath::Sqrt(n));
1272 w = TMath::Floor(TMath::Sqrt(n));
1276 Divide( w, h, xmargin, ymargin, color);
1282 void TPad::Draw(Option_t *option)
1286 gROOT->MakeDefCanvas();
1290 if (!fPrimitives) fPrimitives =
new TList;
1292 if (fMother && fMother->TestBit(kNotDeleted)) fMother->GetListOfPrimitives()->Remove(
this);
1293 TPad *oldMother = fMother;
1294 fCanvas = gPad->GetCanvas();
1296 fMother = (TPad*)gPad;
1297 if (oldMother != fMother || fPixmapID == -1) ResizePad();
1302 if (gPad->IsRetained() && gPad !=
this && fMother)
1303 fMother->GetListOfPrimitives()->Add(
this, option);
1315 void TPad::DrawClassObject(
const TObject *classobj, Option_t *option)
1318 const Int_t kMAXLEVELS = 10;
1319 TClass *clevel[kMAXLEVELS], *cl, *cll;
1320 TBaseClass *base, *cinherit;
1323 Double_t x,y,dy,y1,v1,v2,dv;
1324 Int_t nd,nf,nc,nkd,nkf,i,j;
1327 if (opt.Contains(
"2")) maxlev = 2;
1328 if (opt.Contains(
"3")) maxlev = 3;
1329 if (opt.Contains(
"5")) maxlev = 5;
1330 if (opt.Contains(
"6")) maxlev = 6;
1331 if (opt.Contains(
"7")) maxlev = 7;
1334 Double_t xpad = 20.5;
1335 Double_t ypad = 27.5;
1337 Range(0,0,xpad,ypad);
1341 TClass *obj = (TClass*)classobj;
1342 clevel[nlevel] = obj;
1343 TList *lbase = obj->GetListOfBases();
1345 base = (TBaseClass*)lbase->First();
1347 if ( base->GetClassPointer() == 0)
break;
1349 clevel[nlevel] = base->GetClassPointer();
1350 lbase = clevel[nlevel]->GetListOfBases();
1351 if (nlevel >= maxlev-1)
break;
1355 Int_t ilevel, nelem;
1356 for (ilevel=nlevel;ilevel>=0;ilevel--) {
1357 cl = clevel[ilevel];
1358 nelem = cl->GetNdata() + cl->GetNmethods();
1359 if (nelem > maxelem) maxelem = nelem;
1360 nc = (nelem/50) + 1;
1364 Double_t tsizcm = 0.40;
1369 dx = dx - 0.42*Double_t(ncdraw-5);
1370 if (dx < 1.3) dx = 1.3;
1371 tsizcm = tsizcm - 0.03*Double_t(ncdraw-5);
1372 if (tsizcm < 0.27) tsizcm = 0.27;
1374 Double_t tsiz = 1.2*tsizcm/ypad;
1377 for (ilevel=nlevel;ilevel>=0;ilevel--) {
1378 cl = clevel[ilevel];
1379 nelem = cl->GetNdata() + cl->GetNmethods();
1380 if (nelem > maxelem) maxelem = nelem;
1381 nc = (nelem/50) + 1;
1383 if (ilevel < nlevel) x1 = x2 + 0.5;
1386 lbase = cl->GetListOfBases();
1388 if (lbase) cinherit = (TBaseClass*)lbase->First();
1391 nd = cl->GetNdata();
1392 nf = cl->GetNmethods() - 2;
1393 if (cl->GetListOfMethods()->FindObject(
"Dictionary")) {
1401 v1 = y1 - Double_t(nkf+nkd+nc-1)*dy;
1405 pt =
new TPaveText(x1,v1,x2,v2);
1406 pt->SetBit(kCanDelete);
1407 pt->SetFillColor(19);
1409 pt->SetTextColor(4);
1410 pt->SetTextFont(61);
1411 pt->SetTextAlign(12);
1412 pt->SetTextSize(tsiz);
1413 TBox *box = pt->AddBox(0,(y1+0.01-v1)/dv,0,(v2-0.01-v1)/dv);
1414 if (box) box->SetFillColor(17);
1415 pt->AddLine(0,(y1-v1)/dv,0,(y1-v1)/dv);
1416 TText *title = pt->AddText(0.5,(0.5*(y1+v2)-v1)/dv,(
char*)cl->GetName());
1417 title->SetTextAlign(22);
1418 title->SetTextSize(0.6*(v2-y1)/ypad);
1425 TIter nextd(cl->GetListOfDataMembers());
1426 while ((d = (TDataMember *) nextd())) {
1427 if (i >= nkd) { i = 1; y = y1 - 0.5*dy; x += 1/Double_t(nc); }
1428 else { i++; y -= dy; }
1432 Int_t dim = d->GetArrayDim();
1434 snprintf(dname,256,
"%s",d->GetName());
1436 while (indx < dim ){
1437 ldname = strlen(dname);
1438 snprintf(&dname[ldname],256-ldname,
"[%d]",d->GetMaxIndex(indx));
1441 pt->AddText(x,(y-v1)/dv,dname);
1447 ysep = y1 - Double_t(nkd)*dy;
1448 pt->AddLine(0,(ysep-v1)/dv,0,(ysep-v1)/dv);
1458 TIter nextm(cl->GetListOfMethods());
1459 while ((m = (TMethod *) nextm())) {
1461 !strcmp( m->GetName(),
"Dictionary" ) ||
1462 !strcmp( m->GetName(),
"Class_Version" ) ||
1463 !strcmp( m->GetName(),
"DeclFileName" ) ||
1464 !strcmp( m->GetName(),
"DeclFileLine" ) ||
1465 !strcmp( m->GetName(),
"ImplFileName" ) ||
1466 !strcmp( m->GetName(),
"ImplFileLine" )
1469 if (fcount > nf)
break;
1470 if (i >= nkf) { i = 1; y = ysep - 0.5*dy; x += 1/Double_t(nc); }
1471 else { i++; y -= dy; }
1473 ptext = pt->AddText(x,(y-v1)/dv,m->GetName());
1476 for (j=ilevel-1;j>=0;j--) {
1477 if (cl == clevel[ilevel]) {
1478 if (clevel[j]->GetMethodAny((
char*)m->GetName())) {
1479 ptext->SetTextColor(15);
1489 cinherit = (TBaseClass*)lbase->After(cinherit);
1491 cl = cinherit->GetClassPointer();
1516 void TPad::DrawCrosshair()
1518 if (gPad->GetEvent() == kMouseEnter)
return;
1520 TPad *cpad = (TPad*)gPad;
1521 TCanvas *canvas = cpad->GetCanvas();
1522 canvas->FeedbackMode(kTRUE);
1525 Int_t pxmin,pxmax,pymin,pymax,pxold,pyold,px,py;
1526 pxold = fCrosshairPos%10000;
1527 pyold = fCrosshairPos/10000;
1528 px = cpad->GetEventX();
1529 py = cpad->GetEventY()+1;
1530 if (canvas->GetCrosshair() > 1) {
1531 pxmin = cpad->XtoAbsPixel(fX1);
1532 pxmax = cpad->XtoAbsPixel(fX2);
1533 pymin = cpad->YtoAbsPixel(fY1);
1534 pymax = cpad->YtoAbsPixel(fY2);
1537 pxmax = canvas->GetWw();
1539 pymax = cpad->GetWh();
1541 if(pxold) gVirtualX->DrawLine(pxold,pymin,pxold,pymax);
1542 if(pyold) gVirtualX->DrawLine(pxmin,pyold,pxmax,pyold);
1543 if (cpad->GetEvent() == kButton1Down ||
1544 cpad->GetEvent() == kButton1Up ||
1545 cpad->GetEvent() == kMouseLeave) {
1549 gVirtualX->DrawLine(px,pymin,px,pymax);
1550 gVirtualX->DrawLine(pxmin,py,pxmax,py);
1551 fCrosshairPos = px + 10000*py;
1584 TH1F *TPad::DrawFrame(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax,
const char *title)
1586 if (!IsEditable())
return 0;
1587 TPad *padsav = (TPad*)gPad;
1588 if (
this != padsav) {
1589 Warning(
"DrawFrame",
"Must be called for the current pad only");
1590 return padsav->DrawFrame(xmin,ymin,xmax,ymax,title);
1595 TH1F *hframe = (TH1F*)FindObject(
"hframe");
1596 if (hframe)
delete hframe;
1600 if (fLogx && xmin > 0 && xmax > xmin) {
1601 Double_t xminl = TMath::Log(xmin);
1602 Double_t xmaxl = TMath::Log(xmax);
1603 Double_t dx = (xmaxl-xminl)/nbins;
1604 Double_t *xbins =
new Double_t[nbins+1];
1606 for (Int_t i=1;i<=nbins;i++) {
1607 xbins[i] = TMath::Exp(xminl+i*dx);
1609 hframe =
new TH1F(
"hframe",title,nbins,xbins);
1612 hframe =
new TH1F(
"hframe",title,nbins,xmin,xmax);
1614 hframe->SetBit(TH1::kNoStats);
1615 hframe->SetBit(kCanDelete);
1616 hframe->SetMinimum(ymin);
1617 hframe->SetMaximum(ymax);
1618 hframe->GetYaxis()->SetLimits(ymin,ymax);
1619 hframe->SetDirectory(0);
1622 if (padsav) padsav->cd();
1629 void TPad::DrawColorTable()
1633 Double_t xlow, ylow, xup, yup, hs, ws;
1634 Double_t x1, y1, x2, y2;
1638 gPad->SetFillColor(0);
1640 gPad->Range(x1,y1,x2,y2);
1642 TText *text =
new TText(0,0,
"");
1643 text->SetTextFont(61);
1644 text->SetTextSize(0.07);
1645 text->SetTextAlign(22);
1647 TBox *box =
new TBox();
1650 hs = (y2-y1)/Double_t(5);
1651 ws = (x2-x1)/Double_t(10);
1652 for (i=0;i<10;i++) {
1653 xlow = x1 + ws*(Double_t(i)+0.1);
1654 xup = x1 + ws*(Double_t(i)+0.9);
1656 ylow = y1 + hs*(Double_t(j)+0.1);
1657 yup = y1 + hs*(Double_t(j)+0.9);
1659 box->SetFillStyle(1001);
1660 box->SetFillColor(color);
1661 box->DrawBox(xlow, ylow, xup, yup);
1662 box->SetFillStyle(0);
1663 box->SetLineColor(1);
1664 box->DrawBox(xlow, ylow, xup, yup);
1665 if (color == 1) text->SetTextColor(0);
1666 else text->SetTextColor(1);
1667 text->DrawText(0.5*(xlow+xup), 0.5*(ylow+yup), Form(
"%d",color));
1692 void TPad::ExecuteEvent(Int_t event, Int_t px, Int_t py)
1694 const Int_t kMaxDiff = 5;
1695 const Int_t kMinSize = 20;
1696 static Int_t pxorg, pyorg;
1697 static Int_t px1, px2, py1, py2, pxl, pyl, pxt, pyt, pxold, pyold;
1698 static Int_t px1p, px2p, py1p, py2p, pxlp, pylp, pxtp, pytp;
1699 static Bool_t pA, pB, pC, pD, pTop, pL, pR, pBot, pINSIDE;
1701 Bool_t opaque = OpaqueMoving();
1702 Bool_t ropaque = OpaqueResizing();
1703 Bool_t fixedr = HasFixedAspectRatio();
1705 if (!IsEditable() && event != kMouseEnter)
return;
1706 TVirtualPad *parent = GetMother();
1707 if (!parent->IsEditable())
return;
1711 if (fXlowNDC < 0 && event != kButton1Down)
return;
1712 if (fYlowNDC < 0 && event != kButton1Down)
return;
1715 if (event == kButton1Down) {
1720 Int_t newcode = gROOT->GetEditorMode();
1722 pA = pB = pC = pD = pTop = pL = pR = pBot = pINSIDE = kFALSE;
1725 TCreatePrimitives::Pad(event,px,py,0);
1729 TCreatePrimitives::Text(event,px,py,newcode);
1732 TCreatePrimitives::Line(event,px,py,kLine);
1735 TCreatePrimitives::Line(event,px,py,kArrow);
1738 TCreatePrimitives::Line(event,px,py,kCurlyLine);
1741 TCreatePrimitives::Line(event,px,py,kCurlyArc);
1744 TCreatePrimitives::PolyLine(event,px,py,kPolyLine);
1747 TCreatePrimitives::PolyLine(event,px,py,kCutG);
1750 TCreatePrimitives::Ellipse(event,px,py,kArc);
1753 TCreatePrimitives::Ellipse(event,px,py,kEllipse);
1761 TCreatePrimitives::Pave(event,px,py,newcode);
1766 if (newcode)
return;
1775 case kArrowKeyPress:
1778 fXUpNDC = fXlowNDC + fWNDC;
1779 fYUpNDC = fYlowNDC + fHNDC;
1781 GetPainter()->SetLineColor(-1);
1784 GetPainter()->SetLineColor(GetFillColor());
1786 GetPainter()->SetLineColor(1);
1787 GetPainter()->SetLineWidth(2);
1793 px1 = XtoAbsPixel(fX1);
1794 py1 = YtoAbsPixel(fY1);
1795 px2 = XtoAbsPixel(fX2);
1796 py2 = YtoAbsPixel(fY2);
1813 px1p = parent->XtoAbsPixel(parent->GetX1()) + parent->GetBorderSize();
1814 py1p = parent->YtoAbsPixel(parent->GetY1()) - parent->GetBorderSize();
1815 px2p = parent->XtoAbsPixel(parent->GetX2()) - parent->GetBorderSize();
1816 py2p = parent->YtoAbsPixel(parent->GetY2()) + parent->GetBorderSize();
1833 pA = pB = pC = pD = pTop = pL = pR = pBot = pINSIDE = kFALSE;
1836 if (TMath::Abs(px - pxl) <= kMaxDiff && TMath::Abs(py - pyl) <= kMaxDiff) {
1837 pxold = pxl; pyold = pyl; pA = kTRUE;
1838 SetCursor(kTopLeft);
1841 if (TMath::Abs(px - pxt) <= kMaxDiff && TMath::Abs(py - pyl) <= kMaxDiff) {
1842 pxold = pxt; pyold = pyl; pB = kTRUE;
1843 SetCursor(kTopRight);
1846 if (TMath::Abs(px - pxt) <= kMaxDiff && TMath::Abs(py - pyt) <= kMaxDiff) {
1847 pxold = pxt; pyold = pyt; pC = kTRUE;
1848 SetCursor(kBottomRight);
1851 if (TMath::Abs(px - pxl) <= kMaxDiff && TMath::Abs(py - pyt) <= kMaxDiff) {
1852 pxold = pxl; pyold = pyt; pD = kTRUE;
1853 SetCursor(kBottomLeft);
1856 if ((px > pxl+kMaxDiff && px < pxt-kMaxDiff) &&
1857 TMath::Abs(py - pyl) < kMaxDiff) {
1858 pxold = pxl; pyold = pyl; pTop = kTRUE;
1859 SetCursor(kTopSide);
1862 if ((px > pxl+kMaxDiff && px < pxt-kMaxDiff) &&
1863 TMath::Abs(py - pyt) < kMaxDiff) {
1864 pxold = pxt; pyold = pyt; pBot = kTRUE;
1865 SetCursor(kBottomSide);
1868 if ((py > pyl+kMaxDiff && py < pyt-kMaxDiff) &&
1869 TMath::Abs(px - pxl) < kMaxDiff) {
1870 pxold = pxl; pyold = pyl; pL = kTRUE;
1871 SetCursor(kLeftSide);
1874 if ((py > pyl+kMaxDiff && py < pyt-kMaxDiff) &&
1875 TMath::Abs(px - pxt) < kMaxDiff) {
1876 pxold = pxt; pyold = pyt; pR = kTRUE;
1877 SetCursor(kRightSide);
1880 if ((px > pxl+kMaxDiff && px < pxt-kMaxDiff) &&
1881 (py > pyl+kMaxDiff && py < pyt-kMaxDiff)) {
1882 pxold = px; pyold = py; pINSIDE = kTRUE;
1883 if (event == kButton1Down)
1890 if (pA || pB || pC || pD || pTop || pL || pR || pBot)
1893 if (!pA && !pB && !pC && !pD && !pTop && !pL && !pR && !pBot && !pINSIDE)
1898 case kArrowKeyRelease:
1899 case kButton1Motion:
1901 if (TestBit(kCannotMove))
break;
1905 if (!ropaque) gVirtualX->DrawBox(pxold, pyt, pxt, pyold, TVirtualX::kHollow);
1906 if (px > pxt-kMinSize) { px = pxt-kMinSize; wx = px; }
1907 if (py > pyt-kMinSize) { py = pyt-kMinSize; wy = py; }
1908 if (px < pxlp) { px = pxlp; wx = px; }
1909 if (py < pylp) { py = pylp; wy = py; }
1911 Double_t dy = Double_t(TMath::Abs(pxt-px))/parent->UtoPixel(1.) /
1913 Int_t npy2 = pyt - TMath::Abs(parent->VtoAbsPixel(dy) -
1914 parent->VtoAbsPixel(0));
1923 if (!ropaque) gVirtualX->DrawBox(px, pyt, pxt, py, TVirtualX::kHollow);
1926 if (!ropaque) gVirtualX->DrawBox(pxl , pyt, pxold, pyold, TVirtualX::kHollow);
1927 if (px < pxl+kMinSize) { px = pxl+kMinSize; wx = px; }
1928 if (py > pyt-kMinSize) { py = pyt-kMinSize; wy = py; }
1929 if (px > pxtp) { px = pxtp; wx = px; }
1930 if (py < pylp) { py = pylp; wy = py; }
1932 Double_t dy = Double_t(TMath::Abs(pxl-px))/parent->UtoPixel(1.) /
1934 Int_t npy2 = pyt - TMath::Abs(parent->VtoAbsPixel(dy) -
1935 parent->VtoAbsPixel(0));
1944 if (!ropaque) gVirtualX->DrawBox(pxl , pyt, px , py, TVirtualX::kHollow);
1947 if (!ropaque) gVirtualX->DrawBox(pxl , pyl, pxold, pyold, TVirtualX::kHollow);
1948 if (px < pxl+kMinSize) { px = pxl+kMinSize; wx = px; }
1949 if (py < pyl+kMinSize) { py = pyl+kMinSize; wy = py; }
1950 if (px > pxtp) { px = pxtp; wx = px; }
1951 if (py > pytp) { py = pytp; wy = py; }
1953 Double_t dy = Double_t(TMath::Abs(pxl-px))/parent->UtoPixel(1.) /
1955 Int_t npy2 = pyl + TMath::Abs(parent->VtoAbsPixel(dy) -
1956 parent->VtoAbsPixel(0));
1965 if (!ropaque) gVirtualX->DrawBox(pxl, pyl, px, py, TVirtualX::kHollow);
1968 if (!ropaque) gVirtualX->DrawBox(pxold, pyold, pxt, pyl, TVirtualX::kHollow);
1969 if (px > pxt-kMinSize) { px = pxt-kMinSize; wx = px; }
1970 if (py < pyl+kMinSize) { py = pyl+kMinSize; wy = py; }
1971 if (px < pxlp) { px = pxlp; wx = px; }
1972 if (py > pytp) { py = pytp; wy = py; }
1974 Double_t dy = Double_t(TMath::Abs(pxt-px))/parent->UtoPixel(1.) /
1976 Int_t npy2 = pyl + TMath::Abs(parent->VtoAbsPixel(dy) -
1977 parent->VtoAbsPixel(0));
1986 if (!ropaque) gVirtualX->DrawBox(px, py, pxt, pyl, TVirtualX::kHollow);
1989 if (!ropaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
1991 if (py2 > py1-kMinSize) { py2 = py1-kMinSize; wy = py2; }
1992 if (py2 < py2p) { py2 = py2p; wy = py2; }
1994 Double_t dx = Double_t(TMath::Abs(py2-py1))/parent->VtoPixel(0) *
1996 Int_t npx2 = px1 + parent->UtoPixel(dx);
2002 if (!ropaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
2005 if (!ropaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
2007 if (py1 < py2+kMinSize) { py1 = py2+kMinSize; wy = py1; }
2008 if (py1 > py1p) { py1 = py1p; wy = py1; }
2010 Double_t dx = Double_t(TMath::Abs(py2-py1))/parent->VtoPixel(0) *
2012 Int_t npx2 = px1 + parent->UtoPixel(dx);
2018 if (!ropaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
2021 if (!ropaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
2023 if (px1 > px2-kMinSize) { px1 = px2-kMinSize; wx = px1; }
2024 if (px1 < px1p) { px1 = px1p; wx = px1; }
2026 Double_t dy = Double_t(TMath::Abs(px2-px1))/parent->UtoPixel(1.) /
2028 Int_t npy2 = py1 - TMath::Abs(parent->VtoAbsPixel(dy) -
2029 parent->VtoAbsPixel(0));
2035 if (!ropaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
2038 if (!ropaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
2040 if (px2 < px1+kMinSize) { px2 = px1+kMinSize; wx = px2; }
2041 if (px2 > px2p) { px2 = px2p; wx = px2; }
2043 Double_t dy = Double_t(TMath::Abs(px2-px1))/parent->UtoPixel(1.) /
2045 Int_t npy2 = py1 - TMath::Abs(parent->VtoAbsPixel(dy) -
2046 parent->VtoAbsPixel(0));
2052 if (!ropaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
2055 if (!opaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
2056 Int_t dx = px - pxold;
2057 Int_t dy = py - pyold;
2058 px1 += dx; py1 += dy; px2 += dx; py2 += dy;
2059 if (px1 < px1p) { dx = px1p - px1; px1 += dx; px2 += dx; wx = px+dx; }
2060 if (px2 > px2p) { dx = px2 - px2p; px1 -= dx; px2 -= dx; wx = px-dx; }
2061 if (py1 > py1p) { dy = py1 - py1p; py1 -= dy; py2 -= dy; wy = py-dy; }
2062 if (py2 < py2p) { dy = py2p - py2; py1 += dy; py2 += dy; wy = py+dy; }
2063 if (!opaque) gVirtualX->DrawBox(px1, py1, px2, py2, TVirtualX::kHollow);
2069 gVirtualX->Warp(px, py);
2075 Double_t x1, y1, x2, y2;
2076 x1 = x2 = y1 = y2 = 0;
2078 if ((!fResizing && opaque) || (fResizing && ropaque)) {
2080 x1 = AbsPixeltoX(pxold);
2081 y1 = AbsPixeltoY(pyt);
2082 x2 = AbsPixeltoX(pxt);
2083 y2 = AbsPixeltoY(pyold);
2086 x1 = AbsPixeltoX(pxl);
2087 y1 = AbsPixeltoY(pyt);
2088 x2 = AbsPixeltoX(pxold);
2089 y2 = AbsPixeltoY(pyold);
2092 x1 = AbsPixeltoX(pxl);
2093 y1 = AbsPixeltoY(pyold);
2094 x2 = AbsPixeltoX(pxold);
2095 y2 = AbsPixeltoY(pyl);
2098 x1 = AbsPixeltoX(pxold);
2099 y1 = AbsPixeltoY(pyold);
2100 x2 = AbsPixeltoX(pxt);
2101 y2 = AbsPixeltoY(pyl);
2103 if (pTop || pBot || pL || pR || pINSIDE) {
2104 x1 = AbsPixeltoX(px1);
2105 y1 = AbsPixeltoY(py1);
2106 x2 = AbsPixeltoX(px2);
2107 y2 = AbsPixeltoY(py2);
2110 if (px != pxorg || py != pyorg) {
2113 Int_t parentpx1 = fMother->XtoAbsPixel(parent->GetX1());
2114 Int_t parentpx2 = fMother->XtoAbsPixel(parent->GetX2());
2115 Int_t parentpy1 = fMother->YtoAbsPixel(parent->GetY1());
2116 Int_t parentpy2 = fMother->YtoAbsPixel(parent->GetY2());
2119 Int_t apx1 = XtoAbsPixel(x1);
if (apx1 < parentpx1) {apx1 = parentpx1; }
2120 Int_t apx2 = XtoAbsPixel(x2);
if (apx2 > parentpx2) {apx2 = parentpx2; }
2121 Int_t apy1 = YtoAbsPixel(y1);
if (apy1 > parentpy1) {apy1 = parentpy1; }
2122 Int_t apy2 = YtoAbsPixel(y2);
if (apy2 < parentpy2) {apy2 = parentpy2; }
2125 fXlowNDC = Double_t(apx1 - parentpx1)/Double_t(parentpx2 - parentpx1);
2126 fYlowNDC = Double_t(apy1 - parentpy1)/Double_t(parentpy2 - parentpy1);
2127 fWNDC = Double_t(apx2 - apx1)/Double_t(parentpx2 - parentpx1);
2128 fHNDC = Double_t(apy2 - apy1)/Double_t(parentpy2 - parentpy1);
2134 if (pINSIDE) gPad->ShowGuidelines(
this, event);
2135 if (pTop) gPad->ShowGuidelines(
this, event,
't',
true);
2136 if (pBot) gPad->ShowGuidelines(
this, event,
'b',
true);
2137 if (pL) gPad->ShowGuidelines(
this, event,
'l',
true);
2138 if (pR) gPad->ShowGuidelines(
this, event,
'r',
true);
2139 if (pA) gPad->ShowGuidelines(
this, event,
'1',
true);
2140 if (pB) gPad->ShowGuidelines(
this, event,
'2',
true);
2141 if (pC) gPad->ShowGuidelines(
this, event,
'3',
true);
2142 if (pD) gPad->ShowGuidelines(
this, event,
'4',
true);
2151 if (gROOT->IsEscaped()) {
2152 gROOT->SetEscape(kFALSE);
2156 if (opaque||ropaque) {
2157 ShowGuidelines(
this, event);
2159 x1 = x2 = y1 = y2 = 0;
2162 x1 = AbsPixeltoX(pxold);
2163 y1 = AbsPixeltoY(pyt);
2164 x2 = AbsPixeltoX(pxt);
2165 y2 = AbsPixeltoY(pyold);
2168 x1 = AbsPixeltoX(pxl);
2169 y1 = AbsPixeltoY(pyt);
2170 x2 = AbsPixeltoX(pxold);
2171 y2 = AbsPixeltoY(pyold);
2174 x1 = AbsPixeltoX(pxl);
2175 y1 = AbsPixeltoY(pyold);
2176 x2 = AbsPixeltoX(pxold);
2177 y2 = AbsPixeltoY(pyl);
2180 x1 = AbsPixeltoX(pxold);
2181 y1 = AbsPixeltoY(pyold);
2182 x2 = AbsPixeltoX(pxt);
2183 y2 = AbsPixeltoY(pyl);
2185 if (pTop || pBot || pL || pR || pINSIDE) {
2186 x1 = AbsPixeltoX(px1);
2187 y1 = AbsPixeltoY(py1);
2188 x2 = AbsPixeltoX(px2);
2189 y2 = AbsPixeltoY(py2);
2192 if (pA || pB || pC || pD || pTop || pL || pR || pBot)
2195 gVirtualX->SetLineColor(-1);
2196 gVirtualX->SetLineWidth(-1);
2198 if (px != pxorg || py != pyorg) {
2201 Int_t parentpx1 = fMother->XtoAbsPixel(parent->GetX1());
2202 Int_t parentpx2 = fMother->XtoAbsPixel(parent->GetX2());
2203 Int_t parentpy1 = fMother->YtoAbsPixel(parent->GetY1());
2204 Int_t parentpy2 = fMother->YtoAbsPixel(parent->GetY2());
2207 Int_t apx1 = XtoAbsPixel(x1);
if (apx1 < parentpx1) {apx1 = parentpx1; }
2208 Int_t apx2 = XtoAbsPixel(x2);
if (apx2 > parentpx2) {apx2 = parentpx2; }
2209 Int_t apy1 = YtoAbsPixel(y1);
if (apy1 > parentpy1) {apy1 = parentpy1; }
2210 Int_t apy2 = YtoAbsPixel(y2);
if (apy2 < parentpy2) {apy2 = parentpy2; }
2213 fXlowNDC = Double_t(apx1 - parentpx1)/Double_t(parentpx2 - parentpx1);
2214 fYlowNDC = Double_t(apy1 - parentpy1)/Double_t(parentpy2 - parentpy1);
2215 fWNDC = Double_t(apx2 - apx1)/Double_t(parentpx2 - parentpx1);
2216 fHNDC = Double_t(apy2 - apy1)/Double_t(parentpy2 - parentpy1);
2229 case kButton1Locate:
2231 ExecuteEvent(kButton1Down, px, py);
2235 event = gVirtualX->RequestLocator(1, 1, px, py);
2237 ExecuteEvent(kButton1Motion, px, py);
2240 ExecuteEvent(kButton1Up, px, py);
2267 void TPad::ExecuteEventAxis(Int_t event, Int_t px, Int_t py, TAxis *axis)
2269 if (!IsEditable())
return;
2273 TView *view = GetView();
2274 static Int_t axisNumber;
2275 static Double_t ratio1, ratio2;
2276 static Int_t px1old, py1old, px2old, py2old;
2277 Int_t bin1, bin2, first, last;
2278 Double_t temp, xmin,xmax;
2279 Bool_t opaque = gPad->OpaqueMoving();
2280 static TBox *zoombox;
2281 Double_t zbx1=0,zbx2=0,zby1=0,zby2=0;
2285 TString opt = axis->GetParent()->GetDrawOption();
2287 Bool_t kCont4 = kFALSE;
2288 if (strstr(opt,
"cont4")) {
2297 if (!strcmp(axis->GetName(),
"xaxis")) {
2299 if (!IsVertical()) axisNumber = 2;
2301 if (!strcmp(axis->GetName(),
"yaxis")) {
2303 if (!IsVertical()) axisNumber = 1;
2305 if (!strcmp(axis->GetName(),
"zaxis")) {
2309 view->GetDistancetoAxis(axisNumber, px, py, ratio1);
2311 if (axisNumber == 1) {
2312 ratio1 = (AbsPixeltoX(px) - GetUxmin())/(GetUxmax() - GetUxmin());
2313 px1old = XtoAbsPixel(GetUxmin()+ratio1*(GetUxmax() - GetUxmin()));
2314 py1old = YtoAbsPixel(GetUymin());
2316 py2old = YtoAbsPixel(GetUymax());
2317 }
else if (axisNumber == 2) {
2318 ratio1 = (AbsPixeltoY(py) - GetUymin())/(GetUymax() - GetUymin());
2319 py1old = YtoAbsPixel(GetUymin()+ratio1*(GetUymax() - GetUymin()));
2320 px1old = XtoAbsPixel(GetUxmin());
2321 px2old = XtoAbsPixel(GetUxmax());
2324 ratio1 = (AbsPixeltoY(py) - GetUymin())/(GetUymax() - GetUymin());
2325 py1old = YtoAbsPixel(GetUymin()+ratio1*(GetUymax() - GetUymin()));
2326 px1old = XtoAbsPixel(GetUxmax());
2327 px2old = XtoAbsPixel(GetX2());
2331 gVirtualX->DrawBox(px1old, py1old, px2old, py2old, TVirtualX::kHollow);
2333 if (axisNumber == 1) {
2334 zbx1 = AbsPixeltoX(px1old);
2335 zbx2 = AbsPixeltoX(px2old);
2338 }
else if (axisNumber == 2) {
2341 zby1 = AbsPixeltoY(py1old);
2342 zby2 = AbsPixeltoY(py2old);
2345 zbx1 = TMath::Power(10,zbx1);
2346 zbx2 = TMath::Power(10,zbx2);
2349 zby1 = TMath::Power(10,zby1);
2350 zby2 = TMath::Power(10,zby2);
2352 zoombox =
new TBox(zbx1, zby1, zbx2, zby2);
2353 Int_t ci = TColor::GetColor(
"#7d7dff");
2354 TColor *zoomcolor = gROOT->GetColor(ci);
2355 if (!TCanvas::SupportAlpha() || !zoomcolor) zoombox->SetFillStyle(3002);
2356 else zoomcolor->SetAlpha(0.5);
2357 zoombox->SetFillColor(ci);
2363 if (!opaque) gVirtualX->SetLineColor(-1);
2366 case kButton1Motion:
2368 view->GetDistancetoAxis(axisNumber, px, py, ratio2);
2370 if (!opaque) gVirtualX->DrawBox(px1old, py1old, px2old, py2old, TVirtualX::kHollow);
2371 if (axisNumber == 1) {
2372 ratio2 = (AbsPixeltoX(px) - GetUxmin())/(GetUxmax() - GetUxmin());
2373 px2old = XtoAbsPixel(GetUxmin()+ratio2*(GetUxmax() - GetUxmin()));
2375 ratio2 = (AbsPixeltoY(py) - GetUymin())/(GetUymax() - GetUymin());
2376 py2old = YtoAbsPixel(GetUymin()+ratio2*(GetUymax() - GetUymin()));
2379 gVirtualX->DrawBox(px1old, py1old, px2old, py2old, TVirtualX::kHollow);
2381 if (axisNumber == 1) {
2382 zbx1 = AbsPixeltoX(px1old);
2383 zbx2 = AbsPixeltoX(px2old);
2386 }
else if (axisNumber == 2) {
2389 zby1 = AbsPixeltoY(py1old);
2390 zby2 = AbsPixeltoY(py2old);
2393 zbx1 = TMath::Power(10,zbx1);
2394 zbx2 = TMath::Power(10,zbx2);
2397 zby1 = TMath::Power(10,zby1);
2398 zby2 = TMath::Power(10,zby2);
2401 zoombox->SetX1(zbx1);
2402 zoombox->SetY1(zby1);
2403 zoombox->SetX2(zbx2);
2404 zoombox->SetY2(zby2);
2413 bin1 = axis->GetFirst()+1;
2414 bin2 = axis->GetLast()-1;
2415 bin1 = TMath::Max(bin1, 1);
2416 bin2 = TMath::Min(bin2, axis->GetNbins());
2418 axis->SetRange(bin1,bin2);
2425 bin1 = axis->GetFirst()-1;
2426 bin2 = axis->GetLast()+1;
2427 bin1 = TMath::Max(bin1, 1);
2428 bin2 = TMath::Min(bin2, axis->GetNbins());
2430 axis->SetRange(bin1,bin2);
2437 if (gROOT->IsEscaped()) {
2438 gROOT->SetEscape(kFALSE);
2439 if (opaque && zoombox) {
2447 view->GetDistancetoAxis(axisNumber, px, py, ratio2);
2448 if (ratio1 > ratio2) {
2453 if (ratio2 - ratio1 > 0.05) {
2454 TH1 *hobj = (TH1*)axis->GetParent();
2455 if (axisNumber == 3 && hobj && hobj->GetDimension() != 3) {
2456 Float_t zmin = hobj->GetMinimum();
2457 Float_t zmax = hobj->GetMaximum();
2459 if (zmin <= 0 && zmax > 0) zmin = TMath::Min((Double_t)1,
2460 (Double_t)0.001*zmax);
2461 zmin = TMath::Log10(zmin);
2462 zmax = TMath::Log10(zmax);
2464 Float_t newmin = zmin + (zmax-zmin)*ratio1;
2465 Float_t newmax = zmin + (zmax-zmin)*ratio2;
2466 if(newmin < zmin)newmin = hobj->GetBinContent(hobj->GetMinimumBin());
2467 if(newmax > zmax)newmax = hobj->GetBinContent(hobj->GetMaximumBin());
2469 newmin = TMath::Exp(2.302585092994*newmin);
2470 newmax = TMath::Exp(2.302585092994*newmax);
2472 hobj->SetMinimum(newmin);
2473 hobj->SetMaximum(newmax);
2474 hobj->SetBit(TH1::kIsZoomed);
2476 first = axis->GetFirst();
2477 last = axis->GetLast();
2478 bin1 = first + Int_t((last-first+1)*ratio1);
2479 bin2 = first + Int_t((last-first+1)*ratio2);
2480 bin1 = TMath::Max(bin1, 1);
2481 bin2 = TMath::Min(bin2, axis->GetNbins());
2482 axis->SetRange(bin1, bin2);
2489 if (axisNumber == 1) {
2490 ratio2 = (AbsPixeltoX(px) - GetUxmin())/(GetUxmax() - GetUxmin());
2491 xmin = GetUxmin() +ratio1*(GetUxmax() - GetUxmin());
2492 xmax = GetUxmin() +ratio2*(GetUxmax() - GetUxmin());
2493 if (GetLogx() && !kCont4) {
2494 xmin = PadtoX(xmin);
2495 xmax = PadtoX(xmax);
2497 }
else if (axisNumber == 2) {
2498 ratio2 = (AbsPixeltoY(py) - GetUymin())/(GetUymax() - GetUymin());
2499 xmin = GetUymin() +ratio1*(GetUymax() - GetUymin());
2500 xmax = GetUymin() +ratio2*(GetUymax() - GetUymin());
2501 if (GetLogy() && !kCont4) {
2502 xmin = PadtoY(xmin);
2503 xmax = PadtoY(xmax);
2506 ratio2 = (AbsPixeltoY(py) - GetUymin())/(GetUymax() - GetUymin());
2521 Double_t low = axis->GetBinLowEdge(axis->GetFirst());
2522 Double_t up = axis->GetBinUpEdge(axis->GetLast());
2523 Double_t xmi = GetUxmin();
2524 Double_t xma = GetUxmax();
2525 xmin = ((xmin-xmi)/(xma-xmi))*(up-low)+low;
2526 xmax = ((xmax-xmi)/(xma-xmi))*(up-low)+low;
2529 if (!strcmp(axis->GetName(),
"xaxis")) axisNumber = 1;
2530 if (!strcmp(axis->GetName(),
"yaxis")) axisNumber = 2;
2531 if (ratio2 - ratio1 > 0.05) {
2533 TH1 *hobj1 = (TH1*)axis->GetParent();
2534 bin1 = axis->FindFixBin(xmin);
2535 bin2 = axis->FindFixBin(xmax);
2536 bin1 = TMath::Max(bin1, 1);
2537 bin2 = TMath::Min(bin2, axis->GetNbins());
2538 if (axisNumber == 1) axis->SetRange(bin1,bin2);
2539 if (axisNumber == 2 && hobj1) {
2540 if (hobj1->GetDimension() == 1) {
2541 if (hobj1->GetNormFactor() != 0) {
2542 Double_t norm = hobj1->GetSumOfWeights()/hobj1->GetNormFactor();
2546 hobj1->SetMinimum(xmin);
2547 hobj1->SetMaximum(xmax);
2548 hobj1->SetBit(TH1::kIsZoomed);
2550 axis->SetRange(bin1,bin2);
2554 TIter next(GetListOfPrimitives());
2556 while ((obj= next())) {
2557 if (!obj->InheritsFrom(TH1::Class()))
continue;
2558 TH1 *hobj = (TH1*)obj;
2559 if (hobj == hobj1)
continue;
2560 bin1 = hobj->GetXaxis()->FindFixBin(xmin);
2561 bin2 = hobj->GetXaxis()->FindFixBin(xmax);
2562 if (axisNumber == 1) {
2563 hobj->GetXaxis()->SetRange(bin1,bin2);
2564 }
else if (axisNumber == 2) {
2565 if (hobj->GetDimension() == 1) {
2566 Double_t xxmin = xmin;
2567 Double_t xxmax = xmax;
2568 if (hobj->GetNormFactor() != 0) {
2569 Double_t norm = hobj->GetSumOfWeights()/hobj->GetNormFactor();
2573 hobj->SetMinimum(xxmin);
2574 hobj->SetMaximum(xxmax);
2575 hobj->SetBit(TH1::kIsZoomed);
2577 bin1 = hobj->GetYaxis()->FindFixBin(xmin);
2578 bin2 = hobj->GetYaxis()->FindFixBin(xmax);
2579 hobj->GetYaxis()->SetRange(bin1,bin2);
2587 gVirtualX->SetLineColor(-1);
2603 TObject *TPad::FindObject(
const char *name)
const
2605 if (!fPrimitives)
return nullptr;
2606 TObject *found = fPrimitives->FindObject(name);
2607 if (found)
return found;
2609 TIter next(GetListOfPrimitives());
2610 while ((cur = next())) {
2611 if (cur->InheritsFrom(TPad::Class())) {
2612 found = ((TPad*)cur)->FindObject(name);
2613 if (found)
return found;
2624 TObject *TPad::FindObject(
const TObject *obj)
const
2626 if (!fPrimitives)
return nullptr;
2627 TObject *found = fPrimitives->FindObject(obj);
2628 if (found)
return found;
2630 TIter next(GetListOfPrimitives());
2631 while ((cur = next())) {
2632 if (cur->InheritsFrom(TPad::Class())) {
2633 found = ((TPad*)cur)->FindObject(obj);
2634 if (found)
return found;
2643 Int_t TPad::GetCanvasID()
const
2645 return fCanvas ? fCanvas->GetCanvasID() : -1;
2651 TCanvasImp *TPad::GetCanvasImp()
const
2653 return fCanvas ? fCanvas->GetCanvasImp() :
nullptr;
2659 Int_t TPad::GetEvent()
const
2661 return fCanvas ? fCanvas->GetEvent() : 0;
2667 Int_t TPad::GetEventX()
const
2669 return fCanvas ? fCanvas->GetEventX() : 0;
2675 Int_t TPad::GetEventY()
const
2677 return fCanvas ? fCanvas->GetEventY() : 0;
2683 TVirtualPad *TPad::GetVirtCanvas()
const
2685 return fCanvas ? (TVirtualPad*) fCanvas :
nullptr;
2691 Color_t TPad::GetHighLightColor()
const
2693 return fCanvas ? fCanvas->GetHighLightColor() : 0;
2699 Int_t TPad::GetMaxPickDistance()
2701 return fgMaxPickDistance;
2707 TObject *TPad::GetSelected()
const
2709 if (fCanvas ==
this)
return nullptr;
2710 return fCanvas ? fCanvas->GetSelected() :
nullptr;
2716 TVirtualPad *TPad::GetSelectedPad()
const
2718 if (fCanvas ==
this)
return nullptr;
2719 return fCanvas ? fCanvas->GetSelectedPad() :
nullptr;
2725 TVirtualPad *TPad::GetPadSave()
const
2727 if (fCanvas ==
this)
return nullptr;
2728 return fCanvas ? fCanvas->GetPadSave() :
nullptr;
2734 UInt_t TPad::GetWh()
const
2736 return fCanvas ? fCanvas->GetWh() : 0;
2742 UInt_t TPad::GetWw()
const
2744 return fCanvas ? fCanvas->GetWw() : 0;
2752 void TPad::HideToolTip(Int_t event)
2754 if (event != kMouseEnter && event != kMouseMotion && fTip)
2755 gPad->CloseToolTip(fTip);
2761 Bool_t TPad::IsBatch()
const
2763 return fCanvas ? fCanvas->IsBatch() : kFALSE;
2769 Bool_t TPad::IsRetained()
const
2771 return fCanvas ? fCanvas->IsRetained() : kFALSE;
2777 Bool_t TPad::OpaqueMoving()
const
2779 return fCanvas ? fCanvas->OpaqueMoving() : kFALSE;
2785 Bool_t TPad::OpaqueResizing()
const
2787 return fCanvas ? fCanvas->OpaqueResizing() : kFALSE;
2793 void TPad::SetBatch(Bool_t batch)
2795 if (fCanvas) fCanvas->SetBatch(batch);
2801 void TPad::SetCanvasSize(UInt_t ww, UInt_t wh)
2803 if (fCanvas) fCanvas->SetCanvasSize(ww,wh);
2809 void TPad::SetCursor(ECursor cursor)
2811 if (fCanvas) fCanvas->SetCursor(cursor);
2817 void TPad::SetDoubleBuffer(Int_t mode)
2819 if (fCanvas) fCanvas->SetDoubleBuffer(mode);
2825 void TPad::SetSelected(TObject *obj)
2827 if (fCanvas) fCanvas->SetSelected(obj);
2835 if (fCanvas) fCanvas->Update();
2841 TFrame *TPad::GetFrame()
2843 if (!fPrimitives) fPrimitives =
new TList;
2844 TFrame *frame = (TFrame*)GetListOfPrimitives()->FindObject(fFrame);
2845 if (!frame) frame = (TFrame*)GetListOfPrimitives()->FindObject(
"TFrame");
2848 if (!frame) fFrame =
new TFrame(0,0,1,1);
2849 Int_t framecolor = GetFrameFillColor();
2850 if (!framecolor) framecolor = GetFillColor();
2851 fFrame->SetFillColor(framecolor);
2852 fFrame->SetFillStyle(GetFrameFillStyle());
2853 fFrame->SetLineColor(GetFrameLineColor());
2854 fFrame->SetLineStyle(GetFrameLineStyle());
2855 fFrame->SetLineWidth(GetFrameLineWidth());
2856 fFrame->SetBorderSize(GetFrameBorderSize());
2857 fFrame->SetBorderMode(GetFrameBorderMode());
2865 TObject *TPad::GetPrimitive(
const char *name)
const
2867 if (!fPrimitives)
return nullptr;
2868 TIter next(fPrimitives);
2869 TObject *found, *obj;
2870 while ((obj=next())) {
2871 if (!strcmp(name, obj->GetName()))
return obj;
2872 if (obj->InheritsFrom(TPad::Class()))
continue;
2873 found = obj->FindObject(name);
2874 if (found)
return found;
2882 TVirtualPad *TPad::GetPad(Int_t subpadnumber)
const
2884 if (!subpadnumber) {
2885 return (TVirtualPad*)
this;
2889 if (!fPrimitives)
return nullptr;
2890 TIter next(GetListOfPrimitives());
2891 while ((obj = next())) {
2892 if (obj->InheritsFrom(TVirtualPad::Class())) {
2893 TVirtualPad *pad = (TVirtualPad*)obj;
2894 if (pad->GetNumber() == subpadnumber)
return pad;
2903 void TPad::GetPadPar(Double_t &xlow, Double_t &ylow, Double_t &xup, Double_t &yup)
2907 xup = fXlowNDC+fWNDC;
2908 yup = fYlowNDC+fHNDC;
2914 void TPad::GetRange(Double_t &x1, Double_t &y1, Double_t &x2, Double_t &y2)
2925 void TPad::GetRangeAxis(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax)
2937 void TPad::HighLight(Color_t color, Bool_t set)
2939 if (gVirtualPS && gVirtualPS->TestBit(kPrintingPS))
return;
2941 if (color <= 0)
return;
2943 AbsCoordinates(kTRUE);
2947 if (GetMother() && GetMother()->IsEditable() && !InheritsFrom(TButton::Class())) {
2959 gROOT->SetSelectedPad(
this);
2960 if (GetBorderMode()>0) {
2961 if (set) PaintBorder(-color, kFALSE);
2962 else PaintBorder(-GetFillColor(), kFALSE);
2966 AbsCoordinates(kFALSE);
2972 void TPad::ls(Option_t *option)
const
2974 TROOT::IndentLevel();
2975 std::cout <<IsA()->GetName()<<
" fXlowNDC=" <<fXlowNDC<<
" fYlowNDC="<<fYlowNDC<<
" fWNDC="<<GetWNDC()<<
" fHNDC="<<GetHNDC()
2976 <<
" Name= "<<GetName()<<
" Title= "<<GetTitle()<<
" Option="<<option<<std::endl;
2977 TROOT::IncreaseDirLevel();
2978 if (!fPrimitives)
return;
2979 fPrimitives->ls(option);
2980 TROOT::DecreaseDirLevel();
2986 Int_t TPad::IncrementPaletteColor(Int_t i, TString opt)
2988 if (opt.Index(
"pfc")>=0 || opt.Index(
"plc")>=0 || opt.Index(
"pmc")>=0) {
2989 if (i==1) fNumPaletteColor++;
2990 else fNumPaletteColor = i;
2991 return fNumPaletteColor;
3000 Int_t TPad::NextPaletteColor()
3003 Int_t ncolors = gStyle->GetNumberOfColors();
3004 if (fNumPaletteColor>1) {
3005 i = fNextPaletteColor*(ncolors/(fNumPaletteColor-1));
3006 if (i>=ncolors) i = ncolors-1;
3008 fNextPaletteColor++;
3009 if (fNextPaletteColor > fNumPaletteColor-1) fNextPaletteColor = 0;
3010 return gStyle->GetColorPalette(i);
3016 void TPad::FillCollideGrid(TObject *oi)
3018 Int_t
const cellSize = 10;
3020 if (fCGnx == 0 && fCGny == 0) {
3021 fCGnx = gPad->GetWw()/cellSize;
3022 fCGny = gPad->GetWh()/cellSize;
3024 Int_t CGnx = gPad->GetWw()/cellSize;
3025 Int_t CGny = gPad->GetWh()/cellSize;
3026 if (fCGnx != CGnx || fCGny != CGny) {
3029 delete [] fCollideGrid;
3030 fCollideGrid =
nullptr;
3035 if (!fCollideGrid) {
3036 fCollideGrid =
new Bool_t [fCGnx*fCGny];
3037 for (
int i = 0; i<fCGnx; i++) {
3038 for (
int j = 0; j<fCGny; j++) {
3039 fCollideGrid[i + j*fCGnx] = kTRUE;
3045 TList *l = GetListOfPrimitives();
3046 Int_t np = l->GetSize();
3049 for (
int i=0; i<np; i++) {
3050 o = (TObject *) l->At(i);
3052 if (o->InheritsFrom(TFrame::Class())) { FillCollideGridTFrame(o);
continue;}
3053 if (o->InheritsFrom(TBox::Class())) { FillCollideGridTBox(o);
continue;}
3054 if (o->InheritsFrom(TH1::Class())) { FillCollideGridTH1(o);
continue;}
3055 if (o->InheritsFrom(TGraph::Class())) { FillCollideGridTGraph(o);
continue;}
3056 if (o->InheritsFrom(TMultiGraph::Class())) {
3057 TList * grlist = ((TMultiGraph *)o)->GetListOfGraphs();
3058 TIter nextgraph(grlist);
3060 while ((og = nextgraph())) FillCollideGridTGraph(og);
3062 if (o->InheritsFrom(THStack::Class())) {
3063 TList * hlist = ((THStack *)o)->GetHists();
3064 TIter nexthist(hlist);
3066 while ((oh = nexthist())) {
3067 if (oh->InheritsFrom(TH1::Class())) FillCollideGridTH1(oh);
3078 Bool_t TPad::Collide(Int_t i, Int_t j, Int_t w, Int_t h)
3080 for (
int r=i; r<w+i; r++) {
3081 for (
int c=j; c<h+j; c++) {
3082 if (!fCollideGrid[r + c*fCGnx])
return kTRUE;
3098 Bool_t TPad::PlaceBox(TObject *o, Double_t w, Double_t h, Double_t &xl, Double_t &yb)
3102 Int_t iw = (int)(fCGnx*w);
3103 Int_t ih = (int)(fCGny*h);
3105 Int_t nxmax = fCGnx-iw-1;
3106 Int_t nymax = fCGny-ih-1;
3108 for (Int_t i = 0; i<nxmax; i++) {
3109 for (Int_t j = 0; j<=nymax; j++) {
3110 if (Collide(i,j,iw,ih)) {
3113 xl = (Double_t)(i)/(Double_t)(fCGnx);
3114 yb = (Double_t)(j)/(Double_t)(fCGny);
3122 #define NotFree(i, j) fCollideGrid[TMath::Max(TMath::Min(i+j*fCGnx,fCGnx*fCGny),0)] = kFALSE;
3127 void TPad::LineNotFree(Int_t x1, Int_t x2, Int_t y1, Int_t y2)
3135 for (i=x1+1; i<x2; i++) NotFree(i,y1);
3141 for (i=y1+1; i<y2; i++) NotFree(x1,i);
3146 if (TMath::Abs(x2-x1)>TMath::Abs(y2-y1)) {
3148 xt = x1; x1 = x2; x2 = xt;
3149 yt = y1; y1 = y2; y2 = yt;
3151 for (i=x1+1; i<x2; i++) {
3152 j = (Int_t)((Double_t)(y2-y1)*(Double_t)((i-x1)/(Double_t)(x2-x1))+y1);
3158 yt = y1; y1 = y2; y2 = yt;
3159 xt = x1; x1 = x2; x2 = xt;
3161 for (j=y1+1; j<y2; j++) {
3162 i = (Int_t)((Double_t)(x2-x1)*(Double_t)((j-y1)/(Double_t)(y2-y1))+x1);
3170 void TPad::FillCollideGridTBox(TObject *o)
3172 TBox *b = (TBox *)o;
3174 Double_t xs = (fX2-fX1)/fCGnx;
3175 Double_t ys = (fY2-fY1)/fCGny;
3177 Int_t x1 = (Int_t)((b->GetX1()-fX1)/xs);
3178 Int_t x2 = (Int_t)((b->GetX2()-fX1)/xs);
3179 Int_t y1 = (Int_t)((b->GetY1()-fY1)/ys);
3180 Int_t y2 = (Int_t)((b->GetY2()-fY1)/ys);
3181 for (
int i = x1; i<=x2; i++) {
3182 for (
int j = y1; j<=y2; j++) NotFree(i, j);
3187 void TPad::FillCollideGridTFrame(TObject *o)
3189 TFrame *f = (TFrame *)o;
3191 Double_t xs = (fX2-fX1)/fCGnx;
3192 Double_t ys = (fY2-fY1)/fCGny;
3194 Int_t x1 = (Int_t)((f->GetX1()-fX1)/xs);
3195 Int_t x2 = (Int_t)((f->GetX2()-fX1)/xs);
3196 Int_t y1 = (Int_t)((f->GetY1()-fY1)/ys);
3197 Int_t y2 = (Int_t)((f->GetY2()-fY1)/ys);
3200 for (i = x1; i<=x2; i++) {
3205 for (i = y1; i<=y2; i++) {
3213 void TPad::FillCollideGridTGraph(TObject *o)
3215 TGraph *g = (TGraph *)o;
3217 Double_t xs = (fX2-fX1)/fCGnx;
3218 Double_t ys = (fY2-fY1)/fCGny;
3220 Int_t n = g->GetN();
3221 Double_t x1, x2, y1, y2;
3223 for (Int_t i=1; i<n; i++) {
3224 g->GetPoint(i-1,x1,y1);
3225 g->GetPoint(i ,x2,y2);
3227 if (x1 > 0) x1 = TMath::Log10(x1);
3229 if (x2 > 0) x2 = TMath::Log10(x2);
3233 if (y1 > 0) y1 = TMath::Log10(y1);
3235 if (y2 > 0) y2 = TMath::Log10(y2);
3238 LineNotFree((
int)((x1-fX1)/xs), (
int)((x2-fX1)/xs),
3239 (
int)((y1-fY1)/ys), (
int)((y2-fY1)/ys));
3244 void TPad::FillCollideGridTH1(TObject *o)
3248 if (o->InheritsFrom(TH2::Class()))
return;
3249 if (o->InheritsFrom(TH3::Class()))
return;
3251 TString name = h->GetName();
3252 if (name.Index(
"hframe") >= 0)
return;
3254 Double_t xs = (fX2-fX1)/fCGnx;
3255 Double_t ys = (fY2-fY1)/fCGny;
3257 bool haserrors =
false;
3258 TString drawOption = h->GetDrawOption();
3259 drawOption.ToLower();
3260 drawOption.ReplaceAll(
"same",
"");
3262 if (drawOption.Index(
"hist") < 0) {
3263 if (drawOption.Index(
"e") >= 0) haserrors =
true;
3266 Int_t nx = h->GetNbinsX();
3269 Double_t x1l, y1l, y2l;
3271 for (i = 1; i<nx; i++) {
3273 x1l = h->GetBinCenter(i);
3275 if (x1l > 0) x1l = TMath::Log10(x1l);
3278 x1 = (Int_t)((x1l-fX1)/xs);
3279 y1l = h->GetBinContent(i)-h->GetBinErrorLow(i);
3281 if (y1l > 0) y1l = TMath::Log10(y1l);
3284 y1 = (Int_t)((y1l-fY1)/ys);
3285 y2l = h->GetBinContent(i)+h->GetBinErrorUp(i);
3287 if (y2l > 0) y2l = TMath::Log10(y2l);
3290 y2 = (Int_t)((y2l-fY1)/ys);
3291 for (j=y1; j<=y2; j++) {
3295 x1l = h->GetBinLowEdge(i);
3297 if (x1l > 0) x1l = TMath::Log10(x1l);
3300 x1 = (Int_t)((x1l-fX1)/xs);
3301 y1l = h->GetBinContent(i);
3303 if (y1l > 0) y1l = TMath::Log10(y1l);
3306 y1 = (Int_t)((y1l-fY1)/ys);
3308 x1l = h->GetBinLowEdge(i)+h->GetBinWidth(i);
3310 if (x1l > 0) x1l = TMath::Log10(x1l);
3313 x1 = (int)((x1l-fX1)/xs);
3318 TPaveStats *ps = (TPaveStats*)h->GetListOfFunctions()->FindObject(
"stats");
3319 if (ps) FillCollideGridTBox(ps);
3326 void TPad::DrawCollideGrid()
3328 auto box =
new TBox();
3329 box->SetFillColorAlpha(kRed,0.5);
3331 Double_t xs = (fX2-fX1)/fCGnx;
3332 Double_t ys = (fY2-fY1)/fCGny;
3334 Double_t X1L, X2L, Y1L, Y2L;
3338 Double_t X2 = X1+xs;
3340 for (
int i = 0; i<fCGnx; i++) {
3343 for (
int j = 0; j<fCGny; j++) {
3344 if (gPad->GetLogx()) {
3345 X1L = TMath::Power(10,X1);
3346 X2L = TMath::Power(10,X2);
3351 if (gPad->GetLogy()) {
3352 Y1L = TMath::Power(10,Y1);
3353 Y2L = TMath::Power(10,Y2);
3358 if (!fCollideGrid[i + j*fCGnx]) {
3359 box->SetFillColorAlpha(kBlack,t);
3360 box->DrawBox(X1L, Y1L, X2L, Y2L);
3362 box->SetFillColorAlpha(kRed,t);
3363 box->DrawBox(X1L, Y1L, X2L, Y2L);
3367 if (t==0.15) t = 0.1;
3379 Double_t TPad::PadtoX(Double_t x)
const
3381 if (fLogx && x < 50)
return Double_t(TMath::Exp(2.302585092994*x));
3388 Double_t TPad::PadtoY(Double_t y)
const
3390 if (fLogy && y < 50)
return Double_t(TMath::Exp(2.302585092994*y));
3397 Double_t TPad::XtoPad(Double_t x)
const
3400 if (x > 0) x = TMath::Log10(x);
3409 Double_t TPad::YtoPad(Double_t y)
const
3412 if (y > 0) y = TMath::Log10(y);
3421 void TPad::Paint(Option_t * )
3423 if (!fPrimitives) fPrimitives =
new TList;
3424 if (fViewer3D && fViewer3D->CanLoopOnPrimitives()) {
3425 fViewer3D->PadPaint(
this);
3427 if (GetGLDevice()!=-1 && gVirtualPS) {
3428 TPad *padsav = (TPad*)gPad;
3430 gGLManager->PrintViewer(GetViewer3D());
3436 if (fCanvas) TColor::SetGrayscale(fCanvas->IsGrayscale());
3438 TPad *padsav = (TPad*)gPad;
3443 PaintBorder(GetFillColor(), kTRUE);
3446 TObjOptLink *lnk = (TObjOptLink*)GetListOfPrimitives()->FirstLink();
3449 Bool_t began3DScene = kFALSE;
3451 obj = lnk->GetObject();
3454 if (!fViewer3D && obj->InheritsFrom(TAtt3D::Class())) {
3459 if (fViewer3D && !fViewer3D->BuildingScene()) {
3460 fViewer3D->BeginScene();
3461 began3DScene = kTRUE;
3464 obj->Paint(lnk->GetOption());
3465 lnk = (TObjOptLink*)lnk->Next();
3468 if (padsav) padsav->cd();
3475 fViewer3D->EndScene();
3483 void TPad::PaintBorder(Color_t color, Bool_t tops)
3492 if (!gROOT->IsBatch() && gVirtualX->InheritsFrom(
"TGCocoa") && GetPainter())
3493 GetPainter()->ClearDrawable();
3495 PaintBox(fX1,fY1,fX2,fY2);
3497 if (color < 0) color = -color;
3499 if (IsTransparent())
return;
3502 if (fBorderMode == 0)
return;
3503 Int_t bordersize = fBorderSize;
3504 if (bordersize <= 0) bordersize = 2;
3506 const Double_t realBsX = bordersize / (GetAbsWNDC() * GetWw()) * (fX2 - fX1);
3507 const Double_t realBsY = bordersize / (GetAbsHNDC() * GetWh()) * (fY2 - fY1);
3509 Short_t px1,py1,px2,py2;
3510 Double_t xl, xt, yl, yt;
3513 Color_t oldcolor = GetFillColor();
3514 SetFillColor(color);
3516 Color_t light = 0, dark = 0;
3518 light = TColor::GetColorBright(color);
3519 dark = TColor::GetColorDark(color);
3523 px1 = XtoPixel(fX1); py1 = YtoPixel(fY1);
3524 px2 = XtoPixel(fX2); py2 = YtoPixel(fY2);
3525 if (px1 < px2) {xl = fX1; xt = fX2; }
3526 else {xl = fX2; xt = fX1;}
3527 if (py1 > py2) {yl = fY1; yt = fY2;}
3528 else {yl = fY2; yt = fY1;}
3530 Double_t frameXs[7] = {}, frameYs[7] = {};
3534 frameXs[0] = xl; frameYs[0] = yl;
3535 frameXs[1] = xl + realBsX; frameYs[1] = yl + realBsY;
3536 frameXs[2] = frameXs[1]; frameYs[2] = yt - realBsY;
3537 frameXs[3] = xt - realBsX; frameYs[3] = frameYs[2];
3538 frameXs[4] = xt; frameYs[4] = yt;
3539 frameXs[5] = xl; frameYs[5] = yt;
3540 frameXs[6] = xl; frameYs[6] = yl;
3542 if (fBorderMode == -1) GetPainter()->SetFillColor(dark);
3543 else GetPainter()->SetFillColor(light);
3544 GetPainter()->DrawFillArea(7, frameXs, frameYs);
3547 frameXs[0] = xl; frameYs[0] = yl;
3548 frameXs[1] = xl + realBsX; frameYs[1] = yl + realBsY;
3549 frameXs[2] = xt - realBsX; frameYs[2] = frameYs[1];
3550 frameXs[3] = frameXs[2]; frameYs[3] = yt - realBsY;
3551 frameXs[4] = xt; frameYs[4] = yt;
3552 frameXs[5] = xt; frameYs[5] = yl;
3553 frameXs[6] = xl; frameYs[6] = yl;
3555 if (fBorderMode == -1) GetPainter()->SetFillColor(light);
3556 else GetPainter()->SetFillColor(dark);
3557 GetPainter()->DrawFillArea(7, frameXs, frameYs);
3560 if (InheritsFrom(TButton::Class()) && fBorderMode == -1) {
3561 if (TestBit(kFraming)) {
3562 if (GetFillColor() != 2) GetPainter()->SetLineColor(2);
3563 else GetPainter()->SetLineColor(4);
3564 GetPainter()->DrawBox(xl + realBsX, yl + realBsY, xt - realBsX, yt - realBsY, TVirtualPadPainter::kHollow);
3567 GetPainter()->SetFillColor(-1);
3568 SetFillColor(oldcolor);
3573 PaintBorderPS(xl, yl, xt, yt, fBorderMode, bordersize, dark, light);
3579 void TPad::PaintBorderPS(Double_t xl,Double_t yl,Double_t xt,Double_t yt,Int_t bmode,Int_t bsize,Int_t dark,Int_t light)
3581 if (!gVirtualPS)
return;
3582 gVirtualPS->DrawFrame(xl, yl, xt, yt, bmode,bsize,dark,light);
3588 void TPad::PaintDate()
3590 if (fCanvas ==
this && gStyle->GetOptDate()) {
3594 if (gStyle->GetOptDate() < 10) {
3596 dates = dt.AsString();
3597 }
else if (gStyle->GetOptDate() < 20) {
3599 strlcpy(iso,dt.AsSQLString(),16);
3603 dates = dt.AsSQLString();
3605 TText tdate(gStyle->GetDateX(),gStyle->GetDateY(),dates);
3606 tdate.SetTextSize( gStyle->GetAttDate()->GetTextSize());
3607 tdate.SetTextFont( gStyle->GetAttDate()->GetTextFont());
3608 tdate.SetTextColor(gStyle->GetAttDate()->GetTextColor());
3609 tdate.SetTextAlign(gStyle->GetAttDate()->GetTextAlign());
3610 tdate.SetTextAngle(gStyle->GetAttDate()->GetTextAngle());
3619 void TPad::PaintPadFrame(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax)
3621 if (!fPrimitives) fPrimitives =
new TList;
3622 TList *glist = GetListOfPrimitives();
3623 TFrame *frame = GetFrame();
3628 if (!glist->FindObject(fFrame)) {
3629 glist->AddFirst(frame);
3630 fFrame->SetBit(kMustCleanup);
3638 void TPad::PaintModified()
3640 if (fViewer3D && fViewer3D->CanLoopOnPrimitives()) {
3642 fViewer3D->PadPaint(
this);
3645 TList *pList = GetListOfPrimitives();
3646 TObjOptLink *lnk = 0;
3647 if (pList) lnk = (TObjOptLink*)pList->FirstLink();
3650 obj = lnk->GetObject();
3651 if (obj->InheritsFrom(TPad::Class()))
3652 ((TPad*)obj)->PaintModified();
3653 lnk = (TObjOptLink*)lnk->Next();
3658 if (fCanvas) TColor::SetGrayscale(fCanvas->IsGrayscale());
3660 TPad *padsav = (TPad*)gPad;
3661 TVirtualPS *saveps = gVirtualPS;
3663 if (gVirtualPS->TestBit(kPrintingPS)) gVirtualPS = 0;
3667 if (IsModified() || IsTransparent()) {
3668 if ((fFillStyle < 3026) && (fFillStyle > 3000)) {
3669 if (!gPad->IsBatch()) GetPainter()->ClearDrawable();
3671 PaintBorder(GetFillColor(), kTRUE);
3676 TList *pList = GetListOfPrimitives();
3677 TObjOptLink *lnk = 0;
3678 if (pList) lnk = (TObjOptLink*)pList->FirstLink();
3681 Bool_t began3DScene = kFALSE;
3684 obj = lnk->GetObject();
3685 if (obj->InheritsFrom(TPad::Class())) {
3686 ((TPad*)obj)->PaintModified();
3687 }
else if (IsModified() || IsTransparent()) {
3691 if (!fViewer3D && obj->InheritsFrom(TAtt3D::Class())) {
3696 if (fViewer3D && !fViewer3D->BuildingScene()) {
3697 fViewer3D->BeginScene();
3698 began3DScene = kTRUE;
3701 obj->Paint(lnk->GetOption());
3703 lnk = (TObjOptLink*)lnk->Next();
3706 if (padsav) padsav->cd();
3713 fViewer3D->EndScene();
3716 gVirtualPS = saveps;
3725 void TPad::PaintBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Option_t *option)
3727 if (!gPad->IsBatch()) {
3728 Int_t style0 = GetPainter()->GetFillStyle();
3729 Int_t style = style0;
3730 if (option[0] ==
's') {
3731 GetPainter()->SetFillStyle(0);
3735 if (style > 3000 && style < 4000) {
3738 GetPainter()->DrawBox(x1, y1, x2, y2, TVirtualPadPainter::kFilled);
3741 if (style >= 3100 && style < 4000) {
3742 Double_t xb[4], yb[4];
3743 xb[0] = x1; xb[1] = x1; xb[2] = x2; xb[3] = x2;
3744 yb[0] = y1; yb[1] = y2; yb[2] = y2; yb[3] = y1;
3745 PaintFillAreaHatches(4, xb, yb, style);
3749 if (GetPainter()->GetFillColor() == 10) {
3750 GetPainter()->SetFillColor(1);
3751 GetPainter()->DrawBox(x1, y1, x2, y2, TVirtualPadPainter::kFilled);
3752 GetPainter()->SetFillColor(10);
3754 }
else if (style >= 4000 && style <= 4100) {
3759 if (
this == fMother) {
3761 const Style_t oldFillStyle = GetPainter()->GetFillStyle();
3762 if (gVirtualX->InheritsFrom(
"TGCocoa"))
3763 GetPainter()->SetFillStyle(1000);
3764 GetPainter()->DrawBox(x1, y1, x2, y2, TVirtualPadPainter::kFilled);
3765 if (gVirtualX->InheritsFrom(
"TGCocoa"))
3766 GetPainter()->SetFillStyle(oldFillStyle);
3770 XYtoAbsPixel(fX1, fY2, px, py);
3773 fMother->CopyBackgroundPixmap(px, py);
3774 CopyBackgroundPixmaps(fMother,
this, px, py);
3777 GetPainter()->SetOpacity(style - 4000);
3779 }
else if (style >= 1000 && style <= 1999) {
3780 GetPainter()->DrawBox(x1, y1, x2, y2, TVirtualPadPainter::kFilled);
3782 GetPainter()->DrawBox(x1, y1, x2, y2, TVirtualPadPainter::kHollow);
3784 if (option[0] ==
'l') GetPainter()->DrawBox(x1, y1, x2, y2, TVirtualPadPainter::kHollow);
3786 GetPainter()->DrawBox(x1, y1, x2, y2, TVirtualPadPainter::kHollow);
3787 if (option[0] ==
's') GetPainter()->SetFillStyle(style0);
3792 Int_t style0 = gVirtualPS->GetFillStyle();
3793 if (option[0] ==
's') {
3794 gVirtualPS->SetFillStyle(0);
3796 if (style0 >= 3100 && style0 < 4000) {
3797 Double_t xb[4], yb[4];
3798 xb[0] = x1; xb[1] = x1; xb[2] = x2; xb[3] = x2;
3799 yb[0] = y1; yb[1] = y2; yb[2] = y2; yb[3] = y1;
3800 PaintFillAreaHatches(4, xb, yb, style0);
3804 gVirtualPS->DrawBox(x1, y1, x2, y2);
3805 if (option[0] ==
'l') {
3806 gVirtualPS->SetFillStyle(0);
3807 gVirtualPS->DrawBox(x1, y1, x2, y2);
3809 if (option[0] ==
's' || option[0] ==
'l') gVirtualPS->SetFillStyle(style0);
3819 void TPad::CopyBackgroundPixmaps(TPad *start, TPad *stop, Int_t x, Int_t y)
3822 if (!fPrimitives) fPrimitives =
new TList;
3823 TIter next(start->GetListOfPrimitives());
3824 while ((obj = next())) {
3825 if (obj->InheritsFrom(TPad::Class())) {
3826 if (obj == stop)
break;
3827 ((TPad*)obj)->CopyBackgroundPixmap(x, y);
3828 ((TPad*)obj)->CopyBackgroundPixmaps((TPad*)obj, stop, x, y);
3836 void TPad::CopyBackgroundPixmap(Int_t x, Int_t y)
3839 XYtoAbsPixel(fX1, fY2, px, py);
3840 GetPainter()->CopyDrawable(GetPixmapID(), px-x, py-y);
3845 void TPad::PaintFillArea(Int_t, Float_t *, Float_t *, Option_t *)
3847 Warning(
"TPad::PaintFillArea",
"Float_t signature is obsolete. Use Double_t signature.");
3853 void TPad::PaintFillArea(Int_t nn, Double_t *xx, Double_t *yy, Option_t *)
3857 Double_t xmin,xmax,ymin,ymax;
3858 if (TestBit(TGraph::kClipFrame)) {
3859 xmin = fUxmin; ymin = fUymin; xmax = fUxmax; ymax = fUymax;
3861 xmin = fX1; ymin = fY1; xmax = fX2; ymax = fY2;
3865 std::vector<Double_t> x(nc, 0.);
3866 std::vector<Double_t> y(nc, 0.);
3868 n = ClipPolygon(nn, xx, yy, nc, &x.front(), &y.front(),xmin,ymin,xmax,ymax);
3873 Int_t fillstyle = GetPainter()->GetFillStyle();
3874 if (gPad->IsBatch() && gVirtualPS) fillstyle = gVirtualPS->GetFillStyle();
3875 if (fillstyle >= 3100 && fillstyle < 4000) {
3876 PaintFillAreaHatches(nn, &x.front(), &y.front(), fillstyle);
3880 if (!gPad->IsBatch())
3882 GetPainter()->DrawFillArea(n, &x.front(), &y.front());
3885 gVirtualPS->DrawPS(-n, &x.front(), &y.front());
3893 void TPad::PaintFillAreaNDC(Int_t n, Double_t *x, Double_t *y, Option_t *option)
3895 auto xw =
new Double_t[n];
3896 auto yw =
new Double_t[n];
3897 for (
int i=0; i<n; i++) {
3898 xw[i] = fX1 + x[i]*(fX2 - fX1);
3899 yw[i] = fY1 + y[i]*(fY2 - fY1);
3901 PaintFillArea(n, xw, yw, option);
3939 void TPad::PaintFillAreaHatches(Int_t nn, Double_t *xx, Double_t *yy, Int_t FillStyle)
3941 static Double_t ang1[10] = { 0., 10., 20., 30., 45.,5., 60., 70., 80., 89.99};
3942 static Double_t ang2[10] = {180.,170.,160.,150.,135.,5.,120.,110.,100., 89.99};
3944 Int_t fasi = FillStyle%1000;
3945 Int_t idSPA = (Int_t)(fasi/100);
3946 Int_t iAng2 = (Int_t)((fasi-100*idSPA)/10);
3947 Int_t iAng1 = fasi%10;
3948 Double_t dy = 0.003*(Double_t)(idSPA)*gStyle->GetHatchesSpacing();
3949 Int_t lw = gStyle->GetHatchesLineWidth();
3955 if (!gPad->IsBatch()) {
3956 lws = GetPainter()->GetLineWidth();
3957 lss = GetPainter()->GetLineStyle();
3958 lcs = GetPainter()->GetLineColor();
3961 lws = gVirtualPS->GetLineWidth();
3962 lss = gVirtualPS->GetLineStyle();
3963 lcs = gVirtualPS->GetLineColor();
3968 if (!gPad->IsBatch()) {
3969 GetPainter()->SetLineStyle(1);
3970 GetPainter()->SetLineWidth(Short_t(lw));
3971 GetPainter()->SetLineColor(GetPainter()->GetFillColor());
3974 gVirtualPS->SetLineStyle(1);
3975 gVirtualPS->SetLineWidth(Short_t(lw));
3976 gVirtualPS->SetLineColor(gVirtualPS->GetFillColor());
3980 if (ang1[iAng1] != 5.) PaintHatches(dy, ang1[iAng1], nn, xx, yy);
3981 if (ang2[iAng2] != 5.) PaintHatches(dy, ang2[iAng2], nn, xx, yy);
3984 if (!gPad->IsBatch()) {
3985 GetPainter()->SetLineStyle(lss);
3986 GetPainter()->SetLineWidth(lws);
3987 GetPainter()->SetLineColor(lcs);
3990 gVirtualPS->SetLineStyle(lss);
3991 gVirtualPS->SetLineWidth(lws);
3992 gVirtualPS->SetLineColor(lcs);
4001 void TPad::PaintHatches(Double_t dy, Double_t angle,
4002 Int_t nn, Double_t *xx, Double_t *yy)
4004 Int_t i, i1, i2, nbi, m, inv;
4005 Double_t ratiox, ratioy, ymin, ymax, yrot, ycur;
4006 const Double_t angr = TMath::Pi()*(180.-angle)/180.;
4007 const Double_t epsil = 0.0001;
4008 const Int_t maxnbi = 100;
4009 Double_t xli[maxnbi], xlh[2], ylh[2], xt1, xt2, yt1, yt2;
4010 Double_t ll, x, y, x1, x2, y1, y2, a, b, xi, xip, xin, yi, yip;
4012 Double_t rwxmin = gPad->GetX1();
4013 Double_t rwxmax = gPad->GetX2();
4014 Double_t rwymin = gPad->GetY1();
4015 Double_t rwymax = gPad->GetY2();
4016 ratiox = 1./(rwxmax-rwxmin);
4017 ratioy = 1./(rwymax-rwymin);
4019 Double_t sina = TMath::Sin(angr), sinb;
4020 Double_t cosa = TMath::Cos(angr), cosb;
4021 if (TMath::Abs(cosa) <= epsil) cosa=0.;
4022 if (TMath::Abs(sina) <= epsil) sina=0.;
4027 Int_t iw = gPad->GetWw();
4028 Int_t ih = gPad->GetWh();
4029 Double_t x1p,y1p,x2p,y2p;
4030 gPad->GetPadPar(x1p,y1p,x2p,y2p);
4031 iw = (Int_t)(iw*x2p)-(Int_t)(iw*x1p);
4032 ih = (Int_t)(ih*y2p)-(Int_t)(ih*y1p);
4033 Double_t wndc = TMath::Min(1.,(Double_t)iw/(Double_t)ih);
4034 Double_t hndc = TMath::Min(1.,(Double_t)ih/(Double_t)iw);
4039 for (i=1; i<=nn; i++) {
4040 x = wndc*ratiox*(xx[i-1]-rwxmin);
4041 y = hndc*ratioy*(yy[i-1]-rwymin);
4042 yrot = sina*x+cosa*y;
4043 if (yrot > ymax) ymax = yrot;
4044 if (yrot < ymin) ymin = yrot;
4046 ymax = (Double_t)((Int_t)(ymax/dy))*dy;
4048 for (ycur=ymax; ycur>=ymin; ycur=ycur-dy) {
4050 for (i=2; i<=nn+1; i++) {
4053 if (i == nn+1) i2=1;
4054 x1 = wndc*ratiox*(xx[i1-1]-rwxmin);
4055 y1 = hndc*ratioy*(yy[i1-1]-rwymin);
4056 x2 = wndc*ratiox*(xx[i2-1]-rwxmin);
4057 y2 = hndc*ratioy*(yy[i2-1]-rwymin);
4058 xt1 = cosa*x1-sina*y1;
4059 yt1 = sina*x1+cosa*y1;
4060 xt2 = cosa*x2-sina*y2;
4061 yt2 = sina*x2+cosa*y2;
4072 if ((yi <= ycur) && (ycur < yip)) {
4074 if (nbi >= maxnbi)
return;
4084 if (nbi >= maxnbi)
return;
4087 if (nbi >= maxnbi)
return;
4094 a = (yt1-yt2)/(xt1-xt2);
4095 b = (yt2*xt1-xt2*yt1)/(xt1-xt2);
4104 if ((xi <= xin) && (xin < xip) &&
4105 (TMath::Min(yt1,yt2) <= ycur) &&
4106 (ycur < TMath::Max(yt1,yt2))) {
4108 if (nbi >= maxnbi)
return;
4117 for (i=1; i<=m; i++) {
4118 if (xli[i] < xli[i-1]) {
4126 if (inv == 0)
goto L50;
4132 if (nbi%2 != 0)
continue;
4134 for (i=1; i<=nbi; i=i+2) {
4136 xlh[0] = cosb*xli[i-1]-sinb*ycur;
4137 ylh[0] = sinb*xli[i-1]+cosb*ycur;
4138 xlh[1] = cosb*xli[i] -sinb*ycur;
4139 ylh[1] = sinb*xli[i] +cosb*ycur;
4141 xlh[0] = (xlh[0]/wndc)*(rwxmax-rwxmin)+rwxmin;
4142 ylh[0] = (ylh[0]/hndc)*(rwymax-rwymin)+rwymin;
4143 xlh[1] = (xlh[1]/wndc)*(rwxmax-rwxmin)+rwxmin;
4144 ylh[1] = (ylh[1]/hndc)*(rwymax-rwymin)+rwymin;
4145 gPad->PaintLine(xlh[0], ylh[0], xlh[1], ylh[1]);
4153 void TPad::PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
4155 Double_t x[2], y[2];
4156 x[0] = x1; x[1] = x2; y[0] = y1; y[1] = y2;
4159 if (TestBit(TGraph::kClipFrame)) {
4160 if (Clip(x,y,fUxmin,fUymin,fUxmax,fUymax) == 2)
return;
4162 if (Clip(x,y,fX1,fY1,fX2,fY2) == 2)
return;
4165 if (!gPad->IsBatch())
4166 GetPainter()->DrawLine(x[0], y[0], x[1], y[1]);
4169 gVirtualPS->DrawPS(2, x, y);
4178 void TPad::PaintLineNDC(Double_t u1, Double_t v1,Double_t u2, Double_t v2)
4180 static Double_t xw[2], yw[2];
4181 if (!gPad->IsBatch())
4182 GetPainter()->DrawLineNDC(u1, v1, u2, v2);
4185 xw[0] = fX1 + u1*(fX2 - fX1);
4186 xw[1] = fX1 + u2*(fX2 - fX1);
4187 yw[0] = fY1 + v1*(fY2 - fY1);
4188 yw[1] = fY1 + v2*(fY2 - fY1);
4189 gVirtualPS->DrawPS(2, xw, yw);
4198 void TPad::PaintLine3D(Float_t *p1, Float_t *p2)
4206 for (i=0;i<3;i++) temp[i] = p1[i];
4207 fView->WCtoNDC(temp, &xpad[0]);
4208 for (i=0;i<3;i++) temp[i] = p2[i];
4209 fView->WCtoNDC(temp, &xpad[3]);
4210 PaintLine(xpad[0],xpad[1],xpad[3],xpad[4]);
4216 void TPad::PaintLine3D(Double_t *p1, Double_t *p2)
4224 for (i=0;i<3;i++) temp[i] = p1[i];
4225 fView->WCtoNDC(temp, &xpad[0]);
4226 for (i=0;i<3;i++) temp[i] = p2[i];
4227 fView->WCtoNDC(temp, &xpad[3]);
4228 PaintLine(xpad[0],xpad[1],xpad[3],xpad[4]);
4234 void TPad::PaintPolyLine(Int_t n, Float_t *x, Float_t *y, Option_t *)
4238 Double_t xmin,xmax,ymin,ymax;
4239 if (TestBit(TGraph::kClipFrame)) {
4240 xmin = fUxmin; ymin = fUymin; xmax = fUxmax; ymax = fUymax;
4242 xmin = fX1; ymin = fY1; xmax = fX2; ymax = fY2;
4244 Int_t i, i1=-1,np=1;
4245 for (i=0; i<n-1; i++) {
4250 Int_t iclip = Clip(&x[i],&y[i],xmin,ymin,xmax,ymax);
4257 if (iclip == 0 && i < n-2)
continue;
4258 if (!gPad->IsBatch())
4259 GetPainter()->DrawPolyLine(np, &x[i1], &y[i1]);
4261 gVirtualPS->DrawPS(np, &x[i1], &y[i1]);
4281 void TPad::PaintPolyLine(Int_t n, Double_t *x, Double_t *y, Option_t *option)
4285 Double_t xmin,xmax,ymin,ymax;
4286 Bool_t mustClip = kTRUE;
4287 if (TestBit(TGraph::kClipFrame)) {
4288 xmin = fUxmin; ymin = fUymin; xmax = fUxmax; ymax = fUymax;
4290 xmin = fX1; ymin = fY1; xmax = fX2; ymax = fY2;
4291 if (option && (option[0] ==
'C')) mustClip = kFALSE;
4294 Int_t i, i1=-1, np=1, iclip=0;
4296 for (i=0; i < n-1; i++) {
4302 iclip = Clip(&x[i],&y[i],xmin,ymin,xmax,ymax);
4310 if (iclip == 0 && i < n-2)
continue;
4311 if (!gPad->IsBatch())
4312 GetPainter()->DrawPolyLine(np, &x[i1], &y[i1]);
4314 gVirtualPS->DrawPS(np, &x[i1], &y[i1]);
4332 void TPad::PaintPolyLineNDC(Int_t n, Double_t *x, Double_t *y, Option_t *)
4336 if (!gPad->IsBatch())
4337 GetPainter()->DrawPolyLineNDC(n, x, y);
4340 Double_t *xw =
new Double_t[n];
4341 Double_t *yw =
new Double_t[n];
4342 for (Int_t i=0; i<n; i++) {
4343 xw[i] = fX1 + x[i]*(fX2 - fX1);
4344 yw[i] = fY1 + y[i]*(fY2 - fY1);
4346 gVirtualPS->DrawPS(n, xw, yw);
4356 void TPad::PaintPolyLine3D(Int_t n, Double_t *p)
4361 for (Int_t i = 1; i < n; i++)
4362 PaintLine3D(&p[3*i-3], &p[3*i]);
4370 void TPad::PaintPolyMarker(Int_t nn, Float_t *x, Float_t *y, Option_t *)
4372 Int_t n = TMath::Abs(nn);
4373 Double_t xmin,xmax,ymin,ymax;
4374 if (nn > 0 || TestBit(TGraph::kClipFrame)) {
4375 xmin = fUxmin; ymin = fUymin; xmax = fUxmax; ymax = fUymax;
4377 xmin = fX1; ymin = fY1; xmax = fX2; ymax = fY2;
4380 for (i=0; i<n; i++) {
4381 if (x[i] >= xmin && x[i] <= xmax && y[i] >= ymin && y[i] <= ymax) {
4384 if (i < n-1)
continue;
4386 if (np == 0)
continue;
4387 if (!gPad->IsBatch())
4388 GetPainter()->DrawPolyMarker(np, &x[i1], &y[i1]);
4390 gVirtualPS->DrawPolyMarker(np, &x[i1], &y[i1]);
4401 void TPad::PaintPolyMarker(Int_t nn, Double_t *x, Double_t *y, Option_t *)
4403 Int_t n = TMath::Abs(nn);
4404 Double_t xmin,xmax,ymin,ymax;
4405 if (nn > 0 || TestBit(TGraph::kClipFrame)) {
4406 xmin = fUxmin; ymin = fUymin; xmax = fUxmax; ymax = fUymax;
4408 xmin = fX1; ymin = fY1; xmax = fX2; ymax = fY2;
4411 for (i=0; i<n; i++) {
4412 if (x[i] >= xmin && x[i] <= xmax && y[i] >= ymin && y[i] <= ymax) {
4415 if (i < n-1)
continue;
4417 if (np == 0)
continue;
4418 if (!gPad->IsBatch())
4419 GetPainter()->DrawPolyMarker(np, &x[i1], &y[i1]);
4421 gVirtualPS->DrawPolyMarker(np, &x[i1], &y[i1]);
4432 void TPad::PaintText(Double_t x, Double_t y,
const char *text)
4436 if (!gPad->IsBatch())
4437 GetPainter()->DrawText(x, y, text, TVirtualPadPainter::kClear);
4439 if (gVirtualPS) gVirtualPS->Text(x, y, text);
4445 void TPad::PaintText(Double_t x, Double_t y,
const wchar_t *text)
4449 if (!gPad->IsBatch())
4450 GetPainter()->DrawText(x, y, text, TVirtualPadPainter::kClear);
4452 if (gVirtualPS) gVirtualPS->Text(x, y, text);
4458 void TPad::PaintTextNDC(Double_t u, Double_t v,
const char *text)
4462 if (!gPad->IsBatch())
4463 GetPainter()->DrawTextNDC(u, v, text, TVirtualPadPainter::kClear);
4466 Double_t x = fX1 + u*(fX2 - fX1);
4467 Double_t y = fY1 + v*(fY2 - fY1);
4468 gVirtualPS->Text(x, y, text);
4475 void TPad::PaintTextNDC(Double_t u, Double_t v,
const wchar_t *text)
4479 if (!gPad->IsBatch())
4480 GetPainter()->DrawTextNDC(u, v, text, TVirtualPadPainter::kClear);
4483 Double_t x = fX1 + u*(fX2 - fX1);
4484 Double_t y = fY1 + v*(fY2 - fY1);
4485 gVirtualPS->Text(x, y, text);
4502 TPad *TPad::Pick(Int_t px, Int_t py, TObjLink *&pickobj)
4507 if (gPad == 0)
return 0;
4508 if (GetListOfPrimitives() == 0)
return 0;
4512 Double_t x = AbsPixeltoX(px);
4513 Double_t y = AbsPixeltoY(py);
4514 if (
this != gPad->GetCanvas()) {
4515 if (!((x >= fX1 && x <= fX2) && (y >= fY1 && y <= fY2)))
return 0;
4519 static TObjOptLink dummyLink(0,
"");
4520 TPad *padsav = (TPad*)gPad;
4523 TPad *picked =
this;
4525 if (DistancetoPrimitive(px,py) < fgMaxPickDistance) {
4526 dummyLink.SetObject(
this);
4527 pickobj = &dummyLink;
4535 Bool_t gotPrim = kFALSE;
4536 TObjLink *lnk = GetListOfPrimitives()->LastLink();
4545 TObject *obj = lnk->GetObject();
4549 if (obj->InheritsFrom(TAtt3D::Class()) && fEmbeddedGL) {
4555 if (obj->InheritsFrom(TPad::Class())) {
4556 pick = ((TPad*)obj)->Pick(px, py, pickobj);
4561 }
else if (!gROOT->GetEditorMode()) {
4563 if (!obj->TestBit(kCannotPick)) {
4564 dist = obj->DistancetoPrimitive(px, py);
4565 if (dist < fgMaxPickDistance) {
4568 if (dist == 0)
break;
4583 if (fView && !gotPrim) {
4584 Double_t dx = 0.05*(fUxmax-fUxmin);
4585 if ((x > fUxmin + dx) && (x < fUxmax-dx)) {
4591 py -= Int_t((1 - GetHNDC() - GetYlowNDC()) * GetWh());
4592 px -= Int_t(GetXlowNDC() * GetWw());
4593 fViewer3D->DistancetoPrimitive(px, py);
4596 dummyLink.SetObject(fView);
4600 if (picked->InheritsFrom(TButton::Class())) {
4601 TButton *button = (TButton*)picked;
4602 if (!button->IsEditable()) pickobj = 0;
4605 if (TestBit(kCannotPick)) {
4607 if (picked ==
this) {
4623 if (!fMother)
return;
4624 if (!fMother->TestBit(kNotDeleted))
return;
4625 if (!fPrimitives) fPrimitives =
new TList;
4626 if (
this == fMother->GetListOfPrimitives()->Last())
return;
4628 TListIter next(fMother->GetListOfPrimitives());
4630 while ((obj = next()))
4632 char *opt = StrDup(next.GetOption());
4633 fMother->GetListOfPrimitives()->Remove(
this);
4634 fMother->GetListOfPrimitives()->AddLast(
this, opt);
4657 void TPad::Print(
const char *filename)
const
4659 ((TPad*)
this)->SaveAs(filename);
4666 static Bool_t ContainsTImage(TList *li)
4671 while ((obj = next())) {
4672 if (obj->InheritsFrom(TImage::Class())) {
4674 }
else if (obj->InheritsFrom(TPad::Class())) {
4675 if (ContainsTImage(((TPad*)obj)->GetListOfPrimitives())) {
4824 void TPad::Print(
const char *filenam, Option_t *option)
4826 TString psname, fs1 = filenam;
4830 if (fs1.EndsWith(
"[")) {
4831 fs1.Replace((fs1.Length()-1),1,
" ");
4832 gSystem->ExpandPathName(fs1);
4833 fs1.Replace((fs1.Length()-1),1,
"[");
4834 }
else if (fs1.EndsWith(
"]")) {
4835 fs1.Replace((fs1.Length()-1),1,
" ");
4836 gSystem->ExpandPathName(fs1);
4837 fs1.Replace((fs1.Length()-1),1,
"]");
4839 gSystem->ExpandPathName(fs1);
4843 const char *opt_default =
"ps";
4845 TString opt = !option ? opt_default : option;
4846 Bool_t image = kFALSE;
4848 if (!fs1.Length()) {
4856 if (psname.BeginsWith(
'.') && (psname.Contains(
'/') == 0)) {
4859 psname.Prepend(
"/");
4860 psname.Prepend(gEnv->GetValue(
"Canvas.PrintDirectory",
"."));
4862 if (!gPad->IsBatch() && fCanvas)
4863 GetPainter()->SelectDrawable(GetCanvasID());
4866 TImage::EImageFileTypes gtype = TImage::kUnknown;
4867 if (strstr(opt,
"gif+")) {
4868 gtype = TImage::kAnimGif;
4870 }
else if (strstr(opt,
"gif")) {
4871 gtype = TImage::kGif;
4873 }
else if (strstr(opt,
"png")) {
4874 gtype = TImage::kPng;
4876 }
else if (strstr(opt,
"jpg")) {
4877 gtype = TImage::kJpeg;
4879 }
else if (strstr(opt,
"tiff")) {
4880 gtype = TImage::kTiff;
4882 }
else if (strstr(opt,
"xpm")) {
4883 gtype = TImage::kXpm;
4885 }
else if (strstr(opt,
"bmp")) {
4886 gtype = TImage::kBmp;
4891 if (!GetCanvas())
return;
4892 if (!gROOT->IsBatch() && image) {
4893 if ((gtype == TImage::kGif) && !ContainsTImage(fPrimitives)) {
4894 wid = (
this == GetCanvas()) ? GetCanvas()->GetCanvasID() : GetPixmapID();
4895 Color_t hc = gPad->GetCanvas()->GetHighLightColor();
4896 gPad->GetCanvas()->SetHighLightColor(-1);
4899 GetPainter()->SelectDrawable(wid);
4900 GetPainter()->SaveImage(
this, psname.Data(), gtype);
4901 if (!gSystem->AccessPathName(psname.Data())) {
4902 Info(
"Print",
"GIF file %s has been created", psname.Data());
4904 gPad->GetCanvas()->SetHighLightColor(hc);
4907 if (gtype != TImage::kUnknown) {
4908 Color_t hc = gPad->GetCanvas()->GetHighLightColor();
4909 gPad->GetCanvas()->SetHighLightColor(-1);
4912 gVirtualX->Update(1);
4914 GetPainter()->SaveImage(
this, psname, gtype);
4915 if (!gSystem->AccessPathName(psname)) {
4916 Info(
"Print",
"file %s has been created", psname.Data());
4918 gPad->GetCanvas()->SetHighLightColor(hc);
4920 Warning(
"Print",
"Unsupported image format %s", psname.Data());
4926 if (strstr(opt,
"cxx")) {
4927 GetCanvas()->SaveSource(psname,
"");
4932 if (strstr(opt,
"root")) {
4933 if (gDirectory) gDirectory->SaveObjectAs(
this,psname.Data(),
"");
4938 if (strstr(opt,
"xml")) {
4940 if (gDirectory) gDirectory->SaveObjectAs(
this,psname.Data(),
"");
4945 if (strstr(opt,
"json")) {
4946 if (gDirectory) gDirectory->SaveObjectAs(
this,psname.Data(),
"");
4951 if (strstr(opt,
"svg")) {
4952 gVirtualPS = (TVirtualPS*)gROOT->GetListOfSpecials()->FindObject(psname);
4954 Bool_t noScreen = kFALSE;
4955 if (!GetCanvas()->IsBatch() && GetCanvas()->GetCanvasID() == -1) {
4957 GetCanvas()->SetBatch(kTRUE);
4960 TPad *padsav = (TPad*)gPad;
4966 if ((h = gROOT->GetPluginManager()->FindHandler(
"TVirtualPS",
"svg"))) {
4967 if (h->LoadPlugin() == -1)
4975 gVirtualPS->SetName(psname);
4976 gVirtualPS->Open(psname);
4977 gVirtualPS->SetBit(kPrintingPS);
4978 gVirtualPS->NewPage();
4981 if (noScreen) GetCanvas()->SetBatch(kFALSE);
4983 if (!gSystem->AccessPathName(psname)) Info(
"Print",
"SVG file %s has been created", psname.Data());
4993 if (strstr(opt,
"tex")) {
4994 gVirtualPS = (TVirtualPS*)gROOT->GetListOfSpecials()->FindObject(psname);
4996 Bool_t noScreen = kFALSE;
4997 if (!GetCanvas()->IsBatch() && GetCanvas()->GetCanvasID() == -1) {
4999 GetCanvas()->SetBatch(kTRUE);
5002 TPad *padsav = (TPad*)gPad;
5008 if ((h = gROOT->GetPluginManager()->FindHandler(
"TVirtualPS",
"tex"))) {
5009 if (h->LoadPlugin() == -1)
5017 gVirtualPS->SetName(psname);
5018 gVirtualPS->Open(psname);
5019 gVirtualPS->SetBit(kPrintingPS);
5020 gVirtualPS->NewPage();
5023 if (noScreen) GetCanvas()->SetBatch(kFALSE);
5025 if (!gSystem->AccessPathName(psname)) Info(
"Print",
"TeX file %s has been created", psname.Data());
5039 Bool_t mustOpen = kTRUE;
5040 Bool_t mustClose = kTRUE;
5041 Bool_t copen=kFALSE, cclose=kFALSE, copenb=kFALSE, ccloseb=kFALSE;
5044 copen = psname.EndsWith(
"(");
if (copen) psname[psname.Length()-1] = 0;
5045 cclose = psname.EndsWith(
")");
if (cclose) psname[psname.Length()-1] = 0;
5046 copenb = psname.EndsWith(
"[");
if (copenb) psname[psname.Length()-1] = 0;
5047 ccloseb = psname.EndsWith(
"]");
if (ccloseb) psname[psname.Length()-1] = 0;
5049 gVirtualPS = (TVirtualPS*)gROOT->GetListOfSpecials()->FindObject(psname);
5050 if (gVirtualPS) {mustOpen = kFALSE; mustClose = kFALSE;}
5051 if (copen || copenb) mustClose = kFALSE;
5052 if (cclose || ccloseb) mustClose = kTRUE;
5054 Bool_t noScreen = kFALSE;
5055 if (!GetCanvas()->IsBatch() && GetCanvas()->GetCanvasID() == -1) {
5057 GetCanvas()->SetBatch(kTRUE);
5060 Double_t xcanvas = GetCanvas()->XtoPixel(GetCanvas()->GetX2());
5061 Double_t ycanvas = GetCanvas()->YtoPixel(GetCanvas()->GetY1());
5062 Double_t ratio = ycanvas/xcanvas;
5063 if (ratio < 1) pstype = 112;
5064 if (strstr(opt,
"Portrait")) pstype = 111;
5065 if (strstr(opt,
"Landscape")) pstype = 112;
5066 if (strstr(opt,
"eps")) pstype = 113;
5067 if (strstr(opt,
"Preview")) pstype = 113;
5068 TPad *padsav = (TPad*)gPad;
5070 TVirtualPS *psave = gVirtualPS;
5072 if (!gVirtualPS || mustOpen) {
5075 if (strstr(opt,
"pdf") || strstr(opt,
"Title:") || strstr(opt,
"EmbedFonts")) {
5076 if ((h = gROOT->GetPluginManager()->FindHandler(
"TVirtualPS",
"pdf"))) {
5077 if (h->LoadPlugin() == -1)
return;
5082 if ((h = gROOT->GetPluginManager()->FindHandler(
"TVirtualPS",
"image"))) {
5083 if (h->LoadPlugin() == -1)
return;
5087 if ((h = gROOT->GetPluginManager()->FindHandler(
"TVirtualPS",
"ps"))) {
5088 if (h->LoadPlugin() == -1)
return;
5094 if (gVirtualPS) gVirtualPS->SetName(psname);
5095 const Ssiz_t titlePos = opt.Index(
"Title:");
5096 if (titlePos != kNPOS) {
5097 if (gVirtualPS) gVirtualPS->SetTitle(opt.Data()+titlePos+6);
5098 opt.Replace(titlePos,opt.Length(),
"pdf");
5100 if (gVirtualPS) gVirtualPS->Open(psname,pstype);
5101 if (gVirtualPS) gVirtualPS->SetBit(kPrintingPS);
5103 if (!strstr(opt,
"pdf") || image) {
5104 if (gVirtualPS) gVirtualPS->NewPage();
5108 if (noScreen) GetCanvas()->SetBatch(kFALSE);
5111 gROOT->GetListOfSpecials()->Remove(gVirtualPS);
5115 gROOT->GetListOfSpecials()->Add(gVirtualPS);
5119 if (!gSystem->AccessPathName(psname)) {
5120 if (!copen) Info(
"Print",
"%s file %s has been created", opt.Data(), psname.Data());
5121 else Info(
"Print",
"%s file %s has been created using the current canvas", opt.Data(), psname.Data());
5126 gVirtualPS->NewPage();
5129 const Ssiz_t titlePos = opt.Index(
"Title:");
5130 if (titlePos != kNPOS) {
5131 gVirtualPS->SetTitle(opt.Data()+titlePos+6);
5132 opt.Replace(titlePos,opt.Length(),
"pdf");
5134 gVirtualPS->SetTitle(
"PDF");
5137 if (cclose) Info(
"Print",
"Current canvas added to %s file %s and file closed", opt.Data(), psname.Data());
5138 else Info(
"Print",
"%s file %s has been closed", opt.Data(), psname.Data());
5139 gROOT->GetListOfSpecials()->Remove(gVirtualPS);
5143 Info(
"Print",
"Current canvas added to %s file %s", opt.Data(), psname.Data());
5148 if (strstr(opt,
"Preview")) gSystem->Exec(Form(
"epstool --quiet -t6p %s %s",psname.Data(),psname.Data()));
5149 if (strstr(opt,
"EmbedFonts")) {
5150 gSystem->Exec(Form(
"gs -quiet -dSAFER -dNOPLATFONTS -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dUseCIEColor -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -sOutputFile=pdf_temp.pdf -f %s",
5152 gSystem->Rename(
"pdf_temp.pdf", psname.Data());
5163 void TPad::Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
5165 if ((x1 >= x2) || (y1 >= y2)) {
5166 Error(
"Range",
"illegal world coordinates range: x1=%f, y1=%f, x2=%f, y2=%f",x1,y1,x2,y2);
5175 if (fX1 == x1 && fY1 == y1 && fX2 == x2 && fY2 == y2)
return;
5186 GetPainter()->InvalidateCS();
5201 void TPad::RangeAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax)
5203 if ((xmin >= xmax) || (ymin >= ymax)) {
5204 Error(
"RangeAxis",
"illegal axis coordinates range: xmin=%f, ymin=%f, xmax=%f, ymax=%f",
5205 xmin, ymin, xmax, ymax);
5221 void TPad::RecursiveRemove(TObject *obj)
5223 if (obj == fCanvas->GetSelected()) fCanvas->SetSelected(0);
5224 if (obj == fCanvas->GetClickSelected()) fCanvas->SetClickSelected(0);
5225 if (obj == fView) fView =
nullptr;
5226 if (!fPrimitives)
return;
5227 Int_t nold = fPrimitives->GetSize();
5228 fPrimitives->RecursiveRemove(obj);
5229 if (nold != fPrimitives->GetSize()) fModified = kTRUE;
5245 void TPad::RedrawAxis(Option_t *option)
5248 TString opt = option;
5251 TPad *padsav = (TPad*)gPad;
5254 if (!fPrimitives) fPrimitives =
new TList;
5255 TIter next(fPrimitives);
5257 while ((obj = next())) {
5258 if (obj->InheritsFrom(TH1::Class())) {
5259 TH1 *hobj = (TH1*)obj;
5260 if (opt.Contains(
"g")) hobj->DrawCopy(
"sameaxig");
5261 else hobj->DrawCopy(
"sameaxis");
5264 if (obj->InheritsFrom(TMultiGraph::Class())) {
5265 TMultiGraph *mg = (TMultiGraph*)obj;
5267 TH1F *h1f = mg->GetHistogram();
5268 if (h1f) h1f->DrawCopy(
"sameaxis");
5272 if (obj->InheritsFrom(TGraph::Class())) {
5273 TGraph *g = (TGraph*)obj;
5274 if (g) g->GetHistogram()->DrawCopy(
"sameaxis");
5277 if (obj->InheritsFrom(THStack::Class())) {
5278 THStack *hs = (THStack*)obj;
5280 TH1 *h1 = hs->GetHistogram();
5281 if (h1) h1->DrawCopy(
"sameaxis");
5287 if (padsav) padsav->cd();
5413 void TPad::ResizePad(Option_t *option)
5417 Error(
"ResizePad",
"Cannot resize pad. No current pad available.");
5422 TPad *parent = fMother;
5423 if (
this == gPad->GetCanvas()) {
5424 fAbsXlowNDC = fXlowNDC;
5425 fAbsYlowNDC = fYlowNDC;
5430 fAbsXlowNDC = fXlowNDC*parent->GetAbsWNDC() + parent->GetAbsXlowNDC();
5431 fAbsYlowNDC = fYlowNDC*parent->GetAbsHNDC() + parent->GetAbsYlowNDC();
5432 fAbsWNDC = fWNDC*parent->GetAbsWNDC();
5433 fAbsHNDC = fHNDC*parent->GetAbsHNDC();
5436 Double_t ww = (Double_t)gPad->GetWw();
5437 Double_t wh = (Double_t)gPad->GetWh();
5438 Double_t pxlow = fAbsXlowNDC*ww;
5439 Double_t pylow = (1-fAbsYlowNDC)*wh;
5440 Double_t pxrange = fAbsWNDC*ww;
5441 Double_t pyrange = -fAbsHNDC*wh;
5444 Double_t rounding = 0.00005;
5445 Double_t xrange = fX2 - fX1;
5446 fXtoAbsPixelk = rounding + pxlow - pxrange*fX1/xrange;
5447 fXtoPixelk = rounding + -pxrange*fX1/xrange;
5448 fXtoPixel = pxrange/xrange;
5449 fAbsPixeltoXk = fX1 - pxlow*xrange/pxrange;
5451 fPixeltoX = xrange/pxrange;
5453 Double_t yrange = fY2 - fY1;
5454 fYtoAbsPixelk = rounding + pylow - pyrange*fY1/yrange;
5455 fYtoPixelk = rounding + -pyrange - pyrange*fY1/yrange;
5456 fYtoPixel = pyrange/yrange;
5457 fAbsPixeltoYk = fY1 - pylow*yrange/pyrange;
5459 fPixeltoY = yrange/pyrange;
5463 fUtoAbsPixelk = rounding + pxlow;
5464 fUtoPixelk = rounding;
5465 fUtoPixel = pxrange;
5466 fVtoAbsPixelk = rounding + pylow;
5467 fVtoPixelk = -pyrange;
5468 fVtoPixel = pyrange;
5474 if (!fPrimitives) fPrimitives =
new TList;
5475 TIter next(GetListOfPrimitives());
5476 while ((obj = next())) {
5477 if (obj->InheritsFrom(TPad::Class()))
5478 ((TPad*)obj)->ResizePad(option);
5482 if (gPad->IsBatch())
5485 GetPainter()->SetLineWidth(-1);
5486 GetPainter()->SetTextSize(-1);
5490 int w = TMath::Abs(XtoPixel(fX2) - XtoPixel(fX1));
5491 int h = TMath::Abs(YtoPixel(fY2) - YtoPixel(fY1));
5496 if ( !(TMath::Finite(fX1)) || !(TMath::Finite(fX2))
5497 || !(TMath::Finite(fY1)) || !(TMath::Finite(fY2))
5498 || (TMath::IsNaN(fX1)) || (TMath::IsNaN(fX2))
5499 || (TMath::IsNaN(fY1)) || (TMath::IsNaN(fY2)))
5500 Warning(
"ResizePad",
"Inf/NaN propagated to the pad. Check drawn objects.");
5501 if (w <= 0 || w > 10000) {
5502 Warning(
"ResizePad",
"%s width changed from %d to %d\n",GetName(),w,10);
5505 if (h <= 0 || h > 10000) {
5506 Warning(
"ResizePad",
"%s height changed from %d to %d\n",GetName(),h,10);
5509 if (fPixmapID == -1) {
5510 fPixmapID = GetPainter()->CreateDrawable(w, h);
5512 if (gVirtualX->ResizePixmap(fPixmapID, w, h)) {
5520 TPad *padsav = (TPad*)gPad;
5521 if (padsav ==
this) {
5552 void TPad::SaveAs(
const char *filename, Option_t * )
const
5555 Int_t lenfil = filename ? strlen(filename) : 0;
5557 if (!lenfil) { psname = GetName(); psname.Append(
".ps"); }
5558 else psname = filename;
5561 if (psname.BeginsWith(
'.') && (psname.Contains(
'/') == 0)) {
5563 psname.Append(filename);
5564 psname.Prepend(
"/");
5565 psname.Prepend(gEnv->GetValue(
"Canvas.PrintDirectory",
"."));
5568 if (psname.EndsWith(
".gif"))
5569 ((TPad*)
this)->Print(psname,
"gif");
5570 else if (psname.Contains(
".gif+"))
5571 ((TPad*)
this)->Print(psname,
"gif+");
5572 else if (psname.EndsWith(
".C") || psname.EndsWith(
".cxx") || psname.EndsWith(
".cpp"))
5573 ((TPad*)
this)->Print(psname,
"cxx");
5574 else if (psname.EndsWith(
".root"))
5575 ((TPad*)
this)->Print(psname,
"root");
5576 else if (psname.EndsWith(
".xml"))
5577 ((TPad*)
this)->Print(psname,
"xml");
5578 else if (psname.EndsWith(
".json"))
5579 ((TPad*)
this)->Print(psname,
"json");
5580 else if (psname.EndsWith(
".eps"))
5581 ((TPad*)
this)->Print(psname,
"eps");
5582 else if (psname.EndsWith(
".pdf"))
5583 ((TPad*)
this)->Print(psname,
"pdf");
5584 else if (psname.EndsWith(
".pdf["))
5585 ((TPad*)
this)->Print(psname,
"pdf");
5586 else if (psname.EndsWith(
".pdf]"))
5587 ((TPad*)
this)->Print(psname,
"pdf");
5588 else if (psname.EndsWith(
".pdf("))
5589 ((TPad*)
this)->Print(psname,
"pdf");
5590 else if (psname.EndsWith(
".pdf)"))
5591 ((TPad*)
this)->Print(psname,
"pdf");
5592 else if (psname.EndsWith(
".svg"))
5593 ((TPad*)
this)->Print(psname,
"svg");
5594 else if (psname.EndsWith(
".tex"))
5595 ((TPad*)
this)->Print(psname,
"tex");
5596 else if (psname.EndsWith(
".xpm"))
5597 ((TPad*)
this)->Print(psname,
"xpm");
5598 else if (psname.EndsWith(
".png"))
5599 ((TPad*)
this)->Print(psname,
"png");
5600 else if (psname.EndsWith(
".jpg"))
5601 ((TPad*)
this)->Print(psname,
"jpg");
5602 else if (psname.EndsWith(
".jpeg"))
5603 ((TPad*)
this)->Print(psname,
"jpg");
5604 else if (psname.EndsWith(
".bmp"))
5605 ((TPad*)
this)->Print(psname,
"bmp");
5606 else if (psname.EndsWith(
".tiff"))
5607 ((TPad*)
this)->Print(psname,
"tiff");
5609 ((TPad*)
this)->Print(psname,
"ps");
5615 void TPad::SavePrimitive(std::ostream &out, Option_t * )
5617 TPad *padsav = (TPad*)gPad;
5621 const char *cname = GetName();
5622 Int_t nch = strlen(cname);
5624 strlcpy(lcname,cname,10);
5625 for (Int_t k=1;k<=nch;k++) {
if (lcname[nch-k] ==
' ') lcname[nch-k] = 0;}
5626 if (lcname[0] == 0) {
5627 if (
this == gPad->GetCanvas()) {strlcpy(lcname,
"c1",10); nch = 2;}
5628 else {strlcpy(lcname,
"pad",10); nch = 3;}
5634 if (
this != gPad->GetCanvas()) {
5635 out <<
" "<<std::endl;
5636 out <<
"// ------------>Primitives in pad: "<<GetName()<<std::endl;
5638 out<<
" TPad *"<<cname<<
" = new TPad("<<quote<<GetName()<<quote<<
", "<<quote<<GetTitle()
5642 <<
","<<fXlowNDC+fWNDC
5643 <<
","<<fYlowNDC+fHNDC
5645 out<<
" "<<cname<<
"->Draw();"<<std::endl;
5646 out<<
" "<<cname<<
"->cd();"<<std::endl;
5648 out<<
" "<<cname<<
"->Range("<<fX1<<
","<<fY1<<
","<<fX2<<
","<<fY2<<
");"<<std::endl;
5649 TView *view = GetView();
5650 Double_t rmin[3], rmax[3];
5652 view->GetRange(rmin, rmax);
5653 static Int_t viewNumber = 0;
5654 out<<
" TView *view"<<++viewNumber<<
" = TView::CreateView(1);"<<std::endl;
5655 out<<
" view"<<viewNumber<<
"->SetRange("<<rmin[0]<<
","<<rmin[1]<<
","<<rmin[2]<<
","
5656 <<rmax[0]<<
","<<rmax[1]<<
","<<rmax[2]<<
");"<<std::endl;
5658 if (GetFillColor() != 19) {
5659 if (GetFillColor() > 228) {
5660 TColor::SaveColor(out, GetFillColor());
5661 out<<
" "<<cname<<
"->SetFillColor(ci);" << std::endl;
5663 out<<
" "<<cname<<
"->SetFillColor("<<GetFillColor()<<
");"<<std::endl;
5665 if (GetFillStyle() != 1001) {
5666 out<<
" "<<cname<<
"->SetFillStyle("<<GetFillStyle()<<
");"<<std::endl;
5668 if (GetBorderMode() != 1) {
5669 out<<
" "<<cname<<
"->SetBorderMode("<<GetBorderMode()<<
");"<<std::endl;
5671 if (GetBorderSize() != 4) {
5672 out<<
" "<<cname<<
"->SetBorderSize("<<GetBorderSize()<<
");"<<std::endl;
5675 out<<
" "<<cname<<
"->SetLogx();"<<std::endl;
5678 out<<
" "<<cname<<
"->SetLogy();"<<std::endl;
5681 out<<
" "<<cname<<
"->SetLogz();"<<std::endl;
5684 out<<
" "<<cname<<
"->SetGridx();"<<std::endl;
5687 out<<
" "<<cname<<
"->SetGridy();"<<std::endl;
5690 out<<
" "<<cname<<
"->SetTickx("<<GetTickx()<<
");"<<std::endl;
5693 out<<
" "<<cname<<
"->SetTicky("<<GetTicky()<<
");"<<std::endl;
5695 if (GetTheta() != 30) {
5696 out<<
" "<<cname<<
"->SetTheta("<<GetTheta()<<
");"<<std::endl;
5698 if (GetPhi() != 30) {
5699 out<<
" "<<cname<<
"->SetPhi("<<GetPhi()<<
");"<<std::endl;
5701 if (TMath::Abs(fLeftMargin-0.1) > 0.01) {
5702 out<<
" "<<cname<<
"->SetLeftMargin("<<GetLeftMargin()<<
");"<<std::endl;
5704 if (TMath::Abs(fRightMargin-0.1) > 0.01) {
5705 out<<
" "<<cname<<
"->SetRightMargin("<<GetRightMargin()<<
");"<<std::endl;
5707 if (TMath::Abs(fTopMargin-0.1) > 0.01) {
5708 out<<
" "<<cname<<
"->SetTopMargin("<<GetTopMargin()<<
");"<<std::endl;
5710 if (TMath::Abs(fBottomMargin-0.1) > 0.01) {
5711 out<<
" "<<cname<<
"->SetBottomMargin("<<GetBottomMargin()<<
");"<<std::endl;
5714 if (GetFrameFillColor() != GetFillColor()) {
5715 if (GetFrameFillColor() > 228) {
5716 TColor::SaveColor(out, GetFrameFillColor());
5717 out<<
" "<<cname<<
"->SetFrameFillColor(ci);" << std::endl;
5719 out<<
" "<<cname<<
"->SetFrameFillColor("<<GetFrameFillColor()<<
");"<<std::endl;
5721 if (GetFrameFillStyle() != 1001) {
5722 out<<
" "<<cname<<
"->SetFrameFillStyle("<<GetFrameFillStyle()<<
");"<<std::endl;
5724 if (GetFrameLineStyle() != 1) {
5725 out<<
" "<<cname<<
"->SetFrameLineStyle("<<GetFrameLineStyle()<<
");"<<std::endl;
5727 if (GetFrameLineColor() != 1) {
5728 if (GetFrameLineColor() > 228) {
5729 TColor::SaveColor(out, GetFrameLineColor());
5730 out<<
" "<<cname<<
"->SetFrameLineColor(ci);" << std::endl;
5732 out<<
" "<<cname<<
"->SetFrameLineColor("<<GetFrameLineColor()<<
");"<<std::endl;
5734 if (GetFrameLineWidth() != 1) {
5735 out<<
" "<<cname<<
"->SetFrameLineWidth("<<GetFrameLineWidth()<<
");"<<std::endl;
5737 if (GetFrameBorderMode() != 1) {
5738 out<<
" "<<cname<<
"->SetFrameBorderMode("<<GetFrameBorderMode()<<
");"<<std::endl;
5740 if (GetFrameBorderSize() != 1) {
5741 out<<
" "<<cname<<
"->SetFrameBorderSize("<<GetFrameBorderSize()<<
");"<<std::endl;
5744 TFrame *frame = fFrame;
5745 if (!frame) frame = (TFrame*)GetPrimitive(
"TFrame");
5747 if (frame->GetFillColor() != GetFillColor()) {
5748 if (frame->GetFillColor() > 228) {
5749 TColor::SaveColor(out, frame->GetFillColor());
5750 out<<
" "<<cname<<
"->SetFrameFillColor(ci);" << std::endl;
5752 out<<
" "<<cname<<
"->SetFrameFillColor("<<frame->GetFillColor()<<
");"<<std::endl;
5754 if (frame->GetFillStyle() != 1001) {
5755 out<<
" "<<cname<<
"->SetFrameFillStyle("<<frame->GetFillStyle()<<
");"<<std::endl;
5757 if (frame->GetLineStyle() != 1) {
5758 out<<
" "<<cname<<
"->SetFrameLineStyle("<<frame->GetLineStyle()<<
");"<<std::endl;
5760 if (frame->GetLineColor() != 1) {
5761 if (frame->GetLineColor() > 228) {
5762 TColor::SaveColor(out, frame->GetLineColor());
5763 out<<
" "<<cname<<
"->SetFrameLineColor(ci);" << std::endl;
5765 out<<
" "<<cname<<
"->SetFrameLineColor("<<frame->GetLineColor()<<
");"<<std::endl;
5767 if (frame->GetLineWidth() != 1) {
5768 out<<
" "<<cname<<
"->SetFrameLineWidth("<<frame->GetLineWidth()<<
");"<<std::endl;
5770 if (frame->GetBorderMode() != 1) {
5771 out<<
" "<<cname<<
"->SetFrameBorderMode("<<frame->GetBorderMode()<<
");"<<std::endl;
5773 if (frame->GetBorderSize() != 1) {
5774 out<<
" "<<cname<<
"->SetFrameBorderSize("<<frame->GetBorderSize()<<
");"<<std::endl;
5778 TIter next(GetListOfPrimitives());
5782 while ((obj = next())) {
5783 if (obj->InheritsFrom(TGraph::Class()))
5784 if (!strcmp(obj->GetName(),
"Graph")) ((TGraph*)obj)->SetName(Form(
"Graph%d",grnum++));
5785 obj->SavePrimitive(out, (Option_t *)next.GetOption());
5787 out<<
" "<<cname<<
"->Modified();"<<std::endl;
5788 out<<
" "<<GetMother()->GetName()<<
"->cd();"<<std::endl;
5789 if (padsav) padsav->cd();
5795 void TPad::SetFixedAspectRatio(Bool_t fixed)
5798 if (!fFixedAspectRatio) {
5800 fAspectRatio = fWNDC / fHNDC;
5802 Error(
"SetAspectRatio",
"cannot fix aspect ratio, height of pad is 0");
5805 fFixedAspectRatio = kTRUE;
5808 fFixedAspectRatio = kFALSE;
5819 void TPad::SetEditable(Bool_t mode)
5824 if (!fPrimitives) fPrimitives =
new TList;
5825 TIter next(GetListOfPrimitives());
5826 while ((obj = next())) {
5827 if (obj->InheritsFrom(TPad::Class())) {
5828 TPad *pad = (TPad*)obj;
5829 pad->SetEditable(mode);
5838 void TPad::SetFillStyle(Style_t fstyle)
5840 if (fstyle == 0) fstyle = 4000;
5841 TAttFill::SetFillStyle(fstyle);
5850 void TPad::SetLogx(Int_t value)
5853 delete fView; fView =
nullptr;
5864 void TPad::SetLogy(Int_t value)
5867 delete fView; fView =
nullptr;
5875 void TPad::SetLogz(Int_t value)
5878 delete fView; fView =
nullptr;
5887 void TPad::SetPad(Double_t xlow, Double_t ylow, Double_t xup, Double_t yup)
5909 SetFixedAspectRatio(kFALSE);
5917 void TPad::SetPad(
const char *name,
const char *title,
5918 Double_t xlow, Double_t ylow, Double_t xup, Double_t yup,
5919 Color_t color, Short_t bordersize, Short_t bordermode)
5924 SetBottomMargin(gStyle->GetPadBottomMargin());
5925 SetTopMargin(gStyle->GetPadTopMargin());
5926 SetLeftMargin(gStyle->GetPadLeftMargin());
5927 SetRightMargin(gStyle->GetPadRightMargin());
5928 if (color >= 0) SetFillColor(color);
5929 else SetFillColor(gStyle->GetPadColor());
5930 if (bordersize < 0) fBorderSize = gStyle->GetPadBorderSize();
5931 else fBorderSize = bordersize;
5932 if (bordermode < -1) fBorderMode = gStyle->GetPadBorderMode();
5933 else fBorderMode = bordermode;
5935 SetPad(xlow, ylow, xup, yup);
5941 void TPad::SetView(TView *view)
5943 if (!view)
delete fView;
5950 void TPad::SetAttFillPS(Color_t color, Style_t style)
5953 gVirtualPS->SetFillColor(color);
5954 gVirtualPS->SetFillStyle(style);
5961 void TPad::SetAttLinePS(Color_t color, Style_t style, Width_t lwidth)
5964 gVirtualPS->SetLineColor(color);
5965 gVirtualPS->SetLineStyle(style);
5966 gVirtualPS->SetLineWidth(lwidth);
5973 void TPad::SetAttMarkerPS(Color_t color, Style_t style, Size_t msize)
5976 gVirtualPS->SetMarkerColor(color);
5977 gVirtualPS->SetMarkerStyle(style);
5978 gVirtualPS->SetMarkerSize(msize);
5985 void TPad::SetAttTextPS(Int_t align, Float_t angle, Color_t color, Style_t font, Float_t tsize)
5988 gVirtualPS->SetTextAlign(align);
5989 gVirtualPS->SetTextAngle(angle);
5990 gVirtualPS->SetTextColor(color);
5991 gVirtualPS->SetTextFont(font);
5993 Float_t wh = (Float_t)gPad->XtoPixel(gPad->GetX2());
5994 Float_t hh = (Float_t)gPad->YtoPixel(gPad->GetY1());
5997 dy = AbsPixeltoX(Int_t(tsize)) - AbsPixeltoX(0);
5998 tsize = dy/(fX2-fX1);
6000 dy = AbsPixeltoY(0) - AbsPixeltoY(Int_t(tsize));
6001 tsize = dy/(fY2-fY1);
6004 gVirtualPS->SetTextSize(tsize);
6012 void TPad::DrawDist(Rectangle_t aBBox, Rectangle_t bBBox,
char mode)
6014 Int_t lineColor = TColor::GetColor(239, 202, 0);
6016 x1 = x2 = y1 = y2 = 0;
6018 if (aBBox.fX<bBBox.fX) {
6019 x1 = aBBox.fX+aBBox.fWidth;
6023 x1 = bBBox.fX+bBBox.fWidth;
6027 if ((aBBox.fY > bBBox.fY) && (aBBox.fY + aBBox.fHeight < bBBox.fY + bBBox.fHeight))
6028 y1 = y2 = aBBox.fY + TMath::Nint(0.5*(Double_t)(aBBox.fHeight))+1;
6029 else if ((bBBox.fY > aBBox.fY) && (bBBox.fY + bBBox.fHeight < aBBox.fY + aBBox.fHeight))
6030 y1 = y2 = bBBox.fY + TMath::Nint(0.5*(Double_t)(bBBox.fHeight))+1;
6031 else if (aBBox.fY>bBBox.fY) y1 = y2 = aBBox.fY-TMath::Nint(0.5*(Double_t)(aBBox.fY-(bBBox.fY+bBBox.fHeight)));
6032 else y1 = y2 = bBBox.fY-TMath::Nint(0.5*(Double_t)(bBBox.fY-(aBBox.fY+aBBox.fHeight)));
6034 else if (mode ==
'y') {
6035 if (aBBox.fY<bBBox.fY) {
6036 y1 = aBBox.fY+aBBox.fHeight;
6040 y1 = bBBox.fY+bBBox.fHeight;
6043 if ((aBBox.fX > bBBox.fX) && (aBBox.fX + aBBox.fWidth < bBBox.fX + bBBox.fWidth))
6044 x1 = x2 = aBBox.fX + TMath::Nint(0.5*(Double_t)(aBBox.fWidth))+1;
6045 else if ((bBBox.fX > aBBox.fX) && (bBBox.fX + bBBox.fWidth < aBBox.fX + aBBox.fWidth))
6046 x1 = x2 = bBBox.fX + TMath::Nint(0.5*(Double_t)(bBBox.fWidth))+1;
6047 else if (aBBox.fX>bBBox.fX) x1 = x2 = aBBox.fX+TMath::Nint(0.5*(Double_t)(bBBox.fX+bBBox.fWidth-aBBox.fX));
6048 else x1 = x2 = bBBox.fX+TMath::Nint(0.5*(Double_t)(aBBox.fX+aBBox.fWidth-bBBox.fX));
6051 TArrow *A =
new TArrow(gPad->PixeltoX(x1), gPad->PixeltoY(y1-gPad->VtoPixel(0)), gPad->PixeltoX(x2), gPad->PixeltoY(y2-gPad->VtoPixel(0)), 0.01,
"<|>");
6052 A->SetBit(kCanDelete);
6053 A->SetFillColor(lineColor);
6055 A->SetLineColor(lineColor);
6073 : fa(0), fb(0), fdist(0), fdir(
' ')
6076 dField(TAttBBox2D *a, TAttBBox2D *b, Int_t dist,
char direction)
6077 : fa(a), fb(b), fdist(dist), fdir(direction)
6096 void TPad::ShowGuidelines(TObject *
object,
const Int_t event,
const char mode,
const bool cling )
6100 if ((event == kArrowKeyRelease) || (event == kArrowKeyPress) ||
6101 !gEnv->GetValue(
"Canvas.ShowGuideLines", 0))
return;
6103 std::vector<dField> curDist;
6104 std::vector<dField> otherDist;
6110 Rectangle_t aBBox, bBBox;
6111 aBBox = bBBox = Rectangle_t();
6114 Int_t dSizeArrow = 12;
6115 Bool_t movedX, movedY;
6116 movedX = movedY =
false;
6117 Bool_t resize =
false;
6118 Bool_t log = gPad->GetLogx() || gPad->GetLogy();
6119 if (mode !=
'i') resize =
true;
6121 TPad *is_pad =
dynamic_cast<TPad *
>( object );
6122 TVirtualPad *padSave = 0;
6124 if (is_pad) is_pad->GetMother()->cd();
6126 static TPad * tmpGuideLinePad;
6129 if (tmpGuideLinePad) {
6130 if (
object == tmpGuideLinePad) {
6131 tmpGuideLinePad->Delete();
6132 tmpGuideLinePad = 0;
6135 tmpGuideLinePad->Delete();
6136 tmpGuideLinePad = 0;
6140 prims = gPad->GetListOfPrimitives();
6141 n = TMath::Min(15,prims->GetSize());
6142 Int_t lineColor = TColor::GetColor(239, 202, 0);
6144 TAttBBox2D *cur =
dynamic_cast<TAttBBox2D *
>( object );
6147 if (!tmpGuideLinePad){
6148 tmpGuideLinePad =
new TPad(
"tmpGuideLinePad",
"tmpGuideLinePad", 0, 0, 1, 1);
6149 Double_t x1, y1, x2, y2;
6150 gPad->GetRange(x1, y1, x2, y2);
6151 tmpGuideLinePad->Range(x1, y1, x2, y2);
6152 tmpGuideLinePad->SetFillStyle(0);
6153 tmpGuideLinePad->SetFillColor(0);
6154 tmpGuideLinePad->Draw();
6155 tmpGuideLinePad->cd();
6156 gPad->GetRange(x1, y1, x2, y2);
6158 if (cling && !log) threshold = 7;
6161 Rectangle_t BBox = cur->GetBBox();
6162 TPoint center = cur->GetBBoxCenter();
6170 case kButton1Motion:
6171 MX = gPad->GetX1() + 0.5 * (gPad->GetX2()-gPad->GetX1());
6172 MY = gPad->GetY1() + 0.5 * (gPad->GetY2()-gPad->GetY1());
6173 pMX = gPad->XtoPixel(MX);
6174 pMY = gPad->YtoPixel(MY);
6176 if (TMath::Abs(pMX-center.GetX())<threshold) {
6177 if (cling && (!resize)) {
6178 cur->SetBBoxCenterX(pMX);
6179 center = cur->GetBBoxCenter();
6180 BBox = cur->GetBBox();
6181 center = cur->GetBBoxCenter();
6183 L =
new TLine(MX, gPad->GetY1(), MX, gPad->GetY2());
6184 L->SetBit(kCanDelete);
6185 L->SetLineColor(lineColor);
6188 if (TMath::Abs(pMY-center.GetY())<threshold) {
6189 if (cling && (!resize)) {
6190 cur->SetBBoxCenterY(pMY);
6191 center = cur->GetBBoxCenter();
6192 BBox = cur->GetBBox();
6193 center = cur->GetBBoxCenter();
6195 L =
new TLine(gPad->GetX1(), MY, gPad->GetX2(), MY);
6196 L->SetBit(kCanDelete);
6197 L->SetLineColor(lineColor);
6201 for (UInt_t i = 0; i<n; i++) {
6202 TAttBBox2D *other =
dynamic_cast<TAttBBox2D *
>( prims->At(i) );
6205 TPoint centerOther = other->GetBBoxCenter();
6206 if (TMath::Abs(center.GetX()-centerOther.GetX())<threshold) {
6207 if (cling && (!resize)) {
6208 cur->SetBBoxCenterX(centerOther.GetX());
6209 BBox = cur->GetBBox();
6210 center = cur->GetBBoxCenter();
6212 L =
new TLine(gPad->PixeltoX(centerOther.GetX()), gPad->PixeltoY(center.GetY()-gPad->VtoPixel(0)),
6213 gPad->PixeltoX(centerOther.GetX()), gPad->PixeltoY(centerOther.GetY()-gPad->VtoPixel(0)));
6214 L->SetLineColor(lineColor);
6216 L->SetBit(kCanDelete);
6218 if (TMath::Abs(center.GetY()-centerOther.GetY())<threshold) {
6219 if (cling && (!resize)) {
6220 cur->SetBBoxCenterY(centerOther.GetY());
6221 BBox = cur->GetBBox();
6222 center = cur->GetBBoxCenter();
6224 L =
new TLine(gPad->PixeltoX(center.GetX()), gPad->PixeltoY(centerOther.GetY()-gPad->VtoPixel(0)),
6225 gPad->PixeltoX(centerOther.GetX()), gPad->PixeltoY(centerOther.GetY()-gPad->VtoPixel(0)));
6226 L->SetBit(kCanDelete);
6227 L->SetLineColor(lineColor);
6234 for (UInt_t i = 0; i<n; i++) {
6235 TAttBBox2D *a =
dynamic_cast<TAttBBox2D *
>( prims->At(i) );
6237 aBBox = a->GetBBox();
6238 for (UInt_t j = i+1; j<n; j++) {
6239 TAttBBox2D *b =
dynamic_cast<TAttBBox2D *
>( prims->At(j) );
6241 bBBox = b->GetBBox();
6244 if (((aBBox.fX<bBBox.fX)&&(bBBox.fX-aBBox.fX<=aBBox.fWidth))||((aBBox.fX>bBBox.fX)&&(aBBox.fX-bBBox.fX<=bBBox.fWidth))){
6245 if ((aBBox.fY+aBBox.fHeight<bBBox.fY)||(bBBox.fY+bBBox.fHeight<aBBox.fY)) {
6246 dField abDist = dField();
6247 if (aBBox.fY>bBBox.fY) abDist = dField(a, b, TMath::Abs(aBBox.fY-(bBBox.fY+bBBox.fHeight)),
'y');
6248 else abDist = dField(a, b, TMath::Abs(bBBox.fY-(aBBox.fY+aBBox.fHeight)),
'y');
6249 if ((b != cur)&&(a != cur)) otherDist.push_back(abDist);
6250 else curDist.push_back(abDist);
6252 }
else if (((aBBox.fY<bBBox.fY)&&(bBBox.fY-aBBox.fY<=aBBox.fHeight))||((aBBox.fY>bBBox.fY)&&(aBBox.fY-bBBox.fY<=bBBox.fHeight))) {
6253 if ((aBBox.fX+aBBox.fWidth<bBBox.fX)||(bBBox.fX+bBBox.fWidth<aBBox.fX)) {
6254 dField abDist = dField();
6255 if (aBBox.fX>bBBox.fX) abDist = dField(a, b, TMath::Abs(aBBox.fX-(bBBox.fX+bBBox.fWidth)),
'x');
6256 else abDist = dField(a, b, TMath::Abs(bBBox.fX-(aBBox.fX+aBBox.fWidth)),
'x');
6257 if ((b != cur)&&(a != cur)) otherDist.push_back(abDist);
6258 else curDist.push_back(abDist);
6266 for (UInt_t i = 0; i<curDist.size(); i++) {
6267 for (UInt_t j = 0; j<otherDist.size(); j++) {
6268 if ((curDist[i].fdir == otherDist[j].fdir)&&(otherDist[j].fdir==
'x')&&(TMath::Abs(curDist[i].fdist-otherDist[j].fdist)<threshold)) {
6269 if (cling && (!movedX) && (!resize)) {
6270 if ((cur->GetBBoxCenter().fX < curDist[i].fb->GetBBoxCenter().fX)||(cur->GetBBoxCenter().fX < curDist[i].fa->GetBBoxCenter().fX))
6271 cur->SetBBoxCenterX(cur->GetBBoxCenter().fX - otherDist[j].fdist + curDist[i].fdist);
6272 else cur->SetBBoxCenterX(cur->GetBBoxCenter().fX + otherDist[j].fdist - curDist[i].fdist);
6275 DrawDist(curDist[i].fa->GetBBox(), curDist[i].fb->GetBBox(),
'x');
6276 DrawDist(otherDist[j].fa->GetBBox(), otherDist[j].fb->GetBBox(),
'x');
6278 if ((curDist[i].fdir == otherDist[j].fdir)&&(otherDist[j].fdir==
'y')&&(TMath::Abs(curDist[i].fdist-otherDist[j].fdist)<threshold)) {
6279 if (cling && (!movedY) && (!resize)) {
6280 if ((cur->GetBBoxCenter().fY < curDist[i].fb->GetBBoxCenter().fY)||(cur->GetBBoxCenter().fY < curDist[i].fa->GetBBoxCenter().fY))
6281 cur->SetBBoxCenterY(cur->GetBBoxCenter().fY - otherDist[j].fdist + curDist[i].fdist);
6282 else cur->SetBBoxCenterY(cur->GetBBoxCenter().fY + otherDist[j].fdist - curDist[i].fdist);
6285 DrawDist(curDist[i].fa->GetBBox(), curDist[i].fb->GetBBox(),
'y');
6286 DrawDist(otherDist[j].fa->GetBBox(), otherDist[j].fb->GetBBox(),
'y');
6289 for (UInt_t j = i; j<curDist.size(); j++) {
6291 if ((curDist[i].fdir == curDist[j].fdir)&&(curDist[j].fdir==
'x')&&(TMath::Abs(curDist[i].fdist-curDist[j].fdist)<threshold)) {
6292 if (cling && (!movedX) && (!resize)) {
6293 if ((cur->GetBBoxCenter().fX < curDist[i].fb->GetBBoxCenter().fX)||(cur->GetBBoxCenter().fX < curDist[i].fa->GetBBoxCenter().fX))
6294 cur->SetBBoxCenterX(cur->GetBBoxCenter().fX - floor(0.5*(curDist[j].fdist - curDist[i].fdist)));
6295 else cur->SetBBoxCenterX(cur->GetBBoxCenter().fX + floor(0.5*(curDist[j].fdist - curDist[i].fdist)));
6297 DrawDist(curDist[i].fa->GetBBox(), curDist[i].fb->GetBBox(),
'x');
6298 DrawDist(curDist[j].fa->GetBBox(), curDist[j].fb->GetBBox(),
'x');
6301 if ((curDist[i].fdir == curDist[j].fdir)&&(curDist[j].fdir==
'y')&&(TMath::Abs(curDist[i].fdist-curDist[j].fdist)<threshold)) {
6302 if (cling && (!movedY) && (!resize)) {
6303 if ((cur->GetBBoxCenter().fY < curDist[i].fb->GetBBoxCenter().fY)||(cur->GetBBoxCenter().fY < curDist[i].fa->GetBBoxCenter().fY))
6304 cur->SetBBoxCenterY(cur->GetBBoxCenter().fY - floor(0.5*(curDist[j].fdist - curDist[i].fdist)));
6305 else cur->SetBBoxCenterY(cur->GetBBoxCenter().fY + floor(0.5*(curDist[j].fdist - curDist[i].fdist)));
6307 DrawDist(curDist[i].fa->GetBBox(), curDist[i].fb->GetBBox(),
'y');
6308 DrawDist(curDist[j].fa->GetBBox(), curDist[j].fb->GetBBox(),
'y');
6315 for (UInt_t i = 0; i<n; i++) {
6316 TAttBBox2D *a =
dynamic_cast<TAttBBox2D *
>( prims->At(i) );
6317 if (a && (cur != a)) {
6318 aBBox = a->GetBBox();
6320 if ((TMath::Abs(aBBox.fWidth - BBox.fWidth)<threshold) && (mode !=
't') && (mode !=
'b')) {
6322 if (mode ==
'l') cur->SetBBoxX1(BBox.fX + BBox.fWidth - aBBox.fWidth);
6323 if (mode ==
'r') cur->SetBBoxX2(BBox.fX + aBBox.fWidth);
6324 if ((mode ==
'1')||(mode ==
'4')) cur->SetBBoxX1(BBox.fX + BBox.fWidth - aBBox.fWidth);
6325 if ((mode ==
'2')||(mode ==
'3')) cur->SetBBoxX2(BBox.fX + aBBox.fWidth);
6326 BBox = cur->GetBBox();
6329 A =
new TArrow(gPad->PixeltoX(aBBox.fX), gPad->PixeltoY(aBBox.fY-dSizeArrow-gPad->VtoPixel(0)),
6330 gPad->PixeltoX(aBBox.fX+aBBox.fWidth), gPad->PixeltoY(aBBox.fY-dSizeArrow-gPad->VtoPixel(0)), 0.01,
"<|>");
6331 A->SetBit(kCanDelete);
6332 A->SetLineColor(lineColor);
6333 A->SetFillColor(lineColor);
6336 A =
new TArrow(gPad->PixeltoX(BBox.fX), gPad->PixeltoY(BBox.fY-dSizeArrow-gPad->VtoPixel(0)),
6337 gPad->PixeltoX(BBox.fX+BBox.fWidth), gPad->PixeltoY(BBox.fY-dSizeArrow-gPad->VtoPixel(0)), 0.01,
"<|>");
6338 A->SetBit(kCanDelete);
6339 A->SetLineColor(lineColor);
6340 A->SetFillColor(lineColor);
6343 if ((TMath::Abs(aBBox.fHeight - BBox.fHeight)<threshold) && (mode !=
'r') && (mode !=
'l')) {
6345 if (mode ==
't') cur->SetBBoxY1(BBox.fY + BBox.fHeight - aBBox.fHeight);
6346 if (mode ==
'b') cur->SetBBoxY2(BBox.fY + aBBox.fHeight);
6347 if ((mode ==
'1')||(mode ==
'2')) cur->SetBBoxY1(BBox.fY + BBox.fHeight - aBBox.fHeight);
6348 if ((mode ==
'3')||(mode ==
'4')) cur->SetBBoxY2(BBox.fY + aBBox.fHeight);
6349 BBox = cur->GetBBox();
6351 A =
new TArrow(gPad->PixeltoX(aBBox.fX-dSizeArrow), gPad->PixeltoY(aBBox.fY-gPad->VtoPixel(0)),
6352 gPad->PixeltoX(aBBox.fX-dSizeArrow), gPad->PixeltoY(aBBox.fY+aBBox.fHeight-gPad->VtoPixel(0)), 0.01,
"<|>");
6353 A->SetBit(kCanDelete);
6354 A->SetLineColor(lineColor);
6355 A->SetFillColor(lineColor);
6358 A =
new TArrow(gPad->PixeltoX(BBox.fX-dSizeArrow), gPad->PixeltoY(BBox.fY-gPad->VtoPixel(0)),
6359 gPad->PixeltoX(BBox.fX-dSizeArrow), gPad->PixeltoY(BBox.fY+BBox.fHeight-gPad->VtoPixel(0)), 0.01,
"<|>");
6360 A->SetBit(kCanDelete);
6361 A->SetLineColor(lineColor);
6362 A->SetFillColor(lineColor);
6372 if (tmpGuideLinePad) {
6375 tmpGuideLinePad->Delete();
6376 tmpGuideLinePad = 0;
6382 gPad->Modified(kTRUE);
6389 Bool_t TPad::HasCrosshair()
const
6391 return (Bool_t)GetCrosshair();
6398 Int_t TPad::GetCrosshair()
const
6400 if (
this == (TPad*)fCanvas)
6402 return fCanvas ? fCanvas->GetCrosshair() : 0;
6411 void TPad::SetCrosshair(Int_t crhair)
6413 fCrosshair = crhair;
6416 if (
this != (TPad*)fCanvas) fCanvas->SetCrosshair(crhair);
6426 void TPad::SetMaxPickDistance(Int_t maxPick)
6428 fgMaxPickDistance = maxPick;
6436 void TPad::SetToolTipText(
const char *text, Long_t delayms)
6439 DeleteToolTip(fTip);
6443 if (text && strlen(text))
6444 fTip = CreateToolTip((TBox*)
nullptr, text, delayms);
6450 void TPad::SetVertical(Bool_t vert)
6452 if (vert) ResetBit(kHori);
6459 void TPad::Streamer(TBuffer &b)
6462 Int_t nch, nobjects;
6465 if (b.IsReading()) {
6466 Version_t v = b.ReadVersion(&R__s, &R__c);
6468 if (!gPad) gPad =
new TCanvas(GetName());
6469 TPad *padsave = (TPad*)gPad;
6470 fMother = (TPad*)gPad;
6471 if (fMother) fCanvas = fMother->GetCanvas();
6475 gROOT->SetReadingObject(kTRUE);
6477 b.ReadClassBuffer(TPad::Class(),
this, v, R__s, R__c);
6481 TIter next(fPrimitives);
6482 while ((obj = next())) {
6483 obj->SetBit(kCanDelete);
6487 fPadPointer =
nullptr;
6489 if (gReadLevel == 0 && IsA() == TPad::Class()) ResizePad();
6490 gROOT->SetReadingObject(kFALSE);
6501 TObject::Streamer(b);
6502 TAttLine::Streamer(b);
6503 TAttFill::Streamer(b);
6504 b >> single; fX1 = single;
6505 b >> single; fY1 = single;
6506 b >> single; fX2 = single;
6507 b >> single; fY2 = single;
6510 TAttPad::Streamer(b);
6512 TVirtualPad::Streamer(b);
6513 TAttPad::Streamer(b);
6514 b >> single; fX1 = single;
6515 b >> single; fY1 = single;
6516 b >> single; fX2 = single;
6517 b >> single; fY2 = single;
6524 b >> single; fXtoAbsPixelk = single;
6525 b >> single; fXtoPixelk = single;
6526 b >> single; fXtoPixel = single;
6527 b >> single; fYtoAbsPixelk = single;
6528 b >> single; fYtoPixelk = single;
6529 b >> single; fYtoPixel = single;
6530 b >> single; fUtoAbsPixelk = single;
6531 b >> single; fUtoPixelk = single;
6532 b >> single; fUtoPixel = single;
6533 b >> single; fVtoAbsPixelk = single;
6534 b >> single; fVtoPixelk = single;
6535 b >> single; fVtoPixel = single;
6536 b >> single; fAbsPixeltoXk = single;
6537 b >> single; fPixeltoXk = single;
6538 b >> single; fPixeltoX = single;
6539 b >> single; fAbsPixeltoYk = single;
6540 b >> single; fPixeltoYk = single;
6541 b >> single; fPixeltoY = single;
6542 b >> single; fXlowNDC = single;
6543 b >> single; fYlowNDC = single;
6544 b >> single; fWNDC = single;
6545 b >> single; fHNDC = single;
6546 b >> single; fAbsXlowNDC = single;
6547 b >> single; fAbsYlowNDC = single;
6548 b >> single; fAbsWNDC = single;
6549 b >> single; fAbsHNDC = single;
6550 b >> single; fUxmin = single;
6551 b >> single; fUymin = single;
6552 b >> single; fUxmax = single;
6553 b >> single; fUymax = single;
6555 TVirtualPad::Streamer(b);
6556 TAttPad::Streamer(b);
6598 if (!gPad) gPad =
new TCanvas(GetName());
6599 if (gReadLevel == 0) fMother = (TPad*)gROOT->GetSelectedPad();
6600 else fMother = (TPad*)gPad;
6601 if (!fMother) fMother = (TPad*)gPad;
6602 if (fMother) fCanvas = fMother->GetCanvas();
6609 gROOT->SetReadingObject(kTRUE);
6610 fPrimitives =
new TList;
6613 TPad *padsav = (TPad*)gPad;
6615 char drawoption[64];
6616 for (Int_t i = 0; i < nobjects; i++) {
6619 b.ReadFastArray(drawoption,nch);
6620 fPrimitives->AddLast(obj, drawoption);
6626 gROOT->SetReadingObject(kFALSE);
6641 b >> single; fTheta = single;
6642 b >> single; fPhi = single;
6647 fPadPointer =
nullptr;
6654 fTickx = fTicky = 0;
6656 if (gReadLevel == 0 && IsA() == TPad::Class()) ResizePad();
6657 b.CheckByteCount(R__s, R__c, TPad::IsA());
6661 b.WriteClassBuffer(TPad::Class(),
this);
6668 void TPad::UseCurrentStyle()
6670 if (gStyle->IsReading()) {
6671 SetFillColor(gStyle->GetPadColor());
6672 SetBottomMargin(gStyle->GetPadBottomMargin());
6673 SetTopMargin(gStyle->GetPadTopMargin());
6674 SetLeftMargin(gStyle->GetPadLeftMargin());
6675 SetRightMargin(gStyle->GetPadRightMargin());
6676 fBorderSize = gStyle->GetPadBorderSize();
6677 fBorderMode = gStyle->GetPadBorderMode();
6678 fGridx = gStyle->GetPadGridX();
6679 fGridy = gStyle->GetPadGridY();
6680 fTickx = gStyle->GetPadTickX();
6681 fTicky = gStyle->GetPadTickY();
6682 fLogx = gStyle->GetOptLogx();
6683 fLogy = gStyle->GetOptLogy();
6684 fLogz = gStyle->GetOptLogz();
6686 gStyle->SetPadColor(GetFillColor());
6687 gStyle->SetPadBottomMargin(GetBottomMargin());
6688 gStyle->SetPadTopMargin(GetTopMargin());
6689 gStyle->SetPadLeftMargin(GetLeftMargin());
6690 gStyle->SetPadRightMargin(GetRightMargin());
6691 gStyle->SetPadBorderSize(GetBorderSize());
6692 gStyle->SetPadBorderMode(GetBorderMode());
6693 gStyle->SetPadGridX(fGridx);
6694 gStyle->SetPadGridY(fGridy);
6695 gStyle->SetPadTickX(fTickx);
6696 gStyle->SetPadTickY(fTicky);
6697 gStyle->SetOptLogx (fLogx);
6698 gStyle->SetOptLogy (fLogy);
6699 gStyle->SetOptLogz (fLogz);
6702 if (!fPrimitives) fPrimitives =
new TList;
6703 TIter next(GetListOfPrimitives());
6706 while ((obj = next())) {
6707 obj->UseCurrentStyle();
6710 TPaveText *title = (TPaveText*)FindObject(
"title");
6712 if (gStyle->IsReading()) {
6713 title->SetFillColor(gStyle->GetTitleFillColor());
6714 title->SetTextFont(gStyle->GetTitleFont(
""));
6715 title->SetTextColor(gStyle->GetTitleTextColor());
6716 title->SetBorderSize(gStyle->GetTitleBorderSize());
6717 if (!gStyle->GetOptTitle())
delete title;
6719 gStyle->SetTitleFillColor(title->GetFillColor());
6720 gStyle->SetTitleFont(title->GetTextFont());
6721 gStyle->SetTitleTextColor(title->GetTextColor());
6722 gStyle->SetTitleBorderSize(title->GetBorderSize());
6725 if (fFrame) fFrame->UseCurrentStyle();
6727 if (gStyle->IsReading()) Modified();
6788 TObject *TPad::WaitPrimitive(
const char *pname,
const char *emode)
6790 if (!gPad)
return 0;
6792 if (strlen(emode)) gROOT->SetEditorMode(emode);
6793 if (gROOT->GetEditorMode() == 0 && strlen(pname) > 2) gROOT->SetEditorMode(&pname[1]);
6795 if (!fPrimitives) fPrimitives =
new TList;
6796 gSystem->ProcessEvents();
6797 TObject *oldlast = gPad->GetListOfPrimitives()->Last();
6799 Bool_t testlast = kFALSE;
6800 Bool_t hasname = strlen(pname) > 0;
6801 if (!pname[0] && !emode[0]) testlast = kTRUE;
6802 if (testlast) gROOT->SetEditorMode();
6803 while (!gSystem->ProcessEvents() && gROOT->GetSelectedPad()) {
6804 if (gROOT->GetEditorMode() == 0) {
6806 obj = FindObject(pname);
6807 if (obj)
return obj;
6810 obj = gPad->GetListOfPrimitives()->Last();
6811 if (obj != oldlast)
return obj;
6812 Int_t
event = GetEvent();
6813 if (event == kButton1Double || event == kKeyPress) {
6816 fCanvas->HandleInput((EEventType)-1,0,0);
6830 TObject *TPad::CreateToolTip(
const TBox *box,
const char *text, Long_t delayms)
6832 if (gPad->IsBatch())
return 0;
6833 return (TObject*)gROOT->ProcessLineFast(Form(
"new TGToolTip((TBox*)0x%lx,\"%s\",%d)",
6834 (Long_t)box,text,(Int_t)delayms));
6840 void TPad::DeleteToolTip(TObject *tip)
6844 gROOT->ProcessLineFast(Form(
"delete (TGToolTip*)0x%lx", (Long_t)tip));
6851 void TPad::ResetToolTip(TObject *tip)
6855 gROOT->ProcessLineFast(Form(
"((TGToolTip*)0x%lx)->Reset((TPad*)0x%lx)",
6856 (Long_t)tip,(Long_t)
this));
6862 void TPad::CloseToolTip(TObject *tip)
6866 gROOT->ProcessLineFast(Form(
"((TGToolTip*)0x%lx)->Hide()",(Long_t)tip));
6872 void TPad::x3d(Option_t *type)
6874 ::Info(
"TPad::x3d()",
"This function is deprecated. Use %s->GetViewer3D(\"x3d\") instead",this->GetName());
6877 if (!type || !type[0]) {
6890 TVirtualViewer3D *TPad::GetViewer3D(Option_t *type)
6892 Bool_t validType = kFALSE;
6894 if ( (!type || !type[0] || (strstr(type,
"gl") && !strstr(type,
"ogl"))) && !fCanvas->UseGL())
6897 if (type && type[0]) {
6899 if (gPluginMgr->FindHandler(
"TVirtualViewer3D", type))
6917 TVirtualViewer3D *newViewer = 0;
6919 Bool_t createdExternal = kFALSE;
6922 if (!strstr(type,
"pad")) {
6923 newViewer = TVirtualViewer3D::Viewer3D(
this,type);
6926 Warning(
"TPad::CreateViewer3D",
"Cannot create 3D viewer of type: %s", type);
6932 if (strstr(type,
"gl") && !strstr(type,
"ogl"))
6933 fEmbeddedGL = kTRUE, fCopyGLDevice = kTRUE, Modified();
6935 createdExternal = kTRUE;
6938 newViewer =
new TViewer3DPad(*
this);
6946 fViewer3D = newViewer;
6951 if (createdExternal) {
6962 void TPad::ReleaseViewer3D(Option_t * )
6964 fViewer3D =
nullptr;
6978 Int_t TPad::GetGLDevice()
6986 void TPad::RecordPave(
const TObject *obj)
6988 Emit(
"RecordPave(const TObject*)", (Long_t)obj);
6994 void TPad::RecordLatex(
const TObject *obj)
6996 Emit(
"RecordLatex(const TObject*)", (Long_t)obj);
7002 TVirtualPadPainter *TPad::GetPainter()
7004 if (!fCanvas)
return nullptr;
7005 return fCanvas->GetCanvasPainter();
7011 Rectangle_t TPad::GetBBox()
7014 BBox.fX = gPad->XtoPixel(fXlowNDC*(gPad->GetX2()-gPad->GetX1()) + gPad->GetX1());
7015 BBox.fY = gPad->YtoPixel((fYlowNDC+fHNDC)*(gPad->GetY2()-gPad->GetY1()) + gPad->GetY1());
7016 BBox.fWidth = gPad->XtoPixel((fXlowNDC+fWNDC)*(gPad->GetX2()-gPad->GetX1()) + gPad->GetX1()) - gPad->XtoPixel(fXlowNDC*(gPad->GetX2()-gPad->GetX1()) + gPad->GetX1());
7017 BBox.fHeight = gPad->YtoPixel((fYlowNDC)*(gPad->GetY2()-gPad->GetY1()) + gPad->GetY1()) - gPad->YtoPixel((fYlowNDC+fHNDC)*(gPad->GetY2()-gPad->GetY1()) + gPad->GetY1());
7025 TPoint TPad::GetBBoxCenter()
7028 Double_t x = ((fXlowNDC+0.5*fWNDC)*(gPad->GetX2()-gPad->GetX1())) + gPad->GetX1();
7029 Double_t y = ((fYlowNDC+0.5*fHNDC)*(gPad->GetY2()-gPad->GetY1())) + gPad->GetY1();
7031 p.SetX(gPad->XtoPixel(x));
7032 p.SetY(gPad->YtoPixel(y));
7039 void TPad::SetBBoxCenter(
const TPoint &p)
7041 fXlowNDC = (gPad->PixeltoX(p.GetX()) - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1())-0.5*fWNDC;
7042 fYlowNDC = (gPad->PixeltoY(p.GetY()-gPad->VtoPixel(0)) - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1())-0.5*fHNDC;
7049 void TPad::SetBBoxCenterX(
const Int_t x)
7051 fXlowNDC = (gPad->PixeltoX(x) - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1())-0.5*fWNDC;
7058 void TPad::SetBBoxCenterY(
const Int_t y)
7060 fYlowNDC = (gPad->PixeltoY(y-gPad->VtoPixel(0)) - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1())-0.5*fHNDC;
7068 void TPad::SetBBoxX1(
const Int_t x)
7070 fXlowNDC = (gPad->PixeltoX(x) - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1());
7071 fWNDC = fXUpNDC - fXlowNDC;
7079 void TPad::SetBBoxX2(
const Int_t x)
7081 fWNDC = (gPad->PixeltoX(x) - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1())-fXlowNDC;
7088 void TPad::SetBBoxY1(
const Int_t y)
7090 fHNDC = (gPad->PixeltoY(y-gPad->VtoPixel(0)) - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1())-fYlowNDC;
7098 void TPad::SetBBoxY2(
const Int_t y)
7100 fYlowNDC = (gPad->PixeltoY(y-gPad->VtoPixel(0)) - gPad->GetY1())/(gPad->GetY2()-gPad->GetY1());
7101 fHNDC = fYUpNDC - fYlowNDC;