Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPad.cxx
Go to the documentation of this file.
1// @(#)root/gpad:$Id$
2// Author: Rene Brun 12/12/94
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include <cstring>
13#include <cstdlib>
14#include <iostream>
15#include <locale>
16#include <memory>
17#include <cmath>
18
19#include "TROOT.h"
20#include "TBuffer.h"
21#include "TBoxInteractive.h"
22#include "TError.h"
23#include "TMath.h"
24#include "TSystem.h"
25#include "TStyle.h"
26#include "TFile.h"
27#include "TH1.h"
28#include "TH2.h"
29#include "TH3.h"
30#include "TClass.h"
31#include "TBaseClass.h"
32#include "TClassTable.h"
33#include "TVirtualPS.h"
34#include "TVirtualViewer3D.h"
35#include "TView.h"
36#include "TPoint.h"
37#include "TGraph.h"
38#include "TMultiGraph.h"
39#include "THStack.h"
40#include "TPaveText.h"
41#include "TPaveStats.h"
42#include "TGroupButton.h"
43#include "TBrowser.h"
44#include "TVirtualGL.h"
45#include "TString.h"
46#include "TDataMember.h"
47#include "TMethod.h"
48#include "TDataType.h"
49#include "TFrame.h"
50#include "TWbox.h"
51#include "TExec.h"
52#include "TDatime.h"
53#include "TColor.h"
54#include "TCanvas.h"
55#include "TCanvasImp.h"
56#include "TPluginManager.h"
57#include "TEnv.h"
58#include "TImage.h"
59#include "TViewer3DPad.h"
60#include "TCreatePrimitives.h"
61#include "TArrow.h"
62#include "TLegend.h"
63#include "TAtt3D.h"
64#include "TVirtualPadPainter.h"
65#include "strlcpy.h"
66
67#include "TVirtualMutex.h"
68
69#include <cstdio>
70
71static Int_t gReadLevel = 0;
72
74
75/** \class TPad
76\ingroup gpad
77
78The most important graphics class in the ROOT system.
79
80A Pad is contained in a Canvas.
81
82A Pad may contain other pads (unlimited pad hierarchy).
83
84A pad is a linked list of primitives of any type (graphics objects,
85histograms, detectors, tracks, etc.).
86
87Adding a new element into a pad is in general performed by the Draw
88member function of the object classes.
89
90It is important to realize that the pad is a linked list of references
91to the original object.
92For example, in case of a histogram, the histogram.Draw() operation
93only stores a reference to the histogram object and not a graphical
94representation of this histogram.
95When the mouse is used to change (say the bin content), the bin content
96of the original histogram is changed.
97
98The convention used in ROOT is that a Draw operation only adds
99a reference to the object. The effective drawing is performed
100when the canvas receives a signal to be painted.
101
102\image html gpad_pad1.png
103
104This signal is generally sent when typing carriage return in the
105command input or when a graphical operation has been performed on one
106of the pads of this canvas.
107When a Canvas/Pad is repainted, the member function Paint for all
108objects in the Pad linked list is invoked.
109
110\image html gpad_pad2.png
111
112When the mouse is moved on the Pad, The member function DistancetoPrimitive
113is called for all the elements in the pad. DistancetoPrimitive returns
114the distance in pixels to this object.
115
116When the object is within the distance window, the member function
117ExecuteEvent is called for this object.
118
119In ExecuteEvent, move, changes can be performed on the object.
120
121For examples of DistancetoPrimitive and ExecuteEvent functions,
122see classes
123~~~ {.cpp}
124 TLine::DistancetoPrimitive, TLine::ExecuteEvent
125 TBox::DistancetoPrimitive, TBox::ExecuteEvent
126 TH1::DistancetoPrimitive, TH1::ExecuteEvent
127~~~
128A Pad supports linear and log scales coordinate systems.
129The transformation coefficients are explained in TPad::ResizePad.
130*/
131
133
134 public:
136
137 template<typename T>
138 TPadDrawOperation(Int_t n, T *x, T *y, EKind kind, Int_t arg = 1, Bool_t ndc = kFALSE)
139 {
140 fX.assign(x, x + n);
141 fY.assign(y, y + n);
142 fKind = kind;
143 fArg = arg; // operation arg like line width
144 fNDC = ndc;
145 }
146 virtual ~TPadDrawOperation() = default;
147
148 void Draw(TPad &pad, TVirtualPadPainter *pp, Bool_t withXor)
149 {
150 auto doFill = [pp, withXor](Int_t n, Double_t *xx, Double_t *yy) {
151 Color_t col = kBlack;
152 if (!withXor)
153 col = TColor::GetColor(0, 0, 0, 0.25);
154 pp->SetAttFill({col, 1001});
155 pp->DrawFillArea(n, xx, yy);
156 };
157
158 if (fKind == drawFill)
159 doFill(fX.size(), fX.data(), fY.data());
160 else if (fKind == drawLine) {
161 pp->SetAttLine({kBlack, 1, (Width_t)fArg});
162 if (fNDC)
163 pp->DrawPolyLineNDC(fX.size(), fX.data(), fY.data());
164 else
165 pp->DrawPolyLine(fX.size(), fX.data(), fY.data());
166 } else {
167 Double_t dx = (pad.GetX2() - pad.GetX1()) / pad.GetPadWidth() * 5;
168 Double_t dy = (pad.GetY2() - pad.GetY1()) / pad.GetPadHeight() * 5;
169
170 for (std::size_t i = 0; i < fX.size(); ++i) {
171 Double_t mx = fX[i], my = fY[i];
172 if (!fArg) {
173 // fill diamond
174 Double_t xc[5] = { mx, mx + dx, mx, mx - dx, mx };
175 Double_t yc[5] = { my - dy, my, my + dy, my, my - dy };
176 doFill(5, xc, yc);
177 } else {
178 // rectangle
179 pp->SetAttLine({kBlack, 1, (Width_t)fArg});
180 Double_t xl[5] = { mx - dx, mx + dx, mx + dx, mx - dx, mx - dx };
181 Double_t yl[5] = { my - dy, my - dy, my + dy, my + dy, my - dy };
182 pp->DrawPolyLine(5, xl, yl);
183 }
184 }
185 }
186 }
187
188 protected:
189 std::vector<Double_t> fX, fY;
193};
194
195
196////////////////////////////////////////////////////////////////////////////////
197/// Pad default constructor.
198
200{
202 fTip = nullptr;
203 fPadPointer = nullptr;
204 fPrimitives = nullptr;
205 fExecs = nullptr;
206 fCanvas = nullptr;
207 fPadPaint = 0;
208 fPixmapID = -1;
209 fGLDevice = -1;
212 fTheta = 30;
213 fPhi = 30;
214 fNumber = 0;
217 fCrosshair = 0;
218 fCrosshairPos = 0;
219 fPadView3D = nullptr;
220 fMother = (TPad*)gPad;
221
222 fAbsHNDC = 0.;
223 fAbsPixeltoXk = 0.;
224 fAbsPixeltoYk = 0.;
225 fAbsWNDC = 0.;
226 fAbsXlowNDC = 0.;
227 fAbsYlowNDC = 0.;
228 fBorderMode = 0;
229 fBorderSize = 0;
230 fPixeltoX = 0;
231 fPixeltoXk = 0.;
232 fPixeltoY = 0.;
233 fPixeltoYk = 0.;
234 fUtoAbsPixelk = 0.;
235 fUtoPixel = 0.;
236 fUtoPixelk = 0.;
237 fVtoAbsPixelk = 0.;
238 fVtoPixel = 0.;
239 fVtoPixelk = 0.;
240 fXtoAbsPixelk = 0.;
241 fXtoPixel = 0.;
242 fXtoPixelk = 0.;
243 fYtoAbsPixelk = 0.;
244 fYtoPixel = 0.;
245 fYtoPixelk = 0.;
246 fXUpNDC = 0.;
247 fYUpNDC = 0.;
248
250 fAspectRatio = 0.;
251
254 fCGnx = 0;
255 fCGny = 0;
256
257 fLogx = 0;
258 fLogy = 0;
259 fLogz = 0;
260 fGridx = false;
261 fGridy = false;
262 fTickx = 0;
263 fTicky = 0;
264 fFrame = nullptr;
265 fView = nullptr;
266
267 fUxmin = fUymin = fUxmax = fUymax = 0;
268
269 // Set default world coordinates to NDC [0,1]
270 fX1 = 0;
271 fX2 = 1;
272 fY1 = 0;
273 fY2 = 1;
274
275 // Set default pad range
276 fXlowNDC = 0;
277 fYlowNDC = 0;
278 fWNDC = 1;
279 fHNDC = 1;
280
281 fViewer3D = nullptr;
283
284 // the following line is temporarily disabled. It has side effects
285 // when the pad is a TDrawPanelHist or a TFitPanel.
286 // the line was supposed to fix a problem with DrawClonePad
287 // gROOT->SetSelectedPad(this);
288}
289
290////////////////////////////////////////////////////////////////////////////////
291/// Pad constructor.
292///
293/// A pad is a linked list of primitives.
294/// A pad is contained in a canvas. It may contain other pads.
295/// A pad has attributes. When a pad is created, the attributes
296/// defined in the current style are copied to the pad attributes.
297///
298/// \param[in] name pad name
299/// \param[in] title pad title
300/// \param[in] xlow [0,1] is the position of the bottom left point of the pad
301/// expressed in the mother pad reference system
302/// \param[in] ylow [0,1] is the Y position of this point.
303/// \param[in] xup [0,1] is the x position of the top right point of the pad
304/// expressed in the mother pad reference system
305/// \param[in] yup [0,1] is the Y position of this point.
306/// \param[in] color pad color
307/// \param[in] bordersize border size in pixels
308/// \param[in] bordermode border mode
309/// - bordermode = -1 box looks as it is behind the screen
310/// - bordermode = 0 no special effects
311/// - bordermode = 1 box looks as it is in front of the screen
312
313TPad::TPad(const char *name, const char *title, Double_t xlow,
314 Double_t ylow, Double_t xup, Double_t yup,
315 Color_t color, Short_t bordersize, Short_t bordermode)
316 : TVirtualPad(name,title,xlow,ylow,xup,yup,color,bordersize,bordermode)
317{
319 fTip = nullptr;
320 fBorderSize = bordersize;
321 fBorderMode = bordermode;
322 if (gPad) fCanvas = gPad->GetCanvas();
323 else fCanvas = (TCanvas*)this;
324 fMother = (TPad*)gPad;
325 fPrimitives = new TList;
326 fExecs = new TList;
327 fPadPointer = nullptr;
328 fTheta = 30;
329 fPhi = 30;
334 fFrame = nullptr;
335 fView = nullptr;
336 fPadPaint = 0;
337 fPadView3D = nullptr;
338 fPixmapID = -1; // -1 means pixmap will be created by ResizePad()
341 fNumber = 0;
344 fCrosshair = 0;
345 fCrosshairPos = 0;
346
347 fVtoAbsPixelk = 0.;
348 fVtoPixelk = 0.;
349 fVtoPixel = 0.;
350 fAbsPixeltoXk = 0.;
351 fPixeltoXk = 0.;
352 fPixeltoX = 0;
353 fAbsPixeltoYk = 0.;
354 fPixeltoYk = 0.;
355 fPixeltoY = 0.;
356 fXlowNDC = 0;
357 fYlowNDC = 0;
358 fWNDC = 1;
359 fHNDC = 1;
360 fXUpNDC = 0.;
361 fYUpNDC = 0.;
362 fAbsXlowNDC = 0.;
363 fAbsYlowNDC = 0.;
364 fAbsWNDC = 0.;
365 fAbsHNDC = 0.;
366 fXtoAbsPixelk = 0.;
367 fXtoPixelk = 0.;
368 fXtoPixel = 0.;
369 fYtoAbsPixelk = 0.;
370 fYtoPixelk = 0.;
371 fYtoPixel = 0.;
372 fUtoAbsPixelk = 0.;
373 fUtoPixelk = 0.;
374 fUtoPixel = 0.;
375
376 fUxmin = fUymin = fUxmax = fUymax = 0;
380
382 fAspectRatio = 0.;
383
386 fCGnx = 0;
387 fCGny = 0;
388
389 fViewer3D = nullptr;
390
392 // Set default world coordinates to NDC [0,1]
393 fX1 = 0;
394 fX2 = 1;
395 fY1 = 0;
396 fY2 = 1;
397
398 if (!gPad) {
399 Error("TPad", "You must create a TCanvas before creating a TPad");
400 MakeZombie();
401 return;
402 }
403
404 TContext ctxt(kTRUE);
405
406 Bool_t zombie = kFALSE;
407
408 if ((xlow < 0) || (xlow > 1) || (ylow < 0) || (ylow > 1)) {
409 Error("TPad", "illegal bottom left position: x=%f, y=%f", xlow, ylow);
410 zombie = kTRUE;
411 } else if ((xup < 0) || (xup > 1) || (yup < 0) || (yup > 1)) {
412 Error("TPad", "illegal top right position: x=%f, y=%f", xup, yup);
413 zombie = kTRUE;
414 } else if (xup-xlow <= 0) {
415 Error("TPad", "illegal width: %f", xup-xlow);
416 zombie = kTRUE;
417 } else if (yup-ylow <= 0) {
418 Error("TPad", "illegal height: %f", yup-ylow);
419 zombie = kTRUE;
420 }
421
422 if (zombie) {
423 // error in creating pad occurred, make this pad a zombie
424 MakeZombie();
425 return;
426 }
427
428
432
433 fUxmin = fUymin = fUxmax = fUymax = 0;
434
435 // Set pad parameters and Compute conversion coefficients
436 SetPad(name, title, xlow, ylow, xup, yup, color, bordersize, bordermode);
437 Range(0, 0, 1, 1);
440}
441
442
443////////////////////////////////////////////////////////////////////////////////
444/// Pad destructor.
445
447{
448 if (ROOT::Detail::HasBeenDeleted(this)) return;
449 Close();
452 auto primitives = fPrimitives;
453 // In some cases, fPrimitives has the kMustCleanup bit set which will lead
454 // its destructor to call RecursiveRemove and since this pad is still
455 // likely to be (indirectly) in the list of cleanups, we must set
456 // fPrimitives to nullptr to avoid TPad::RecursiveRemove from calling
457 // a member function of a partially destructed object.
458 fPrimitives = nullptr;
459 delete primitives;
461 delete fViewer3D;
462
463 // Required since we overload TObject::Hash.
465 if (this == gPad)
466 gPad = nullptr;
467}
468
469////////////////////////////////////////////////////////////////////////////////
470/// Add an object to list of primitives with specified draw option
471/// When \par modified set to kTRUE (default) pad will be marked as modified
472/// Let avoid usage of gPad when drawing object(s) in canvas or in subpads.
473///
474/// ~~~{.cpp}
475/// auto c1 = new TCanvas("c1","Canvas with subpads", 600, 600);
476/// c1->Divide(2,2);
477///
478/// for (Int_t n = 1; n <= 4; ++n) {
479/// auto h1 = new TH1I(TString::Format("hist_%d",n), "Random hist", 100, -5, 5);
480/// h1->FillRandom("gaus", 2000 + n*1000);
481/// c1->GetPad(n)->Add(h1);
482/// }
483/// ~~~
484
485void TPad::Add(TObject *obj, Option_t *opt, Bool_t modified)
486{
487 if (!obj)
488 return;
489
490 if (!fPrimitives)
491 fPrimitives = new TList;
492
493 obj->SetBit(kMustCleanup);
494
495 fPrimitives->Add(obj, opt);
496
497 if (modified)
498 Modified();
499}
500
501////////////////////////////////////////////////////////////////////////////////
502/// Add an object as first in list of primitives with specified draw option
503/// When \par modified set to kTRUE (default) pad will be marked as modified
504/// Let avoid usage of gPad when drawing object(s) in canvas or in subpads.
505
506void TPad::AddFirst(TObject *obj, Option_t *opt, Bool_t modified)
507{
508 if (!obj)
509 return;
510
511 if (!fPrimitives)
512 fPrimitives = new TList;
513
514 obj->SetBit(kMustCleanup);
515
516 fPrimitives->AddFirst(obj, opt);
517
518 if (modified)
519 Modified();
520}
521
522////////////////////////////////////////////////////////////////////////////////
523/// Add a new TExec object to the list of Execs.
524///
525/// When an event occurs in the pad (mouse click, etc) the list of C++ commands
526/// in the list of Execs are executed via TPad::AutoExec.
527///
528/// When a pad event occurs (mouse move, click, etc) all the commands
529/// contained in the fExecs list are executed in the order found in the list.
530///
531/// This facility is activated by default. It can be deactivated by using
532/// the canvas "Option" menu.
533///
534/// The following examples of TExec commands are provided in the tutorials:
535/// macros exec1.C and exec2.C.
536///
537/// ### Example1 of use of exec1.C
538///
539/// ~~~ {.cpp}
540/// Root > TFile f("hsimple.root")
541/// Root > hpx.Draw()
542/// Root > c1.AddExec("ex1",".x exec1.C")
543/// ~~~
544///
545/// At this point you can use the mouse to click on the contour of
546/// the histogram hpx. When the mouse is clicked, the bin number and its
547/// contents are printed.
548///
549/// ### Example2 of use of exec1.C
550///
551/// ~~~ {.cpp}
552/// Root > TFile f("hsimple.root")
553/// Root > hpxpy.Draw()
554/// Root > c1.AddExec("ex2",".x exec2.C")
555/// ~~~
556///
557/// When moving the mouse in the canvas, a second canvas shows the
558/// projection along X of the bin corresponding to the Y position
559/// of the mouse. The resulting histogram is fitted with a gaussian.
560/// A "dynamic" line shows the current bin position in Y.
561/// This more elaborated example can be used as a starting point
562/// to develop more powerful interactive applications exploiting the C++
563/// interpreter as a development engine.
564
565void TPad::AddExec(const char *name, const char *command)
566{
567 if (!fExecs) fExecs = new TList;
568 TExec *ex = new TExec(name,command);
569 fExecs->Add(ex);
570}
571
572////////////////////////////////////////////////////////////////////////////////
573/// Execute the list of Execs when a pad event occurs.
574
576{
577 TIter next(fExecs);
578 while (auto exec = static_cast<TExec *>(next()))
579 exec->Exec();
580
581 if (GetCrosshair())
583}
584
585////////////////////////////////////////////////////////////////////////////////
586/// Browse pad.
587
589{
590 cd();
592}
593
594////////////////////////////////////////////////////////////////////////////////
595/// Build a legend from the graphical objects in the pad.
596///
597/// A simple method to build automatically a TLegend from the primitives in a TPad.
598///
599/// Only those deriving from TAttLine, TAttMarker and TAttFill are added, excluding
600/// TPave and TFrame derived classes.
601///
602/// \return The built TLegend
603///
604/// \param[in] x1, y1, x2, y2 The TLegend coordinates
605/// \param[in] title The legend title. By default it is " "
606/// \param[in] option The TLegend option
607///
608/// The caller program owns the returned TLegend.
609///
610/// If the pad contains some TMultiGraph or THStack the individual
611/// graphs or histograms in them are added to the TLegend.
612///
613/// ### Automatic placement of the legend
614/// If `x1` is equal to `x2` and `y1` is equal to `y2` the legend will be automatically
615/// placed to avoid overlapping with the existing primitives already displayed.
616/// `x1` is considered as the width of the legend and `y1` the height. By default
617/// the legend is automatically placed with width = `x1`= `x2` = 0.3 and
618/// height = `y1`= `y2` = 0.21.
619
621 const char* title, Option_t *option)
622{
623 TList *lop = GetListOfPrimitives();
624 if (!lop) return nullptr;
625 TList *lof = nullptr;
626 TLegend *leg = nullptr;
627 TObject *obj = nullptr;
628 TIter next(lop);
629 TString mes;
630 TString opt;
631
632 auto AddEntryFromListOfFunctions = [&]() {
633 TIter nextobj(lof);
634 while ((obj = nextobj())) {
635 if (obj->InheritsFrom(TNamed::Class())) {
636 if (strlen(obj->GetTitle()))
637 mes = obj->GetTitle();
638 else
639 mes = obj->GetName();
640 } else {
641 mes = obj->ClassName();
642 }
643 leg->AddEntry(obj, mes.Data(), "lpf");
644 }
645 };
646
647 while(auto o = next()) {
648 if ((o->InheritsFrom(TAttLine::Class()) || o->InheritsFrom(TAttMarker::Class()) ||
649 o->InheritsFrom(TAttFill::Class())) &&
650 ( !(o->InheritsFrom(TFrame::Class())) && !(o->InheritsFrom(TPave::Class())) )) {
651 if (!leg)
652 leg = new TLegend(x1, y1, x2, y2, title);
653 if (o->InheritsFrom(TNamed::Class()) && strlen(o->GetTitle()))
654 mes = o->GetTitle();
655 else if (strlen(o->GetName()))
656 mes = o->GetName();
657 else
658 mes = o->ClassName();
659 if (option && strlen(option)) {
660 opt = option;
661 } else {
662 if (o->InheritsFrom(TAttLine::Class()))
663 opt += "l";
664 if (o->InheritsFrom(TAttMarker::Class()))
665 opt += "p";
666 if (o->InheritsFrom(TAttFill::Class()))
667 opt += "f";
668 }
669 leg->AddEntry(o,mes.Data(), opt.Data());
670 if (o->InheritsFrom(TH1::Class())) {
671 lof = ((TH1 *)o)->GetListOfFunctions();
672 AddEntryFromListOfFunctions();
673 }
674 if (o->InheritsFrom(TGraph::Class())) {
675 lof = ((TGraph *)o)->GetListOfFunctions();
676 AddEntryFromListOfFunctions();
677 }
678 } else if (o->InheritsFrom(TMultiGraph::Class())) {
679 if (!leg)
680 leg = new TLegend(x1, y1, x2, y2, title);
681 TList * grlist = ((TMultiGraph *)o)->GetListOfGraphs();
682 TIter nextgraph(grlist);
683 TGraph *gr = nullptr;
684 while ((obj = nextgraph())) {
685 gr = (TGraph*) obj;
686 if (strlen(gr->GetTitle()))
687 mes = gr->GetTitle();
688 else if (strlen(gr->GetName()))
689 mes = gr->GetName();
690 else
691 mes = gr->ClassName();
692 if (option && strlen(option))
693 opt = option;
694 else
695 opt = "lpf";
696 leg->AddEntry(obj, mes.Data(), opt);
697 }
698 lof = ((TMultiGraph *)o)->GetListOfFunctions();
699 AddEntryFromListOfFunctions();
700 } else if (o->InheritsFrom(THStack::Class())) {
701 if (!leg)
702 leg = new TLegend(x1, y1, x2, y2, title);
703 TList * hlist = ((THStack *)o)->GetHists();
704 TIter nexthist(hlist);
705 while ((obj = nexthist())) {
706 TH1 *hist = (TH1*) obj;
707 if (strlen(hist->GetTitle()))
708 mes = hist->GetTitle();
709 else if (strlen(hist->GetName()))
710 mes = hist->GetName();
711 else
712 mes = hist->ClassName();
713 if (option && strlen(option))
714 opt = option;
715 else
716 opt = "lpf";
717 leg->AddEntry( obj, mes.Data(), opt );
718 }
719 }
720 opt = "";
721 }
722 if (leg) {
723 TContext ctxt(this, kTRUE);
724 leg->Draw();
725 } else {
726 Info("BuildLegend", "No object(s) to build a TLegend.");
727 }
728 return leg;
729}
730
731////////////////////////////////////////////////////////////////////////////////
732/// Set Current pad.
733///
734/// When a canvas/pad is divided via TPad::Divide, one can directly
735/// set the current path to one of the subdivisions.
736/// See TPad::Divide for the convention to number sub-pads.
737///
738/// Returns the new current pad, or 0 in case of failure.
739///
740/// For example:
741/// ~~~ {.cpp}
742/// c1.Divide(2,3); // create 6 pads (2 divisions along x, 3 along y).
743/// ~~~
744/// To set the current pad to the bottom right pad, do
745/// ~~~ {.cpp}
746/// c1.cd(6);
747/// ~~~
748/// Note1: c1.cd() is equivalent to c1.cd(0) and sets the current pad
749/// to c1 itself.
750///
751/// Note2: after a statement like c1.cd(6), the global variable gPad
752/// points to the current pad. One can use gPad to set attributes
753/// of the current pad.
754///
755/// Note3: One can get a pointer to one of the sub-pads of pad with:
756/// TPad *subpad = (TPad*)pad->GetPad(subpadnumber);
757
759{
760 if (!subpadnumber) {
761 gPad = this;
762 if (!gPad->IsBatch() && GetPainter()) GetPainter()->SelectDrawable(fPixmapID);
763 if (!fPrimitives) fPrimitives = new TList;
764 return gPad;
765 }
766
767 if (!fPrimitives) fPrimitives = new TList;
768 TIter next(fPrimitives);
769 while (auto obj = next()) {
770 if (obj->InheritsFrom(TPad::Class())) {
771 Int_t n = ((TPad*)obj)->GetNumber();
772 if (n == subpadnumber) {
773 return ((TPad*)obj)->cd();
774 }
775 }
776 }
777 return nullptr;
778}
779
780////////////////////////////////////////////////////////////////////////////////
781/// Delete all pad primitives.
782///
783/// If the bit kClearAfterCR has been set for this pad, the Clear function
784/// will execute only after having pressed a CarriageReturn
785/// Set the bit with `mypad->SetBit(TPad::kClearAfterCR)`
786
788{
789 if (!IsEditable()) return;
790
792
793 if (!fPadPaint) {
796 if (fFrame) {
798 fFrame = nullptr;
799 }
800 }
801 if (fCanvas) fCanvas->Cleared(this);
802
803 cd();
804
805 if (TestBit(kClearAfterCR)) {
806 // Intentional do not use the return value of getchar,
807 // we just want to get it and forget it
808 getchar();
809 }
810
811 auto pp = GetPainter();
812 // If pad painter uses PS, TPad::Clear() start new page
813 if (pp && pp->GetPS())
814 pp->NewPage();
815
817 fCrosshairPos = 0;
819 fCollideGrid.clear();
820 fCGnx = 0;
821 fCGny = 0;
823}
824
825////////////////////////////////////////////////////////////////////////////////
826/// Clipping routine: Cohen Sutherland algorithm.
827///
828/// - If Clip ==2 the segment is outside the boundary.
829/// - If Clip ==1 the segment has one point outside the boundary.
830/// - If Clip ==0 the segment is inside the boundary.
831///
832/// \param[inout] x[],y[] Segment coordinates (2 points)
833/// \param[in] xclipl,yclipb,xclipr,yclipt Clipping boundary
834
835Int_t TPad::Clip(Float_t *x, Float_t *y, Float_t xclipl, Float_t yclipb, Float_t xclipr, Float_t yclipt)
836{
837 const Float_t kP=10000;
838 Int_t clip = 0;
839
840 for (Int_t i=0;i<2;i++) {
841 if (TMath::Abs(xclipl-x[i]) <= TMath::Abs(xclipr-xclipl)/kP) x[i] = xclipl;
842 if (TMath::Abs(xclipr-x[i]) <= TMath::Abs(xclipr-xclipl)/kP) x[i] = xclipr;
843 if (TMath::Abs(yclipb-y[i]) <= TMath::Abs(yclipt-yclipb)/kP) y[i] = yclipb;
844 if (TMath::Abs(yclipt-y[i]) <= TMath::Abs(yclipt-yclipb)/kP) y[i] = yclipt;
845 }
846
847 // Compute the first endpoint codes.
848 Int_t code1 = ClippingCode(x[0],y[0],xclipl,yclipb,xclipr,yclipt);
849 Int_t code2 = ClippingCode(x[1],y[1],xclipl,yclipb,xclipr,yclipt);
850
851 Double_t xt=0, yt=0;
852 Int_t clipped = 0; //this variable could be used in a future version
853 while(code1 + code2) {
854 clipped = 1;
855
856 // The line lies entirely outside the clipping boundary
857 if (code1&code2) {
858 clip = 2;
859 return clip;
860 }
861
862 // The line is subdivided into several parts
863 Int_t ic = code1;
864 if (ic == 0) ic = code2;
865 if (ic & 0x1) {
866 yt = y[0] + (y[1]-y[0])*(xclipl-x[0])/(x[1]-x[0]);
867 xt = xclipl;
868 }
869 if (ic & 0x2) {
870 yt = y[0] + (y[1]-y[0])*(xclipr-x[0])/(x[1]-x[0]);
871 xt = xclipr;
872 }
873 if (ic & 0x4) {
874 xt = x[0] + (x[1]-x[0])*(yclipb-y[0])/(y[1]-y[0]);
875 yt = yclipb;
876 }
877 if (ic & 0x8) {
878 xt = x[0] + (x[1]-x[0])*(yclipt-y[0])/(y[1]-y[0]);
879 yt = yclipt;
880 }
881 if (ic == code1) {
882 x[0] = xt;
883 y[0] = yt;
884 code1 = ClippingCode(xt,yt,xclipl,yclipb,xclipr,yclipt);
885 } else {
886 x[1] = xt;
887 y[1] = yt;
888 code2 = ClippingCode(xt,yt,xclipl,yclipb,xclipr,yclipt);
889 }
890 }
891 clip = clipped;
892 return clip;
893}
894
895/// @copydoc TPad::Clip(Float_t*,Float_t*,Float_t,Float_t,Float_t,Float_t)
896
898{
899 const Double_t kP = 10000;
900 Int_t clip = 0;
901
902 for (Int_t i=0;i<2;i++) {
903 if (TMath::Abs(xclipl-x[i]) <= TMath::Abs(xclipr-xclipl)/kP) x[i] = xclipl;
904 if (TMath::Abs(xclipr-x[i]) <= TMath::Abs(xclipr-xclipl)/kP) x[i] = xclipr;
905 if (TMath::Abs(yclipb-y[i]) <= TMath::Abs(yclipt-yclipb)/kP) y[i] = yclipb;
906 if (TMath::Abs(yclipt-y[i]) <= TMath::Abs(yclipt-yclipb)/kP) y[i] = yclipt;
907 }
908
909 // Compute the first endpoint codes.
910 Int_t code1 = 0;
911 if (x[0] < xclipl) code1 = code1 | 0x1;
912 if (x[0] > xclipr) code1 = code1 | 0x2;
913 if (y[0] < yclipb) code1 = code1 | 0x4;
914 if (y[0] > yclipt) code1 = code1 | 0x8;
915 Int_t code2 = 0;
916 if (x[1] < xclipl) code2 = code2 | 0x1;
917 if (x[1] > xclipr) code2 = code2 | 0x2;
918 if (y[1] < yclipb) code2 = code2 | 0x4;
919 if (y[1] > yclipt) code2 = code2 | 0x8;
920
921 Double_t xt=0, yt=0;
922 Int_t clipped = 0; //this variable could be used in a future version
923 while(code1 + code2) {
924 clipped = 1;
925
926 // The line lies entirely outside the clipping boundary
927 if (code1&code2) {
928 clip = 2;
929 return clip;
930 }
931
932 // The line is subdivided into several parts
933 Int_t ic = code1;
934 if (ic == 0) ic = code2;
935 if (ic & 0x1) {
936 yt = y[0] + (y[1]-y[0])*(xclipl-x[0])/(x[1]-x[0]);
937 xt = xclipl;
938 }
939 if (ic & 0x2) {
940 yt = y[0] + (y[1]-y[0])*(xclipr-x[0])/(x[1]-x[0]);
941 xt = xclipr;
942 }
943 if (ic & 0x4) {
944 xt = x[0] + (x[1]-x[0])*(yclipb-y[0])/(y[1]-y[0]);
945 yt = yclipb;
946 }
947 if (ic & 0x8) {
948 xt = x[0] + (x[1]-x[0])*(yclipt-y[0])/(y[1]-y[0]);
949 yt = yclipt;
950 }
951 if (ic == code1) {
952 x[0] = xt;
953 y[0] = yt;
954 code1 = ClippingCode(xt,yt,xclipl,yclipb,xclipr,yclipt);
955 } else {
956 x[1] = xt;
957 y[1] = yt;
958 code2 = ClippingCode(xt,yt,xclipl,yclipb,xclipr,yclipt);
959 }
960 }
961 clip = clipped;
962 return clip;
963}
964
965////////////////////////////////////////////////////////////////////////////////
966/// Compute the endpoint codes for TPad::Clip.
967
969{
970 Int_t code = 0;
971 if (x < xcl1) code = code | 0x1;
972 if (x > xcl2) code = code | 0x2;
973 if (y < ycl1) code = code | 0x4;
974 if (y > ycl2) code = code | 0x8;
975 return code;
976}
977
978////////////////////////////////////////////////////////////////////////////////
979/// Clip polygon using the Sutherland-Hodgman algorithm.
980///
981/// \param[in] n Number of points in the polygon to
982/// be clipped
983/// \param[in] x,y Polygon x[n], y[n] do be clipped vertices
984/// \param[in] xclipl,yclipb,xclipr,yclipt Clipping boundary
985/// \param[out] nn Number of points in xc and yc
986/// \param[out] xc,yc Clipped polygon vertices. The Int_t
987/// returned by this function is
988/// the number of points in the clipped
989/// polygon. These vectors must
990/// be allocated by the calling function.
991/// A size of 2*n for each is
992/// enough.
993///
994/// Sutherland and Hodgman's polygon-clipping algorithm uses a divide-and-conquer
995/// strategy: It solves a series of simple and identical problems that, when
996/// combined, solve the overall problem. The simple problem is to clip a polygon
997/// against a single infinite clip edge. Four clip edges, each defining one boundary
998/// of the clip rectangle, successively clip a polygon against a clip rectangle.
999///
1000/// Steps of Sutherland-Hodgman's polygon-clipping algorithm:
1001///
1002/// * Polygons can be clipped against each edge of the window one at a time.
1003/// Windows/edge intersections, if any, are easy to find since the X or Y coordinates
1004/// are already known.
1005/// * Vertices which are kept after clipping against one window edge are saved for
1006/// clipping against the remaining edges.
1007/// * Note that the number of vertices usually changes and will often increases.
1008///
1009/// The clip boundary determines a visible and invisible region. The edges from
1010/// vertex i to vertex i+1 can be one of four types:
1011///
1012/// * Case 1 : Wholly inside visible region - save endpoint
1013/// * Case 2 : Exit visible region - save the intersection
1014/// * Case 3 : Wholly outside visible region - save nothing
1015/// * Case 4 : Enter visible region - save intersection and endpoint
1016
1018{
1019 if (n <= 0)
1020 return 0;
1021
1022 Int_t nc, nc2;
1023 Double_t x1, y1, x2, y2, slope; // Segment to be clipped
1024
1025 std::vector<Double_t> xc2(nn), yc2(nn);
1026
1027 // Clip against the left boundary
1028 x1 = x[n - 1];
1029 y1 = y[n - 1];
1030 nc2 = 0;
1031 Int_t i;
1032 for (i = 0; i < n; i++) {
1033 x2 = x[i]; y2 = y[i];
1034 if (x1 == x2) {
1035 slope = 0;
1036 } else {
1037 slope = (y2-y1)/(x2-x1);
1038 }
1039 if (x1 >= xclipl) {
1040 if (x2 < xclipl) {
1041 xc2[nc2] = xclipl; yc2[nc2++] = slope*(xclipl-x1)+y1;
1042 } else {
1043 xc2[nc2] = x2; yc2[nc2++] = y2;
1044 }
1045 } else {
1046 if (x2 >= xclipl) {
1047 xc2[nc2] = xclipl; yc2[nc2++] = slope*(xclipl-x1)+y1;
1048 xc2[nc2] = x2; yc2[nc2++] = y2;
1049 }
1050 }
1051 x1 = x2; y1 = y2;
1052 }
1053
1054 // Clip against the top boundary
1055 if (nc2 > 0) {
1056 x1 = xc2[nc2 - 1];
1057 y1 = yc2[nc2 - 1];
1058 }
1059 nc = 0;
1060 for (i = 0; i < nc2; i++) {
1061 x2 = xc2[i]; y2 = yc2[i];
1062 if (y1 == y2) {
1063 slope = 0;
1064 } else {
1065 slope = (x2-x1)/(y2-y1);
1066 }
1067 if (y1 <= yclipt) {
1068 if (y2 > yclipt) {
1069 xc[nc] = x1+(yclipt-y1)*slope; yc[nc++] = yclipt;
1070 } else {
1071 xc[nc] = x2; yc[nc++] = y2;
1072 }
1073 } else {
1074 if (y2 <= yclipt) {
1075 xc[nc] = x1+(yclipt-y1)*slope; yc[nc++] = yclipt;
1076 xc[nc] = x2; yc[nc++] = y2;
1077 }
1078 }
1079 x1 = x2; y1 = y2;
1080 }
1081
1082 // Clip against the right boundary
1083 if (nc > 0) {
1084 x1 = xc[nc - 1];
1085 y1 = yc[nc - 1];
1086 nc2 = 0;
1087 for (i = 0; i < nc; i++) {
1088 x2 = xc[i]; y2 = yc[i];
1089 if (x1 == x2) {
1090 slope = 0;
1091 } else {
1092 slope = (y2-y1)/(x2-x1);
1093 }
1094 if (x1 <= xclipr) {
1095 if (x2 > xclipr) {
1096 xc2[nc2] = xclipr; yc2[nc2++] = slope*(xclipr-x1)+y1;
1097 } else {
1098 xc2[nc2] = x2; yc2[nc2++] = y2;
1099 }
1100 } else {
1101 if (x2 <= xclipr) {
1102 xc2[nc2] = xclipr; yc2[nc2++] = slope*(xclipr-x1)+y1;
1103 xc2[nc2] = x2; yc2[nc2++] = y2;
1104 }
1105 }
1106 x1 = x2; y1 = y2;
1107 }
1108
1109 // Clip against the bottom boundary
1110 if (nc2 > 0) {
1111 x1 = xc2[nc2 - 1];
1112 y1 = yc2[nc2 - 1];
1113 }
1114 nc = 0;
1115 for (i = 0; i < nc2; i++) {
1116 x2 = xc2[i]; y2 = yc2[i];
1117 if (y1 == y2) {
1118 slope = 0;
1119 } else {
1120 slope = (x2-x1)/(y2-y1);
1121 }
1122 if (y1 >= yclipb) {
1123 if (y2 < yclipb) {
1124 xc[nc] = x1+(yclipb-y1)*slope; yc[nc++] = yclipb;
1125 } else {
1126 xc[nc] = x2; yc[nc++] = y2;
1127 }
1128 } else {
1129 if (y2 >= yclipb) {
1130 xc[nc] = x1+(yclipb-y1)*slope; yc[nc++] = yclipb;
1131 xc[nc] = x2; yc[nc++] = y2;
1132 }
1133 }
1134 x1 = x2; y1 = y2;
1135 }
1136 }
1137
1138 if (nc < 3)
1139 nc = 0;
1140 return nc;
1141}
1142
1143////////////////////////////////////////////////////////////////////////////////
1144/// Delete all primitives in pad and pad itself.
1145/// Pad cannot be used anymore after this call.
1146/// Emits signal "Closed()".
1147
1149{
1150 if (ROOT::Detail::HasBeenDeleted(this)) return;
1151 if (!fMother) return;
1153
1154 if (fPrimitives)
1155 fPrimitives->Clear();
1156 if (fView) {
1158 fView = nullptr;
1159 }
1160 if (fFrame) {
1162 fFrame = nullptr;
1163 }
1164
1165 // emit signal
1166 if (IsA() != TCanvas::Class())
1167 Closed();
1168
1169 if (fPixmapID != -1) {
1170 if (gPad) {
1171 if (!gPad->IsBatch() && GetPainter())
1173 }
1174 fPixmapID = -1;
1175
1176 if (!gROOT->GetListOfCanvases()) return;
1177 if (fMother == this) {
1178 gROOT->GetListOfCanvases()->Remove(this);
1179 return; // in case of TCanvas
1180 }
1181
1182 // remove from the mother's list of primitives
1183 if (fMother) {
1184 fMother->Remove(this, kFALSE); // do not produce modified
1185
1186 if (gPad == this)
1187 fMother->cd();
1188 }
1189 if (fCanvas) {
1190 if (fCanvas->GetPadSave() == this)
1192 if (fCanvas->GetSelectedPad() == this)
1193 fCanvas->SetSelectedPad(nullptr);
1194 if (fCanvas->GetClickSelectedPad() == this)
1195 fCanvas->SetClickSelectedPad(nullptr);
1196 }
1197 }
1198
1199 fMother = nullptr;
1200 if (gROOT->GetSelectedPad() == this)
1201 gROOT->SetSelectedPad(nullptr);
1202}
1203
1204////////////////////////////////////////////////////////////////////////////////
1205/// Copy the pixmap of the pad to the canvas.
1206
1208{
1209 int px, py;
1210 XYtoAbsPixel(fX1, fY2, px, py);
1211
1212 if (fPixmapID != -1)
1213 if (auto pp = GetPainter())
1214 pp->CopyDrawable(fPixmapID, px, py);
1215
1216 // if pixmap copied, stored XOR operations are no longer valid
1217 fDrawOperXor.clear();
1218}
1219
1220////////////////////////////////////////////////////////////////////////////////
1221/// Copy the sub-pixmaps of the pad to the canvas.
1222
1224{
1225 if (!fPrimitives)
1226 fPrimitives = new TList;
1227 TIter next(GetListOfPrimitives());
1228 while (auto obj = next()) {
1229 if (auto pad = dynamic_cast<TPad*>(obj)) {
1230 pad->CopyPixmap();
1231 pad->CopyPixmaps();
1232 }
1233 }
1234
1235 if (this == gPad)
1237}
1238
1239////////////////////////////////////////////////////////////////////////////////
1240/// Remove TExec name from the list of Execs.
1241
1242void TPad::DeleteExec(const char *name)
1243{
1244 if (!fExecs) fExecs = new TList;
1246 if (!ex) return;
1247 fExecs->Remove(ex);
1248 delete ex;
1249}
1250
1251////////////////////////////////////////////////////////////////////////////////
1252/// Compute distance from point px,py to a box.
1253///
1254/// Compute the closest distance of approach from point px,py to the
1255/// edges of this pad.
1256/// The distance is computed in pixels units.
1257
1259{
1260 Int_t pxl, pyl, pxt, pyt;
1261 Int_t px1 = gPad->XtoAbsPixel(fX1);
1262 Int_t py1 = gPad->YtoAbsPixel(fY1);
1263 Int_t px2 = gPad->XtoAbsPixel(fX2);
1264 Int_t py2 = gPad->YtoAbsPixel(fY2);
1265 if (px1 < px2) {pxl = px1; pxt = px2;}
1266 else {pxl = px2; pxt = px1;}
1267 if (py1 < py2) {pyl = py1; pyt = py2;}
1268 else {pyl = py2; pyt = py1;}
1269
1270 // Are we inside the box?
1271 // ======================
1272 if ( (px > pxl && px < pxt) && (py > pyl && py < pyt) ) {
1273 if (GetFillStyle()) return 0; //*-* if pad is filled
1274 }
1275
1276 // Are we on the edges?
1277 // ====================
1278 Int_t dxl = TMath::Abs(px - pxl);
1279 if (py < pyl) dxl += pyl - py;
1280 if (py > pyt) dxl += py - pyt;
1281 Int_t dxt = TMath::Abs(px - pxt);
1282 if (py < pyl) dxt += pyl - py;
1283 if (py > pyt) dxt += py - pyt;
1284 Int_t dyl = TMath::Abs(py - pyl);
1285 if (px < pxl) dyl += pxl - px;
1286 if (px > pxt) dyl += px - pxt;
1287 Int_t dyt = TMath::Abs(py - pyt);
1288 if (px < pxl) dyt += pxl - px;
1289 if (px > pxt) dyt += px - pxt;
1290
1291 Int_t distance = dxl;
1292 if (dxt < distance) distance = dxt;
1293 if (dyl < distance) distance = dyl;
1294 if (dyt < distance) distance = dyt;
1295
1296 return distance - Int_t(0.5*fLineWidth);
1297}
1298
1299////////////////////////////////////////////////////////////////////////////////
1300/// Automatic pad generation by division.
1301///
1302/// - The current canvas is divided in nx by ny equal divisions (pads).
1303/// - xmargin defines the horizontal spacing around each pad as a percentage of the canvas
1304/// width. Therefore, the distance between two adjacent pads along the x-axis is equal
1305/// to twice the xmargin value.
1306/// - ymargin defines the vertical spacing around each pad as a percentage of the canvas
1307/// height. Therefore, the distance between two adjacent pads along the y-axis is equal
1308/// to twice the ymargin value.
1309/// - color is the color of the new pads. If 0, color is the canvas color.
1310///
1311/// Pads are automatically named `canvasname_n` where `n` is the division number
1312/// starting from top left pad.
1313///
1314/// Example if canvasname=c1 , nx=2, ny=3:
1315///
1316/// \image html gpad_pad3.png
1317///
1318/// Once a pad is divided into sub-pads, one can set the current pad
1319/// to a subpad with a given division number as illustrated above
1320/// with TPad::cd(subpad_number).
1321///
1322/// For example, to set the current pad to c1_4, one can do:
1323/// ~~~ {.cpp}
1324/// c1->cd(4)
1325/// ~~~
1326/// __Note1:__ c1.cd() is equivalent to c1.cd(0) and sets the current pad
1327/// to c1 itself.
1328///
1329/// __Note2:__ after a statement like c1.cd(6), the global variable gPad
1330/// points to the current pad. One can use gPad to set attributes
1331/// of the current pad.
1332///
1333/// __Note3:__ in case xmargin < 0 or ymargin < 0, there is no space
1334/// between pads. The current pad margins are recomputed to
1335/// optimize the layout in order to have similar frames' areas.
1336/// See the following example:
1337///
1338/// ~~~ {.cpp}
1339/// void divpad(Int_t nx=3, Int_t ny=2) {
1340/// gStyle->SetOptStat(0);
1341/// auto C = new TCanvas();
1342/// C->SetMargin(0.3, 0.3, 0.3, 0.3);
1343/// C->Divide(nx,ny,-1);
1344/// Int_t number = 0;
1345/// auto h = new TH1F("","",100,-3.3,3.3);
1346/// h->GetXaxis()->SetLabelFont(43);
1347/// h->GetXaxis()->SetLabelSize(12);
1348/// h->GetYaxis()->SetLabelFont(43);
1349/// h->GetYaxis()->SetLabelSize(12);
1350/// h->GetYaxis()->SetNdivisions(505);
1351/// h->SetMaximum(30*nx*ny);
1352/// h->SetFillColor(42);
1353/// for (Int_t i=0;i<nx*ny;i++) {
1354/// number++;
1355/// C->cd(number);
1356/// h->FillRandom("gaus",1000);
1357/// h->DrawCopy();
1358/// }
1359/// }
1360/// ~~~
1361
1362void TPad::Divide(Int_t nx, Int_t ny, Float_t xmargin, Float_t ymargin, Int_t color)
1363{
1364 if (!IsEditable()) return;
1365
1366 if (gThreadXAR) {
1367 void *arr[7];
1368 arr[1] = this; arr[2] = (void*)&nx;arr[3] = (void*)& ny;
1369 arr[4] = (void*)&xmargin; arr[5] = (void *)& ymargin; arr[6] = (void *)&color;
1370 if ((*gThreadXAR)("PDCD", 7, arr, nullptr)) return;
1371 }
1372
1373 TContext ctxt(kTRUE);
1374
1375 cd();
1376 if (nx <= 0) nx = 1;
1377 if (ny <= 0) ny = 1;
1378 Int_t ix, iy;
1379 Double_t x1, y1, x2, y2, dx, dy;
1380 TPad *pad;
1381 TString name, title;
1382 Int_t n = 0;
1383 if (color == 0) color = GetFillColor();
1384 if (xmargin >= 0 && ymargin >= 0) {
1385 //general case
1386 dy = 1/Double_t(ny);
1387 dx = 1/Double_t(nx);
1388 for (iy=0;iy<ny;iy++) {
1389 y2 = 1 - iy*dy - ymargin;
1390 y1 = y2 - dy + 2*ymargin;
1391 if (y1 < 0) y1 = 0;
1392 if (y1 > y2) continue;
1393 for (ix=0;ix<nx;ix++) {
1394 x1 = ix*dx + xmargin;
1395 x2 = x1 +dx -2*xmargin;
1396 if (x1 > x2) continue;
1397 n++;
1398 name.Form("%s_%d", GetName(), n);
1399 pad = new TPad(name.Data(), name.Data(), x1, y1, x2, y2, color);
1400 pad->SetNumber(n);
1401 pad->Draw();
1402 }
1403 }
1404 } else {
1405 // special case when xmargin < 0 or ymargin < 0
1406 Double_t xl = GetLeftMargin();
1407 Double_t xr = GetRightMargin();
1409 Double_t yt = GetTopMargin();
1410 xl /= (1-xl+xr)*nx;
1411 xr /= (1-xl+xr)*nx;
1412 yb /= (1-yb+yt)*ny;
1413 yt /= (1-yb+yt)*ny;
1414 SetLeftMargin(xl);
1415 SetRightMargin(xr);
1416 SetBottomMargin(yb);
1417 SetTopMargin(yt);
1418 dx = (1-xl-xr)/nx;
1419 dy = (1-yb-yt)/ny;
1420 Int_t number = 0;
1421 for (Int_t i=0;i<nx;i++) {
1422 x1 = i*dx+xl;
1423 x2 = x1 + dx;
1424 if (i == 0) x1 = 0;
1425 if (i == nx-1) x2 = 1-xr;
1426 for (Int_t j=0;j<ny;j++) {
1427 number = j*nx + i +1;
1428 y2 = 1 -j*dy -yt;
1429 y1 = y2 - dy;
1430 if (j == 0) y2 = 1-yt;
1431 if (j == ny-1) y1 = 0;
1432 name.Form("%s_%d", GetName(), number);
1433 title.Form("%s_%d", GetTitle(), number);
1434 pad = new TPad(name.Data(), title.Data(), x1, y1, x2, y2, color);
1435 pad->SetNumber(number);
1436 pad->SetBorderMode(0);
1437 if (i == 0) pad->SetLeftMargin(xl*nx);
1438 else pad->SetLeftMargin(0);
1439 pad->SetRightMargin(0);
1440 pad->SetTopMargin(0);
1441 if (j == ny-1) pad->SetBottomMargin(yb*ny);
1442 else pad->SetBottomMargin(0);
1443 pad->Draw();
1444 }
1445 }
1446 }
1447 Modified();
1448}
1449
1450////////////////////////////////////////////////////////////////////////////////
1451/// Divide the canvas according to ratios.
1452///
1453/// The current canvas is divided in nx by ny according to the width and height ratios.
1454/// If the ratios are not specified they are assumed to be equal.
1455///
1456/// Pads are automatically named `canvasname_n` where `n` is the division number
1457/// starting from top left pad.
1458///
1459/// Top and left margins can be defined.
1460
1462 const std::vector<double>& widthRatios,
1463 const std::vector<double>& heightRatios,
1464 const double canvasTopMargin,
1465 const double canvasLeftMargin
1466 )
1467{
1468 cd();
1469
1470 int wrs = widthRatios.size();
1471 int hrs = heightRatios.size();
1472 int nxl = TMath::Min(nx,wrs), nyl = TMath::Min(ny,hrs);
1473
1474 if (wrs==0) nxl = nx;
1475 if (hrs==0) nyl = ny;
1476
1477 int pn = 1;
1478 double xr = 0.;
1479 double yr = 0.;
1480 double x = 0.;
1481 double y = 1.;
1482 double x1, y1, x2, y2;
1483
1484 // Check the validity of the margins
1485 if (canvasTopMargin <0 || canvasTopMargin >1 ) {
1486 Error("DivideRatios", "The canvas top margin must be >= 0 and <= 1");
1487 return;
1488 } else {
1489 y = 1.- canvasTopMargin;
1490 }
1491 if (canvasLeftMargin <0 || canvasLeftMargin >1 ) {
1492 Error("DivideRatios", "The canvas left margin must be >= 0 and <= 1");
1493 return;
1494 }
1495
1496 // Check the validity of the ratios
1497 double sumOfHeightRatios = canvasTopMargin;
1498 if (hrs) {
1499 for (int i=0; i<nyl; i++) {
1500 yr = heightRatios[i];
1501 sumOfHeightRatios = sumOfHeightRatios + yr;
1502 if (yr <0 || yr >1 ) {
1503 Error("DivideRatios", "Y ratios plus the top margin must be >= 0 and <= 1");
1504 return;
1505 }
1506 }
1507 }
1508 if (sumOfHeightRatios > 1.) {
1509 Error("DivideRatios", "The sum of Y ratios plus the top margin must be <= 1 %g",sumOfHeightRatios);
1510 return;
1511 }
1512 double sumOfWidthRatios = canvasLeftMargin;
1513 if (wrs) {
1514 for (int j=0; j<nxl; j++) {
1515 xr = widthRatios[j];
1516 sumOfWidthRatios = sumOfWidthRatios +xr;
1517 if (xr <0 || xr >1 ) {
1518 Error("DivideRatios", "X ratios must be >= 0 and <= 1");
1519 return;
1520 }
1521 }
1522 }
1523 if (sumOfWidthRatios > 1.) {
1524 Error("DivideRatios", "The sum of X ratios must be <= 1 %g ",sumOfWidthRatios);
1525 return;
1526 }
1527
1528 // Create the pads according to the ratios
1529 for (int i=0; i<nyl; i++) {
1530 x = canvasLeftMargin;
1531 if (hrs) yr = heightRatios[i];
1532 else yr = 1./nyl;
1533 for (int j=0; j<nxl; j++) {
1534 if (wrs) xr = widthRatios[j];
1535 else xr = 1./nxl;
1536 x1 = TMath::Max(0., x);
1537 y1 = TMath::Max(0., y - yr);
1538 x2 = TMath::Min(1., x + xr);
1539 y2 = TMath::Min(1., y);
1540 auto pad = new TPad(TString::Format("%s_%d", GetName(), pn),
1541 TString::Format("%s_%d", GetName(), pn),
1542 x1, y1, x2 ,y2);
1543 pad->SetNumber(pn);
1544 pad->Draw();
1545 x = x + xr;
1546 pn++;
1547 }
1548 y = y - yr;
1549 }
1550}
1551
1552////////////////////////////////////////////////////////////////////////////////
1553/// "n" is the total number of sub-pads. The number of sub-pads along the X
1554/// and Y axis are computed according to the square root of n.
1555
1556void TPad::DivideSquare(Int_t n, Float_t xmargin, Float_t ymargin, Int_t color)
1557{
1558 Int_t w = 1, h = 1;
1559 if (!fCanvas) {
1560 Error("DivideSquare", "No canvas associated with this pad.");
1561 return;
1562 }
1566 if (w*h < n) w++;
1567 } else {
1570 if (w*h < n) h++;
1571 }
1572
1573 Divide( w, h, xmargin, ymargin, color);
1574}
1575
1576////////////////////////////////////////////////////////////////////////////////
1577/// Draw Pad in Current pad (re-parent pad if necessary).
1578
1580{
1581 // if no canvas opened yet create a default canvas
1582 if (!gPad) {
1583 gROOT->MakeDefCanvas();
1584 }
1585
1586 // pad cannot be in itself and it can only be in one other pad at a time
1587 if (!fPrimitives) fPrimitives = new TList;
1588 if (gPad != this) {
1590 fMother->Remove(this, kFALSE);
1591 TPad *oldMother = fMother;
1592 fCanvas = gPad->GetCanvas();
1593 //
1594 fMother = (TPad*)gPad;
1595 if (oldMother != fMother || fPixmapID == -1) ResizePad();
1596 }
1597
1598 if (fCanvas && fCanvas->IsWeb()) {
1599 Modified();
1601 } else {
1602 Paint();
1603 }
1604
1605 if (gPad->IsRetained() && gPad != this && fMother)
1606 fMother->Add(this, option);
1607}
1608
1609////////////////////////////////////////////////////////////////////////////////
1610/// Draw class inheritance tree of the class to which obj belongs.
1611///
1612/// If a class B inherits from a class A, description of B is drawn
1613/// on the right side of description of A.
1614///
1615/// Member functions overridden by B are shown in class A with a blue line
1616/// crossing-out the corresponding member function.
1617
1619{
1620 if (!classobj) return;
1621 char dname[256];
1622 const Int_t kMAXLEVELS = 10;
1623 TClass *clevel[kMAXLEVELS], *cl, *cll;
1624 TBaseClass *base, *cinherit;
1625 TText *ptext = nullptr;
1626 TString opt=option;
1627 Double_t x,y,dy,y1,v1,v2,dv;
1628 Int_t nd,nf,nc,nkd,nkf,i,j;
1629 TPaveText *pt;
1630 Int_t maxlev = 4;
1631 if (opt.Contains("2")) maxlev = 2;
1632 if (opt.Contains("3")) maxlev = 3;
1633 if (opt.Contains("5")) maxlev = 5;
1634 if (opt.Contains("6")) maxlev = 6;
1635 if (opt.Contains("7")) maxlev = 7;
1636
1637 // Clear and Set Pad range
1638 Double_t xpad = 20.5;
1639 Double_t ypad = 27.5;
1640 Clear();
1641 Range(0,0,xpad,ypad);
1642
1643 // Find number of levels
1644 Int_t nlevel = 0;
1645 TClass *obj = (TClass*)classobj;
1646 clevel[nlevel] = obj;
1647 TList *lbase = obj->GetListOfBases();
1648 while(lbase) {
1649 base = (TBaseClass*)lbase->First();
1650 if (!base) break;
1651 if (!base->GetClassPointer()) break;
1652 nlevel++;
1653 clevel[nlevel] = base->GetClassPointer();
1654 lbase = clevel[nlevel]->GetListOfBases();
1655 if (nlevel >= maxlev-1) break;
1656 }
1657 Int_t maxelem = 0;
1658 Int_t ncdraw = 0;
1659 Int_t ilevel, nelem;
1660 for (ilevel=nlevel;ilevel>=0;ilevel--) {
1661 cl = clevel[ilevel];
1662 nelem = cl->GetNdata() + cl->GetNmethods();
1663 if (nelem > maxelem) maxelem = nelem;
1664 nc = (nelem/50) + 1;
1665 ncdraw += nc;
1666 }
1667
1668 Double_t tsizcm = 0.40;
1669 Double_t x1 = 0.25;
1670 Double_t x2 = 0;
1671 Double_t dx = 3.5;
1672 if (ncdraw > 4) {
1673 dx = dx - 0.42*Double_t(ncdraw-5);
1674 if (dx < 1.3) dx = 1.3;
1675 tsizcm = tsizcm - 0.03*Double_t(ncdraw-5);
1676 if (tsizcm < 0.27) tsizcm = 0.27;
1677 }
1678 Double_t tsiz = 1.2*tsizcm/ypad;
1679
1680 // Now loop on levels
1681 for (ilevel=nlevel;ilevel>=0;ilevel--) {
1682 cl = clevel[ilevel];
1683 nelem = cl->GetNdata() + cl->GetNmethods();
1684 if (nelem > maxelem) maxelem = nelem;
1685 nc = (nelem/50) + 1;
1686 dy = 0.45;
1687 if (ilevel < nlevel) x1 = x2 + 0.5;
1688 x2 = x1 + nc*dx;
1689 v2 = ypad - 0.5;
1690 lbase = cl->GetListOfBases();
1691 cinherit = nullptr;
1692 if (lbase) cinherit = (TBaseClass*)lbase->First();
1693
1694 do {
1695 nd = cl->GetNdata();
1696 nf = cl->GetNmethods() - 2; //do not show default constructor and destructor
1697 if (cl->GetListOfMethods()->FindObject("Dictionary")) {
1698 nf -= 6; // do not count the Dictionary/ClassDef functions
1699 }
1700 nkf= nf/nc +1;
1701 nkd= nd/nc +1;
1702 if (nd == 0) nkd=0;
1703 if (nf == 0) nkf=0;
1704 y1 = v2 - 0.7;
1705 v1 = y1 - Double_t(nkf+nkd+nc-1)*dy;
1706 dv = v2 - v1;
1707
1708 // Create a new PaveText
1709 pt = new TPaveText(x1,v1,x2,v2);
1711 pt->SetFillColor(19);
1712 pt->Draw();
1713 pt->SetTextColor(4);
1714 pt->SetTextFont(61);
1715 pt->SetTextAlign(12);
1716 pt->SetTextSize(tsiz);
1717 TBox *box = pt->AddBox(0,(y1+0.01-v1)/dv,0,(v2-0.01-v1)/dv);
1718 if (box) box->SetFillColor(17);
1719 pt->AddLine(0,(y1-v1)/dv,0,(y1-v1)/dv);
1720 TText *title = pt->AddText(0.5,(0.5*(y1+v2)-v1)/dv,(char*)cl->GetName());
1721 title->SetTextAlign(22);
1722 title->SetTextSize(0.6*(v2-y1)/ypad);
1723
1724 // Draw data Members
1725 i = 0;
1726 x = 0.03;
1727 y = y1 + 0.5*dy;
1728 TDataMember *d;
1729 TIter nextd(cl->GetListOfDataMembers());
1730 while ((d = (TDataMember *) nextd())) {
1731 if (i >= nkd) { i = 1; y = y1 - 0.5*dy; x += 1/Double_t(nc); }
1732 else { i++; y -= dy; }
1733
1734 // Take in account the room the array index will occupy
1735
1736 Int_t dim = d->GetArrayDim();
1737 Int_t indx = 0;
1738 snprintf(dname,256,"%s",d->GetName());
1739 Int_t ldname = 0;
1740 while (indx < dim ){
1741 ldname = strlen(dname);
1742 snprintf(&dname[ldname],256-ldname,"[%d]",d->GetMaxIndex(indx));
1743 indx++;
1744 }
1745 pt->AddText(x,(y-v1)/dv,dname);
1746 }
1747
1748 // Draw a separator line
1749 Double_t ysep;
1750 if (nd) {
1751 ysep = y1 - Double_t(nkd)*dy;
1752 pt->AddLine(0,(ysep-v1)/dv,0,(ysep-v1)/dv);
1753 ysep -= 0.5*dy;
1754 } else ysep = y1;
1755
1756 // Draw Member Functions
1757 Int_t fcount = 0;
1758 i = 0;
1759 x = 0.03;
1760 y = ysep + 0.5*dy;
1761 TMethod *m;
1762 TIter nextm(cl->GetListOfMethods());
1763 while ((m = (TMethod *) nextm())) {
1764 if (
1765 !strcmp( m->GetName(), "Dictionary" ) ||
1766 !strcmp( m->GetName(), "Class_Version" ) ||
1767 !strcmp( m->GetName(), "DeclFileName" ) ||
1768 !strcmp( m->GetName(), "DeclFileLine" ) ||
1769 !strcmp( m->GetName(), "ImplFileName" ) ||
1770 !strcmp( m->GetName(), "ImplFileLine" )
1771 ) continue;
1772 fcount++;
1773 if (fcount > nf) break;
1774 if (i >= nkf) { i = 1; y = ysep - 0.5*dy; x += 1/Double_t(nc); }
1775 else { i++; y -= dy; }
1776
1777 ptext = pt->AddText(x,(y-v1)/dv,m->GetName());
1778 // Check if method is overloaded in a derived class
1779 // If yes, Change the color of the text to blue
1780 for (j=ilevel-1;j>=0;j--) {
1781 if (cl == clevel[ilevel]) {
1782 if (clevel[j]->GetMethodAny((char*)m->GetName())) {
1783 ptext->SetTextColor(15);
1784 break;
1785 }
1786 }
1787 }
1788 }
1789
1790 // Draw second inheritance classes for this class
1791 cll = nullptr;
1792 if (cinherit) {
1793 cinherit = (TBaseClass*)lbase->After(cinherit);
1794 if (cinherit) {
1795 cl = cinherit->GetClassPointer();
1796 cll = cl;
1797 v2 = v1 -0.4;
1798 dy = 0.35;
1799 }
1800 }
1801 } while (cll);
1802 }
1803 Update();
1804}
1805
1806////////////////////////////////////////////////////////////////////////////////
1807/// Function called to draw a crosshair in the canvas
1808///
1809/// Example:
1810/// ~~~ {.cpp}
1811/// Root > TFile f("hsimple.root");
1812/// Root > hpxpy.Draw();
1813/// Root > c1.SetCrosshair();
1814/// ~~~
1815/// When moving the mouse in the canvas, a crosshair is drawn
1816///
1817/// - if the canvas fCrosshair = 1 , the crosshair spans the full canvas
1818/// - if the canvas fCrosshair > 1 , the crosshair spans only the pad
1819
1821{
1822 if (!gPad || (gPad->GetEvent() == kMouseEnter))
1823 return;
1824
1825 auto cpad = static_cast<TPad *>(gPad);
1826 auto canvas = cpad->GetCanvas();
1827
1828 if (cpad->GetEvent() == kButton1Down || cpad->GetEvent() == kButton1Up || cpad->GetEvent() == kMouseLeave) {
1829 if (fCrosshairPos)
1830 UpdateAsync();
1831 fCrosshairPos = 0;
1832 return;
1833 }
1834
1835 //erase old position and draw a line at current position
1836 Double_t umin, umax, vmin, vmax;
1837 Int_t px = cpad->GetEventX();
1838 Int_t py = cpad->GetEventY() + 1;
1839 if (canvas->GetCrosshair() > 1) {
1840 //crosshair only in the current pad
1841 umin = GetAbsXlowNDC();
1842 umax = GetAbsXlowNDC() + GetAbsWNDC();
1843 vmin = GetAbsYlowNDC();
1844 vmax = GetAbsYlowNDC() + GetAbsHNDC();
1845 } else {
1846 //default; crosshair spans the full canvas
1847 umin = 0;
1848 umax = 1;
1849 vmin = 0;
1850 vmax = 1;
1851 }
1852
1853 TAttLine att(kBlack, 1, 1);
1854 att.ModifyOn(*this);
1855
1856 Double_t uu[2], vv[2];
1857 uu[0] = umin; uu[1] = umax;
1858 vv[0] = vv[1] = 1. - 1. * py / canvas->GetWh();
1859 canvas->PaintPolyLineNDC(2, uu, vv, "icrosshair1");
1860 uu[0] = uu[1] = 1. * px / canvas->GetWw();
1861 vv[0] = vmin; vv[1] = vmax;
1862 canvas->PaintPolyLineNDC(2, uu, vv, "icrosshair2");
1863
1864 UpdateAsync();
1865 // just indication that crosshair was drawn before
1866 fCrosshairPos = px + 10000*py;
1867}
1868
1869////////////////////////////////////////////////////////////////////////////////
1870/// Draw an empty pad frame with X and Y axis.
1871///
1872/// \return The pointer to the histogram used to draw the frame.
1873///
1874/// \param[in] xmin X axis lower limit
1875/// \param[in] xmax X axis upper limit
1876/// \param[in] ymin Y axis lower limit
1877/// \param[in] ymax Y axis upper limit
1878/// \param[in] title Pad title.If title is of the form "stringt;stringx;stringy"
1879/// the pad title is set to stringt, the x axis title to
1880/// stringx, the y axis title to stringy.
1881///
1882/// #### Example:
1883///
1884/// Begin_Macro(source)
1885/// {
1886/// auto c = new TCanvas("c","c",200,10,500,300);
1887///
1888/// const Int_t n = 50;
1889/// auto g = new TGraph();
1890/// for (Int_t i=0;i<n;i++) g->SetPoint(i,i*0.1,100*sin(i*0.1+0.2));
1891///
1892/// auto frame = c->DrawFrame(0, -110, 2, 110);
1893/// frame->GetXaxis()->SetTitle("X axis");
1894///
1895/// g->Draw("L*");
1896/// }
1897/// End_Macro
1898
1900{
1901 if (!IsEditable())
1902 return nullptr;
1903
1904 if (this != gPad) {
1905 Warning("DrawFrame", "Must be called for the current pad only");
1906 if (gPad) return gPad->DrawFrame(xmin,ymin,xmax,ymax,title);
1907 }
1908
1909 cd();
1910
1911 TH1F *hframe = (TH1F*)FindObject("hframe");
1912 if (hframe) delete hframe;
1913 Int_t nbins = 1000;
1914 //if log scale in X, use variable bin size linear with log(x)
1915 //this gives a better precision when zooming on the axis
1916 if (fLogx && xmin > 0 && xmax > xmin) {
1917 Double_t xminl = TMath::Log(xmin);
1918 Double_t xmaxl = TMath::Log(xmax);
1919 Double_t dx = (xmaxl-xminl)/nbins;
1920 std::vector<Double_t> xbins(nbins+1);
1921 xbins[0] = xmin;
1922 for (Int_t i=1;i<=nbins;i++) {
1923 xbins[i] = TMath::Exp(xminl+i*dx);
1924 }
1925 hframe = new TH1F("hframe",title,nbins,xbins.data());
1926 } else {
1927 hframe = new TH1F("hframe",title,nbins,xmin,xmax);
1928 }
1929 hframe->SetBit(TH1::kNoStats);
1930 hframe->SetBit(kCanDelete);
1931 hframe->SetMinimum(ymin);
1932 hframe->SetMaximum(ymax);
1933 hframe->GetYaxis()->SetLimits(ymin,ymax);
1934 hframe->SetDirectory(nullptr);
1935 hframe->Draw(" ");
1936 Update();
1937 cd();
1938 return hframe;
1939}
1940
1941////////////////////////////////////////////////////////////////////////////////
1942/// Static function to Display Color Table in a pad.
1943
1945{
1946 Int_t i, j;
1947 Int_t color;
1948 Double_t xlow, ylow, xup, yup, hs, ws;
1949 Double_t x1, y1, x2, y2;
1950 x1 = y1 = 0;
1951 x2 = y2 = 20;
1952
1953 gPad->SetFillColor(0);
1954 gPad->Clear();
1955 gPad->Range(x1,y1,x2,y2);
1956
1957 TText text(0,0,"");
1958 text.SetTextFont(61);
1959 text.SetTextSize(0.07);
1960 text.SetTextAlign(22);
1961
1962 TBox box;
1963
1964 // Draw color table boxes.
1965 hs = (y2-y1)/Double_t(5);
1966 ws = (x2-x1)/Double_t(10);
1967 for (i=0;i<10;i++) {
1968 xlow = x1 + ws*(Double_t(i)+0.1);
1969 xup = x1 + ws*(Double_t(i)+0.9);
1970 for (j=0;j<5;j++) {
1971 ylow = y1 + hs*(Double_t(j)+0.1);
1972 yup = y1 + hs*(Double_t(j)+0.9);
1973 color = 10*j + i;
1974 box.SetFillStyle(1001);
1975 box.SetFillColor(color);
1976 box.DrawBox(xlow, ylow, xup, yup);
1977 box.SetFillStyle(0);
1978 box.SetLineColor(1);
1979 box.DrawBox(xlow, ylow, xup, yup);
1980 if (color == 1) text.SetTextColor(0);
1981 else text.SetTextColor(1);
1982 text.DrawText(0.5*(xlow+xup), 0.5*(ylow+yup), TString::Format("%d",color).Data());
1983 }
1984 }
1985}
1986
1987////////////////////////////////////////////////////////////////////////////////
1988/// Execute action corresponding to one event.
1989///
1990/// This member function is called when a TPad object is clicked.
1991///
1992/// If the mouse is clicked in one of the 4 corners of the pad (pA,pB,pC,pD)
1993/// the pad is resized with the rubber rectangle.
1994///
1995/// If the mouse is clicked inside the pad, the pad is moved.
1996///
1997/// If the mouse is clicked on the 4 edges (pL,pR,pTop,pBot), the pad is scaled
1998/// parallel to this edge.
1999///
2000/// \image html gpad_pad4.png
2001///
2002/// Note that this function reuses internal TBoxInteractive class
2003/// designed for TBox movement avoiding code duplication
2004
2006{
2007 if (!IsEditable() && event != kMouseEnter)
2008 return;
2009 TVirtualPad &parent = *GetMother();
2010 if (!parent.IsEditable())
2011 return;
2012
2014
2015 if (((fXlowNDC < 0) || (fYlowNDC < 0)) && (event != kButton1Down))
2016 return;
2017
2018 Int_t newcode = gROOT->GetEditorMode();
2019 if (newcode) {
2020 TCreatePrimitives::ExecuteEvent(*this, newcode, event, px, py);
2021 return;
2022 }
2023
2024 auto inter = parent.GetInteractive<TBoxInteractive>(this);
2025
2026 auto setNewValues = [&inter, &parent, this]() {
2027 // Get parent corners pixels coordinates
2028 Int_t parentpx1 = parent.XtoAbsPixel(parent.GetX1());
2029 Int_t parentpx2 = parent.XtoAbsPixel(parent.GetX2());
2030 Int_t parentpy1 = parent.YtoAbsPixel(parent.GetY1());
2031 Int_t parentpy2 = parent.YtoAbsPixel(parent.GetY2());
2032
2033 // Get pad new corners pixels coordinates
2034 Int_t apx1 = TMath::Max(inter->px1, parentpx1);
2035 Int_t apx2 = TMath::Min(inter->px2, parentpx2);
2036 Int_t apy1 = TMath::Min(inter->py1, parentpy1);
2037 Int_t apy2 = TMath::Max(inter->py2, parentpy2);
2038
2039 // Compute new pad positions in the NDC space of parent
2040 fXlowNDC = Double_t(apx1 - parentpx1)/Double_t(parentpx2 - parentpx1);
2041 fYlowNDC = Double_t(apy1 - parentpy1)/Double_t(parentpy2 - parentpy1);
2042 fWNDC = Double_t(apx2 - apx1)/Double_t(parentpx2 - parentpx1);
2043 fHNDC = Double_t(apy2 - apy1)/Double_t(parentpy2 - parentpy1);
2044 };
2045
2046
2047 switch (event) {
2048
2049 case kMouseEnter:
2050 if (fTip)
2052 break;
2053
2054 case kArrowKeyPress:
2055 case kButton1Down:
2059 // No break !!!
2060
2061 case kMouseMotion: {
2062 TBoxInteractive dummy(kFALSE);
2063 if (!inter) inter = &dummy;
2064 // use pad itself to calculate its pixel coordinates
2065 inter->CalcPixelCoord(*this, GetX1(), GetY1(), GetX2(), GetY2());
2066
2067 if (TestBit(kCannotMove) || !inter->SelectCorner(px, py)) {
2068 // refuse interactive changes
2069 parent.FreeInteractive(this);
2070 } else {
2071 inter->SetCursor(parent, event == kButton1Down);
2072 fResizing = inter->IsResizing() && (event != kMouseMotion);
2073 }
2074
2075 break;
2076 }
2077
2078 case kArrowKeyRelease:
2079 case kButton1Motion: {
2080 if (!inter)
2081 return;
2082
2083 Double_t ratio = HasFixedAspectRatio() ? fAspectRatio : 0.;
2084
2085 if (!inter->ProcessMouseMove(parent, px, py, kTRUE, kTRUE, ratio))
2086 return;
2087
2088 // paint if necessary
2089 inter->ApplyChanges(parent);
2090
2091 if (inter->IsOpaque(parent)) {
2092 setNewValues();
2093 ResizePad();
2094 parent.ShowGuidelines(this, event, inter->GetGuideChar(), true);
2095 Modified(kTRUE);
2096 }
2097
2098 break;
2099 }
2100
2101 case kButton1Up:
2102 if (inter && inter->IsOpaque(parent))
2103 parent.ShowGuidelines(this, event);
2104
2105 if (gROOT->IsEscaped()) {
2106 gROOT->SetEscape(kFALSE);
2107 if (inter && inter->IsOpaque(parent)) {
2108 fXlowNDC = inter->oldX1;
2109 fYlowNDC = inter->oldY1;
2110 fWNDC = inter->oldX2;
2111 fHNDC = inter->oldY2;
2112 ResizePad();
2113 Modified(kTRUE);
2114
2115 }
2116 } else if (inter && !inter->IsOpaque(parent) && (inter->newX1 != inter->newX2)) {
2117 setNewValues();
2118 ResizePad();
2119 Modified(kTRUE);
2120 }
2121
2122 RangeChanged();
2123
2124 fResizing = kFALSE;
2125 parent.FreeInteractive(this);
2126
2127 break;
2128
2129 case kButton1Locate:
2130
2131 ExecuteEvent(kButton1Down, px, py);
2132
2133 while (true) {
2134 px = py = 0;
2135 event = GetCanvasImp()->RequestLocator(px, py);
2136
2138
2139 if (event != -1) { // button is released
2140 ExecuteEvent(kButton1Up, px, py);
2141 return;
2142 }
2143 }
2144
2145 case kButton2Down:
2146
2147 Pop();
2148 break;
2149
2150 }
2151}
2152
2154 public:
2155
2158 Double_t px1old = 0, py1old = 0, px2old = 0, py2old = 0;
2159
2161 {
2162 Double_t zbx1 = pad.GetUxmin();
2163 Double_t zbx2 = pad.GetUxmax();
2164 Double_t zby1 = pad.GetUymin();
2165 Double_t zby2 = pad.GetUymax();
2166 if (axisNumber == 1) {
2167 zbx1 = px1old;
2168 zbx2 = px2old;
2169 } else {
2170 zby1 = py1old;
2171 zby2 = py2old;
2172 }
2173
2174 if (pad.OpaqueMoving()) {
2175 TAttLine{kBlack, 1, 1}.ModifyOn(pad);
2176 Double_t xx[4], yy[4];
2177
2178 if (axisNumber == 1) {
2179 xx[0] = xx[1] = zbx1;
2180 xx[2] = xx[3] = zbx2;
2181 yy[0] = yy[2] = zby1;
2182 yy[1] = yy[3] = zby2;
2183 } else {
2184 xx[0] = xx[2] = zbx1;
2185 xx[1] = xx[3] = zbx2;
2186 yy[0] = yy[1] = zby1;
2187 yy[2] = yy[3] = zby2;
2188 }
2189 pad.PaintPolyLine(2, xx, yy, "iaxiszoom1");
2190 pad.PaintPolyLine(2, xx+2, yy+2, "iaxiszoom2");
2191 } else {
2192 pad.PaintBox(zbx1, zby1, zbx2, zby2, "iaxiszoom");
2193 }
2194 pad.UpdateAsync();
2195 }
2196};
2197
2198
2199////////////////////////////////////////////////////////////////////////////////
2200/// Execute action corresponding to one event for a TAxis object
2201/// (called by TAxis::ExecuteEvent.)
2202/// This member function is called when an axis is clicked with the locator
2203///
2204/// The axis range is set between the position where the mouse is pressed
2205/// and the position where it is released.
2206///
2207/// If the mouse position is outside the current axis range when it is released
2208/// the axis is unzoomed with the corresponding proportions.
2209///
2210/// Note that the mouse does not need to be in the pad or even canvas
2211/// when it is released.
2212
2214{
2215 if (!IsEditable() || !axis)
2216 return;
2218
2219 TView *view = GetView();
2220
2221 // The CONT4 option, used to paint TH2, is a special case; it uses a 3D
2222 // drawing technique to paint a 2D plot.
2223 TString opt = axis->GetParent()->GetDrawOption();
2224 opt.ToLower();
2225 Bool_t kCont4 = kFALSE;
2226 if (strstr(opt,"cont4")) {
2227 view = nullptr;
2228 kCont4 = kTRUE;
2229 }
2230
2231 auto inter = dynamic_cast<TAxisInteractive *>(Interactive(axis));
2232
2233 switch (event) {
2234
2235 case kButton1Down:
2236 inter = new TAxisInteractive();
2237 Interactive(axis, inter);
2238
2239 inter->axisNumber = 1;
2240 if (!strcmp(axis->GetName(), "xaxis"))
2241 inter->axisNumber = IsVertical() ? 1 : 2;
2242 else if (!strcmp(axis->GetName(), "yaxis"))
2243 inter->axisNumber = IsVertical() ? 2 : 1;
2244 else if (!strcmp(axis->GetName(), "zaxis"))
2245 inter->axisNumber = 3;
2246 if (view) {
2247 view->GetDistancetoAxis(inter->axisNumber, px, py, inter->ratio1);
2248 } else if (inter->axisNumber == 1) {
2249 inter->ratio1 = (AbsPixeltoX(px) - GetUxmin()) / (GetUxmax() - GetUxmin());
2250 inter->px1old = GetUxmin() + inter->ratio1 * (GetUxmax() - GetUxmin());
2251 inter->py1old = GetUymin();
2252 inter->px2old = inter->px1old;
2253 inter->py2old = GetUymax();
2254 } else {
2255 inter->ratio1 = (AbsPixeltoY(py) - GetUymin()) / (GetUymax() - GetUymin());
2256 inter->px1old = GetUxmin();
2257 inter->py1old = GetUymin() + inter->ratio1 * (GetUymax() - GetUymin());
2258 inter->px2old = GetUxmax();
2259 inter->py2old = inter->py1old;
2260 }
2261 // No break !!!
2262
2263 case kButton1Motion:
2264 if (!inter)
2265 break;
2266 if (view) {
2267 view->GetDistancetoAxis(inter->axisNumber, px, py, inter->ratio2);
2268 } else if (inter->axisNumber == 1) {
2269 inter->ratio2 = (AbsPixeltoX(px) - GetUxmin())/(GetUxmax() - GetUxmin());
2270 inter->px2old = GetUxmin() + inter->ratio2 * (GetUxmax() - GetUxmin());
2271 } else {
2272 inter->ratio2 = (AbsPixeltoY(py) - GetUymin())/(GetUymax() - GetUymin());
2273 inter->py2old = GetUymin() + inter->ratio2 * (GetUymax() - GetUymin());
2274 }
2275 inter->PaintZoomBox(*this);
2276 break;
2277
2278 case kWheelUp: {
2279 Int_t nbd = (axis->GetLast()-axis->GetFirst());
2280 Int_t inc = TMath::Max(nbd/100,1);
2281 Int_t bin1 = TMath::Max(1, axis->GetFirst() + inc);
2282 Int_t bin2 = TMath::Min(axis->GetNbins(), axis->GetLast() - inc);
2283 if (bin2 > bin1) {
2284 axis->SetRange(bin1, bin2);
2285 Modified();
2286 UpdateAsync();
2287 }
2288 break;
2289 }
2290
2291 case kWheelDown: {
2292 Int_t nbd = (axis->GetLast()-axis->GetFirst());
2293 Int_t inc = TMath::Max(nbd/100,1);
2294 Int_t bin1 = TMath::Max(1, axis->GetFirst()-inc);
2295 Int_t bin2 = TMath::Min(axis->GetNbins(), axis->GetLast()+inc);
2296 Bool_t resetAxisRange = (bin1 == 1 && axis->GetFirst() == 1 && bin2 == axis->GetNbins() && axis->GetLast() == axis->GetNbins());
2297 if (bin2 > bin1)
2298 axis->SetRange(bin1,bin2);
2299 if (resetAxisRange)
2301 if (bin2 > bin1) {
2302 Modified();
2303 UpdateAsync();
2304 }
2305 break;
2306 }
2307
2308 case kButton1Up:
2309 if (gROOT->IsEscaped()) {
2310 gROOT->SetEscape(kFALSE);
2311 break;
2312 }
2313
2314 if (view && inter) {
2315 view->GetDistancetoAxis(inter->axisNumber, px, py, inter->ratio2);
2316 if (inter->ratio1 > inter->ratio2)
2317 std::swap(inter->ratio1, inter->ratio2);
2318 if (inter->ratio2 - inter->ratio1 > 0.05) {
2319 auto hobj = static_cast<TH1 *>(axis->GetParent());
2320 if (inter->axisNumber == 3 && hobj && hobj->GetDimension() != 3) {
2321 Float_t zmin = hobj->GetMinimum();
2322 Float_t zmax = hobj->GetMaximum();
2323 if (GetLogz()) {
2324 if (zmin <= 0 && zmax > 0)
2325 zmin = TMath::Min((Double_t)1, (Double_t)0.001 * zmax);
2326 zmin = TMath::Log10(zmin);
2327 zmax = TMath::Log10(zmax);
2328 }
2329 Float_t newmin = zmin + (zmax - zmin) * inter->ratio1;
2330 Float_t newmax = zmin + (zmax - zmin) * inter->ratio2;
2331 if (newmin < zmin)
2332 newmin = hobj->GetBinContent(hobj->GetMinimumBin());
2333 if (newmax > zmax)
2334 newmax = hobj->GetBinContent(hobj->GetMaximumBin());
2335 if (GetLogz()){
2336 newmin = TMath::Exp(2.302585092994*newmin);
2337 newmax = TMath::Exp(2.302585092994*newmax);
2338 }
2339 hobj->SetMinimum(newmin);
2340 hobj->SetMaximum(newmax);
2341 hobj->SetBit(TH1::kIsZoomed);
2342 } else {
2343 Int_t first = axis->GetFirst();
2344 Int_t last = axis->GetLast();
2345 Int_t bin1 = TMath::Max(1, first + Int_t((last-first+1) * inter->ratio1));
2346 Int_t bin2 = TMath::Min(axis->GetNbins(), first + Int_t((last-first+1) * inter->ratio2));
2347 axis->SetRange(bin1, bin2);
2348 }
2349 delete view;
2350 SetView(nullptr);
2351 Modified();
2352 }
2353 } else if (inter) {
2355 if (inter->axisNumber == 1) {
2356 inter->ratio2 = (AbsPixeltoX(px) - GetUxmin()) / (GetUxmax() - GetUxmin());
2357 xmin = GetUxmin() + inter->ratio1 * (GetUxmax() - GetUxmin());
2358 xmax = GetUxmin() + inter->ratio2 * (GetUxmax() - GetUxmin());
2359 if (GetLogx() && !kCont4) {
2360 xmin = PadtoX(xmin);
2361 xmax = PadtoX(xmax);
2362 }
2363 } else if (inter->axisNumber == 2) {
2364 inter->ratio2 = (AbsPixeltoY(py) - GetUymin()) / (GetUymax() - GetUymin());
2365 xmin = GetUymin() + inter->ratio1 * (GetUymax() - GetUymin());
2366 xmax = GetUymin() + inter->ratio2 * (GetUymax() - GetUymin());
2367 if (GetLogy() && !kCont4) {
2368 xmin = PadtoY(xmin);
2369 xmax = PadtoY(xmax);
2370 }
2371 } else {
2372 inter->ratio2 = (AbsPixeltoY(py) - GetUymin()) / (GetUymax() - GetUymin());
2373 xmin = inter->ratio1;
2374 xmax = inter->ratio2;
2375 }
2376 if (xmin > xmax) {
2377 std::swap(xmin, xmax);
2378 std::swap(inter->ratio1, inter->ratio2);
2379 }
2380
2381 // xmin and xmax need to be adjusted in case of CONT4.
2382 if (kCont4) {
2383 Double_t low = axis->GetBinLowEdge(axis->GetFirst());
2384 Double_t up = axis->GetBinUpEdge(axis->GetLast());
2385 Double_t xmi = GetUxmin();
2386 Double_t xma = GetUxmax();
2387 xmin = ((xmin - xmi) / (xma - xmi)) * (up - low) + low;
2388 xmax = ((xmax - xmi) / (xma - xmi)) * (up - low) + low;
2389 }
2390
2391 if (!strcmp(axis->GetName(),"xaxis"))
2392 inter->axisNumber = 1;
2393 if (!strcmp(axis->GetName(),"yaxis"))
2394 inter->axisNumber = 2;
2395 if (inter->ratio2 - inter->ratio1 > 0.05) {
2396 //update object owning this axis
2397 TH1 *hobj1 = static_cast<TH1 *>(axis->GetParent());
2398 Int_t bin1 = TMath::Max(1, axis->FindFixBin(xmin));
2399 Int_t bin2 = TMath::Min(axis->GetNbins(), axis->FindFixBin(xmax));
2400 if (inter->axisNumber == 1)
2401 axis->SetRange(bin1,bin2);
2402 if (inter->axisNumber == 2 && hobj1) {
2403 if (hobj1->GetDimension() == 1) {
2404 if (hobj1->GetNormFactor() != 0) {
2405 Double_t norm = hobj1->GetSumOfWeights()/hobj1->GetNormFactor();
2406 xmin *= norm;
2407 xmax *= norm;
2408 }
2409 hobj1->SetMinimum(xmin);
2410 hobj1->SetMaximum(xmax);
2411 hobj1->SetBit(TH1::kIsZoomed);
2412 } else {
2413 axis->SetRange(bin1,bin2);
2414 }
2415 }
2416 //update all histograms in the pad
2417 TIter next(GetListOfPrimitives());
2418 while (auto obj = next()) {
2419 if (auto hobj = dynamic_cast<TH1 *> (obj)) {
2420 if (hobj == hobj1)
2421 continue;
2422 bin1 = hobj->GetXaxis()->FindFixBin(xmin);
2423 bin2 = hobj->GetXaxis()->FindFixBin(xmax);
2424 if (inter->axisNumber == 1) {
2425 hobj->GetXaxis()->SetRange(bin1,bin2);
2426 } else if (inter->axisNumber == 2) {
2427 if (hobj->GetDimension() == 1) {
2428 Double_t xxmin = xmin;
2429 Double_t xxmax = xmax;
2430 if (hobj->GetNormFactor() != 0) {
2431 Double_t norm = hobj->GetSumOfWeights()/hobj->GetNormFactor();
2432 xxmin *= norm;
2433 xxmax *= norm;
2434 }
2435 hobj->SetMinimum(xxmin);
2436 hobj->SetMaximum(xxmax);
2437 hobj->SetBit(TH1::kIsZoomed);
2438 } else {
2439 bin1 = hobj->GetYaxis()->FindFixBin(xmin);
2440 bin2 = hobj->GetYaxis()->FindFixBin(xmax);
2441 hobj->GetYaxis()->SetRange(bin1,bin2);
2442 }
2443 }
2444 }
2445 }
2446 Modified();
2447 }
2448 }
2449 Interactive(); // remove interactive object
2450 break;
2451 }
2452}
2453
2454////////////////////////////////////////////////////////////////////////////////
2455/// Switch feedback mode for the canvas
2456/// Only for internal use when implementing special painters
2457
2459{
2460 if (fCanvas)
2461 fCanvas->FeedbackMode(set);
2462}
2463
2464////////////////////////////////////////////////////////////////////////////////
2465/// Search if object named name is inside this pad or in pads inside this pad.
2466///
2467/// In case name is in several sub-pads the first one is returned.
2468
2469TObject *TPad::FindObject(const char *name) const
2470{
2471 if (!fPrimitives) return nullptr;
2473 if (found) return found;
2474 TIter next(GetListOfPrimitives());
2475 while (auto cur = next()) {
2476 if (cur->InheritsFrom(TPad::Class())) {
2477 found = ((TPad*)cur)->FindObject(name);
2478 if (found) return found;
2479 }
2480 }
2481 return nullptr;
2482}
2483
2484////////////////////////////////////////////////////////////////////////////////
2485/// Search if obj is in pad or in pads inside this pad.
2486///
2487/// In case obj is in several sub-pads the first one is returned.
2488
2490{
2491 if (!fPrimitives) return nullptr;
2492 TObject *found = fPrimitives->FindObject(obj);
2493 if (found) return found;
2494 TIter next(GetListOfPrimitives());
2495 while (auto cur = next()) {
2496 if (cur->InheritsFrom(TPad::Class())) {
2497 found = ((TPad*)cur)->FindObject(obj);
2498 if (found) return found;
2499 }
2500 }
2501 return nullptr;
2502}
2503
2504////////////////////////////////////////////////////////////////////////////////
2505/// Get canvas identifier.
2506
2508{
2509 return fCanvas ? fCanvas->GetCanvasID() : -1;
2510}
2511
2512////////////////////////////////////////////////////////////////////////////////
2513/// Get canvas implementation pointer if any
2514
2516{
2517 return fCanvas ? fCanvas->GetCanvasImp() : nullptr;
2518}
2519
2520////////////////////////////////////////////////////////////////////////////////
2521/// Get Event.
2522
2524{
2525 return fCanvas ? fCanvas->GetEvent() : 0;
2526}
2527
2528////////////////////////////////////////////////////////////////////////////////
2529/// Get X event.
2530
2532{
2533 return fCanvas ? fCanvas->GetEventX() : 0;
2534}
2535
2536////////////////////////////////////////////////////////////////////////////////
2537/// Get Y event.
2538
2540{
2541 return fCanvas ? fCanvas->GetEventY() : 0;
2542}
2543
2544////////////////////////////////////////////////////////////////////////////////
2545/// Get virtual canvas.
2546
2548{
2549 return fCanvas ? (TVirtualPad*) fCanvas : nullptr;
2550}
2551
2552////////////////////////////////////////////////////////////////////////////////
2553/// Get doublebuffer mode - 1 by default.
2554
2556{
2557 return fCanvas ? fCanvas->GetDoubleBuffer() : 1;
2558}
2559
2560////////////////////////////////////////////////////////////////////////////////
2561/// Get highlight color.
2562
2564{
2565 return fCanvas ? fCanvas->GetHighLightColor() : 0;
2566}
2567
2568////////////////////////////////////////////////////////////////////////////////
2569/// Static function (see also TPad::SetMaxPickDistance)
2570
2575
2576////////////////////////////////////////////////////////////////////////////////
2577/// Get selected.
2578
2580{
2581 if (fCanvas == this) return nullptr;
2582 return fCanvas ? fCanvas->GetSelected() : nullptr;
2583}
2584
2585////////////////////////////////////////////////////////////////////////////////
2586/// Get selected pad.
2587
2589{
2590 if (fCanvas == this) return nullptr;
2591 return fCanvas ? fCanvas->GetSelectedPad() : nullptr;
2592}
2593
2594////////////////////////////////////////////////////////////////////////////////
2595/// Get save pad.
2596
2598{
2599 if (fCanvas == this) return nullptr;
2600 return fCanvas ? fCanvas->GetPadSave() : nullptr;
2601}
2602
2603////////////////////////////////////////////////////////////////////////////////
2604/// Get canvas height
2605
2607{
2608 return fCanvas ? fCanvas->GetWh() : 0;
2609}
2610
2611////////////////////////////////////////////////////////////////////////////////
2612/// Get canvas width
2613
2615{
2616 return fCanvas ? fCanvas->GetWw() : 0;
2617}
2618
2619////////////////////////////////////////////////////////////////////////////////
2620/// Get pad width
2621
2623{
2624 // Very often pad width was calculated as XtoPixel(GetX2());
2625 // But if coordinate system broken such transformation fail.
2626 // Therefore use canvas width multiplied by absolute NDC width value
2627 // Keep fallback solution only when canvas width cannot be defined
2628
2629 auto cw = GetWw();
2630 if (!cw)
2631 return XtoPixel(GetX2());
2632
2633 return static_cast<UInt_t>(std::lround(cw * GetAbsWNDC()));
2634}
2635
2636////////////////////////////////////////////////////////////////////////////////
2637/// Get pad height
2638
2640{
2641 // Very often pad height was calculated as YtoPixel(GetY1())
2642 // But if coordinate system broken such transformation fail.
2643 // Therefore use canvas height multiplied by absolute NDC height value
2644 // Keep fallback solution only when canvas height cannot be defined
2645
2646 auto ch = GetWh();
2647 if (!ch)
2648 return YtoPixel(GetY1());
2649
2650 return static_cast<UInt_t>(std::lround(GetWh() * GetAbsHNDC()));
2651}
2652
2653////////////////////////////////////////////////////////////////////////////////
2654/// Hide tool tip depending on the event type. Typically tool tips
2655/// are hidden when event is not a kMouseEnter and not a kMouseMotion
2656/// event.
2657
2659{
2660 if (event != kMouseEnter && event != kMouseMotion && fTip)
2661 gPad->CloseToolTip(fTip);
2662}
2663
2664////////////////////////////////////////////////////////////////////////////////
2665/// Check if pad or any subpads need to be repaint
2666/// Returns flag with following mask:
2667/// 1 - some pad is modified
2668/// 2 - some pad is transparent (also trigger repaint in modified)
2669/// 4 - some pad has interactive XOR draw operations
2670
2672{
2673 Int_t mask = IsModified() ? 1 : 0;
2674 if (IsTransparent())
2675 mask |= 2;
2676 if (fDrawOper.size())
2677 mask |= 4;
2678
2679 TIter next(GetListOfPrimitives());
2680 while (auto obj = next())
2681 if (auto p = dynamic_cast<TPad *>(obj))
2682 mask |= p->IsAnyNeedRepaint();
2683
2684 return mask;
2685}
2686
2687////////////////////////////////////////////////////////////////////////////////
2688/// Is pad in batch mode ?
2689
2691{
2692 return fCanvas ? fCanvas->IsBatch() : kFALSE;
2693}
2694
2695////////////////////////////////////////////////////////////////////////////////
2696/// Is pad retained ?
2697
2699{
2700 return fCanvas ? fCanvas->IsRetained() : kFALSE;
2701}
2702
2703////////////////////////////////////////////////////////////////////////////////
2704/// Is web ?
2706{
2707 return fCanvas ? fCanvas->IsWeb() : kFALSE;
2708}
2709
2710////////////////////////////////////////////////////////////////////////////////
2711/// Is pad moving in opaque mode ?
2712
2714{
2715 return fCanvas ? fCanvas->OpaqueMoving() : kFALSE;
2716}
2717
2718////////////////////////////////////////////////////////////////////////////////
2719/// Is pad resizing in opaque mode ?
2720
2722{
2723 return fCanvas ? fCanvas->OpaqueResizing() : kFALSE;
2724}
2725
2726////////////////////////////////////////////////////////////////////////////////
2727/// Set pad in batch mode.
2728
2730{
2731 if (fCanvas) fCanvas->SetBatch(batch);
2732}
2733
2734////////////////////////////////////////////////////////////////////////////////
2735/// Set canvas size.
2736
2738{
2739 if (fCanvas) fCanvas->SetCanvasSize(ww,wh);
2740}
2741
2742////////////////////////////////////////////////////////////////////////////////
2743/// Set cursor type.
2744
2749
2750////////////////////////////////////////////////////////////////////////////////
2751/// Set double buffer mode ON or OFF.
2752
2757
2758////////////////////////////////////////////////////////////////////////////////
2759/// Set selected.
2760
2762{
2763 if (fCanvas) fCanvas->SetSelected(obj);
2764}
2765
2766////////////////////////////////////////////////////////////////////////////////
2767/// Update pad.
2768
2770{
2771 if (fCanvas) fCanvas->Update();
2772}
2773
2774////////////////////////////////////////////////////////////////////////////////
2775/// Asynchronous pad update.
2776/// In case of web-based canvas triggers update of the canvas on the client side,
2777/// but does not wait that real update is completed. Avoids blocking of caller thread.
2778/// Have to be used if called from other web-based widget to avoid logical dead-locks.
2779/// In case of normal canvas just canvas->Update() is performed.
2780
2782{
2783 if (fCanvas) fCanvas->UpdateAsync();
2784}
2785
2786////////////////////////////////////////////////////////////////////////////////
2787/// Get frame.
2788
2790{
2791 if (!fPrimitives) fPrimitives = new TList;
2793 if (!frame) frame = (TFrame*)GetListOfPrimitives()->FindObject("TFrame");
2794 fFrame = frame;
2795 if (!fFrame) {
2796 if (!frame) fFrame = new TFrame(0,0,1,1);
2797 Int_t framecolor = GetFrameFillColor();
2798 if (!framecolor) framecolor = GetFillColor();
2799 fFrame->SetFillColor(framecolor);
2806 } else {
2807 // Preexisting and now assigned to fFrame, let's make sure it is not
2808 // deleted twice (the bit might have been set in TPad::Streamer)
2810 }
2811 return fFrame;
2812}
2813
2814////////////////////////////////////////////////////////////////////////////////
2815/// Get primitive.
2816
2818{
2819 if (!fPrimitives) return nullptr;
2820 TIter next(fPrimitives);
2821 TObject *found, *obj;
2822 while ((obj=next())) {
2823 if (!strcmp(name, obj->GetName())) return obj;
2824 if (obj->InheritsFrom(TPad::Class())) continue;
2825 found = obj->FindObject(name);
2826 if (found) return found;
2827 }
2828 return nullptr;
2829}
2830
2831////////////////////////////////////////////////////////////////////////////////
2832/// Get a pointer to subpadnumber of this pad.
2833
2834TVirtualPad *TPad::GetPad(Int_t subpadnumber) const
2835{
2836 if (!subpadnumber) {
2837 return (TVirtualPad*)this;
2838 }
2839
2840 TObject *obj;
2841 if (!fPrimitives) return nullptr;
2842 TIter next(GetListOfPrimitives());
2843 while ((obj = next())) {
2844 if (obj->InheritsFrom(TVirtualPad::Class())) {
2845 TVirtualPad *pad = (TVirtualPad*)obj;
2846 if (pad->GetNumber() == subpadnumber) return pad;
2847 }
2848 }
2849 return nullptr;
2850}
2851
2852////////////////////////////////////////////////////////////////////////////////
2853/// Return lower and upper bounds of the pad in NDC coordinates.
2854
2855void TPad::GetPadPar(Double_t &xlow, Double_t &ylow, Double_t &xup, Double_t &yup)
2856{
2857 xlow = fXlowNDC;
2858 ylow = fYlowNDC;
2859 xup = fXlowNDC+fWNDC;
2860 yup = fYlowNDC+fHNDC;
2861}
2862
2863////////////////////////////////////////////////////////////////////////////////
2864/// Return pad world coordinates range.
2865
2867{
2868 x1 = fX1;
2869 y1 = fY1;
2870 x2 = fX2;
2871 y2 = fY2;
2872}
2873
2874////////////////////////////////////////////////////////////////////////////////
2875/// Return pad axis coordinates range.
2876
2878{
2879 xmin = fUxmin;
2880 ymin = fUymin;
2881 xmax = fUxmax;
2882 ymax = fUymax;
2883}
2884
2885////////////////////////////////////////////////////////////////////////////////
2886/// Highlight pad.
2887/// do not highlight when printing on Postscript
2888
2890{
2891 if (auto pp = GetPainter())
2892 if(!pp->IsNative())
2893 return;
2894
2895 if (color <= 0)
2896 return;
2897
2899
2900 // We do not want to have active(executable) buttons, etc highlighted
2901 // in this manner, unless we want to edit'em
2903 //When doing a DrawClone from the GUI you would do
2904 // - select an empty pad -
2905 // - right click on object -
2906 // - select DrawClone on menu -
2907 //
2908 // Without the SetSelectedPad(); in the HighLight function, the
2909 // above instruction lead to the clone to be drawn in the
2910 // same canvas as the original object. This is because the
2911 // 'right clicking' (via TCanvas::HandleInput) changes gPad
2912 // momentarily such that when DrawClone is called, it is
2913 // not the right value (for DrawClone). Should be FIXED.
2914 gROOT->SetSelectedPad(this);
2915 if (GetBorderMode() > 0)
2916 PaintBorder(set ? -color : -GetFillColor(), kFALSE);
2917 }
2918
2920}
2921
2922////////////////////////////////////////////////////////////////////////////////
2923/// List all primitives in pad.
2924
2926{
2928 std::cout <<IsA()->GetName()<<" fXlowNDC=" <<fXlowNDC<<" fYlowNDC="<<fYlowNDC<<" fWNDC="<<GetWNDC()<<" fHNDC="<<GetHNDC()
2929 <<" Name= "<<GetName()<<" Title= "<<GetTitle()<<" Option="<<option<<std::endl;
2931 if (!fPrimitives) return;
2934}
2935
2936////////////////////////////////////////////////////////////////////////////////
2937/// Internal method to create, provide or delete TInteractive instance
2938/// It is allowed the only instance of TInteractive object per pad
2939/// It can be assigned for the object when @param init is provided
2940/// Otherwise returns existing instance for the @param obj
2941/// If none of parameters are specified - existing instance will be deleted
2942
2944{
2945 if (obj && init) {
2946 init->SetObject(obj);
2947 fInteractive.reset(init);
2948 } else if (!obj)
2949 fInteractive.reset(nullptr);
2950
2951 if (!fInteractive || (fInteractive->GetObject() != obj))
2952 return nullptr;
2953
2954 return fInteractive.get();
2955}
2956
2957
2958////////////////////////////////////////////////////////////////////////////////
2959/// Increment (i==1) or set (i>1) the number of autocolor in the pad.
2960
2962{
2963 TString opt1 = opt;
2964 opt1.ToLower();
2965
2966 if (opt1.Contains("pfc") || opt1.Contains("plc") || opt1.Contains("pmc")) {
2967 if (i == 1) fNumPaletteColor++;
2968 else fNumPaletteColor = i;
2969 return fNumPaletteColor;
2970 }
2971
2972 return 0;
2973}
2974
2975////////////////////////////////////////////////////////////////////////////////
2976/// Get the next autocolor in the pad.
2977
2979{
2980 Int_t i = 0;
2981 Int_t ncolors = gStyle->GetNumberOfColors();
2982 if (fNumPaletteColor>1) {
2983 i = fNextPaletteColor*(ncolors/(fNumPaletteColor-1));
2984 if (i>=ncolors) i = ncolors-1;
2985 }
2988 return gStyle->GetColorPalette(i);
2989}
2990
2991////////////////////////////////////////////////////////////////////////////////
2992/// Initialise the grid used to find empty space when adding a box (Legend) in a pad
2993
2995{
2996 Int_t const cellSize = 10; // Size of an individual grid cell in pixels.
2997
2998 fCGnx = GetWw()/cellSize;
2999 fCGny = GetWh()/cellSize;
3000
3001 // Initialise the collide grid
3002 fCollideGrid.resize(fCGnx*fCGny);
3003 for (int i = 0; i < fCGnx; i++)
3004 for (int j = 0; j < fCGny; j++)
3005 fCollideGrid[i + j * fCGnx] = kTRUE;
3006
3007 // Fill the collide grid
3008 TIter iter(GetListOfPrimitives());
3009
3010 while(auto o = iter()) {
3011 if (o == oi)
3012 continue;
3013 if (o->InheritsFrom(TFrame::Class()))
3015 else if (o->InheritsFrom(TBox::Class()))
3017 else if (o->InheritsFrom(TH1::Class()))
3019 else if (o->InheritsFrom(TGraph::Class()))
3021 else if (o->InheritsFrom(TMultiGraph::Class())) {
3022 TIter nextgraph(((TMultiGraph *)o)->GetListOfGraphs());
3023 while (auto og = nextgraph())
3025 } else if (o->InheritsFrom(THStack::Class())) {
3026 TIter nexthist(((THStack *)o)->GetHists());
3027 while (auto oh = nexthist()) {
3028 if (oh->InheritsFrom(TH1::Class()))
3030 }
3031 }
3032 }
3033}
3034
3035////////////////////////////////////////////////////////////////////////////////
3036/// Check if a box of size w and h collide some primitives in the pad at
3037/// position i,j
3038
3040{
3041 for (int r = i; r < w + i; r++) {
3042 for (int c = j; c < h + j; c++) {
3043 if (!fCollideGrid[r + c * fCGnx])
3044 return kTRUE;
3045 }
3046 }
3047 return kFALSE;
3048}
3049
3050////////////////////////////////////////////////////////////////////////////////
3051/// Place a box in NDC space
3052///
3053/// \return `true` if the box could be placed, `false` if not.
3054///
3055/// \param[in] o pointer to the box to be placed
3056/// \param[in] w box width to be placed
3057/// \param[in] h box height to be placed
3058/// \param[out] xl x position of the bottom left corner of the placed box
3059/// \param[out] yb y position of the bottom left corner of the placed box
3060/// \param[in] option l=left, r=right, t=top, b=bottom, w=within margins. Order determines
3061/// priority for placement. Default is "lb" (prioritises horizontal over vertical)
3062
3064{
3065 FillCollideGrid(o);
3066
3067 Int_t iw = (int)(fCGnx*w);
3068 Int_t ih = (int)(fCGny*h);
3069
3070 Int_t nxbeg = 0;
3071 Int_t nybeg = 0;
3072 Int_t nxend = fCGnx-iw-1;
3073 Int_t nyend = fCGny-ih-1;
3074 Int_t dx = 1;
3075 Int_t dy = 1;
3076
3077 bool isFirstVertical = false;
3078 bool isFirstHorizontal = false;
3079
3080 for (std::size_t i = 0; option[i] != '\0'; ++i) {
3081 char letter = std::tolower(option[i]);
3082 if (letter == 'w') {
3083 nxbeg += fCGnx*GetLeftMargin();
3084 nybeg += fCGny*GetBottomMargin();
3085 nxend -= fCGnx*GetRightMargin();
3086 nyend -= fCGny*GetTopMargin();
3087 } else if (letter == 't' || letter == 'b') {
3088 isFirstVertical = !isFirstHorizontal;
3089 // go from top to bottom instead of bottom to top
3090 dy = letter == 't' ? -1 : 1;
3091 } else if (letter == 'l' || letter == 'r') {
3092 isFirstHorizontal = !isFirstVertical;
3093 // go from right to left instead of left to right
3094 dx = letter == 'r' ? -1 : 1;
3095 }
3096 }
3097
3098 if(dx < 0) std::swap(nxbeg, nxend);
3099 if(dy < 0) std::swap(nybeg, nyend);
3100
3101 auto attemptPlacement = [&](Int_t i, Int_t j) {
3102 if (Collide(i, j, iw, ih)) {
3103 return false;
3104 } else {
3105 xl = (Double_t)(i) / (Double_t)(fCGnx);
3106 yb = (Double_t)(j) / (Double_t)(fCGny);
3107 return true;
3108 }
3109 };
3110
3111 if(!isFirstVertical) {
3112 for (Int_t i = nxbeg; i != nxend; i += dx) {
3113 for (Int_t j = nybeg; j != nyend; j += dy) {
3114 if (attemptPlacement(i, j)) return true;
3115 }
3116 }
3117 } else {
3118 // prioritizing vertical over horizontal
3119 for (Int_t j = nybeg; j != nyend; j += dy) {
3120 for (Int_t i = nxbeg; i != nxend; i += dx) {
3121 if (attemptPlacement(i, j)) return true;
3122 }
3123 }
3124 }
3125
3126 return kFALSE;
3127}
3128
3129// Set the specific cell element in the grid to false, clamp to (fCGnx*fCGny) - 1 to avoid going out of bounds
3130#define NotFree(i, j) fCollideGrid[TMath::Max(TMath::Min(i + j * fCGnx, (fCGnx * fCGny) - 1), 0)] = kFALSE;
3131
3132////////////////////////////////////////////////////////////////////////////////
3133/// Mark as "not free" the cells along a line.
3134
3136{
3137 NotFree(x1, y1);
3138 NotFree(x2, y2);
3139 Int_t i, j, xt, yt;
3140
3141 // horizontal lines
3142 if (y1==y2) {
3143 for (i=x1+1; i<x2; i++) NotFree(i,y1);
3144 return;
3145 }
3146
3147 // vertical lines
3148 if (x1==x2) {
3149 for (i=y1+1; i<y2; i++) NotFree(x1,i);
3150 return;
3151 }
3152
3153 // other lines
3154 if (TMath::Abs(x2-x1)>TMath::Abs(y2-y1)) {
3155 if (x1>x2) {
3156 xt = x1; x1 = x2; x2 = xt;
3157 yt = y1; y1 = y2; y2 = yt;
3158 }
3159 for (i=x1+1; i<x2; i++) {
3160 j = (Int_t)((Double_t)(y2-y1)*(Double_t)((i-x1)/(Double_t)(x2-x1))+y1);
3161 NotFree(i,j);
3162 NotFree(i,(j+1));
3163 }
3164 } else {
3165 if (y1>y2) {
3166 yt = y1; y1 = y2; y2 = yt;
3167 xt = x1; x1 = x2; x2 = xt;
3168 }
3169 for (j=y1+1; j<y2; j++) {
3170 i = (Int_t)((Double_t)(x2-x1)*(Double_t)((j-y1)/(Double_t)(y2-y1))+x1);
3171 NotFree(i,j);
3172 NotFree((i+1),j);
3173 }
3174 }
3175}
3176
3177////////////////////////////////////////////////////////////////////////////////
3179{
3180 TBox *b = (TBox *)o;
3181 if (fCGnx==0||fCGny==0) return;
3182 Double_t xs = (fX2-fX1)/fCGnx;
3183 Double_t ys = (fY2-fY1)/fCGny;
3184
3185 Int_t x1 = (Int_t)((b->GetX1()-fX1)/xs);
3186 Int_t x2 = (Int_t)((b->GetX2()-fX1)/xs);
3187 Int_t y1 = (Int_t)((b->GetY1()-fY1)/ys);
3188 Int_t y2 = (Int_t)((b->GetY2()-fY1)/ys);
3189 for (int i = x1; i<=x2; i++) {
3190 for (int j = y1; j<=y2; j++) NotFree(i, j);
3191 }
3192}
3193
3194////////////////////////////////////////////////////////////////////////////////
3196{
3197 TFrame *f = (TFrame *)o;
3198 if (fCGnx==0||fCGny==0) return;
3199 Double_t xs = (fX2-fX1)/fCGnx;
3200 Double_t ys = (fY2-fY1)/fCGny;
3201
3202 Int_t x1 = (Int_t)((f->GetX1()-fX1)/xs);
3203 Int_t x2 = (Int_t)((f->GetX2()-fX1)/xs);
3204 Int_t y1 = (Int_t)((f->GetY1()-fY1)/ys);
3205 Int_t y2 = (Int_t)((f->GetY2()-fY1)/ys);
3206 Int_t i;
3207
3208 for (i = x1; i<=x2; i++) {
3209 NotFree(i, y1);
3210 NotFree(i, (y1-1));
3211 NotFree(i, (y1-2));
3212 }
3213 for (i = y1; i<=y2; i++) {
3214 NotFree(x1, i);
3215 NotFree((x1-1), i);
3216 NotFree((x1-2), i);
3217 }
3218}
3219
3220////////////////////////////////////////////////////////////////////////////////
3222{
3223 TGraph *g = (TGraph *)o;
3224 if (fCGnx==0||fCGny==0) return;
3225 Double_t xs = (fX2-fX1)/fCGnx;
3226 Double_t ys = (fY2-fY1)/fCGny;
3227
3228 Int_t n = g->GetN();
3229 Int_t s = TMath::Max(n/10,1);
3230 Double_t x1, x2, y1, y2;
3231 for (Int_t i=s; i<n; i=i+s) {
3232 g->GetPoint(TMath::Max(0,i-s),x1,y1);
3233 g->GetPoint(i ,x2,y2);
3234 if (fLogx) {
3235 if (x1 > 0) x1 = TMath::Log10(x1);
3236 else x1 = fUxmin;
3237 if (x2 > 0) x2 = TMath::Log10(x2);
3238 else x2 = fUxmin;
3239 }
3240 if (fLogy) {
3241 if (y1 > 0) y1 = TMath::Log10(y1);
3242 else y1 = fUymin;
3243 if (y2 > 0) y2 = TMath::Log10(y2);
3244 else y2 = fUymin;
3245 }
3246 LineNotFree((int)((x1-fX1)/xs), (int)((x2-fX1)/xs),
3247 (int)((y1-fY1)/ys), (int)((y2-fY1)/ys));
3248 }
3249}
3250
3251////////////////////////////////////////////////////////////////////////////////
3253{
3254 TH1 *h = (TH1 *)o;
3255 if (fCGnx==0||fCGny==0) return;
3256 if (o->InheritsFrom(TH2::Class())) return;
3257 if (o->InheritsFrom(TH3::Class())) return;
3258
3259 TString name = h->GetName();
3260 if (name.Index("hframe") >= 0) return;
3261
3262 Double_t xs = (fX2-fX1)/fCGnx;
3263 Double_t ys = (fY2-fY1)/fCGny;
3264
3265 bool haserrors = false;
3266 TString drawOption = h->GetDrawOption();
3267 drawOption.ToLower();
3268 drawOption.ReplaceAll("same","");
3269
3270 if (drawOption.Index("hist") < 0) {
3271 if (drawOption.Index("e") >= 0) haserrors = true;
3272 }
3273
3274 Int_t nx = h->GetNbinsX();
3275 Int_t x1, y1, y2;
3276 Int_t i, j;
3277 Double_t x1l, y1l, y2l;
3278
3279 for (i = 1; i<nx; i++) {
3280 if (haserrors) {
3281 x1l = h->GetBinCenter(i);
3282 if (fLogx) {
3283 if (x1l > 0) x1l = TMath::Log10(x1l);
3284 else x1l = fUxmin;
3285 }
3286 x1 = (Int_t)((x1l-fX1)/xs);
3287 y1l = h->GetBinContent(i)-h->GetBinErrorLow(i);
3288 if (fLogy) {
3289 if (y1l > 0) y1l = TMath::Log10(y1l);
3290 else y1l = fUymin;
3291 }
3292 y1 = (Int_t)((y1l-fY1)/ys);
3293 y2l = h->GetBinContent(i)+h->GetBinErrorUp(i);
3294 if (fLogy) {
3295 if (y2l > 0) y2l = TMath::Log10(y2l);
3296 else y2l = fUymin;
3297 }
3298 y2 = (Int_t)((y2l-fY1)/ys);
3299 for (j=y1; j<y2; j++) {
3300 NotFree(x1, j);
3301 }
3302 }
3303 x1l = h->GetBinLowEdge(i);
3304 if (fLogx) {
3305 if (x1l > 0) x1l = TMath::Log10(x1l);
3306 else x1l = fUxmin;
3307 }
3308 x1 = (Int_t)((x1l-fX1)/xs);
3309 y1l = h->GetBinContent(i);
3310 if (fLogy) {
3311 if (y1l > 0) y1l = TMath::Log10(y1l);
3312 else y1l = fUymin;
3313 }
3314 y1 = (Int_t)((y1l-fY1)/ys);
3315 NotFree(x1, y1);
3316 x1l = h->GetBinLowEdge(i)+h->GetBinWidth(i);
3317 if (fLogx) {
3318 if (x1l > 0) x1l = TMath::Log10(x1l);
3319 else x1l = fUxmin;
3320 }
3321 x1 = (int)((x1l-fX1)/xs);
3322 NotFree(x1, y1);
3323 }
3324
3325 // Extra objects in the list of function
3326 TPaveStats *ps = (TPaveStats*)h->GetListOfFunctions()->FindObject("stats");
3327 if (ps) FillCollideGridTBox(ps);
3328}
3329
3330////////////////////////////////////////////////////////////////////////////////
3331/// This method draws the collide grid on top of the canvas. This is used for
3332/// debugging only. At some point it will be removed.
3333
3335{
3336 if (fCGnx==0||fCGny==0) return;
3337
3338 TContext ctxt(this, kTRUE);
3339
3340 TBox box;
3341 box.SetFillColorAlpha(kRed,0.5);
3342
3343 Double_t xs = (fX2-fX1)/fCGnx;
3344 Double_t ys = (fY2-fY1)/fCGny;
3345
3346 Double_t X1L, X2L, Y1L, Y2L;
3347 Double_t t = 0.15;
3348 Double_t Y1, Y2;
3349 Double_t X1 = fX1;
3350 Double_t X2 = X1+xs;
3351
3352 for (int i = 0; i<fCGnx; i++) {
3353 Y1 = fY1;
3354 Y2 = Y1+ys;
3355 for (int j = 0; j<fCGny; j++) {
3356 if (GetLogx()) {
3357 X1L = TMath::Power(10,X1);
3358 X2L = TMath::Power(10,X2);
3359 } else {
3360 X1L = X1;
3361 X2L = X2;
3362 }
3363 if (GetLogy()) {
3364 Y1L = TMath::Power(10,Y1);
3365 Y2L = TMath::Power(10,Y2);
3366 } else {
3367 Y1L = Y1;
3368 Y2L = Y2;
3369 }
3370 if (!fCollideGrid[i + j*fCGnx]) {
3371 box.SetFillColorAlpha(kBlack,t);
3372 box.DrawBox(X1L, Y1L, X2L, Y2L);
3373 } else {
3374 box.SetFillColorAlpha(kRed,t);
3375 box.DrawBox(X1L, Y1L, X2L, Y2L);
3376 }
3377 Y1 = Y2;
3378 Y2 = Y1+ys;
3379 if (t==0.15) t = 0.1;
3380 else t = 0.15;
3381 }
3382 X1 = X2;
3383 X2 = X1+xs;
3384 }
3385}
3386
3387////////////////////////////////////////////////////////////////////////////////
3388/// Short cut to call Modified() and Update() in a single call.
3389/// On Mac with Cocoa, it performs an additional ProcessEvents().
3390
3392{
3393 Modified();
3394 Update();
3395#ifdef R__HAS_COCOA
3397#endif
3398}
3399
3400////////////////////////////////////////////////////////////////////////////////
3401/// Convert x from pad to X.
3402
3404{
3405 if (fLogx && x < 50) return Double_t(TMath::Exp(2.302585092994*x));
3406 return x;
3407}
3408
3409////////////////////////////////////////////////////////////////////////////////
3410/// Convert y from pad to Y.
3411
3413{
3414 if (fLogy && y < 50) return Double_t(TMath::Exp(2.302585092994*y));
3415 return y;
3416}
3417
3418////////////////////////////////////////////////////////////////////////////////
3419/// Convert x from X to pad.
3420
3422{
3423 if (fLogx) {
3424 if (x > 0) x = TMath::Log10(x);
3425 else x = fUxmin;
3426 }
3427 return x;
3428}
3429
3430////////////////////////////////////////////////////////////////////////////////
3431/// Convert y from Y to pad.
3432
3434{
3435 if (fLogy) {
3436 if (y > 0) y = TMath::Log10(y);
3437 else y = fUymin;
3438 }
3439 return y;
3440}
3441
3442////////////////////////////////////////////////////////////////////////////////
3443/// Paint all primitives in pad.
3444
3445void TPad::Paint(Option_t * /* option */)
3446{
3447 if (!fPrimitives)
3448 fPrimitives = new TList;
3450 fViewer3D->PadPaint(this);
3452 if (GetGLDevice()!=-1 && gVirtualPS) {
3453 TContext ctxt(this, kFALSE);
3454 if (gGLManager) gGLManager->PrintViewer(GetViewer3D());
3455 }
3456 return;
3457 }
3458
3459 TVirtualPadPainter *oldpp = nullptr;
3460 Bool_t replace_pp = kFALSE;
3461
3462 if (fCanvas) {
3463 // check if special PS painter should be assigned to TCanvas
3464 replace_pp = fCanvas->EnsurePSPainter(kTRUE, oldpp);
3466 }
3467
3468 Bool_t began3DScene = kFALSE;
3469 fPadPaint = 1;
3470
3471 {
3472 TContext ctxt(this, kTRUE);
3473
3474 fDrawOperXor.clear();
3476 PaintDate();
3477
3478 auto lnk = GetListOfPrimitives()->FirstLink();
3479
3480 while (lnk) {
3481 TObject *obj = lnk->GetObject();
3482
3483 // Create a pad 3D viewer if none exists and we encounter a 3D shape
3484 if (!fViewer3D && obj->InheritsFrom(TAtt3D::Class())) {
3485 GetViewer3D("pad");
3486 }
3487
3488 // Open a 3D scene if required
3489 if (fViewer3D && !fViewer3D->BuildingScene()) {
3491 began3DScene = kTRUE;
3492 }
3493
3494 obj->Paint(lnk->GetOption());
3495 lnk = lnk->Next();
3496 }
3497
3498 if (fCanvas && (fCanvas->fHilightPadBorder == this)) {
3499 auto col = GetHighLightColor();
3500 if (col > 0) PaintBorder(-col, kTRUE);
3501 }
3502
3503 PaintOperations(); // paint operations only for the pad
3504 }
3505
3506 fPadPaint = 0;
3508
3509 if (replace_pp && fCanvas)
3511
3512 // Close the 3D scene if we opened it. This must be done after modified
3513 // flag is cleared, as some viewers will invoke another paint by marking pad modified again
3514 if (began3DScene) {
3516 }
3517}
3518
3519////////////////////////////////////////////////////////////////////////////////
3520/// Paint the pad border.
3521/// Draw first a box as a normal filled box
3522
3523void TPad::PaintBorder(Color_t color, Bool_t /* tops */)
3524{
3525 auto pp = GetPainter();
3526 if (!pp)
3527 return;
3528
3529 pp->OnPad(this);
3530
3531 if (color >= 0) {
3532
3533 Bool_t do_paint_box = kTRUE;
3534
3536 if (!IsBatch() && (pp->IsCocoa() || (pp->IsNative() && (style > 3000) && (style < 3026))))
3537 pp->ClearDrawable();
3538
3539 // special only for transparent pads in plain X11;
3540 // Cocoa, GL, Web and PS implement transparency different
3541 if ((style >= 4000) && (style <= 4100) && pp->IsNative() && !pp->IsCocoa() && !pp->GetPS() && !(fCanvas && fCanvas->UseGL()) && !IsWeb() && !IsBatch()) {
3542 if (this == fMother) {
3543 style = 1001;
3544 } else {
3545 // copy all pixmaps
3546 do_paint_box = kFALSE;
3547 Int_t px, py;
3548 XYtoAbsPixel(GetX1(), GetY2(), px, py);
3549 if (fMother)
3550 fMother->CopyBackgroundPixmaps(this, px, py);
3551 pp->SetAttFill({color, 1001}); // use fill color producing opacity
3552 pp->SetOpacity(style - 4000);
3553 }
3554 } else if ((style >= 4000) && (style <= 4100) && pp->IsCocoa() && (this == fMother))
3555 style = 1001;
3556 else if ((color == 10) && (style > 3000) && (style < 3100))
3557 color = 1;
3558
3559 if (do_paint_box) {
3560 pp->SetAttFill({color, style});
3561 pp->SetAttLine(*this);
3562 PaintBox(fX1, fY1, fX2, fY2);
3563 }
3564 } else
3565 color = -color;
3566
3567 if (IsTransparent() || (fBorderMode == 0))
3568 return;
3569
3570 // then paint 3d frame (depending on bordermode)
3571 // Paint a 3D frame around the pad.
3572
3573 TWbox box;
3574 box.SetFillColor(color);
3575 box.SetFillStyle(GetFillStyle());
3577
3578 box.PaintBorderOn(this, fX1, fY1, fX2, fY2,
3581}
3582
3583////////////////////////////////////////////////////////////////////////////////
3584/// Paint a frame border with Postscript - no longer used
3585
3587{
3588 if (!gVirtualPS) return;
3589 gVirtualPS->DrawFrame(xl, yl, xt, yt, bmode,bsize,dark,light);
3590}
3591
3592////////////////////////////////////////////////////////////////////////////////
3593/// Paint the current date and time if the option `Date` is set on via `gStyle->SetOptDate()`
3594/// Paint the current file name if the option `File` is set on via `gStyle->SetOptFile()`
3595
3597{
3598 if (fCanvas == this) {
3599 if (gStyle->GetOptDate()) {
3600 TDatime dt;
3601 const char *dates;
3602 char iso[16];
3603 if (gStyle->GetOptDate() < 10) {
3604 //by default use format like "Wed Sep 25 17:10:35 2002"
3605 dates = dt.AsString();
3606 } else if (gStyle->GetOptDate() < 20) {
3607 //use ISO format like 2002-09-25
3608 strlcpy(iso,dt.AsSQLString(),16);
3609 dates = iso;
3610 } else {
3611 //use ISO format like 2002-09-25 17:10:35
3612 dates = dt.AsSQLString();
3613 }
3614 TText tdate(gStyle->GetDateX(),gStyle->GetDateY(),dates);
3620 tdate.SetNDC();
3621 tdate.Paint();
3622 }
3623 if (gStyle->GetOptFile() && gFile) {
3624 TText tfile(1. - gStyle->GetDateX(),gStyle->GetDateY(),gFile->GetName());
3628 tfile.SetTextAlign(31);
3630 tfile.SetNDC();
3631 tfile.Paint();
3632 }
3633 }
3634}
3635
3636////////////////////////////////////////////////////////////////////////////////
3637/// Paint histogram/graph frame.
3638
3640{
3641 if (!fPrimitives) fPrimitives = new TList;
3642 TList *glist = GetListOfPrimitives();
3643 TFrame *frame = GetFrame();
3644 frame->SetX1(xmin);
3645 frame->SetX2(xmax);
3646 frame->SetY1(ymin);
3647 frame->SetY2(ymax);
3648 if (!glist->FindObject(fFrame)) {
3649 glist->AddFirst(frame);
3651 }
3652 frame->Paint();
3653}
3654
3655////////////////////////////////////////////////////////////////////////////////
3656/// Traverse pad hierarchy and (re)paint only modified pads.
3657
3659{
3661 if (IsModified()) {
3662 fViewer3D->PadPaint(this);
3664 }
3665 TList *pList = GetListOfPrimitives();
3666 auto lnk = pList ? pList->FirstLink() : nullptr;
3667 while (lnk) {
3668 auto obj = lnk->GetObject();
3669 if (obj->InheritsFrom(TPad::Class()))
3670 ((TPad*)obj)->PaintModified();
3671 lnk = lnk->Next();
3672 }
3673 return;
3674 }
3675
3676 TVirtualPS *saveps = gVirtualPS;
3678 gVirtualPS = nullptr;
3679
3680 TVirtualPadPainter *oldpp = nullptr;
3681 Bool_t replace_pp = kFALSE;
3682
3683 if (fCanvas) {
3684 // check if special PS painter should be assigned to TCanvas
3685 replace_pp = fCanvas->EnsurePSPainter(kTRUE, oldpp);
3687 }
3688
3689 Bool_t began3DScene = kFALSE;
3690 fPadPaint = 1;
3691 {
3692 TContext ctxt(this, kTRUE);
3693
3694 auto pp = GetPainter();
3695 Bool_t useXor = pp && pp->IsNative() && !pp->IsCocoa();
3696 Bool_t needRepaint = IsModified() || IsTransparent() || (!useXor && fDrawOper.size());
3697
3698 if (needRepaint)
3700
3701 PaintDate();
3702
3703 TList *pList = GetListOfPrimitives();
3704 auto lnk = pList ? pList->FirstLink() : nullptr;
3705
3706 while (lnk) {
3707 TObject *obj = lnk->GetObject();
3708 if (obj->InheritsFrom(TPad::Class())) {
3709 ((TPad*)obj)->PaintModified();
3710 } else if (needRepaint) {
3711
3712 // Create a pad 3D viewer if none exists and we encounter a
3713 // 3D shape
3714 if (!fViewer3D && obj->InheritsFrom(TAtt3D::Class())) {
3715 GetViewer3D("pad");
3716 }
3717
3718 // Open a 3D scene if required
3719 if (fViewer3D && !fViewer3D->BuildingScene()) {
3721 began3DScene = kTRUE;
3722 }
3723
3724 obj->Paint(lnk->GetOption());
3725 }
3726 lnk = lnk->Next();
3727 }
3728
3729 // when XOR is not available - paint operations at the ned
3730 if (!useXor && needRepaint)
3732 }
3733
3734 fPadPaint = 0;
3736
3737 // This must be done after modified flag is cleared, as some
3738 // viewers will invoke another paint by marking pad modified again
3739 if (began3DScene && fViewer3D)
3741
3742 if (replace_pp && fCanvas)
3744
3745 gVirtualPS = saveps;
3746}
3747
3748////////////////////////////////////////////////////////////////////////////////
3749/// Perform buffered paint operations
3750/// Used for interactivity functionality immediately after normal painting is performed
3751/// Only when withXor is specified global window context used to perform
3752/// inversion of window, otherwise only draw operations for the current pad are done
3753
3755{
3756 auto pp = GetPainter();
3757 if (!pp)
3758 return;
3759
3760 // IMPORTANT - only when XOR used change gPad only for coordinates calculation
3761 // selected device should never be changed - therefore not use cd()
3762 auto savepad = gPad;
3763 if (withXor)
3764 gPad = this;
3765
3766 pp->OnPad(this);
3767
3768 if (withXor)
3769 for (auto &oper : fDrawOperXor)
3770 oper.second->Draw(*this, pp, withXor);
3771
3772 fDrawOperXor.clear();
3773
3774 for (auto &oper : fDrawOper)
3775 oper.second->Draw(*this, pp, withXor);
3776
3777 if (withXor)
3778 std::swap(fDrawOperXor, fDrawOper);
3779 else
3780 fDrawOper.clear();
3781
3782 if (withXor) {
3783 gPad = savepad;
3784
3785 TIter next(GetListOfPrimitives());
3786 while (auto obj = next()) {
3787 if (auto pad = dynamic_cast<TPad *>(obj))
3788 pad->PaintOperations(withXor);
3789 }
3790 }
3791}
3792
3793////////////////////////////////////////////////////////////////////////////////
3794/// Paint box in CurrentPad World coordinates.
3795///
3796/// - if option[0] = 's' the box is forced to be paint with style=0
3797/// - if option[0] = 'l' the box contour is drawn
3798/// - if option[0] = 'i' the interactive xor box will be painted
3799
3801{
3802 auto pp = GetPainter();
3803 if (!pp)
3804 return;
3805
3806 if (option && *option == 'i') {
3807 Double_t x[5] = {x1, x2, x2, x1, x1};
3808 Double_t y[5] = {y1, y1, y2, y2, y1};
3810 fDrawOper[option] = std::make_unique<TPadDrawOperation>(5, x, y, drawKind, pp->GetLineWidth());
3811 return;
3812 }
3813
3814 pp->OnPad(this);
3815
3816 Style_t style = pp->GetAttFill().GetFillStyle();
3817 Bool_t draw_border = kFALSE, draw_fill = kFALSE, skip_fill = kFALSE;
3818 if (option && *option == 's')
3819 skip_fill = draw_border = kTRUE;
3820 else if (option && *option == 'l')
3821 draw_border = kTRUE;
3822
3823 if (style >= 3100 && style < 4000) {
3824 Double_t xb[4] = {x1, x1, x2, x2};
3825 Double_t yb[4] = {y1, y2, y2, y1};
3826 PaintFillAreaHatches(4, xb, yb, style);
3827 } else if (style >= 0 && style < 1000) {
3828 draw_border = kTRUE;
3829 } else if (style >= 1000 && style < 2000) {
3830 draw_fill = kTRUE;
3831 } else if (style > 3000 && style < 3100) {
3832 draw_fill = style < 3026;
3833 } else if (style >= 4000 && style <= 4100) {
3834 // transparency styles, supported now by all painters
3835 draw_fill = style > 4000;
3836 } else if (style > 0)
3837 draw_border = kTRUE;
3838
3839 if (draw_fill && !skip_fill)
3840 pp->DrawBox(x1, y1, x2, y2, TVirtualPadPainter::kFilled);
3841
3842 if (draw_border)
3843 pp->DrawBox(x1, y1, x2, y2, TVirtualPadPainter::kHollow);
3844
3845 Modified();
3846}
3847
3848////////////////////////////////////////////////////////////////////////////////
3849/// Copy pixmaps of pads laying below pad "stop" into pad "stop". This
3850/// gives the effect of pad "stop" being transparent.
3851
3853{
3854 Int_t px, py;
3855 XYtoAbsPixel(GetX1(), GetY2(), px, py);
3856 /// Copy pixmap of this pad as background of the current pad.
3857 if (auto pp = GetPainter())
3858 pp->CopyDrawable(GetPixmapID(), px - x, py - y);
3859
3860 TIter next(GetListOfPrimitives());
3861 while (auto obj = next()) {
3862 if (obj == stop)
3863 break;
3864 if (auto pad = dynamic_cast<TPad *>(obj))
3865 pad->CopyBackgroundPixmaps(stop, x, y);
3866 }
3867}
3868
3869////////////////////////////////////////////////////////////////////////////////
3870
3872{
3873 Warning("PaintFillArea", "Float_t signature is obsolete. Use Double_t signature.");
3874}
3875
3876////////////////////////////////////////////////////////////////////////////////
3877/// Paint fill area in CurrentPad World coordinates.
3878///
3879/// If option[0] == 'C' no clipping
3880/// If option[0] == 'i' paint during ExecuteEvent (interactive)
3881
3883{
3884 if (nn < 3)
3885 return;
3887 Bool_t mustClip = kTRUE;
3890 } else {
3891 xmin = fX1; ymin = fY1; xmax = fX2; ymax = fY2;
3892 if (option && (*option == 'C')) mustClip = kFALSE;
3893 }
3894
3895 std::vector<Double_t> xclip, yclip;
3896
3897 if (mustClip) {
3898 Int_t nc = 2*nn+1;
3899 xclip.resize(nc, 0.);
3900 yclip.resize(nc, 0.);
3901 Int_t n = ClipPolygon(nn, xx, yy, nc, xclip.data(), yclip.data(), xmin, ymin, xmax, ymax);
3902 if (!n)
3903 return;
3904 nn = n;
3905 xx = xclip.data();
3906 yy = yclip.data();
3907 }
3908
3909 if (option && *option == 'i') {
3910 fDrawOper[option] = std::make_unique<TPadDrawOperation>(nn, xx, yy, TPadDrawOperation::drawFill);
3911 return;
3912 }
3913
3914 auto pp = GetPainter();
3915 if (!pp)
3916 return;
3917
3918 pp->OnPad(this);
3919
3920 // Paint the fill area with hatches
3921 Int_t fillstyle = pp->GetFillStyle();
3922 if (fillstyle >= 3100 && fillstyle < 4000)
3923 PaintFillAreaHatches(nn, xx, yy, fillstyle);
3924 else
3925 pp->DrawFillArea(nn, xx, yy);
3926
3927 Modified();
3928}
3929
3930////////////////////////////////////////////////////////////////////////////////
3931/// Paint fill area in CurrentPad NDC coordinates.
3932
3934{
3935 std::vector<Double_t> xw(n), yw(n);
3936 for (int i=0; i<n; i++) {
3937 xw[i] = fX1 + x[i]*(fX2 - fX1);
3938 yw[i] = fY1 + y[i]*(fY2 - fY1);
3939 }
3940 PaintFillArea(n, xw.data(), yw.data(), option);
3941}
3942
3943////////////////////////////////////////////////////////////////////////////////
3944/// This function paints hatched fill area according to the FillStyle value
3945/// The convention for the Hatch is the following:
3946///
3947/// `FillStyle = 3ijk`
3948///
3949/// - i (1-9) : specify the space between each hatch
3950/// 1 = minimum 9 = maximum
3951/// the final spacing is i*GetHatchesSpacing(). The hatches spacing
3952/// is set by SetHatchesSpacing()
3953/// - j (0-9) : specify angle between 0 and 90 degrees
3954/// * 0 = 0
3955/// * 1 = 10
3956/// * 2 = 20
3957/// * 3 = 30
3958/// * 4 = 45
3959/// * 5 = Not drawn
3960/// * 6 = 60
3961/// * 7 = 70
3962/// * 8 = 80
3963/// * 9 = 90
3964/// - k (0-9) : specify angle between 90 and 180 degrees
3965/// * 0 = 180
3966/// * 1 = 170
3967/// * 2 = 160
3968/// * 3 = 150
3969/// * 4 = 135
3970/// * 5 = Not drawn
3971/// * 6 = 120
3972/// * 7 = 110
3973/// * 8 = 100
3974/// * 9 = 90
3975
3977{
3978 static Double_t ang1[10] = { 0., 10., 20., 30., 45.,5., 60., 70., 80., 89.99};
3979 static Double_t ang2[10] = {180.,170.,160.,150.,135.,5.,120.,110.,100., 89.99};
3980
3981 Int_t fasi = FillStyle % 1000;
3982 Int_t idSPA = fasi / 100;
3983 Int_t iAng2 = (fasi - 100 * idSPA) / 10;
3984 Int_t iAng1 = fasi % 10;
3985 Double_t dy = 0.003 * idSPA * gStyle->GetHatchesSpacing();
3987 auto pp = GetPainter();
3988 if (!pp)
3989 return;
3990
3991 // Save the current line attributes and change to draw hatches
3992 TAttLine saveatt = pp->GetAttLine();
3993
3994 pp->SetAttLine({ pp->GetAttFill().GetFillColor(), 1, lw });
3995
3996 // Draw the hatches
3997 if (ang1[iAng1] != 5.)
3998 PaintHatches(dy, ang1[iAng1], nn, xx, yy);
3999 if (ang2[iAng2] != 5.)
4000 PaintHatches(dy, ang2[iAng2], nn, xx, yy);
4001
4002 pp->SetAttLine(saveatt);
4003}
4004
4005////////////////////////////////////////////////////////////////////////////////
4006/// This routine draw hatches inclined with the
4007/// angle "angle" and spaced of "dy" in normalized device
4008/// coordinates in the surface defined by n,xx,yy.
4009
4011 Int_t nn, Double_t *xx, Double_t *yy)
4012{
4013 Int_t i, i1, i2, nbi;
4014 Double_t ratiox, ratioy, ymin, ymax, yrot, ycur;
4015 const Double_t angr = TMath::Pi()*(180.-angle)/180.;
4016 const Double_t epsil = 0.0001;
4017
4018 std::vector<Double_t> xli;
4019 std::vector<Double_t> yli;
4020
4021 Double_t xt1, xt2, yt1, yt2;
4022 Double_t x, y, x1, x2, y1, y2, a, b, xi, xip, xin, yi, yip;
4023
4024 Double_t rwxmin = gPad->GetX1();
4025 Double_t rwxmax = gPad->GetX2();
4026 Double_t rwymin = gPad->GetY1();
4027 Double_t rwymax = gPad->GetY2();
4028 ratiox = 1./(rwxmax-rwxmin);
4029 ratioy = 1./(rwymax-rwymin);
4030
4031 Double_t sina = TMath::Sin(angr), sinb;
4032 Double_t cosa = TMath::Cos(angr), cosb;
4033 if (TMath::Abs(cosa) <= epsil) cosa=0.;
4034 if (TMath::Abs(sina) <= epsil) sina=0.;
4035 sinb = -sina;
4036 cosb = cosa;
4037
4038 // Values needed to compute the hatches in TRUE normalized space (NDC)
4039 Int_t iw = (Int_t)gPad->GetWw();
4040 Int_t ih = (Int_t)gPad->GetWh();
4041 Double_t x1p,y1p,x2p,y2p;
4042 gPad->GetPadPar(x1p,y1p,x2p,y2p);
4043 iw = (Int_t)(iw*x2p)-(Int_t)(iw*x1p);
4044 ih = (Int_t)(ih*y2p)-(Int_t)(ih*y1p);
4045 Double_t wndc = TMath::Min(1.,(Double_t)iw/(Double_t)ih);
4046 Double_t hndc = TMath::Min(1.,(Double_t)ih/(Double_t)iw);
4047
4048 // Search ymin and ymax
4049 ymin = 1.;
4050 ymax = 0.;
4051 for (i=1; i<=nn; i++) {
4052 x = wndc*ratiox*(xx[i-1]-rwxmin);
4053 y = hndc*ratioy*(yy[i-1]-rwymin);
4054 yrot = sina*x+cosa*y;
4055 if (yrot > ymax) ymax = yrot;
4056 if (yrot < ymin) ymin = yrot;
4057 }
4058
4059 Int_t yindx = (Int_t) (ymax/dy);
4060
4061 while (dy * yindx >= ymin) {
4062 ycur = dy * yindx--;
4063 nbi = 0;
4064
4065 xli.clear();
4066 yli.clear();
4067
4068 for (i=2; i<=nn+1; i++) {
4069 i2 = i;
4070 i1 = i-1;
4071 if (i == nn+1) i2=1;
4072
4073 x1 = wndc*ratiox*(xx[i1-1]-rwxmin);
4074 y1 = hndc*ratioy*(yy[i1-1]-rwymin);
4075 x2 = wndc*ratiox*(xx[i2-1]-rwxmin);
4076 y2 = hndc*ratioy*(yy[i2-1]-rwymin);
4077
4078 xt1 = cosa*x1-sina*y1;
4079 yt1 = sina*x1+cosa*y1;
4080 xt2 = cosa*x2-sina*y2;
4081 yt2 = sina*x2+cosa*y2;
4082
4083 // Line segment parallel to oy
4084 if (xt1 == xt2) {
4085 if (yt1 < yt2) {
4086 yi = yt1;
4087 yip = yt2;
4088 } else {
4089 yi = yt2;
4090 yip = yt1;
4091 }
4092 if ((yi <= ycur) && (ycur < yip)) {
4093 nbi++;
4094 xli.push_back(xt1);
4095 }
4096 continue;
4097 }
4098
4099 // Line segment parallel to ox
4100 if (yt1 == yt2) {
4101 if (yt1 == ycur) {
4102 nbi++;
4103 xli.push_back(xt1);
4104 nbi++;
4105 xli.push_back(xt2);
4106 }
4107 continue;
4108 }
4109
4110 // Other line segment
4111 a = (yt1-yt2)/(xt1-xt2);
4112 b = (yt2*xt1-xt2*yt1)/(xt1-xt2);
4113
4114 if (xt1 < xt2) {
4115 xi = xt1;
4116 xip = xt2;
4117 } else {
4118 xi = xt2;
4119 xip = xt1;
4120 }
4121
4122 xin = (ycur-b)/a;
4123
4124 if ((xi <= xin) && (xin < xip) &&
4125 (TMath::Min(yt1,yt2) <= ycur) &&
4126 (ycur < TMath::Max(yt1,yt2))) {
4127 nbi++;
4128 xli.push_back(xin);
4129 }
4130 }
4131
4132 // Sorting of the x coordinates intersections
4133 std::sort(xli.begin(), xli.end());
4134
4135 // Draw the hatches
4136 if ((nbi%2 != 0) || (nbi == 0))
4137 continue;
4138
4139 for (i=0; i<nbi; ++i) {
4140 // Rotate back the hatches - first calculate y coordinate
4141 Double_t ytmp = sinb*xli[i] + cosb*ycur;
4142 xli[i] = cosb*xli[i] - sinb*ycur;
4143 // Convert hatches' positions from true NDC to WC to handle clipping
4144 xli[i] = (xli[i]/wndc)*(rwxmax-rwxmin)+rwxmin;
4145 ytmp = (ytmp/hndc)*(rwymax-rwymin)+rwymin;
4146 yli.push_back(ytmp);
4147 }
4148
4149 gPad->PaintSegments(nbi/2, xli.data(), yli.data());
4150 }
4151}
4152
4153////////////////////////////////////////////////////////////////////////////////
4154/// Paint line in CurrentPad World coordinates.
4155
4157{
4158 Double_t x[2] = {x1, x2}, y[2] = {y1, y2};
4159
4160 //If line is totally clipped, return
4162 if (Clip(x,y,fUxmin,fUymin,fUxmax,fUymax) == 2) return;
4163 } else {
4164 if (Clip(x,y,fX1,fY1,fX2,fY2) == 2) return;
4165 }
4166
4167 if (auto pp = GetPainter()) {
4168 pp->OnPad(this);
4169 pp->DrawLine(x[0], y[0], x[1], y[1]);
4170 }
4171
4172 Modified();
4173}
4174
4175////////////////////////////////////////////////////////////////////////////////
4176/// Paint line in normalized coordinates.
4177
4179{
4180 if (auto pp = GetPainter()) {
4181 pp->OnPad(this);
4182 pp->DrawLineNDC(u1, v1, u2, v2);
4183 }
4184
4185 Modified();
4186}
4187
4188////////////////////////////////////////////////////////////////////////////////
4189/// Paint 3-D line in the CurrentPad.
4190
4192{
4193 if (!fView) return;
4194
4195 // convert from 3-D to 2-D pad coordinate system
4196 Double_t xpad[6];
4197 Double_t temp[3];
4198 Int_t i;
4199 for (i=0;i<3;i++) temp[i] = p1[i];
4200 fView->WCtoNDC(temp, &xpad[0]);
4201 for (i=0;i<3;i++) temp[i] = p2[i];
4202 fView->WCtoNDC(temp, &xpad[3]);
4203 PaintLine(xpad[0],xpad[1],xpad[3],xpad[4]);
4204}
4205
4206////////////////////////////////////////////////////////////////////////////////
4207/// Paint 3-D line in the CurrentPad.
4208
4210{
4211 if (!fView) return;
4212
4213 // convert from 3-D to 2-D pad coordinate system
4214 Double_t xpad[6];
4215 Double_t temp[3];
4216 Int_t i;
4217 for (i=0;i<3;i++) temp[i] = p1[i];
4218 fView->WCtoNDC(temp, &xpad[0]);
4219 for (i=0;i<3;i++) temp[i] = p2[i];
4220 fView->WCtoNDC(temp, &xpad[3]);
4221 PaintLine(xpad[0],xpad[1],xpad[3],xpad[4]);
4222}
4223
4224////////////////////////////////////////////////////////////////////////////////
4225/// Paint 3-D marker in the CurrentPad.
4226
4228{
4229 if (!fView) return;
4230
4231 Double_t rmin[3], rmax[3];
4232 fView->GetRange(rmin, rmax);
4233
4234 // convert from 3-D to 2-D pad coordinate system
4235 Double_t xpad[3];
4236 Double_t temp[3];
4237 temp[0] = x;
4238 temp[1] = y;
4239 temp[2] = z;
4240 if (x<rmin[0] || x>rmax[0]) return;
4241 if (y<rmin[1] || y>rmax[1]) return;
4242 if (z<rmin[2] || z>rmax[2]) return;
4243 fView->WCtoNDC(temp, &xpad[0]);
4244 PaintPolyMarker(1, &xpad[0], &xpad[1]);
4245}
4246
4247////////////////////////////////////////////////////////////////////////////////
4248/// Paint polyline in CurrentPad World coordinates.
4249///
4250/// If option[0] == 'C' no clipping
4251/// If option[0] == 'i' paint during ExecuteEvent (interactive)
4252
4254{
4255 auto pp = GetPainter();
4256 if ((n < 2) || !pp)
4257 return;
4258
4260 Bool_t mustClip = kTRUE, interactive = option && *option == 'i';
4263 } else {
4264 xmin = fX1; ymin = fY1; xmax = fX2; ymax = fY2;
4265 if (option && (*option == 'C')) mustClip = kFALSE;
4266 }
4267 Int_t i1 = -1, np = 1, iclip = 0;
4268 for (Int_t i = 0; i < n - 1; i++) {
4269 Double_t x1 = x[i];
4270 Double_t y1 = y[i];
4271 Double_t x2 = x[i+1];
4272 Double_t y2 = y[i+1];
4273 if (mustClip) {
4274 iclip = Clip(&x[i],&y[i],xmin,ymin,xmax,ymax);
4275 if (iclip == 2) {
4276 i1 = -1;
4277 continue;
4278 }
4279 }
4280 np++;
4281 if (i1 < 0)
4282 i1 = i;
4283 if (iclip == 0 && i < n-2)
4284 continue;
4285 if (interactive)
4286 fDrawOper[option] = std::make_unique<TPadDrawOperation>(np, &x[i1], &y[i1], TPadDrawOperation::drawLine, pp->GetLineWidth());
4287 else {
4288 pp->OnPad(this);
4289 pp->DrawPolyLine(np, &x[i1], &y[i1]);
4290 }
4291 if (iclip) {
4292 x[i] = x1;
4293 y[i] = y1;
4294 x[i+1] = x2;
4295 y[i+1] = y2;
4296 }
4297 i1 = -1;
4298 np = 1;
4299 }
4300
4301 if (!interactive)
4302 Modified();
4303}
4304
4305////////////////////////////////////////////////////////////////////////////////
4306/// Paint polyline in CurrentPad World coordinates.
4307///
4308/// If option[0] == 'C' no clipping
4309/// If option[0] == 'i' paint during ExecuteEvent (interactive)
4310
4312{
4313 auto pp = GetPainter();
4314 if ((n < 2) || !pp)
4315 return;
4316
4318 Bool_t mustClip = kTRUE, interactive = option && *option == 'i';
4321 } else {
4322 xmin = fX1; ymin = fY1; xmax = fX2; ymax = fY2;
4323 if (option && (*option == 'C')) mustClip = kFALSE;
4324 }
4325
4326 Int_t i1 = -1, np = 1, iclip = 0;
4327
4328 for (Int_t i = 0; i < n-1; i++) {
4329 Double_t x1 = x[i];
4330 Double_t y1 = y[i];
4331 Double_t x2 = x[i+1];
4332 Double_t y2 = y[i+1];
4333 if (mustClip) {
4334 iclip = Clip(&x[i],&y[i],xmin,ymin,xmax,ymax);
4335 if (iclip == 2) {
4336 i1 = -1;
4337 continue;
4338 }
4339 }
4340 np++;
4341 if (i1 < 0)
4342 i1 = i;
4343 if (iclip == 0 && i < n-2)
4344 continue;
4345 if (interactive)
4346 fDrawOper[option] = std::make_unique<TPadDrawOperation>(np, &x[i1], &y[i1], TPadDrawOperation::drawLine, pp->GetLineWidth());
4347 else {
4348 pp->OnPad(this);
4349 pp->DrawPolyLine(np, &x[i1], &y[i1]);
4350 }
4351 if (iclip) {
4352 x[i] = x1;
4353 y[i] = y1;
4354 x[i+1] = x2;
4355 y[i+1] = y2;
4356 }
4357 i1 = -1;
4358 np = 1;
4359 }
4360
4361 if (!interactive)
4362 Modified();
4363}
4364
4365////////////////////////////////////////////////////////////////////////////////
4366/// Paint polyline in CurrentPad NDC coordinates.
4367
4369{
4370 auto pp = GetPainter();
4371 if ((n < 2) || !pp)
4372 return;
4373
4374 if (option && *option == 'i') {
4375 fDrawOper[option] = std::make_unique<TPadDrawOperation>(n, x, y, TPadDrawOperation::drawLine, pp->GetLineWidth(), kTRUE);
4376 return;
4377 }
4378
4379 pp->OnPad(this);
4380 pp->DrawPolyLineNDC(n, x, y);
4381
4382 Modified();
4383}
4384
4385////////////////////////////////////////////////////////////////////////////////
4386/// Paint 3-D polyline in the CurrentPad.
4387
4389{
4390 if (!fView) return;
4391
4392 // Loop on each individual line
4393 for (Int_t i = 1; i < n; i++)
4394 PaintLine3D(&p[3*i-3], &p[3*i]);
4395
4396 Modified();
4397}
4398
4399////////////////////////////////////////////////////////////////////////////////
4400/// Paint polymarker in CurrentPad World coordinates.
4401///
4402/// If option[0] == 'i' paint during ExecuteEvent (interactive)
4403
4405{
4406 Int_t n = TMath::Abs(nn);
4408 if (nn > 0 || TestBit(TGraph::kClipFrame)) {
4410 } else {
4411 xmin = fX1; ymin = fY1; xmax = fX2; ymax = fY2;
4412 }
4413 Int_t i,i1=-1,np=0;
4414 for (i=0; i<n; i++) {
4415 if (x[i] >= xmin && x[i] <= xmax && y[i] >= ymin && y[i] <= ymax) {
4416 np++;
4417 if (i1 < 0) i1 = i;
4418 if (i < n-1) continue;
4419 }
4420 if (np == 0)
4421 continue;
4422 if (option && *option == 'i')
4423 fDrawOper[option] = std::make_unique<TPadDrawOperation>(np, &x[i1], &y[i1], TPadDrawOperation::drawMarker, option[1] == 'f' ? 0 : 1);
4424 else if (auto pp = GetPainter()) {
4425 pp->OnPad(this);
4426 pp->DrawPolyMarker(np, &x[i1], &y[i1]);
4427 }
4428 i1 = -1;
4429 np = 0;
4430 }
4431 Modified();
4432}
4433
4434////////////////////////////////////////////////////////////////////////////////
4435/// Paint polymarker in CurrentPad World coordinates.
4436///
4437/// If option[0] == 'i' paint during ExecuteEvent (interactive)
4438
4440{
4441 Int_t n = TMath::Abs(nn);
4443 if (nn > 0 || TestBit(TGraph::kClipFrame)) {
4445 } else {
4446 xmin = fX1; ymin = fY1; xmax = fX2; ymax = fY2;
4447 }
4448 Int_t i,i1=-1,np=0;
4449 for (i=0; i<n; i++) {
4450 if (x[i] >= xmin && x[i] <= xmax && y[i] >= ymin && y[i] <= ymax) {
4451 np++;
4452 if (i1 < 0) i1 = i;
4453 if (i < n-1) continue;
4454 }
4455 if (np == 0)
4456 continue;
4457
4458 if (option && *option == 'i')
4459 fDrawOper[option] = std::make_unique<TPadDrawOperation>(np, &x[i1], &y[i1], TPadDrawOperation::drawMarker, option[1] == 'f' ? 0 : 1);
4460 else if (auto pp = GetPainter()) {
4461 pp->OnPad(this);
4462 pp->DrawPolyMarker(np, &x[i1], &y[i1]);
4463 }
4464 i1 = -1;
4465 np = 0;
4466 }
4467 Modified();
4468}
4469
4470////////////////////////////////////////////////////////////////////////////////
4471/// Paint N individual segments
4472/// Provided arrays should have 2*n elements
4473/// IMPORTANT! Provided arrays can be modified after function call!
4474
4476{
4477 if (n < 1)
4478 return;
4479
4481 Bool_t mustClip = kTRUE, isAny = kFALSE;
4484 } else {
4485 xmin = fX1; ymin = fY1; xmax = fX2; ymax = fY2;
4486 if (option && *option == 'C') mustClip = kFALSE;
4487 }
4488
4489 if (!mustClip)
4490 isAny = kTRUE;
4491 else {
4492 for (Int_t i = 0; i < 2*n; i+=2) {
4493 Int_t iclip = Clip(&x[i],&y[i],xmin,ymin,xmax,ymax);
4494 if (iclip == 2)
4495 x[i] = y[i] = x[i+1] = y[i+1] = 0;
4496 else
4497 isAny = kTRUE;
4498 }
4499 }
4500
4501 if (isAny)
4502 if (auto pp = GetPainter()) {
4503 pp->OnPad(this);
4504 pp->DrawSegments(n, x, y);
4505 }
4506
4507 Modified();
4508}
4509
4510
4511////////////////////////////////////////////////////////////////////////////////
4512/// Paint N individual segments in NDC coordinates
4513/// Provided arrays should have 2*n elements
4514/// IMPORTANT! Provided arrays can be modified after function call!
4515
4517{
4518 if (auto pp = GetPainter()) {
4519 pp->OnPad(this);
4520 pp->DrawSegmentsNDC(n, u, v);
4521 }
4522
4523 Modified();
4524}
4525
4526
4527////////////////////////////////////////////////////////////////////////////////
4528/// Paint text in CurrentPad World coordinates.
4529
4531{
4532 Modified();
4533
4534 if (auto pp = GetPainter()) {
4535 pp->OnPad(this);
4536 pp->DrawText(x, y, text, TVirtualPadPainter::kClear);
4537 }
4538}
4539
4540////////////////////////////////////////////////////////////////////////////////
4541/// Paint text in CurrentPad World coordinates.
4542
4543void TPad::PaintText(Double_t x, Double_t y, const wchar_t *text)
4544{
4545 Modified();
4546
4547 if (auto pp = GetPainter()) {
4548 pp->OnPad(this);
4549 pp->DrawText(x, y, text, TVirtualPadPainter::kClear);
4550 }
4551}
4552
4553////////////////////////////////////////////////////////////////////////////////
4554/// Paint text with URL in CurrentPad World coordinates.
4555
4556void TPad::PaintTextUrl(Double_t x, Double_t y, const char *text, const char *url)
4557{
4558 Modified();
4559
4560 if (auto pp = GetPainter()) {
4561 pp->OnPad(this);
4562 pp->DrawTextUrl(x, y, text, url);
4563 }
4564}
4565
4566////////////////////////////////////////////////////////////////////////////////
4567/// Paint text in CurrentPad NDC coordinates.
4568
4570{
4571 Modified();
4572
4573 if (auto pp = GetPainter()) {
4574 pp->OnPad(this);
4575 pp->DrawTextNDC(u, v, text, TVirtualPadPainter::kClear);
4576 }
4577}
4578
4579////////////////////////////////////////////////////////////////////////////////
4580/// Paint text in CurrentPad NDC coordinates.
4581
4583{
4584 Modified();
4585
4586 if (auto pp = GetPainter()) {
4587 pp->OnPad(this);
4588 pp->DrawTextNDC(u, v, text, TVirtualPadPainter::kClear);
4589 }
4590}
4591
4592////////////////////////////////////////////////////////////////////////////////
4593/// Search for an object at pixel position px,py.
4594///
4595/// Check if point is in this pad.
4596///
4597/// If yes, check if it is in one of the sub-pads
4598///
4599/// If found in the pad, compute closest distance of approach
4600/// to each primitive.
4601///
4602/// If one distance of approach is found to be within the limit Distancemaximum
4603/// the corresponding primitive is selected and the routine returns.
4604
4606{
4607 //the two following statements are necessary under NT (multithreaded)
4608 //when a TCanvas object is being created and a thread calling TPad::Pick
4609 //before the TPad constructor has completed in the other thread
4610 if (!gPad) return nullptr; //Andy Haas
4611 if (!GetListOfPrimitives()) return nullptr; //Andy Haas
4612
4613 Int_t dist;
4614 // Search if point is in pad itself
4615 Double_t x = AbsPixeltoX(px);
4616 Double_t y = AbsPixeltoY(py);
4617 if (this != gPad->GetCanvas()) {
4618 if (!((x >= fX1 && x <= fX2) && (y >= fY1 && y <= fY2))) return nullptr;
4619 }
4620
4621 // search for a primitive in this pad or its sub-pads
4622 static TObjOptLink dummyLink(nullptr,""); //place holder for when no link available
4623
4624 TContext ctxt(this, kFALSE); // since no drawing will be done, don't use cd() for efficiency reasons
4625
4626 TPad *pick = nullptr;
4627 TPad *picked = this;
4628 pickobj = nullptr;
4630 dummyLink.SetObject(this);
4631 pickobj = &dummyLink;
4632 }
4633
4634 // Loop backwards over the list of primitives. The first non-pad primitive
4635 // found is the selected one. However, we have to keep going down the
4636 // list to see if there is maybe a pad overlaying the primitive. In that
4637 // case look into the pad for a possible primitive. Once a pad has been
4638 // found we can terminate the loop.
4639 Bool_t gotPrim = kFALSE; // true if found a non pad primitive
4641
4642 //We can have 3d stuff in pad. If canvas prefers to draw
4643 //such stuff with OpenGL, the selection of 3d objects is
4644 //a gl viewer business so, in first cycle we do not
4645 //call DistancetoPrimitive for TAtt3D descendants.
4646 //In case of gl we first try to select 2d object first.
4647
4648 while (lnk) {
4649 TObject *obj = lnk->GetObject();
4650
4651 //If canvas prefers GL, all 3d objects must be drawn/selected by
4652 //gl viewer
4653 if (obj->InheritsFrom(TAtt3D::Class()) && fEmbeddedGL) {
4654 lnk = lnk->Prev();
4655 continue;
4656 }
4657
4658 fPadPointer = obj;
4659 if (obj->InheritsFrom(TPad::Class())) {
4660 pick = ((TPad*)obj)->Pick(px, py, pickobj);
4661 if (pick) {
4662 picked = pick;
4663 break;
4664 }
4665 } else if (!gROOT->GetEditorMode()) {
4666 if (!gotPrim) {
4667 if (!obj->TestBit(kCannotPick)) {
4668 dist = obj->DistancetoPrimitive(px, py);
4669 if (dist < fgMaxPickDistance) {
4670 pickobj = lnk;
4671 gotPrim = kTRUE;
4672 if (dist == 0) break;
4673 }
4674 }
4675 }
4676 }
4677
4678 lnk = lnk->Prev();
4679 }
4680
4681 //if no primitive found, check if we have a TView
4682 //if yes, return the view except if you are in the lower or upper X range
4683 //of the pad.
4684 //In case canvas prefers gl, fView existence
4685 //automatically means viewer3d existence. (?)
4686
4687 if (fView && !gotPrim) {
4688 Double_t dx = 0.05*(fUxmax-fUxmin);
4689 if ((x > fUxmin + dx) && (x < fUxmax-dx)) {
4690
4691 if (fEmbeddedGL) {
4692 //No 2d stuff was selected, but we have gl-viewer. Let it select an object in
4693 //scene (or select itself). In any case it'll internally call
4694 //gPad->SetSelected(ptr) as, for example, hist painter does.
4695 py -= Int_t((1 - GetHNDC() - GetYlowNDC()) * GetWh());
4696 px -= Int_t(GetXlowNDC() * GetWw());
4698 }
4699 else
4700 dummyLink.SetObject(fView);
4701 }
4702 }
4703
4704 if (picked->InheritsFrom(TButton::Class())) {
4705 TButton *button = (TButton*)picked;
4706 if (!button->IsEditable()) pickobj = nullptr;
4707 }
4708
4709 if (TestBit(kCannotPick)) {
4710
4711 if (picked == this) {
4712 // cannot pick pad itself!
4713 picked = nullptr;
4714 }
4715
4716 }
4717
4718 return picked;
4719}
4720
4721////////////////////////////////////////////////////////////////////////////////
4722/// Pop pad to the top of the stack.
4723
4725{
4727 return;
4728 if (!fPrimitives)
4729 fPrimitives = new TList;
4730 if (this == fMother->GetListOfPrimitives()->Last())
4731 return;
4732
4734 while (auto obj = next())
4735 if (obj == this) {
4736 TString opt = next.GetOption();
4737 fMother->Remove(this, kFALSE); // do not issue modified
4738 fMother->Add(this, opt.Data());
4739 return;
4740 }
4741}
4742
4743////////////////////////////////////////////////////////////////////////////////
4744/// This method is equivalent to `SaveAs("filename")`. See TPad::SaveAs for details.
4745
4746void TPad::Print(const char *filename) const
4747{
4748 ((TPad*)this)->SaveAs(filename);
4749}
4750
4751////////////////////////////////////////////////////////////////////////////////
4752/// Save Canvas contents in a file in one of various formats.
4753///
4754/// \anchor TPadPrint
4755/// option can be:
4756///
4757/// - `ps`: a Postscript file is produced (default). [See special cases](\ref TPadPrintPS).
4758/// - `Portrait`: Postscript file is produced (Portrait)
4759/// - `Landscape`: Postscript file is produced (Landscape)
4760/// - `eps`: an Encapsulated Postscript file is produced
4761/// - `Preview`: an [Encapsulated Postscript file with preview](\ref TPadPrintPreview) is produced.
4762/// - `pdf`: a PDF file is produced NOTE: TMathText will be converted to TLatex; q.e.d., symbols only available in TMathText will not render properly.
4763/// - `Title:`: The character string after `Title:` becomes a table
4764/// of content entry (for PDF files).
4765/// - `EmbedFonts`: a [PDF file with embedded fonts](\ref TPadPrintEmbedFonts) is generated.
4766/// - `svg`: a SVG file is produced
4767/// - `tex`: a TeX file is produced
4768/// - `Standalone`: a [standalone TeX file](\ref TPadPrintStandalone) is produced.
4769/// - `gif`: a GIF file is produced
4770/// - `gif+NN`: an animated GIF file is produced, where NN is delay in 10ms units NOTE: See other variants for looping animation in TASImage::WriteImage
4771/// - `xpm`: a XPM file is produced
4772/// - `png`: a PNG file is produced
4773/// - `jpg`: a JPEG file is produced. NOTE: JPEG's lossy compression will make all sharp edges fuzzy.
4774/// - `tiff`: a TIFF file is produced
4775/// - `cxx`: a C++ macro file is produced
4776/// - `xml`: a XML file
4777/// - `json`: a JSON file
4778/// - `root`: a ROOT binary file
4779///
4780/// `filename` = 0 - filename is defined by `GetName` and its
4781/// extension is defined with the option
4782///
4783/// When Postscript output is selected (`ps`, `eps`), the canvas is saved
4784/// to `filename.ps` or `filename.eps`. The aspect ratio of the canvas is preserved
4785/// on the Postscript file. When the "ps" option is selected, the Postscript
4786/// page will be landscape format if the canvas is in landscape format, otherwise
4787/// portrait format is selected.
4788///
4789/// The physical size of the Postscript page is the one selected in the
4790/// current style. This size can be modified via TStyle::SetPaperSize.
4791///
4792/// Examples:
4793/// ~~~ {.cpp}
4794/// gStyle->SetPaperSize(TStyle::kA4); //default
4795/// gStyle->SetPaperSize(TStyle::kUSLetter);
4796/// ~~~
4797/// where TStyle::kA4 and TStyle::kUSLetter are defined in the enum
4798/// EPaperSize in TStyle.h
4799///
4800/// An alternative is to call:
4801/// ~~~ {.cpp}
4802/// gStyle->SetPaperSize(20,26); same as kA4
4803/// or gStyle->SetPaperSize(20,24); same as kUSLetter
4804/// ~~~
4805/// The above numbers take into account some margins and are in centimeters.
4806///
4807/// \anchor TPadPrintPreview
4808/// ### The "Preview" option
4809///
4810/// The "Preview" option allows to generate a preview (in the TIFF format) within
4811/// the Encapsulated Postscript file. This preview can be used by programs like
4812/// MSWord to visualize the picture on screen. The "Preview" option relies on the
4813/// ["epstool" command](http://www.cs.wisc.edu/~ghost/gsview/epstool.htm).
4814///
4815/// Example:
4816/// ~~~ {.cpp}
4817/// canvas->Print("example.eps","Preview");
4818/// ~~~
4819///
4820/// \anchor TPadPrintEmbedFonts
4821/// ### The "EmbedFonts" option
4822///
4823/// The "EmbedFonts" option allows to embed the fonts used in a PDF file inside
4824/// that file. This option relies on the ["gs" command](https://ghostscript.com).
4825///
4826/// Example:
4827/// ~~~ {.cpp}
4828/// canvas->Print("example.pdf","EmbedFonts");
4829/// ~~~
4830///
4831/// \anchor TPadPrintStandalone
4832/// ### The "Standalone" option
4833/// The "Standalone" option allows to generate a TeX file ready to be processed by
4834/// tools like `pdflatex`.
4835///
4836/// Example:
4837/// ~~~ {.cpp}
4838/// canvas->Print("example.tex","Standalone");
4839/// ~~~
4840///
4841/// \anchor TPadPrintPS
4842/// ### Writing several canvases to the same Postscript or PDF file:
4843///
4844/// - if the Postscript or PDF file name finishes with "(", the file is not closed
4845/// - if the Postscript or PDF file name finishes with ")" and the file has been opened
4846/// with "(", the file is closed.
4847///
4848/// Example:
4849/// ~~~ {.cpp}
4850/// {
4851/// TCanvas c1("c1");
4852/// h1.Draw();
4853/// c1.Print("c1.ps("); //write canvas and keep the ps file open
4854/// h2.Draw();
4855/// c1.Print("c1.ps"); canvas is added to "c1.ps"
4856/// h3.Draw();
4857/// c1.Print("c1.ps)"); canvas is added to "c1.ps" and ps file is closed
4858/// }
4859/// ~~~
4860/// In the previous example replacing "ps" by "pdf" will create a multi-pages PDF file.
4861///
4862/// Note that the following sequence writes the canvas to "c1.ps" and closes the ps file.:
4863/// ~~~ {.cpp}
4864/// TCanvas c1("c1");
4865/// h1.Draw();
4866/// c1.Print("c1.ps");
4867/// ~~~
4868/// The `TCanvas::Print("file.ps(")` mechanism is very useful, but it can be
4869/// a little inconvenient to have the action of opening/closing a file
4870/// being atomic with printing a page. Particularly if pages are being
4871/// generated in some loop one needs to detect the special cases of first
4872/// and last page and then munge the argument to Print() accordingly.
4873///
4874/// The "[" and "]" can be used instead of "(" and ")" to open / close without
4875/// actual printing.
4876///
4877/// Example:
4878/// ~~~ {.cpp}
4879/// c1.Print("file.ps["); // No actual print, just open file.ps
4880/// for (int i=0; i<10; ++i) {
4881/// // fill canvas for context i
4882/// // ...
4883///
4884/// c1.Print("file.ps"); // actually print canvas to file
4885/// }// end loop
4886/// c1.Print("file.ps]"); // No actual print, just close.
4887/// ~~~
4888/// As before, the same macro is valid for PDF files.
4889///
4890/// It is possible to print a canvas into an animated GIF file by specifying the
4891/// file name as "myfile.gif+" or "myfile.gif+NN", where NN*10ms is delay
4892/// between the subimages' display. If NN is omitted the delay between
4893/// subimages is zero. Each picture is added in the animation thanks to a loop
4894/// similar to the following one:
4895/// ~~~ {.cpp}
4896/// for (int i=0; i<10; ++i) {
4897/// // fill canvas for context i
4898/// // ...
4899///
4900/// c1.Print("file.gif+5"); // print canvas to GIF file with 50ms delays
4901/// }// end loop
4902/// ~~~
4903/// The delay between each frame must be specified in each Print() statement.
4904/// If the file "myfile.gif" already exists, the new frame are appended at
4905/// the end of the file. To avoid this, delete it first with `gSystem->Unlink(myfile.gif);`
4906/// If you want the gif file to repeat or loop forever, check TASImage::WriteImage documentation
4907
4909{
4910 auto canv = GetCanvas();
4911 if (!canv)
4912 return;
4913
4914 TString psname, fs1 = filename;
4915
4916 // "[" and "]" are special characters for ExpandPathName. When they are at the end
4917 // of the file name (see help) they must be removed before doing ExpandPathName.
4918 if (fs1.EndsWith("[")) {
4919 fs1.Replace((fs1.Length()-1),1," ");
4920 gSystem->ExpandPathName(fs1);
4921 fs1.Replace((fs1.Length()-1),1,"[");
4922 } else if (fs1.EndsWith("]")) {
4923 fs1.Replace((fs1.Length()-1),1," ");
4924 gSystem->ExpandPathName(fs1);
4925 fs1.Replace((fs1.Length()-1),1,"]");
4926 } else {
4927 gSystem->ExpandPathName(fs1);
4928 }
4929
4930 // Set the default option as "Postscript" (Should be a data member of TPad)
4931 const char *opt_default = "ps";
4932
4933 TString opt = !option ? opt_default : option;
4934 Bool_t image = kFALSE;
4935 Bool_t title = opt.Contains("Title:");
4936
4937 if (!fs1.Length()) {
4938 psname = GetName();
4939 psname += opt;
4940 } else {
4941 psname = fs1;
4942 }
4943
4944 // lines below protected against case like c1->SaveAs( "../ps/cs.ps" );
4945 if (psname.BeginsWith('.') && (psname.Contains('/') == 0)) {
4946 psname = GetName();
4947 psname.Append(fs1);
4948 psname.Prepend("/");
4949 psname.Prepend(gEnv->GetValue("Canvas.PrintDirectory","."));
4950 }
4951
4952 // Save pad/canvas in alternative formats
4954 if (!title && opt.Contains("gif+")) {
4955 gtype = TImage::kAnimGif;
4956 image = kTRUE;
4957 } else if (!title && opt.Contains("gif")) {
4958 gtype = TImage::kGif;
4959 image = kTRUE;
4960 } else if (!title && opt.Contains("png")) {
4961 gtype = TImage::kPng;
4962 image = kTRUE;
4963 } else if (!title && opt.Contains("jpg")) {
4964 gtype = TImage::kJpeg;
4965 image = kTRUE;
4966 } else if (!title && opt.Contains("tiff")) {
4967 gtype = TImage::kTiff;
4968 image = kTRUE;
4969 } else if (!title && opt.Contains("xpm")) {
4970 gtype = TImage::kXpm;
4971 image = kTRUE;
4972 } else if (!title && opt.Contains("bmp")) {
4973 gtype = TImage::kBmp;
4974 image = kTRUE;
4975 } else if (!title && opt.Contains("svg")) {
4976 gtype = TImage::kSvg;
4977 } else if (!title && opt.Contains("pdf")) {
4978 gtype = TImage::kPdf;
4979 } else if (!title && opt.Contains("html")) {
4980 gtype = TImage::kHtml;
4981 }
4982
4983 auto pp = GetPainter();
4984 Bool_t isweb = canv->IsWeb();
4985 Bool_t isbatch = gROOT->IsBatch() || canv->IsBatch();
4986
4987 // for a moment special handling of web canvas - check if can save directly
4988 if (isweb && pp)
4989 if (pp->SaveAsImage(this, psname.Data(), gtype) != TVirtualPadPainter::kSaveNotImplemented)
4990 return;
4991
4992 // to create HTML file web-based canvas functionality is invoked
4993 if (gtype == TImage::kHtml) {
4994 auto cmd = TString::Format("TWebCanvas::ProduceImage((TPad *) 0x%zx, \"%s\");", (size_t) this, psname.Data());
4995 Long_t res = gROOT->ProcessLine(cmd);
4996 if (!res)
4997 Error("Print", "Fail create HTML file %s", psname.Data());
4998 return;
4999 }
5000
5001 if (((!isbatch && image) || isweb) && pp) {
5002 Color_t hc = canv->GetHighLightColor();
5003
5004 if (!isweb) {
5005 canv->SetHighLightColor(-1);
5006 Modified();
5007 }
5008 canv->Update();
5009
5010 auto res = pp->SaveAsImage(this, psname.Data(), gtype);
5011
5012 if (!isweb)
5013 canv->SetHighLightColor(hc);
5014
5016 Warning("Print", "Unsupported image format %s, fallback to TImageDump", psname.Data());
5017 else if ((res == TVirtualPadPainter::kSaveOk) && !gSystem->AccessPathName(psname.Data()))
5018 Info("Print", "file %s has been created", psname.Data());
5019
5021 return;
5022 }
5023
5024 //==============Save pad/canvas as a C++ script==============================
5025 if (!title && opt.Contains("cxx")) {
5026 GetCanvas()->SaveSource(psname, "");
5027 return;
5028 }
5029
5030 //==============Save pad/canvas as a root file===============================
5031 if (!title && opt.Contains("root")) {
5032 if (gDirectory) gDirectory->SaveObjectAs(this,psname.Data(),"");
5033 return;
5034 }
5035
5036 //==============Save pad/canvas as a XML file================================
5037 if (!title && opt.Contains("xml")) {
5038 // Plugin XML driver
5039 if (gDirectory) gDirectory->SaveObjectAs(this,psname.Data(),"");
5040 return;
5041 }
5042
5043 //==============Save pad/canvas as a JSON file================================
5044 if (!title && opt.Contains("json")) {
5045 if (gDirectory) gDirectory->SaveObjectAs(this,psname.Data(),"");
5046 return;
5047 }
5048
5049 //==============Save pad/canvas as a SVG file================================
5050 if (gtype == TImage::kSvg) {
5051 gVirtualPS = (TVirtualPS*)gROOT->GetListOfSpecials()->FindObject(psname);
5052
5053 Bool_t noScreen = kFALSE, wasModified = IsModified();
5054 if (!GetCanvas()->IsBatch() && GetCanvas()->GetCanvasID() == -1) {
5055 noScreen = kTRUE;
5057 }
5058
5059 TContext ctxt(this, kTRUE);
5060
5061 if (!gVirtualPS) {
5062 // Plugin Postscript/SVG driver
5063 if (auto h = gROOT->GetPluginManager()->FindHandler("TVirtualPS", "svg")) {
5064 if (h->LoadPlugin() == -1)
5065 return;
5066 h->ExecPlugin(0);
5067 }
5068 }
5069
5070 // Create a new SVG file
5071 if (gVirtualPS) {
5072 gVirtualPS->SetName(psname);
5073 gVirtualPS->Open(psname);
5076 }
5077
5078 Paint();
5079 if (noScreen)
5081 if (wasModified && !IsBatch())
5082 Modified(kTRUE);
5083
5084 if (!gSystem->AccessPathName(psname))
5085 Info("Print", "SVG file %s has been created", psname.Data());
5086
5087 delete gVirtualPS;
5088 gVirtualPS = nullptr;
5089
5090 return;
5091 }
5092
5093 //==============Save pad/canvas as a TeX file================================
5094 if (!title && (opt.Contains("tex") || opt.Contains("Standalone"))) {
5095 gVirtualPS = (TVirtualPS*)gROOT->GetListOfSpecials()->FindObject(psname);
5096
5097 Bool_t noScreen = kFALSE, wasModified = IsModified();
5098 if (!GetCanvas()->IsBatch() && GetCanvas()->GetCanvasID() == -1) {
5099 noScreen = kTRUE;
5101 }
5102
5103 TContext ctxt(this, kTRUE);
5104
5105 if (!gVirtualPS) {
5106 // Plugin Postscript/SVG driver
5107 if (auto h = gROOT->GetPluginManager()->FindHandler("TVirtualPS", "tex")) {
5108 if (h->LoadPlugin() == -1)
5109 return;
5110 h->ExecPlugin(0);
5111 }
5112 }
5113
5114 Bool_t standalone = kFALSE;
5115 if (strstr(opt,"Standalone")) standalone = kTRUE;
5116
5117 // Create a new TeX file
5118 if (gVirtualPS) {
5119 gVirtualPS->SetName(psname);
5120 if (standalone) gVirtualPS->SetTitle("Standalone");
5121 gVirtualPS->Open(psname);
5124 }
5125 Paint();
5126 if (noScreen)
5128 if (wasModified && !IsBatch())
5129 Modified(kTRUE);
5130
5131 if (!gSystem->AccessPathName(psname)) {
5132 if (standalone) {
5133 Info("Print", "Standalone TeX file %s has been created", psname.Data());
5134 } else{
5135 Info("Print", "TeX file %s has been created", psname.Data());
5136 }
5137 }
5138
5139 delete gVirtualPS;
5140 gVirtualPS = nullptr;
5141
5142 return;
5143 }
5144
5145 //==============Save pad/canvas as a Postscript file=========================
5146
5147 // in case we read directly from a Root file and the canvas
5148 // is not on the screen, set batch mode
5149
5150 Bool_t mustOpen = kTRUE, mustClose = kTRUE,
5151 copen = kFALSE, cclose = kFALSE, copenb = kFALSE, ccloseb = kFALSE;
5152 if (!image) {
5153 // The parenthesis mechanism is only valid for PS and PDF files.
5154 copen = psname.EndsWith("("); if (copen) psname[psname.Length()-1] = 0;
5155 cclose = psname.EndsWith(")"); if (cclose) psname[psname.Length()-1] = 0;
5156 copenb = psname.EndsWith("["); if (copenb) psname[psname.Length()-1] = 0;
5157 ccloseb = psname.EndsWith("]"); if (ccloseb) psname[psname.Length()-1] = 0;
5158 }
5159 gVirtualPS = (TVirtualPS*)gROOT->GetListOfSpecials()->FindObject(psname);
5160 if (gVirtualPS) mustOpen = mustClose = kFALSE;
5161 if (copen || copenb) mustClose = kFALSE;
5162 if (cclose || ccloseb) mustClose = kTRUE;
5163
5164 Bool_t noScreen = kFALSE, wasModified = IsModified();
5165 if (!GetCanvas()->IsBatch() && GetCanvas()->GetCanvasID() == -1) {
5166 noScreen = kTRUE;
5168 }
5169 Int_t pstype = 111;
5170 Double_t xcanvas = GetCanvas()->XtoPixel(GetCanvas()->GetX2());
5171 Double_t ycanvas = GetCanvas()->YtoPixel(GetCanvas()->GetY1());
5172 Double_t ratio = ycanvas/xcanvas;
5173 if (ratio < 1) pstype = 112;
5174 if (strstr(opt,"Portrait")) pstype = 111;
5175 if (strstr(opt,"Landscape")) pstype = 112;
5176 if (strstr(opt,"eps")) pstype = 113;
5177 if (strstr(opt,"Preview")) pstype = 113;
5178
5179 TContext ctxt(this, kTRUE);
5180 TVirtualPS *psave = gVirtualPS;
5181
5182 if (!gVirtualPS || mustOpen) {
5183
5184 const char *pluginName = "ps"; // Plugin Postscript driver
5185 if (opt.Contains("pdf") || title || opt.Contains("EmbedFonts"))
5186 pluginName = "pdf";
5187 else if (image)
5188 pluginName = "image"; // Plugin TImageDump driver
5189
5190 if (auto h = gROOT->GetPluginManager()->FindHandler("TVirtualPS", pluginName)) {
5191 if (h->LoadPlugin() == -1)
5192 return;
5193 h->ExecPlugin(0);
5194 }
5195
5196 // Create a new Postscript, PDF or image file
5197 if (gVirtualPS)
5198 gVirtualPS->SetName(psname);
5199 const Ssiz_t titlePos = opt.Index("Title:");
5200 if (titlePos != kNPOS) {
5201 if (gVirtualPS)
5202 gVirtualPS->SetTitle(opt.Data()+titlePos+6);
5203 opt.Replace(titlePos,opt.Length(),"pdf");
5204 }
5205 if (gVirtualPS)
5206 gVirtualPS->Open(psname,pstype);
5207 if (gVirtualPS)
5209 if (!copenb) {
5210 if (!opt.Contains("pdf") || image) {
5212 }
5213 Paint();
5214 }
5215 if (noScreen) GetCanvas()->SetBatch(kFALSE);
5216
5217 if (mustClose) {
5218 gROOT->GetListOfSpecials()->Remove(gVirtualPS);
5219 delete gVirtualPS;
5220 gVirtualPS = psave;
5221 } else {
5222 gROOT->GetListOfSpecials()->Add(gVirtualPS);
5223 gVirtualPS = nullptr;
5224 }
5225
5226 if (!gSystem->AccessPathName(psname)) {
5227 if (!copen) Info("Print", "%s file %s has been created", opt.Data(), psname.Data());
5228 else Info("Print", "%s file %s has been created using the current canvas", opt.Data(), psname.Data());
5229 }
5230 } else {
5231 // Append to existing Postscript, PDF or GIF file
5232 if (!ccloseb) {
5234 Paint();
5235 }
5236 const Ssiz_t titlePos = opt.Index("Title:");
5237 if (titlePos != kNPOS) {
5238 gVirtualPS->SetTitle(opt.Data() + titlePos + 6);
5239 opt.Replace(titlePos, opt.Length(), "pdf");
5240 } else if (!ccloseb) {
5241 gVirtualPS->SetTitle("PDF");
5242 }
5243 if (mustClose) {
5244 if (cclose) Info("Print", "Current canvas added to %s file %s and file closed", opt.Data(), psname.Data());
5245 else Info("Print", "%s file %s has been closed", opt.Data(), psname.Data());
5246 gROOT->GetListOfSpecials()->Remove(gVirtualPS);
5247 delete gVirtualPS;
5248 gVirtualPS = nullptr;
5249 } else {
5250 Info("Print", "Current canvas added to %s file %s", opt.Data(), psname.Data());
5251 gVirtualPS = nullptr;
5252 }
5253 }
5254
5255 if (wasModified && !IsBatch())
5256 Modified(kTRUE);
5257
5258 if (opt.Contains("Preview"))
5259 gSystem->Exec(TString::Format("epstool --quiet -t6p %s %s", psname.Data(), psname.Data()).Data());
5260 if (opt.Contains("EmbedFonts")) {
5261 gSystem->Exec(TString::Format("gs -quiet -dSAFER -dNOPLATFONTS -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -sOutputFile=pdf_temp.pdf -f %s",
5262 psname.Data()).Data());
5263 gSystem->Rename("pdf_temp.pdf", psname.Data());
5264 }
5265
5266}
5267
5268////////////////////////////////////////////////////////////////////////////////
5269/// Set world coordinate system for the pad.
5270/// Emits signal "RangeChanged()", in the slot get the range
5271/// via GetRange().
5272
5274{
5275 if ((x1 >= x2) || (y1 >= y2)) {
5276 Error("Range", "illegal world coordinates range: x1=%f, y1=%f, x2=%f, y2=%f",x1,y1,x2,y2);
5277 return;
5278 }
5279
5280 fUxmin = x1;
5281 fUxmax = x2;
5282 fUymin = y1;
5283 fUymax = y2;
5284
5285 if (fX1 == x1 && fY1 == y1 && fX2 == x2 && fY2 == y2) return;
5286
5287 fX1 = x1;
5288 fY1 = y1;
5289 fX2 = x2;
5290 fY2 = y2;
5291
5292 // compute pad conversion coefficients
5293 ResizePad();
5294
5295 if (gPad == this && GetPainter())
5297
5298 // emit signal
5299 RangeChanged();
5300}
5301
5302////////////////////////////////////////////////////////////////////////////////
5303/// Set axis coordinate system for the pad.
5304/// The axis coordinate system is a subset of the world coordinate system
5305/// xmin,ymin is the origin of the current coordinate system,
5306/// xmax is the end of the X axis, ymax is the end of the Y axis.
5307/// By default a margin of 10 per cent is left on all sides of the pad
5308/// Emits signal "RangeAxisChanged()", in the slot get the axis range
5309/// via GetRangeAxis().
5310
5312{
5313 if ((xmin >= xmax) || (ymin >= ymax)) {
5314 Error("RangeAxis", "illegal axis coordinates range: xmin=%f, ymin=%f, xmax=%f, ymax=%f",
5315 xmin, ymin, xmax, ymax);
5316 return;
5317 }
5318
5319 fUxmin = xmin;
5320 fUymin = ymin;
5321 fUxmax = xmax;
5322 fUymax = ymax;
5323
5324 // emit signal
5326}
5327
5328////////////////////////////////////////////////////////////////////////////////
5329/// Recursively remove object from a pad and its sub-pads.
5330
5332{
5333 if (fCanvas) {
5334 if (obj == fCanvas->GetSelected()) fCanvas->SetSelected(nullptr);
5335 if (obj == fCanvas->GetClickSelected()) fCanvas->SetClickSelected(nullptr);
5336 }
5337 if (obj == fView) fView = nullptr;
5338 if (!fPrimitives) return;
5339 Int_t nold = fPrimitives->GetSize();
5341 if (nold != fPrimitives->GetSize()) fModified = kTRUE;
5342}
5343
5344////////////////////////////////////////////////////////////////////////////////
5345/// Remove object from list of primitives
5346/// When \par modified set to kTRUE (default) pad will be marked as modified - if object really removed
5347/// Returns result of GetListOfPrimitives()->Remove(obj) or nullptr if list of primitives not exists
5348
5350{
5351 TObject *res = nullptr;
5352 if (fPrimitives)
5353 res = fPrimitives->Remove(obj);
5354 if (res && modified)
5355 Modified();
5356 return res;
5357}
5358
5359////////////////////////////////////////////////////////////////////////////////
5360/// Redraw the frame axis.
5361///
5362/// Redrawing axis may be necessary in case of superimposed histograms
5363/// when one or more histograms have a fill color.
5364///
5365/// Instead of calling this function, it may be more convenient
5366/// to call directly `h1->Draw("sameaxis")` where h1 is the pointer
5367/// to the first histogram drawn in the pad.
5368///
5369/// By default, if the pad has the options gridx or/and gridy activated,
5370/// the grid is not drawn by this function.
5371///
5372/// If option="g" is specified, this will force the drawing of the grid
5373/// on top of the picture
5374///
5375/// To redraw the axis tick marks do:
5376/// ~~~ {.cpp}
5377/// gPad->RedrawAxis();
5378/// ~~~
5379/// To redraw the axis grid do:
5380/// ~~~ {.cpp}
5381/// gPad->RedrawAxis("G");
5382/// ~~~
5383/// To redraw the axis tick marks and the axis grid do:
5384/// ~~~ {.cpp}
5385/// gPad->RedrawAxis();
5386/// gPad->RedrawAxis("G");
5387/// ~~~
5388///
5389/// If option="f" is specified, this will force the drawing of the frame
5390/// around the plot.
5391
5393{
5394 TString opt = option;
5395 opt.ToLower();
5396
5397 TContext ctxt(this, kTRUE);
5398
5399 TH1 *hobj = nullptr;
5400
5401 // Get the first histogram drawing the axis in the list of primitives
5402 if (!fPrimitives) fPrimitives = new TList;
5403 TIter next(fPrimitives);
5404 TObject *obj;
5405 while ((obj = next())) {
5406 if (obj->InheritsFrom(TH1::Class())) {
5407 hobj = (TH1*)obj;
5408 break;
5409 }
5410 if (obj->InheritsFrom(TMultiGraph::Class())) {
5411 TMultiGraph *mg = (TMultiGraph*)obj;
5412 if (mg) hobj = mg->GetHistogram();
5413 break;
5414 }
5415 if (obj->InheritsFrom(TGraph::Class())) {
5416 TGraph *g = (TGraph*)obj;
5417 if (g) hobj = g->GetHistogram();
5418 break;
5419 }
5420 if (obj->InheritsFrom(THStack::Class())) {
5421 THStack *hs = (THStack*)obj;
5422 if (hs) hobj = hs->GetHistogram();
5423 break;
5424 }
5425 }
5426
5427 if (hobj) {
5428 if (opt.Contains("g")) hobj->DrawCopy("sameaxig");
5429 else hobj->DrawCopy("sameaxis");
5430 }
5431
5432 if (opt.Contains("f")) {
5433 auto b = new TBox(gPad->GetUxmin(), gPad->GetUymin(),
5434 gPad->GetUxmax(), gPad->GetUymax());
5435 b->SetFillStyle(0);
5436 b->SetLineStyle(gPad->GetFrameLineStyle());
5437 b->SetLineWidth(gPad->GetFrameLineWidth());
5438 b->SetLineColor(gPad->GetFrameLineColor());
5439 b->Draw();
5440 }
5441}
5442
5443////////////////////////////////////////////////////////////////////////////////
5444/// Compute pad conversion coefficients.
5445///
5446/// ### Conversion from x to px
5447///
5448/// \f[\frac{x-xmin}{xrange} = \frac{px-pxlow}{pxrange}\f]
5449/// with:
5450/// \f[ xrange = xmax-xmin \f]
5451/// \f[ pxrange = pxmax-pxmin \f]
5452///
5453/// \f[
5454/// \Rightarrow px = \frac{pxrange(x-xmin)}{xrange} + pxlow = fXtoPixelk + fXtoPixel \times x
5455/// \f]
5456///
5457/// \f[
5458/// \Rightarrow fXtoPixelk = pxlow - pxrange \frac{xmin}{xrange}
5459/// \f]
5460/// \f[
5461/// fXtoPixel = \frac{pxrange}{xrange}
5462/// \f]
5463/// where:
5464/// \f[
5465/// pxlow = fAbsXlowNDC \times fCw
5466/// \f]
5467/// \f[
5468/// pxrange = fAbsWNDC \times fCw
5469/// \f]
5470///
5471/// ### Conversion from y to py
5472///
5473/// \f[\frac{y-ymin}{yrange} = \frac{py-pylow}{pyrange}\f]
5474/// with:
5475/// \f[ yrange = ymax-ymin \f]
5476/// \f[ pyrange = pymax-pymin \f]
5477///
5478/// \f[
5479/// \Rightarrow py = \frac{pyrange(y-xmin)}{yrange} + pylow = fYtoPixelk + fYtoPixel \times y
5480/// \f]
5481///
5482/// \f[
5483/// \Rightarrow fYtoPixelk = pylow - pyrange \frac{ymin}{yrange}
5484/// \f]
5485/// \f[
5486/// fYtoPixel = \frac{pyrange}{yrange}
5487/// \f]
5488/// where:
5489/// \f[
5490/// pylow = fAbsYlowNDC \times fCh
5491/// \f]
5492/// \f[
5493/// pyrange = fAbsHNDC \times fCh
5494/// \f]
5495///
5496/// ### Conversion from px to x
5497///
5498/// \f[
5499/// \Rightarrow x = \frac{xrange(px-pxlow)}{pxrange}+ xmin = fPixeltoXk + fPixeltoX \times px
5500/// \f]
5501///
5502/// \f[
5503/// \Rightarrow fPixeltoXk = xmin - pxlow \times\frac{xrange}{pxrange}
5504/// \f]
5505/// \f[
5506/// fPixeltoX = \frac{xrange}{pxrange}
5507/// \f]
5508///
5509/// ### Conversion from py to y
5510///
5511/// \f[
5512/// \Rightarrow y = \frac{yrange(py-pylow)}{pyrange}+ ymin = fPixeltoYk + fPixeltoY \times py
5513/// \f]
5514///
5515/// \f[
5516/// \Rightarrow fPixeltoYk = ymin - pylow \times\frac{yrange}{pyrange}
5517/// \f]
5518/// \f[
5519/// fPixeltoY = \frac{yrange}{pyrange}
5520/// \f]
5521///
5522/// ### Computation of the coefficients in case of LOG scales
5523///
5524/// #### Conversion from pixel coordinates to world coordinates
5525///
5526/// \f[
5527/// u = \frac{Log(x) - Log(xmin)}{Log(xmax) - Log(xmin)} = \frac{Log(x/xmin)}{Log(xmax/xmin)} = \frac{px - pxlow}{pxrange}
5528/// \f]
5529///
5530/// \f[ \Rightarrow Log(\frac{x}{xmin}) = u \times Log(\frac{xmax}{xmin}) \f]
5531/// \f[ x = xmin \times e^{(u \times Log(\frac{xmax}{xmin})} \f]
5532/// Let:
5533/// \f[ alfa = \frac{Log(\frac{xmax}{xmin})}{fAbsWNDC} \f]
5534///
5535/// \f[ x = xmin \times e^{(-alfa \times pxlow)} + e^{(alfa \times px)} \f]
5536/// \f[ x = fPixeltoXk \times e^{(fPixeltoX \times px)} \f]
5537/// \f[ ==> fPixeltoXk = xmin \times e^{(-alfa*pxlow)} \f]
5538/// \f[ fPixeltoX = alfa \f]
5539///
5540/// \f[
5541/// v = \frac{Log(y) - Log(ymin)}{Log(ymax) - Log(ymin)} = \frac{Log(y/ymin)}{Log(ymax/ymin)} = \frac{py - pylow}{pyrange}
5542/// \f]
5543/// Let:
5544/// \f[ beta = Log(\frac{ymax}{ymin}) \f]
5545/// \f[ Log(\frac{y}{ymin}) = beta \times pylow - beta \times py \f]
5546/// \f[ \frac{y}{ymin} = e^{(beta \times pylow - beta \times py)} \f]
5547/// \f[ y = ymin \times e^{(beta \times pylow)} \times e^{(-beta \times py)}\f]
5548/// \f[ \Rightarrow y = fPixeltoYk \times e^{(fPixeltoY \times py)} \f]
5549/// \f[ fPixeltoYk = ymin \times e^{(beta \times pylow)} \f]
5550/// \f[ fPixeltoY = -beta \f]
5551///
5552/// #### Conversion from World coordinates to pixel coordinates
5553///
5554/// \f[ px = pxlow + u*pxrange \f]
5555/// \f[ = pxlow + Log(x/xmin)/alfa \f]
5556/// \f[ = pxlow -Log(xmin)/alfa + Log(x)/alfa \f]
5557/// \f[ = fXtoPixelk + fXtoPixel*Log(x) \f]
5558/// \f[ \Rightarrow fXtoPixelk = pxlow -Log(xmin)/alfa \f]
5559/// \f[ \Rightarrow fXtoPixel = 1/alfa \f]
5560///
5561/// \f[ py = pylow - Log(y/ymin)/beta \f]
5562/// \f[ = fYtoPixelk + fYtoPixel*Log(y) \f]
5563/// \f[ \Rightarrow fYtoPixelk = pylow - Log(ymin)/beta \f]
5564/// \f[ fYtoPixel = 1/beta \f]
5565
5567{
5568
5569 if (!gPad) {
5570 Error("ResizePad", "Cannot resize pad. No current pad available.");
5571 return;
5572 }
5573 if (gPad->GetWw()==0.0||gPad->GetWh()==0.0) {
5574 Warning("ResizePad", "gPad has at least one zero dimension.");
5575 return;
5576 }
5577 if (fX1==fX2||fY1==fY2) {
5578 Warning("ResizePad", "The pad has at least one zero dimension.");
5579 return;
5580 }
5581 // Recompute subpad positions in case pad has been moved/resized
5582 TPad *parent = fMother;
5583 if (this == gPad->GetCanvas()) {
5586 fAbsWNDC = fWNDC;
5587 fAbsHNDC = fHNDC;
5588 }
5589 else {
5590 if (parent->GetAbsHNDC()==0.0||parent->GetAbsWNDC()==0.0||fHNDC==0.0||fWNDC==0.0) {
5591 Warning("ResizePad", "The parent pad has at least one zero dimension.");
5592 return;
5593 }
5594 fAbsXlowNDC = fXlowNDC*parent->GetAbsWNDC() + parent->GetAbsXlowNDC();
5595 fAbsYlowNDC = fYlowNDC*parent->GetAbsHNDC() + parent->GetAbsYlowNDC();
5596 fAbsWNDC = fWNDC*parent->GetAbsWNDC();
5597 fAbsHNDC = fHNDC*parent->GetAbsHNDC();
5598 }
5599
5600 Double_t ww = (Double_t)gPad->GetWw();
5601 Double_t wh = (Double_t)gPad->GetWh();
5602 Double_t pxlow = fAbsXlowNDC*ww;
5603 Double_t pylow = (1-fAbsYlowNDC)*wh;
5604 Double_t pxrange = fAbsWNDC*ww;
5605 Double_t pyrange = -fAbsHNDC*wh;
5606
5607 // Linear X axis
5608 Double_t rounding = 0.; // was used before to adjust somehow wrong int truncation by coordinates transformation
5609 Double_t xrange = fX2 - fX1;
5610 fXtoAbsPixelk = rounding + pxlow - pxrange*fX1/xrange; //origin at left
5611 fXtoPixelk = rounding + -pxrange*fX1/xrange;
5612 fXtoPixel = pxrange/xrange;
5613 fAbsPixeltoXk = fX1 - pxlow*xrange/pxrange;
5614 fPixeltoXk = fX1;
5615 fPixeltoX = xrange/pxrange;
5616 // Linear Y axis
5617 Double_t yrange = fY2 - fY1;
5618 fYtoAbsPixelk = rounding + pylow - pyrange*fY1/yrange; //origin at top
5619 fYtoPixelk = rounding + -pyrange - pyrange*fY1/yrange;
5620 fYtoPixel = pyrange/yrange;
5621 fAbsPixeltoYk = fY1 - pylow*yrange/pyrange;
5622 fPixeltoYk = fY1;
5623 fPixeltoY = yrange/pyrange;
5624
5625 // Coefficients to convert from pad NDC coordinates to pixel coordinates
5626
5627 fUtoAbsPixelk = rounding + pxlow;
5628 fUtoPixelk = rounding;
5629 fUtoPixel = pxrange;
5630 fVtoAbsPixelk = rounding + pylow;
5631 fVtoPixelk = -pyrange;
5632 fVtoPixel = pyrange;
5633
5634 // Coefficients to convert from canvas pixels to pad world coordinates
5635
5636 // Resize all sub-pads
5637 if (!fPrimitives)
5638 fPrimitives = new TList;
5639 TIter next(GetListOfPrimitives());
5640 while (auto obj = next()) {
5641 if (obj->InheritsFrom(TPad::Class()))
5642 ((TPad *)obj)->ResizePad(option);
5643 }
5644
5645 // Reset all current sizes
5646 if (gPad->IsBatch())
5647 fPixmapID = 0;
5648 else if (auto pp = GetPainter()) {
5649 if (pp->IsNative()) {
5650 // TODO: check if this is necessary
5651 auto attl = pp->GetAttLine();
5652 attl.SetLineColor(-1);
5653 pp->SetAttLine(attl);
5654 auto attt = pp->GetAttText();
5655 attt.SetTextSize(-1);
5656 pp->OnPad(this);
5657 pp->SetAttText(attt);
5658 // create or re-create off-screen pixmap
5659 if (fPixmapID) {
5660 int w = TMath::Abs(XtoPixel(fX2) - XtoPixel(fX1));
5661 int h = TMath::Abs(YtoPixel(fY2) - YtoPixel(fY1));
5662 //protection in case of wrong pad parameters.
5663 //without this protection, the OpenPixmap or ResizePixmap crashes with
5664 //the message "Error in <RootX11ErrorHandler>: BadValue (integer parameter out of range for operation)"
5665 //resulting in a frozen xterm
5668 Warning("ResizePad", "Inf/NaN propagated to the pad. Check drawn objects.");
5669 if (w <= 0 || w > 10000) {
5670 Warning("ResizePad", "%s width changed from %d to %d\n",GetName(),w,10);
5671 w = 10;
5672 }
5673 if (h <= 0 || h > 10000) {
5674 Warning("ResizePad", "%s height changed from %d to %d\n",GetName(),h,10);
5675 h = 10;
5676 }
5677 if (fPixmapID == -1) // this case is handled via the ctor
5678 fPixmapID = pp->CreateDrawable(w, h);
5679 else if (pp->ResizeDrawable(fPixmapID, w, h)) {
5680 Resized();
5681 Modified(kTRUE);
5682 }
5683 }
5684 }
5685 }
5686 if (fView) {
5687 if (gPad == this) {
5688 fView->ResizePad();
5689 } else {
5690 TContext ctxt(this, kTRUE);
5691 fView->ResizePad();
5692 }
5693 }
5694}
5695
5696////////////////////////////////////////////////////////////////////////////////
5697/// Save the pad content in a file.
5698///
5699/// The file's format used to save the pad is determined by the `filename` extension:
5700///
5701/// - if `filename` is empty, the file produced is `padname.ps`
5702/// - if `filename` starts with a dot, the padname is added in front
5703/// - if `filename` ends with `.ps`, a Postscript file is produced
5704/// - if `filename` ends with `.eps`, an Encapsulated Postscript file is produced
5705/// - if `filename` ends with `.pdf`, a PDF file is produced NOTE: TMathText will be converted to TLatex; q.e.d., symbols only available in TMathText will not render properly.
5706/// - if `filename` ends with `.svg`, a SVG file is produced
5707/// - if `filename` ends with `.tex`, a TeX file is produced
5708/// - if `filename` ends with `.gif`, a GIF file is produced
5709/// - if `filename` ends with `.gif+NN`, an animated GIF file is produced See comments in TASImage::WriteImage for meaning of NN and other .gif sufix variants
5710/// - if `filename` ends with `.xpm`, a XPM file is produced
5711/// - if `filename` ends with `.png`, a PNG file is produced
5712/// - if `filename` ends with `.bmp`, a BMP file is produced
5713/// - if `filename` ends with `.jpg` or `.jpeg` a JPEG file is produced NOTE: JPEG's lossy compression will make all sharp edges fuzzy.
5714/// - if `filename` ends with `.tiff`, a TIFF file is produced
5715/// - if `filename` ends with `.C`, `.cxx`,`.cpp` or `.cc`, a C++ macro file is produced
5716/// - if `filename` ends with `.root`, a Root file is produced
5717/// - if `filename` ends with `.xml`, a XML file is produced
5718/// - if `filename` ends with `.json`, a JSON file is produced
5719///
5720/// \remarks
5721/// - The parameter `option` is not used.
5722/// - This method calls [TPad::Print(const char *filename, Option_t *option)](\ref TPadPrint)
5723/// the value of `option` is determined by the `filename` extension.
5724/// - Postscript and PDF formats allow to have [several pictures in one file](\ref TPadPrintPS).
5725
5726void TPad::SaveAs(const char *filename, Option_t * /*option*/) const
5727{
5728 TString psname;
5729 Int_t lenfil = filename ? strlen(filename) : 0;
5730
5731 if (!lenfil) { psname = GetName(); psname.Append(".ps"); }
5732 else psname = filename;
5733
5734 // lines below protected against case like c1->SaveAs( "../ps/cs.ps" );
5735 if (psname.BeginsWith('.') && (psname.Contains('/') == 0)) {
5736 psname = GetName();
5737 psname.Append(filename);
5738 psname.Prepend("/");
5739 psname.Prepend(gEnv->GetValue("Canvas.PrintDirectory","."));
5740 }
5741
5742 if (psname.EndsWith(".gif"))
5743 ((TPad*)this)->Print(psname,"gif");
5744 else if (psname.Contains(".gif+"))
5745 ((TPad*)this)->Print(psname,"gif+");
5746 else if (psname.EndsWith(".C") || psname.EndsWith(".cxx") || psname.EndsWith(".cpp") || psname.EndsWith(".cc"))
5747 ((TPad*)this)->Print(psname,"cxx");
5748 else if (psname.EndsWith(".root"))
5749 ((TPad*)this)->Print(psname,"root");
5750 else if (psname.EndsWith(".xml"))
5751 ((TPad*)this)->Print(psname,"xml");
5752 else if (psname.EndsWith(".json"))
5753 ((TPad*)this)->Print(psname,"json");
5754 else if (psname.EndsWith(".html"))
5755 ((TPad*)this)->Print(psname,"html");
5756 else if (psname.EndsWith(".eps"))
5757 ((TPad*)this)->Print(psname,"eps");
5758 else if (psname.EndsWith(".pdf") || psname.EndsWith(".pdf[") || psname.EndsWith(".pdf]") || psname.EndsWith(".pdf("))
5759 ((TPad*)this)->Print(psname,"pdf");
5760 else if (psname.EndsWith(".svg"))
5761 ((TPad*)this)->Print(psname,"svg");
5762 else if (psname.EndsWith(".tex"))
5763 ((TPad*)this)->Print(psname,"tex");
5764 else if (psname.EndsWith(".xpm"))
5765 ((TPad*)this)->Print(psname,"xpm");
5766 else if (psname.EndsWith(".png"))
5767 ((TPad*)this)->Print(psname,"png");
5768 else if (psname.EndsWith(".jpg") || psname.EndsWith(".jpeg"))
5769 ((TPad*)this)->Print(psname,"jpg");
5770 else if (psname.EndsWith(".bmp"))
5771 ((TPad*)this)->Print(psname,"bmp");
5772 else if (psname.EndsWith(".tiff"))
5773 ((TPad*)this)->Print(psname,"tiff");
5774 else
5775 ((TPad*)this)->Print(psname,"ps");
5776}
5777
5778////////////////////////////////////////////////////////////////////////////////
5779/// Save primitives in this pad on the C++ source file out.
5780
5781void TPad::SavePrimitive(std::ostream &out, Option_t * option /*= ""*/)
5782{
5783 TContext ctxt(this, kFALSE); // not interactive
5784
5785 TString padName = GetName();
5786
5787 // check for space in the pad name
5788 auto p = padName.Index(" ");
5789 if (p != kNPOS)
5790 padName.Resize(p);
5791
5792 TString opt = option;
5793 if (!opt.Contains("toplevel")) {
5794 static Int_t pcounter = 0;
5795 padName += TString::Format("__%d", pcounter++);
5796 padName = gInterpreter->MapCppName(padName);
5797 }
5798
5799 const char *pname = padName.Data();
5800 const char *cname = padName.Data();
5801
5802 if (padName.Length() == 0) {
5803 pname = "unnamed";
5804 if (this == gPad->GetCanvas())
5805 cname = "c1";
5806 else
5807 cname = "pad";
5808 }
5809
5810 // Write pad parameters
5811 if (this != gPad->GetCanvas()) {
5812 out << " \n";
5813 out << "// ------------>Primitives in pad: " << GetName() << "\n";
5814 out << " TPad *" << cname << " = new TPad(\"" << GetName() << "\", \""
5815 << TString(GetTitle()).ReplaceSpecialCppChars() << "\", " << fXlowNDC << ", " << fYlowNDC << ", "
5816 << fXlowNDC + fWNDC << ", " << fYlowNDC + fHNDC << ");\n";
5817 out << " " << cname << "->Draw();\n";
5818 out << " " << cname << "->cd();\n";
5819 }
5820 out << " " << cname << "->Range(" << fX1 << "," << fY1 << "," << fX2 << "," << fY2 << ");\n";
5821 TView *view = GetView();
5822 if (view) {
5823 Double_t rmin[3], rmax[3];
5824 view->GetRange(rmin, rmax);
5825 out << " TView::CreateView(1)->SetRange(" << rmin[0] << ", " << rmin[1] << ", " << rmin[2] << ", " << rmax[0]
5826 << ", " << rmax[1] << ", " << rmax[2] << ");\n";
5827 }
5828
5829 SaveFillAttributes(out, cname, -1, -1);
5830
5831 if (GetBorderMode() != 1)
5832 out << " " << cname << "->SetBorderMode(" << GetBorderMode() << ");\n";
5833 if (GetBorderSize() != 4)
5834 out << " " << cname << "->SetBorderSize(" << GetBorderSize() << ");\n";
5835 if (GetLogx())
5836 out << " " << cname << "->SetLogx();\n";
5837 if (GetLogy())
5838 out << " " << cname << "->SetLogy();\n";
5839 if (GetLogz())
5840 out << " " << cname << "->SetLogz();\n";
5841 if (GetGridx())
5842 out << " " << cname << "->SetGridx();\n";
5843 if (GetGridy())
5844 out << " " << cname << "->SetGridy();\n";
5845 if (GetTickx())
5846 out << " " << cname << "->SetTickx(" << GetTickx() << ");\n";
5847 if (GetTicky())
5848 out << " " << cname << "->SetTicky(" << GetTicky() << ");\n";
5849 if (GetTheta() != 30)
5850 out << " " << cname << "->SetTheta(" << GetTheta() << ");\n";
5851 if (GetPhi() != 30)
5852 out << " " << cname << "->SetPhi(" << GetPhi() << ");\n";
5853 if (TMath::Abs(fLeftMargin - 0.1) > 0.01)
5854 out << " " << cname << "->SetLeftMargin(" << GetLeftMargin() << ");\n";
5855 if (TMath::Abs(fRightMargin - 0.1) > 0.01)
5856 out << " " << cname << "->SetRightMargin(" << GetRightMargin() << ");\n";
5857 if (TMath::Abs(fTopMargin - 0.1) > 0.01)
5858 out << " " << cname << "->SetTopMargin(" << GetTopMargin() << ");\n";
5859 if (TMath::Abs(fBottomMargin - 0.1) > 0.01)
5860 out << " " << cname << "->SetBottomMargin(" << GetBottomMargin() << ");\n";
5861
5863 out << " " << cname << "->SetFrameFillColor(" << TColor::SavePrimitiveColor(GetFrameFillColor()) << ");\n";
5864 if (GetFrameFillStyle() != 1001)
5865 out << " " << cname << "->SetFrameFillStyle(" << GetFrameFillStyle() << ");\n";
5866 if (GetFrameLineStyle() != 1)
5867 out << " " << cname << "->SetFrameLineStyle(" << GetFrameLineStyle() << ");\n";
5868 if (GetFrameLineColor() != 1)
5869 out << " " << cname << "->SetFrameLineColor(" << TColor::SavePrimitiveColor(GetFrameLineColor()) << ");\n";
5870 if (GetFrameLineWidth() != 1)
5871 out << " " << cname << "->SetFrameLineWidth(" << GetFrameLineWidth() << ");\n";
5872 if (GetFrameBorderMode() != 0)
5873 out << " " << cname << "->SetFrameBorderMode(" << GetFrameBorderMode() << ");\n";
5874 if (GetFrameBorderSize() != 1)
5875 out << " " << cname << "->SetFrameBorderSize(" << GetFrameBorderSize() << ");\n";
5876
5877 TFrame *frame = fFrame;
5878 if (!frame)
5879 frame = (TFrame *)GetPrimitive("TFrame");
5880 if (frame) {
5881 if (frame->GetFillColor() != GetFillColor())
5882 out << " " << cname << "->SetFrameFillColor(" << TColor::SavePrimitiveColor(frame->GetFillColor()) << ");\n";
5883 if (frame->GetFillStyle() != 1001)
5884 out << " " << cname << "->SetFrameFillStyle(" << frame->GetFillStyle() << ");\n";
5885 if (frame->GetLineStyle() != 1)
5886 out << " " << cname << "->SetFrameLineStyle(" << frame->GetLineStyle() << ");\n";
5887 if (frame->GetLineColor() != 1)
5888 out << " " << cname << "->SetFrameLineColor(" << TColor::SavePrimitiveColor(frame->GetLineColor()) << ");\n";
5889 if (frame->GetLineWidth() != 1)
5890 out << " " << cname << "->SetFrameLineWidth(" << frame->GetLineWidth() << ");\n";
5891 if (frame->GetBorderMode() != 0)
5892 out << " " << cname << "->SetFrameBorderMode(" << frame->GetBorderMode() << ");\n";
5893 if (frame->GetBorderSize() != 1)
5894 out << " " << cname << "->SetFrameBorderSize(" << frame->GetBorderSize() << ");\n";
5895 }
5896
5897 TIter next(GetListOfPrimitives());
5898
5899 while (auto obj = next()) {
5900 obj->SavePrimitive(out, (Option_t *)next.GetOption());
5901 if (obj->InheritsFrom(TPad::Class())) {
5902 if (opt.Contains("toplevel"))
5903 out << " " << pname << "->cd();\n";
5904 else
5905 out << " " << cname << "->cd();\n";
5906 }
5907 }
5908 out << " " << cname << "->Modified();\n";
5909}
5910
5911////////////////////////////////////////////////////////////////////////////////
5912/// Fix pad aspect ratio to current value if fixed is true.
5913
5915{
5916 if (fixed) {
5917 if (!fFixedAspectRatio) {
5918 if (fHNDC != 0.)
5920 else {
5921 Error("SetAspectRatio", "cannot fix aspect ratio, height of pad is 0");
5922 return;
5923 }
5925 }
5926 } else {
5928 fAspectRatio = 0;
5929 }
5930}
5931
5932////////////////////////////////////////////////////////////////////////////////
5933/// Set pad editable yes/no
5934/// If a pad is not editable:
5935/// - one cannot modify the pad and its objects via the mouse.
5936/// - one cannot add new objects to the pad
5937
5939{
5940 fEditable = mode;
5941
5942 TObject *obj;
5943 if (!fPrimitives) fPrimitives = new TList;
5944 TIter next(GetListOfPrimitives());
5945 while ((obj = next())) {
5946 if (obj->InheritsFrom(TPad::Class())) {
5947 TPad *pad = (TPad*)obj;
5948 pad->SetEditable(mode);
5949 }
5950 }
5951}
5952
5953////////////////////////////////////////////////////////////////////////////////
5954/// Override TAttFill::FillStyle for TPad because we want to handle style=0
5955/// as style 4000.
5956
5958{
5959 if (fstyle == 0) fstyle = 4000;
5960 TAttFill::SetFillStyle(fstyle);
5961}
5962
5963////////////////////////////////////////////////////////////////////////////////
5964/// Set Lin/Log scale for X
5965/// - value = 0 X scale will be linear
5966/// - value = 1 X scale will be logarithmic (base 10)
5967/// - value > 1 reserved for possible support of base e or other
5968
5970{
5971 fLogx = value;
5972 delete fView; fView = nullptr;
5973 Modified();
5975}
5976
5977////////////////////////////////////////////////////////////////////////////////
5978/// Set Lin/Log scale for Y
5979/// - value = 0 Y scale will be linear
5980/// - value = 1 Y scale will be logarithmic (base 10)
5981/// - value > 1 reserved for possible support of base e or other
5982
5984{
5985 fLogy = value;
5986 delete fView; fView = nullptr;
5987 Modified();
5989}
5990
5991////////////////////////////////////////////////////////////////////////////////
5992/// Set Lin/Log scale for Z
5993
5995{
5996 fLogz = value;
5997 delete fView; fView = nullptr;
5998 Modified();
6000}
6001
6002////////////////////////////////////////////////////////////////////////////////
6003/// Set canvas range for pad and resize the pad. If the aspect ratio
6004/// was fixed before the call it will be un-fixed.
6005
6007{
6008 // Reorder points to make sure xlow,ylow is bottom left point and
6009 // xup,yup is top right point.
6010 if (xup < xlow) {
6011 Double_t x = xlow;
6012 xlow = xup;
6013 xup = x;
6014 }
6015 if (yup < ylow) {
6016 Double_t y = ylow;
6017 ylow = yup;
6018 yup = y;
6019 }
6020
6021 // Check if the new pad position is valid.
6022 if ((xlow < 0) || (xlow > 1) || (ylow < 0) || (ylow > 1)) {
6023 Error("TPad", "illegal bottom left position: x=%f, y=%f", xlow, ylow);
6024 return;
6025 }
6026 if ((xup < 0) || (xup > 1) || (yup < 0) || (yup > 1)) {
6027 Error("TPad", "illegal top right position: x=%f, y=%f", xup, yup);
6028 return;
6029 }
6030 if (xup-xlow <= 0) {
6031 Error("TPad", "illegal width: %f", xup-xlow);
6032 return;
6033 }
6034 if (yup-ylow <= 0) {
6035 Error("TPad", "illegal height: %f", yup-ylow);
6036 return;
6037 }
6038
6039 fXlowNDC = xlow;
6040 fYlowNDC = ylow;
6041 fXUpNDC = xup;
6042 fYUpNDC = yup;
6043 fWNDC = xup - xlow;
6044 fHNDC = yup - ylow;
6045
6047
6048 ResizePad();
6049}
6050
6051////////////////////////////////////////////////////////////////////////////////
6052/// Set all pad parameters.
6053
6054void TPad::SetPad(const char *name, const char *title,
6055 Double_t xlow, Double_t ylow, Double_t xup, Double_t yup,
6056 Color_t color, Short_t bordersize, Short_t bordermode)
6057{
6058 fName = name;
6059 fTitle = title;
6060 SetFillStyle(1001);
6065 if (color >= 0) SetFillColor(color);
6067 if (bordersize < 0) fBorderSize = gStyle->GetPadBorderSize();
6068 else fBorderSize = bordersize;
6069 if (bordermode < -1) fBorderMode = gStyle->GetPadBorderMode();
6070 else fBorderMode = bordermode;
6071
6072 SetPad(xlow, ylow, xup, yup);
6073}
6074
6075////////////////////////////////////////////////////////////////////////////////
6076/// Set the current TView. Delete previous view if view=0
6077
6079{
6080 if (!view) delete fView;
6081 fView = view;
6082}
6083
6084////////////////////////////////////////////////////////////////////////////////
6085/// Set postscript fill area attributes.
6086///
6087/// DEPRECATED!!! No longer used by ROOT, kept only for backward compatibility
6088
6090{
6091 if (auto pp = GetPainter())
6092 if (pp->GetPS())
6093 pp->SetAttFill({color, style});
6094}
6095
6096////////////////////////////////////////////////////////////////////////////////
6097/// Set postscript line attributes.
6098///
6099/// DEPRECATED!!! No longer used by ROOT, kept only for backward compatibility
6100
6102{
6103 if (auto pp = GetPainter())
6104 if (pp->GetPS())
6105 pp->SetAttLine({color, style, lwidth});
6106}
6107
6108////////////////////////////////////////////////////////////////////////////////
6109/// Set postscript marker attributes.
6110///
6111/// DEPRECATED!!! No longer used by ROOT, kept only for backward compatibility
6112
6114{
6115 if (auto pp = GetPainter())
6116 if (pp->GetPS())
6117 pp->SetAttMarker({color, style, msize});
6118}
6119
6120////////////////////////////////////////////////////////////////////////////////
6121/// Set postscript text attributes.
6122///
6123/// DEPRECATED!!! No longer used by ROOT, kept only for backward compatibility
6124
6126{
6127 if (auto pp = GetPainter())
6128 if (pp->GetPS()) {
6129 if (font % 10 > 2) {
6130 Float_t wh = (Float_t) XtoPixel(GetX2());
6131 Float_t hh = (Float_t) YtoPixel(GetY1());
6132 Float_t dy;
6133 if (wh < hh) {
6134 dy = AbsPixeltoX(Int_t(tsize)) - AbsPixeltoX(0);
6135 tsize = dy/(GetX2()-GetX1());
6136 } else {
6137 dy = AbsPixeltoY(0) - AbsPixeltoY(Int_t(tsize));
6138 tsize = dy/(GetY2()-GetY1());
6139 }
6140 }
6141 pp->OnPad(this);
6142 pp->SetAttText({align, angle, color, font, tsize});
6143 }
6144}
6145
6146////////////////////////////////////////////////////////////////////////////////
6147/// Draw Arrows to indicated equal distances of Objects with given BBoxes.
6148/// Used by ShowGuidelines
6149
6151{
6152 Int_t lineColor = TColor::GetColor(239, 202, 0);
6153 Int_t x1,x2,y1,y2;
6154 x1 = x2 = y1 = y2 = 0;
6155 if (mode == 'x') {
6156 if (aBBox.fX<bBBox.fX) {
6157 x1 = aBBox.fX+aBBox.fWidth;
6158 x2 = bBBox.fX;
6159 }
6160 else {
6161 x1 = bBBox.fX+bBBox.fWidth;
6162 x2 = aBBox.fX;
6163 }
6164
6165 if ((aBBox.fY > bBBox.fY) && (aBBox.fY + aBBox.fHeight < bBBox.fY + bBBox.fHeight))
6166 y1 = y2 = aBBox.fY + TMath::Nint(0.5*(Double_t)(aBBox.fHeight))+1;
6167 else if ((bBBox.fY > aBBox.fY) && (bBBox.fY + bBBox.fHeight < aBBox.fY + aBBox.fHeight))
6168 y1 = y2 = bBBox.fY + TMath::Nint(0.5*(Double_t)(bBBox.fHeight))+1;
6169 else if (aBBox.fY>bBBox.fY) y1 = y2 = aBBox.fY-TMath::Nint(0.5*(Double_t)(aBBox.fY-(bBBox.fY+bBBox.fHeight)));
6170 else y1 = y2 = bBBox.fY-TMath::Nint(0.5*(Double_t)(bBBox.fY-(aBBox.fY+aBBox.fHeight)));
6171 }
6172 else if (mode == 'y') {
6173 if (aBBox.fY<bBBox.fY) {
6174 y1 = aBBox.fY+aBBox.fHeight;
6175 y2 = bBBox.fY;
6176 }
6177 else {
6178 y1 = bBBox.fY+bBBox.fHeight;
6179 y2 = aBBox.fY;
6180 }
6181 if ((aBBox.fX > bBBox.fX) && (aBBox.fX + aBBox.fWidth < bBBox.fX + bBBox.fWidth))
6182 x1 = x2 = aBBox.fX + TMath::Nint(0.5*(Double_t)(aBBox.fWidth))+1;
6183 else if ((bBBox.fX > aBBox.fX) && (bBBox.fX + bBBox.fWidth < aBBox.fX + aBBox.fWidth))
6184 x1 = x2 = bBBox.fX + TMath::Nint(0.5*(Double_t)(bBBox.fWidth))+1;
6185 else if (aBBox.fX>bBBox.fX) x1 = x2 = aBBox.fX+TMath::Nint(0.5*(Double_t)(bBBox.fX+bBBox.fWidth-aBBox.fX));
6186 else x1 = x2 = bBBox.fX+TMath::Nint(0.5*(Double_t)(aBBox.fX+aBBox.fWidth-bBBox.fX));
6187 }
6188
6189 TArrow *A = new TArrow(gPad->PixeltoX(x1), gPad->PixeltoY(y1-gPad->VtoPixel(0)), gPad->PixeltoX(x2), gPad->PixeltoY(y2-gPad->VtoPixel(0)), 0.01, "<|>");
6190 A->SetBit(kCanDelete);
6191 A->SetFillColor(lineColor);
6192 A->SetLineWidth(1);
6193 A->SetLineColor(lineColor);
6194 A->Draw();
6195
6196 return;
6197}
6198
6199////////////////////////////////////////////////////////////////////////////////
6200/// struct used by ShowGuidelines to store the distance Field between objects
6201/// in the canvas.
6202
6203struct dField {
6207 char fdir;
6208
6209
6211 : fa(nullptr), fb(nullptr), fdist(0), fdir(' ')
6212 {}
6213
6214 dField(TAttBBox2D *a, TAttBBox2D *b, Int_t dist, char direction)
6215 : fa(a), fb(b), fdist(dist), fdir(direction)
6216 {}
6217};
6218
6219////////////////////////////////////////////////////////////////////////////////
6220/// Shows lines to indicate if a TAttBBox2D object is aligned to
6221/// the center or to another object, shows distance arrows if two
6222/// objects on screen have the same distance to another object
6223/// Call from primitive in Execute Event, in ButtonMotion after
6224/// the new coordinates have been set, to 'stick'
6225/// once when button is up to delete lines
6226///
6227/// modes: t (Top), b (bottom), l (left), r (right), i (inside)
6228/// in resize modes (t,b,l,r) only size arrows are sticky
6229///
6230/// in mode, the function gets the point on the element that is clicked to
6231/// move (i) or resize (all others). The expected values are:
6232/// \image html gpad_pad5.png
6233
6234void TPad::ShowGuidelines(TObject *object, const Int_t event, const char mode, const bool cling )
6235{
6236 // When the object is moved with arrow or when the ShowGuideLines flag
6237 // is off we do show guide lines.
6238 if ((event == kArrowKeyRelease) || (event == kArrowKeyPress) ||
6239 !gEnv->GetValue("Canvas.ShowGuideLines", 0)) return;
6240
6241 std::vector<dField> curDist;
6242 std::vector<dField> otherDist;
6243 Int_t pMX, pMY;
6244 Double_t MX, MY;
6245 Int_t threshold;
6246 TList *prims;
6247 UInt_t n;
6248 Rectangle_t aBBox, bBBox;
6249 aBBox = bBBox = Rectangle_t();
6250 TLine *L;
6251 TArrow *A;
6252 Int_t dSizeArrow = 12; // distance of arrows indicating same size from BBox in px
6253 Bool_t movedX, movedY; // make sure the current object is moved just once
6254 movedX = movedY = false;
6255 Bool_t resize = false; // indicates resize mode
6256 Bool_t log = gPad->GetLogx() || gPad->GetLogy();
6257 if (mode != 'i') resize = true;
6258
6259 TPad *is_pad = dynamic_cast<TPad *>( object );
6260
6261 TContext ctxt(kTRUE);
6262
6263 if (is_pad && is_pad->GetMother())
6264 is_pad->GetMother()->cd();
6265
6266 static TPad *tmpGuideLinePad = nullptr;
6267
6268 //delete all existing Guidelines and create new invisible pad
6269 if (tmpGuideLinePad) {
6270 ctxt.PadDeleted(tmpGuideLinePad);
6271 auto guidePadClicked = (object == tmpGuideLinePad); // in case of funny button click combination.
6272 tmpGuideLinePad->Delete();
6273 tmpGuideLinePad = nullptr;
6274 if (guidePadClicked) return;
6275 }
6276
6277 // Get Primitives
6278 prims = gPad->GetListOfPrimitives();
6279 n = TMath::Min(15,prims->GetSize());
6280 Int_t lineColor = TColor::GetColor(239, 202, 0);
6281
6282 TAttBBox2D *cur = dynamic_cast<TAttBBox2D *>( object );
6283 if (cur) {
6284 //create invisible TPad above gPad
6285 if (!tmpGuideLinePad){
6286 tmpGuideLinePad = new TPad("tmpGuideLinePad", "tmpGuideLinePad", 0, 0, 1, 1);
6287 Double_t x1, y1, x2, y2;
6288 gPad->GetRange(x1, y1, x2, y2);
6289 tmpGuideLinePad->Range(x1, y1, x2, y2);
6290 tmpGuideLinePad->SetFillStyle(0);
6291 tmpGuideLinePad->SetFillColor(0);
6292 tmpGuideLinePad->Draw();
6293 tmpGuideLinePad->cd();
6294 gPad->GetRange(x1, y1, x2, y2);
6295 }
6296 if (cling && !log) threshold = 7;
6297 else threshold = 1;
6298
6299 Rectangle_t BBox = cur->GetBBox();
6300 TPoint center = cur->GetBBoxCenter();
6301
6302 otherDist.clear();
6303 curDist.clear();
6304
6305 switch (event) {
6306
6307 case kButton1Down:
6308 case kButton1Motion:
6309 MX = gPad->GetX1() + 0.5 * (gPad->GetX2()-gPad->GetX1());
6310 MY = gPad->GetY1() + 0.5 * (gPad->GetY2()-gPad->GetY1());
6311 pMX = gPad->XtoPixel(MX);
6312 pMY = gPad->YtoPixel(MY);
6313 // Middlelines
6314 if (TMath::Abs(pMX-center.GetX())<threshold) {
6315 if (cling && (!resize)) {
6316 cur->SetBBoxCenterX(pMX);
6317 center = cur->GetBBoxCenter();
6318 BBox = cur->GetBBox();
6319 center = cur->GetBBoxCenter();
6320 }
6321 L = new TLine(MX, gPad->GetY1(), MX, gPad->GetY2());
6322 L->SetBit(kCanDelete);
6323 L->SetLineColor(lineColor);
6324 L->Draw();
6325 }
6326 if (TMath::Abs(pMY-center.GetY())<threshold) {
6327 if (cling && (!resize)) {
6328 cur->SetBBoxCenterY(pMY);
6329 center = cur->GetBBoxCenter();
6330 BBox = cur->GetBBox();
6331 center = cur->GetBBoxCenter();
6332 }
6333 L = new TLine(gPad->GetX1(), MY, gPad->GetX2(), MY);
6334 L->SetBit(kCanDelete);
6335 L->SetLineColor(lineColor);
6336 L->Draw();
6337 }
6338 // Alignment to other objects
6339 for (UInt_t i = 0; i<n; i++) {
6340 TAttBBox2D *other = dynamic_cast<TAttBBox2D *>( prims->At(i) );
6341 if (other) {
6342 if (other != cur) {
6343 TPoint centerOther = other->GetBBoxCenter();
6344 if (TMath::Abs(center.GetX()-centerOther.GetX())<threshold) {
6345 if (cling && (!resize)) {
6346 cur->SetBBoxCenterX(centerOther.GetX());
6347 BBox = cur->GetBBox();
6348 center = cur->GetBBoxCenter();
6349 }
6350 L = new TLine(gPad->PixeltoX(centerOther.GetX()), gPad->PixeltoY(center.GetY()-gPad->VtoPixel(0)),
6351 gPad->PixeltoX(centerOther.GetX()), gPad->PixeltoY(centerOther.GetY()-gPad->VtoPixel(0)));
6352 L->SetLineColor(lineColor);
6353 L->Draw();
6354 L->SetBit(kCanDelete);
6355 }
6356 if (TMath::Abs(center.GetY()-centerOther.GetY())<threshold) {
6357 if (cling && (!resize)) {
6358 cur->SetBBoxCenterY(centerOther.GetY());
6359 BBox = cur->GetBBox();
6360 center = cur->GetBBoxCenter();
6361 }
6362 L = new TLine(gPad->PixeltoX(center.GetX()), gPad->PixeltoY(centerOther.GetY()-gPad->VtoPixel(0)),
6363 gPad->PixeltoX(centerOther.GetX()), gPad->PixeltoY(centerOther.GetY()-gPad->VtoPixel(0)));
6364 L->SetBit(kCanDelete);
6365 L->SetLineColor(lineColor);
6366 L->Draw();
6367 }
6368 }
6369 }
6370 }
6371 // Get Distances between objects
6372 for (UInt_t i = 0; i<n; i++) {
6373 TAttBBox2D *a = dynamic_cast<TAttBBox2D *>( prims->At(i) );
6374 if (a) {
6375 aBBox = a->GetBBox();
6376 for (UInt_t j = i+1; j<n; j++) {
6377 TAttBBox2D *b = dynamic_cast<TAttBBox2D *>( prims->At(j) );
6378 if (b) {
6379 bBBox = b->GetBBox();
6380
6381 //only when bounding boxes overlap in x or y direction
6382 if (((aBBox.fX<bBBox.fX) && (bBBox.fX-aBBox.fX<=aBBox.fWidth))||((aBBox.fX>bBBox.fX) && (aBBox.fX-bBBox.fX<=bBBox.fWidth))){ //BBoxes overlap in x direction
6383 if ((aBBox.fY+aBBox.fHeight<bBBox.fY)||(bBBox.fY+bBBox.fHeight<aBBox.fY)) {//No overlap in Y-direction required
6384 dField abDist = dField();
6385 if (aBBox.fY>bBBox.fY) abDist = dField(a, b, TMath::Abs(aBBox.fY-(bBBox.fY+bBBox.fHeight)), 'y');
6386 else abDist = dField(a, b, TMath::Abs(bBBox.fY-(aBBox.fY+aBBox.fHeight)), 'y');
6387 if ((b != cur)&&(a != cur)) otherDist.push_back(abDist);
6388 else curDist.push_back(abDist);
6389 }
6390 } else if (((aBBox.fY<bBBox.fY) && (bBBox.fY-aBBox.fY<=aBBox.fHeight))||((aBBox.fY>bBBox.fY) && (aBBox.fY-bBBox.fY<=bBBox.fHeight))) { //BBoxes overlap in y direction
6391 if ((aBBox.fX+aBBox.fWidth<bBBox.fX)||(bBBox.fX+bBBox.fWidth<aBBox.fX)) {//No overlap in x-direction required
6392 dField abDist = dField();
6393 if (aBBox.fX>bBBox.fX) abDist = dField(a, b, TMath::Abs(aBBox.fX-(bBBox.fX+bBBox.fWidth)), 'x');
6394 else abDist = dField(a, b, TMath::Abs(bBBox.fX-(aBBox.fX+aBBox.fWidth)), 'x');
6395 if ((b != cur)&&(a != cur)) otherDist.push_back(abDist);
6396 else curDist.push_back(abDist);
6397 }
6398 }
6399 }
6400 }
6401 }
6402 }
6403 // Show equal distances
6404 for (UInt_t i = 0; i<curDist.size(); i++) {
6405 for (UInt_t j = 0; j<otherDist.size(); j++) {
6406 if ((curDist[i].fdir == otherDist[j].fdir) && (otherDist[j].fdir=='x') && (TMath::Abs(curDist[i].fdist-otherDist[j].fdist)<threshold)) {
6407 if (cling && (!movedX) && (!resize)) {
6408 if ((cur->GetBBoxCenter().fX < curDist[i].fb->GetBBoxCenter().fX)||(cur->GetBBoxCenter().fX < curDist[i].fa->GetBBoxCenter().fX))
6409 cur->SetBBoxCenterX(cur->GetBBoxCenter().fX - otherDist[j].fdist + curDist[i].fdist);
6410 else cur->SetBBoxCenterX(cur->GetBBoxCenter().fX + otherDist[j].fdist - curDist[i].fdist);
6411 movedX = true;
6412 }
6413 DrawDist(curDist[i].fa->GetBBox(), curDist[i].fb->GetBBox(), 'x');
6414 DrawDist(otherDist[j].fa->GetBBox(), otherDist[j].fb->GetBBox(), 'x');
6415 }
6416 if ((curDist[i].fdir == otherDist[j].fdir) && (otherDist[j].fdir=='y') && (TMath::Abs(curDist[i].fdist-otherDist[j].fdist)<threshold)) {
6417 if (cling && (!movedY) && (!resize)) {
6418 if ((cur->GetBBoxCenter().fY < curDist[i].fb->GetBBoxCenter().fY)||(cur->GetBBoxCenter().fY < curDist[i].fa->GetBBoxCenter().fY))
6419 cur->SetBBoxCenterY(cur->GetBBoxCenter().fY - otherDist[j].fdist + curDist[i].fdist);
6420 else cur->SetBBoxCenterY(cur->GetBBoxCenter().fY + otherDist[j].fdist - curDist[i].fdist);
6421 movedY = true;
6422 }
6423 DrawDist(curDist[i].fa->GetBBox(), curDist[i].fb->GetBBox(), 'y');
6424 DrawDist(otherDist[j].fa->GetBBox(), otherDist[j].fb->GetBBox(), 'y');
6425 }
6426 }
6427 for (UInt_t j = i; j<curDist.size(); j++) {
6428 if (i!=j) {
6429 if ((curDist[i].fdir == curDist[j].fdir) && (curDist[j].fdir=='x') && (TMath::Abs(curDist[i].fdist-curDist[j].fdist)<threshold)) {
6430 if (cling && (!movedX) && (!resize)) {
6431 if ((cur->GetBBoxCenter().fX < curDist[i].fb->GetBBoxCenter().fX)||(cur->GetBBoxCenter().fX < curDist[i].fa->GetBBoxCenter().fX))
6432 cur->SetBBoxCenterX(cur->GetBBoxCenter().fX - floor(0.5*(curDist[j].fdist - curDist[i].fdist)));
6433 else cur->SetBBoxCenterX(cur->GetBBoxCenter().fX + floor(0.5*(curDist[j].fdist - curDist[i].fdist)));
6434 }
6435 DrawDist(curDist[i].fa->GetBBox(), curDist[i].fb->GetBBox(), 'x');
6436 DrawDist(curDist[j].fa->GetBBox(), curDist[j].fb->GetBBox(), 'x');
6437 }
6438
6439 if ((curDist[i].fdir == curDist[j].fdir) && (curDist[j].fdir=='y') && (TMath::Abs(curDist[i].fdist-curDist[j].fdist)<threshold)) {
6440 if (cling && (!movedY) && (!resize)) {
6441 if ((cur->GetBBoxCenter().fY < curDist[i].fb->GetBBoxCenter().fY)||(cur->GetBBoxCenter().fY < curDist[i].fa->GetBBoxCenter().fY))
6442 cur->SetBBoxCenterY(cur->GetBBoxCenter().fY - floor(0.5*(curDist[j].fdist - curDist[i].fdist)));
6443 else cur->SetBBoxCenterY(cur->GetBBoxCenter().fY + floor(0.5*(curDist[j].fdist - curDist[i].fdist)));
6444 }
6445 DrawDist(curDist[i].fa->GetBBox(), curDist[i].fb->GetBBox(), 'y');
6446 DrawDist(curDist[j].fa->GetBBox(), curDist[j].fb->GetBBox(), 'y');
6447 }
6448 }
6449 }
6450 }
6451 if (resize) {
6452 // Show equal Sizes
6453 for (UInt_t i = 0; i<n; i++) {
6454 TAttBBox2D *a = dynamic_cast<TAttBBox2D *>( prims->At(i) );
6455 if (a && (cur != a)) {
6456 aBBox = a->GetBBox();
6457
6458 if ((TMath::Abs(aBBox.fWidth - BBox.fWidth)<threshold) && (mode != 't') && (mode != 'b')) {
6459 if (cling) {
6460 if (mode == 'l') cur->SetBBoxX1(BBox.fX + BBox.fWidth - aBBox.fWidth);
6461 if (mode == 'r') cur->SetBBoxX2(BBox.fX + aBBox.fWidth);
6462 if ((mode == '1')||(mode == '4')) cur->SetBBoxX1(BBox.fX + BBox.fWidth - aBBox.fWidth);
6463 if ((mode == '2')||(mode == '3')) cur->SetBBoxX2(BBox.fX + aBBox.fWidth);
6464 BBox = cur->GetBBox();
6465 }
6466
6467 A = new TArrow(gPad->PixeltoX(aBBox.fX), gPad->PixeltoY(aBBox.fY-dSizeArrow-gPad->VtoPixel(0)),
6468 gPad->PixeltoX(aBBox.fX+aBBox.fWidth), gPad->PixeltoY(aBBox.fY-dSizeArrow-gPad->VtoPixel(0)), 0.01, "<|>");
6469 A->SetBit(kCanDelete);
6470 A->SetLineColor(lineColor);
6471 A->SetFillColor(lineColor);
6472 A->Draw();
6473
6474 A = new TArrow(gPad->PixeltoX(BBox.fX), gPad->PixeltoY(BBox.fY-dSizeArrow-gPad->VtoPixel(0)),
6475 gPad->PixeltoX(BBox.fX+BBox.fWidth), gPad->PixeltoY(BBox.fY-dSizeArrow-gPad->VtoPixel(0)), 0.01, "<|>");
6476 A->SetBit(kCanDelete);
6477 A->SetLineColor(lineColor);
6478 A->SetFillColor(lineColor);
6479 A->Draw();
6480 }
6481 if ((TMath::Abs(aBBox.fHeight - BBox.fHeight)<threshold) && (mode != 'r') && (mode != 'l')) {
6482 if (cling) {
6483 if (mode == 't') cur->SetBBoxY1(BBox.fY + BBox.fHeight - aBBox.fHeight);
6484 if (mode == 'b') cur->SetBBoxY2(BBox.fY + aBBox.fHeight);
6485 if ((mode == '1')||(mode == '2')) cur->SetBBoxY1(BBox.fY + BBox.fHeight - aBBox.fHeight);
6486 if ((mode == '3')||(mode == '4')) cur->SetBBoxY2(BBox.fY + aBBox.fHeight);
6487 BBox = cur->GetBBox();
6488 }
6489 A = new TArrow(gPad->PixeltoX(aBBox.fX-dSizeArrow), gPad->PixeltoY(aBBox.fY-gPad->VtoPixel(0)),
6490 gPad->PixeltoX(aBBox.fX-dSizeArrow), gPad->PixeltoY(aBBox.fY+aBBox.fHeight-gPad->VtoPixel(0)), 0.01, "<|>");
6491 A->SetBit(kCanDelete);
6492 A->SetLineColor(lineColor);
6493 A->SetFillColor(lineColor);
6494 A->Draw();
6495
6496 A = new TArrow(gPad->PixeltoX(BBox.fX-dSizeArrow), gPad->PixeltoY(BBox.fY-gPad->VtoPixel(0)),
6497 gPad->PixeltoX(BBox.fX-dSizeArrow), gPad->PixeltoY(BBox.fY+BBox.fHeight-gPad->VtoPixel(0)), 0.01, "<|>");
6498 A->SetBit(kCanDelete);
6499 A->SetLineColor(lineColor);
6500 A->SetFillColor(lineColor);
6501 A->Draw();
6502 }
6503 }
6504 }
6505 }
6506
6507 break;
6508
6509 case kButton1Up:
6510 if (tmpGuideLinePad) {
6511 // All the arrows and lines in that pad are also deleted because
6512 // they all have the bit kCanDelete on.
6513 tmpGuideLinePad->Delete();
6514 tmpGuideLinePad = nullptr;
6515 }
6516 break;
6517 }
6518 }
6519
6521}
6522
6523////////////////////////////////////////////////////////////////////////////////
6524/// Return kTRUE if the crosshair has been activated (via SetCrosshair).
6525
6527{
6528 return (Bool_t)GetCrosshair();
6529}
6530
6531////////////////////////////////////////////////////////////////////////////////
6532/// Return the crosshair type (from the mother canvas)
6533/// crosshair type = 0 means no crosshair.
6534
6536{
6537 if (this == (TPad*)fCanvas)
6538 return fCrosshair;
6539 return fCanvas ? fCanvas->GetCrosshair() : 0;
6540}
6541
6542////////////////////////////////////////////////////////////////////////////////
6543/// Set crosshair active/inactive.
6544/// - If crhair != 0, a crosshair will be drawn in the pad and its sub-pads.
6545/// - If the canvas crhair = 1 , the crosshair spans the full canvas.
6546/// - If the canvas crhair > 1 , the crosshair spans only the pad.
6547
6549{
6550 if (!fCanvas) return;
6551 fCrosshair = crhair;
6552 fCrosshairPos = 0;
6553
6554 if (this != (TPad*)fCanvas) fCanvas->SetCrosshair(crhair);
6555}
6556
6557////////////////////////////////////////////////////////////////////////////////
6558/// static function to set the maximum Pick Distance fgMaxPickDistance
6559/// This parameter is used in TPad::Pick to select an object if
6560/// its DistancetoPrimitive returns a value < fgMaxPickDistance
6561/// The default value is 5 pixels. Setting a smaller value will make
6562/// picking more precise but also more difficult
6563
6565{
6566 fgMaxPickDistance = maxPick;
6567}
6568
6569////////////////////////////////////////////////////////////////////////////////
6570/// Set tool tip text associated with this pad. The delay is in
6571/// milliseconds (minimum 250). To remove tool tip call method with
6572/// text = 0.
6573
6574void TPad::SetToolTipText(const char *text, Long_t delayms)
6575{
6576 if (fTip) {
6578 fTip = nullptr;
6579 }
6580
6581 if (text && strlen(text))
6582 fTip = CreateToolTip((TBox*)nullptr, text, delayms);
6583}
6584
6585////////////////////////////////////////////////////////////////////////////////
6586/// Set pad vertical (default) or horizontal
6587
6589{
6590 if (vert) ResetBit(kHori);
6591 else SetBit(kHori);
6592}
6593
6594////////////////////////////////////////////////////////////////////////////////
6595/// Stream a class object.
6596
6598{
6599 UInt_t R__s, R__c;
6600 Int_t nch, nobjects;
6601 Float_t single;
6602 TObject *obj;
6603 if (b.IsReading()) {
6604 Version_t v = b.ReadVersion(&R__s, &R__c);
6605 if (v > 5) {
6606 if (!gPad)
6607 gPad = new TCanvas(GetName());
6608 fMother = (TPad*)gPad;
6610 TContext ctxt(this, kFALSE);
6611 fPixmapID = -1; // -1 means pixmap will be created by ResizePad()
6612 gReadLevel++;
6613 gROOT->SetReadingObject(kTRUE);
6614
6615 b.ReadClassBuffer(TPad::Class(), this, v, R__s, R__c);
6616
6617 //Set the kCanDelete bit in all objects in the pad such that when the pad
6618 //is deleted all objects in the pad are deleted too.
6619 //Also set must cleanup bit which normally set for all primitives add to pad,
6620 // but may be reset in IO like TH1::Streamer does
6621 TIter next(fPrimitives);
6622 while ((obj = next())) {
6623 obj->SetBit(kCanDelete);
6624 obj->SetBit(kMustCleanup);
6625 }
6626
6627 fModified = kTRUE;
6628 fPadPointer = nullptr;
6629 gReadLevel--;
6630 if (gReadLevel == 0 && IsA() == TPad::Class()) ResizePad();
6631 gROOT->SetReadingObject(kFALSE);
6632 return;
6633 }
6634
6635 //====process old versions before automatic schema evolution
6636 if (v < 5) { //old TPad in single precision
6637 if (v < 3) { //old TPad derived from TWbox
6638 b.ReadVersion(); // TVirtualPad::Streamer(b)
6639 b.ReadVersion(); // TWbox::Streamer(b)
6640 b.ReadVersion(); // TBox::Streamer(b)
6644 b >> single; fX1 = single;
6645 b >> single; fY1 = single;
6646 b >> single; fX2 = single;
6647 b >> single; fY2 = single;
6648 b >> fBorderSize;
6649 b >> fBorderMode;
6651 } else { //new TPad
6654 b >> single; fX1 = single;
6655 b >> single; fY1 = single;
6656 b >> single; fX2 = single;
6657 b >> single; fY2 = single;
6658 b >> fBorderSize;
6659 b >> fBorderMode;
6660 }
6661 b >> fLogx;
6662 b >> fLogy;
6663 b >> fLogz;
6664 b >> single; fXtoAbsPixelk = single;
6665 b >> single; fXtoPixelk = single;
6666 b >> single; fXtoPixel = single;
6667 b >> single; fYtoAbsPixelk = single;
6668 b >> single; fYtoPixelk = single;
6669 b >> single; fYtoPixel = single;
6670 b >> single; fUtoAbsPixelk = single;
6671 b >> single; fUtoPixelk = single;
6672 b >> single; fUtoPixel = single;
6673 b >> single; fVtoAbsPixelk = single;
6674 b >> single; fVtoPixelk = single;
6675 b >> single; fVtoPixel = single;
6676 b >> single; fAbsPixeltoXk = single;
6677 b >> single; fPixeltoXk = single;
6678 b >> single; fPixeltoX = single;
6679 b >> single; fAbsPixeltoYk = single;
6680 b >> single; fPixeltoYk = single;
6681 b >> single; fPixeltoY = single;
6682 b >> single; fXlowNDC = single;
6683 b >> single; fYlowNDC = single;
6684 b >> single; fWNDC = single;
6685 b >> single; fHNDC = single;
6686 b >> single; fAbsXlowNDC = single;
6687 b >> single; fAbsYlowNDC = single;
6688 b >> single; fAbsWNDC = single;
6689 b >> single; fAbsHNDC = single;
6690 b >> single; fUxmin = single;
6691 b >> single; fUymin = single;
6692 b >> single; fUxmax = single;
6693 b >> single; fUymax = single;
6694 } else {
6697 b >> fX1;
6698 b >> fY1;
6699 b >> fX2;
6700 b >> fY2;
6701 b >> fBorderSize;
6702 b >> fBorderMode;
6703 b >> fLogx;
6704 b >> fLogy;
6705 b >> fLogz;
6706 b >> fXtoAbsPixelk;
6707 b >> fXtoPixelk;
6708 b >> fXtoPixel;
6709 b >> fYtoAbsPixelk;
6710 b >> fYtoPixelk;
6711 b >> fYtoPixel;
6712 b >> fUtoAbsPixelk;
6713 b >> fUtoPixelk;
6714 b >> fUtoPixel;
6715 b >> fVtoAbsPixelk;
6716 b >> fVtoPixelk;
6717 b >> fVtoPixel;
6718 b >> fAbsPixeltoXk;
6719 b >> fPixeltoXk;
6720 b >> fPixeltoX;
6721 b >> fAbsPixeltoYk;
6722 b >> fPixeltoYk;
6723 b >> fPixeltoY;
6724 b >> fXlowNDC;
6725 b >> fYlowNDC;
6726 b >> fWNDC;
6727 b >> fHNDC;
6728 b >> fAbsXlowNDC;
6729 b >> fAbsYlowNDC;
6730 b >> fAbsWNDC;
6731 b >> fAbsHNDC;
6732 b >> fUxmin;
6733 b >> fUymin;
6734 b >> fUxmax;
6735 b >> fUymax;
6736 }
6737
6738 if (!gPad)
6739 gPad = new TCanvas(GetName());
6740 if (gReadLevel == 0)
6742 else
6743 fMother = (TPad *)gPad;
6744 if (!fMother)
6745 fMother = (TPad *)gPad;
6746 if (fMother)
6748 gPad = fMother;
6749 fPixmapID = -1; // -1 means pixmap will be created by ResizePad()
6750 //-------------------------
6751 // read objects and their drawing options
6752 // b >> fPrimitives;
6753 gReadLevel++;
6754 gROOT->SetReadingObject(kTRUE);
6755 fPrimitives = new TList;
6756 b >> nobjects;
6757 if (nobjects > 0) {
6758 TContext ctxt(this, kFALSE);
6759 char drawoption[64];
6760 for (Int_t i = 0; i < nobjects; i++) {
6761 b >> obj;
6762 b >> nch;
6763 b.ReadFastArray(drawoption,nch);
6764 fPrimitives->AddLast(obj, drawoption);
6765 gPad = this; // gPad may be modified in b >> obj if obj is a pad
6766 }
6767 }
6768 gReadLevel--;
6769 gROOT->SetReadingObject(kFALSE);
6770 //////////////////////////////////////////////////////////////////////////
6771
6772 if (v > 3) {
6773 b >> fExecs;
6774 }
6775 fName.Streamer(b);
6776 fTitle.Streamer(b);
6777 b >> fPadPaint;
6778 fModified = kTRUE;
6779 b >> fGridx;
6780 b >> fGridy;
6781 b >> fFrame;
6782 b >> fView;
6783 if (v < 5) {
6784 b >> single; fTheta = single;
6785 b >> single; fPhi = single;
6786 } else {
6787 b >> fTheta;
6788 b >> fPhi;
6789 }
6790 fPadPointer = nullptr;
6791 b >> fNumber;
6792 b >> fAbsCoord;
6793 if (v > 1) {
6794 b >> fTickx;
6795 b >> fTicky;
6796 } else {
6797 fTickx = fTicky = 0;
6798 }
6799 if (gReadLevel == 0 && IsA() == TPad::Class()) ResizePad();
6800 b.CheckByteCount(R__s, R__c, TPad::IsA());
6801 //====end of old versions
6802
6803 } else {
6804 b.WriteClassBuffer(TPad::Class(),this);
6805 }
6806}
6807
6808////////////////////////////////////////////////////////////////////////////////
6809/// Force a copy of current style for all objects in pad.
6810
6812{
6813 if (gStyle->IsReading()) {
6825 fLogx = gStyle->GetOptLogx();
6826 fLogy = gStyle->GetOptLogy();
6827 fLogz = gStyle->GetOptLogz();
6828 } else {
6843 }
6844
6845 if (!fPrimitives) fPrimitives = new TList;
6846 TIter next(GetListOfPrimitives());
6847 TObject *obj;
6848
6849 while ((obj = next())) {
6850 obj->UseCurrentStyle();
6851 }
6852
6853 TPaveText *title = (TPaveText*)FindObject("title");
6854 if (title) {
6855 if (gStyle->IsReading()) {
6857 title->SetTextFont(gStyle->GetTitleFont(""));
6860 if (!gStyle->GetOptTitle()) delete title;
6861 } else {
6863 gStyle->SetTitleFont(title->GetTextFont());
6866 }
6867 }
6869
6870 if (gStyle->IsReading()) Modified();
6871}
6872
6873////////////////////////////////////////////////////////////////////////////////
6874/// Loop and sleep until a primitive with name=pname is found in the pad.
6875///
6876/// If emode is given, the editor is automatically set to emode, ie
6877/// it is not required to have the editor control bar.
6878///
6879/// The possible values for emode are:
6880/// - emode = "" (default). User will select the mode via the editor bar
6881/// - emode = "Arc", "Line", "Arrow", "Button", "Diamond", "Ellipse",
6882/// - emode = "Pad","pave", "PaveLabel","PaveText", "PavesText",
6883/// - emode = "PolyLine", "CurlyLine", "CurlyArc", "Text", "Marker", "CutG"
6884///
6885/// If emode is specified and it is not valid, "PolyLine" is assumed. If emode
6886/// is not specified or ="", an attempt is to use pname[1...]
6887///
6888/// for example if pname="TArc", emode="Arc" will be assumed.
6889/// When this function is called within a macro, the macro execution
6890/// is suspended until a primitive corresponding to the arguments
6891/// is found in the pad.
6892///
6893/// If CRTL/C is typed in the pad, the function returns 0.
6894///
6895/// While this function is executing, one can use the mouse, interact
6896/// with the graphics pads, use the Inspector, Browser, TreeViewer, etc.
6897///
6898/// Examples:
6899/// ~~~ {.cpp}
6900/// c1.WaitPrimitive(); // Return the first created primitive
6901/// // whatever it is.
6902/// // If a double-click with the mouse is executed
6903/// // in the pad or any key pressed, the function
6904/// // returns 0.
6905/// c1.WaitPrimitive("ggg"); // Set the editor in mode "PolyLine/Graph"
6906/// // Create a polyline, then using the context
6907/// // menu item "SetName", change the name
6908/// // of the created TGraph to "ggg"
6909/// c1.WaitPrimitive("TArc");// Set the editor in mode "Arc". Returns
6910/// // as soon as a TArc object is created.
6911/// c1.WaitPrimitive("lat","Text"); // Set the editor in Text/Latex mode.
6912/// // Create a text object, then Set its name to "lat"
6913/// ~~~
6914/// The following macro waits for 10 primitives of any type to be created.
6915///
6916/// ~~~ {.cpp}
6917///{
6918/// TCanvas c1("c1");
6919/// TObject *obj;
6920/// for (Int_t i=0;i<10;i++) {
6921/// obj = gPad->WaitPrimitive();
6922/// if (!obj) break;
6923/// printf("Loop i=%d, found objIsA=%s, name=%s\n",
6924/// i,obj->ClassName(),obj->GetName());
6925/// }
6926///}
6927/// ~~~
6928///
6929/// If ROOT runs in batch mode a call to this method does nothing.
6930
6931TObject *TPad::WaitPrimitive(const char *pname, const char *emode)
6932{
6933 if (!gPad || IsWeb())
6934 return nullptr;
6935
6936 if (emode && strlen(emode)) gROOT->SetEditorMode(emode);
6937 if (gROOT->GetEditorMode() == 0 && pname && strlen(pname) > 2) gROOT->SetEditorMode(&pname[1]);
6938
6939 if (!fPrimitives) fPrimitives = new TList;
6941 TObject *oldlast = gPad->GetListOfPrimitives() ? gPad->GetListOfPrimitives()->Last() : nullptr;
6942 TObject *obj = nullptr;
6943 Bool_t testlast = kFALSE;
6944 Bool_t hasname = pname && (strlen(pname) > 0);
6945 if ((!pname || !pname[0]) && (!emode || !emode[0])) testlast = kTRUE;
6946 if (testlast) gROOT->SetEditorMode();
6947 while (!gSystem->ProcessEvents() && gROOT->GetSelectedPad() && gPad) {
6948 if (gROOT->GetEditorMode() == 0) {
6949 if (hasname) {
6950 obj = FindObject(pname);
6951 if (obj) return obj;
6952 }
6953 if (testlast) {
6954 if (!gPad->GetListOfPrimitives()) return nullptr;
6955 obj = gPad->GetListOfPrimitives()->Last();
6956 if (obj != oldlast) return obj;
6957 Int_t event = GetEvent();
6958 if (event == kButton1Double || event == kKeyPress) {
6959 //the following statement is required against other loop executions
6960 //before returning
6961 fCanvas->HandleInput((EEventType)-1,0,0);
6962 return nullptr;
6963 }
6964 }
6965 }
6966 gSystem->Sleep(10);
6967 }
6968
6969 return nullptr;
6970}
6971
6972////////////////////////////////////////////////////////////////////////////////
6973/// Create a tool tip and return its pointer.
6974
6975TObject *TPad::CreateToolTip(const TBox *box, const char *text, Long_t delayms)
6976{
6977 if (gPad->IsBatch()) return nullptr;
6978 return (TObject*)gROOT->ProcessLineFast(TString::Format("new TGToolTip((TBox*)0x%zx,\"%s\",%d)",
6979 (size_t)box,text,(Int_t)delayms).Data());
6980}
6981
6982////////////////////////////////////////////////////////////////////////////////
6983/// Delete tool tip object.
6984
6986{
6987 // delete tip;
6988 if (!tip) return;
6989 gROOT->ProcessLineFast(TString::Format("delete (TGToolTip*)0x%zx", (size_t)tip).Data());
6990}
6991
6992////////////////////////////////////////////////////////////////////////////////
6993/// Reset tool tip, i.e. within time specified in CreateToolTip the
6994/// tool tip will pop up.
6995
6997{
6998 if (!tip) return;
6999 // tip->Reset(this);
7000 gROOT->ProcessLineFast(TString::Format("((TGToolTip*)0x%zx)->Reset((TPad*)0x%zx)",
7001 (size_t)tip,(size_t)this).Data());
7002}
7003
7004////////////////////////////////////////////////////////////////////////////////
7005/// Hide tool tip.
7006
7008{
7009 if (!tip) return;
7010 // tip->Hide();
7011 gROOT->ProcessLineFast(TString::Format("((TGToolTip*)0x%zx)->Hide()", (size_t)tip).Data());
7012}
7013
7014////////////////////////////////////////////////////////////////////////////////
7015/// Deprecated: use TPad::GetViewer3D() instead
7016
7018{
7019 ::Info("TPad::x3d()", "This function is deprecated. Use %s->GetViewer3D(\"x3d\") instead",this->GetName());
7020
7021 // Default on GetViewer3D is pad - for x3d it was x3d...
7022 if (!type || !type[0]) {
7023 type = "x3d";
7024 }
7026}
7027
7028////////////////////////////////////////////////////////////////////////////////
7029/// Create/obtain handle to 3D viewer. Valid types are:
7030/// - 'pad' - pad drawing via TViewer3DPad
7031/// any others registered with plugin manager supporting TVirtualViewer3D
7032/// If an invalid/null type is requested then the current viewer is returned
7033/// (if any), otherwise a default 'pad' type is returned
7034
7036{
7037 Bool_t validType = kFALSE;
7038
7039 if ((!type || !*type || (strstr(type, "gl") && !strstr(type, "ogl"))) && (!fCanvas || !fCanvas->UseGL()))
7040 type = "pad";
7041
7042 if (type && *type) {
7043 if (gPluginMgr->FindHandler("TVirtualViewer3D", type))
7044 validType = kTRUE;
7045 }
7046
7047 // Invalid/null type requested?
7048 if (!validType) {
7049 // Return current viewer if there is one
7050 if (fViewer3D)
7051 return fViewer3D;
7052 // otherwise default to the pad
7053 else
7054 type = "pad";
7055 }
7056
7057 // Ensure we can create the new viewer before removing any existing one
7058 TVirtualViewer3D *newViewer = nullptr;
7059
7060 Bool_t createdExternal = kFALSE;
7061
7062 // External viewers need to be created via plugin manager via interface...
7063 if (!strstr(type,"pad")) {
7064 newViewer = TVirtualViewer3D::Viewer3D(this, type);
7065
7066 if (!newViewer) {
7067 Warning("GetViewer3D", "Cannot create 3D viewer of type: %s", type);
7068 // Return the existing viewer
7069 return fViewer3D;
7070 }
7071
7072 if (strstr(type, "gl") && !strstr(type, "ogl")) {
7075 Modified();
7076 } else {
7077 createdExternal = kTRUE;
7078 }
7079
7080 } else {
7081 newViewer = new TViewer3DPad(*this);
7082 }
7083
7084 // If we had a previous viewer destroy it now
7085 // In this case we do take responsibility for destroying viewer
7086 // c.f. ReleaseViewer3D
7087 delete fViewer3D;
7088
7089 // Set and return new viewer
7090 fViewer3D = newViewer;
7091
7092 // Ensure any new external viewer is painted
7093 // For internal TViewer3DPad type we assume this is being
7094 // create on demand due to a paint - so this is not required
7095 if (createdExternal) {
7096 Modified();
7097 Update();
7098 }
7099
7100 return fViewer3D;
7101}
7102
7103////////////////////////////////////////////////////////////////////////////////
7104/// Release current (external) viewer
7105
7107{
7108 fViewer3D = nullptr;
7109
7110 // We would like to ensure the pad is repainted
7111 // when external viewer is closed down. However
7112 // a modify/paint call here will repaint the pad
7113 // before the external viewer window actually closes.
7114 // So the pad would have to be redraw twice over.
7115 // Currently we just have to live with the pad staying blank
7116 // any click in pad will refresh.
7117}
7118
7119////////////////////////////////////////////////////////////////////////////////
7120/// Get GL device.
7121
7123{
7124 return fGLDevice;
7125}
7126
7127////////////////////////////////////////////////////////////////////////////////
7128/// Emit RecordPave() signal.
7129
7131{
7132 Emit("RecordPave(const TObject*)", (Longptr_t)obj);
7133}
7134
7135////////////////////////////////////////////////////////////////////////////////
7136/// Emit RecordLatex() signal.
7137
7139{
7140 Emit("RecordLatex(const TObject*)", (Longptr_t)obj);
7141}
7142
7143////////////////////////////////////////////////////////////////////////////////
7144/// Get pad painter from TCanvas.
7145
7147{
7148 if (!fCanvas) return nullptr;
7149 return fCanvas->GetCanvasPainter();
7150}
7151
7152////////////////////////////////////////////////////////////////////////////////
7153/// Return the bounding Box of the Pad
7154
7156{
7157 Rectangle_t BBox{0, 0, 0, 0};
7158 if (gPad) {
7159 BBox.fX = gPad->XtoPixel(fXlowNDC * (gPad->GetX2() - gPad->GetX1()) + gPad->GetX1());
7160 BBox.fY = gPad->YtoPixel((fYlowNDC + fHNDC) * (gPad->GetY2() - gPad->GetY1()) + gPad->GetY1());
7161 BBox.fWidth = gPad->XtoPixel((fXlowNDC + fWNDC) * (gPad->GetX2() - gPad->GetX1()) + gPad->GetX1()) -
7162 gPad->XtoPixel(fXlowNDC * (gPad->GetX2() - gPad->GetX1()) + gPad->GetX1());
7163 BBox.fHeight = gPad->YtoPixel((fYlowNDC) * (gPad->GetY2() - gPad->GetY1()) + gPad->GetY1()) -
7164 gPad->YtoPixel((fYlowNDC + fHNDC) * (gPad->GetY2() - gPad->GetY1()) + gPad->GetY1());
7165 }
7166 return BBox;
7167}
7168
7169////////////////////////////////////////////////////////////////////////////////
7170/// Return the center of the Pad as TPoint in pixels
7171
7173{
7174 TPoint p(0, 0);
7175 if (gPad) {
7176 Double_t x = ((fXlowNDC + 0.5 * fWNDC) * (gPad->GetX2() - gPad->GetX1())) + gPad->GetX1();
7177 Double_t y = ((fYlowNDC + 0.5 * fHNDC) * (gPad->GetY2() - gPad->GetY1())) + gPad->GetY1();
7178 p.SetX(gPad->XtoPixel(x));
7179 p.SetY(gPad->YtoPixel(y));
7180 }
7181 return p;
7182}
7183
7184////////////////////////////////////////////////////////////////////////////////
7185/// Set center of the Pad
7186
7188{
7189 if (!gPad)
7190 return;
7191 fXlowNDC = (gPad->PixeltoX(p.GetX()) - gPad->GetX1()) / (gPad->GetX2() - gPad->GetX1()) - 0.5 * fWNDC;
7192 fYlowNDC =
7193 (gPad->PixeltoY(p.GetY() - gPad->VtoPixel(0)) - gPad->GetY1()) / (gPad->GetY2() - gPad->GetY1()) - 0.5 * fHNDC;
7194 ResizePad();
7195}
7196
7197////////////////////////////////////////////////////////////////////////////////
7198/// Set X coordinate of the center of the Pad
7199
7201{
7202 if (!gPad)
7203 return;
7204 fXlowNDC = (gPad->PixeltoX(x) - gPad->GetX1())/(gPad->GetX2()-gPad->GetX1())-0.5*fWNDC;
7205 ResizePad();
7206}
7207
7208////////////////////////////////////////////////////////////////////////////////
7209/// Set Y coordinate of the center of the Pad
7210
7212{
7213 if (!gPad)
7214 return;
7215 fYlowNDC = (gPad->PixeltoY(y - gPad->VtoPixel(0)) - gPad->GetY1()) / (gPad->GetY2() - gPad->GetY1()) - 0.5 * fHNDC;
7216 ResizePad();
7217}
7218
7219////////////////////////////////////////////////////////////////////////////////
7220/// Set lefthandside of BoundingBox to a value
7221/// (resize in x direction on left)
7222
7224{
7225 if (!gPad)
7226 return;
7227 fXlowNDC = (gPad->PixeltoX(x) - gPad->GetX1()) / (gPad->GetX2() - gPad->GetX1());
7229 ResizePad();
7230}
7231
7232////////////////////////////////////////////////////////////////////////////////
7233/// Set right hand side of BoundingBox to a value
7234/// (resize in x direction on right)
7235
7237{
7238 if (!gPad)
7239 return;
7240 fWNDC = (gPad->PixeltoX(x) - gPad->GetX1()) / (gPad->GetX2() - gPad->GetX1()) - fXlowNDC;
7241 ResizePad();
7242}
7243
7244////////////////////////////////////////////////////////////////////////////////
7245/// Set top of BoundingBox to a value (resize in y direction on top)
7246
7248{
7249 if (!gPad)
7250 return;
7251 fHNDC = (gPad->PixeltoY(y - gPad->VtoPixel(0)) - gPad->GetY1()) / (gPad->GetY2() - gPad->GetY1()) - fYlowNDC;
7252 ResizePad();
7253}
7254
7255////////////////////////////////////////////////////////////////////////////////
7256/// Set bottom of BoundingBox to a value
7257/// (resize in y direction on bottom)
7258
7260{
7261 if (!gPad)
7262 return;
7263 fYlowNDC = (gPad->PixeltoY(y - gPad->VtoPixel(0)) - gPad->GetY1()) / (gPad->GetY2() - gPad->GetY1());
7265 ResizePad();
7266}
7267
7268////////////////////////////////////////////////////////////////////////////////
7269/// Mark pad modified
7270/// Will be repainted when TCanvas::Update() will be called next time
7271
7273{
7274 if (!fModified && flag) Emit("Modified()");
7275 fModified = flag;
7276}
7277
7278////////////////////////////////////////////////////////////////////////////////
7279/// Convert absolute pixel into X/Y coordinates
7280
7282{
7283 x = AbsPixeltoX(xpixel);
7284 y = AbsPixeltoY(ypixel);
7285}
7286
7287
7288////////////////////////////////////////////////////////////////////////////////
7289/// Convert pixel to X coordinate
7290
7292{
7293 if (fAbsCoord) return fAbsPixeltoXk + px*fPixeltoX;
7294 else return fPixeltoXk + px*fPixeltoX;
7295}
7296
7297////////////////////////////////////////////////////////////////////////////////
7298/// Convert pixel to Y coordinate
7299
7301{
7302 if (fAbsCoord) return fAbsPixeltoYk + py*fPixeltoY;
7303 else return fPixeltoYk + py*fPixeltoY;
7304}
7305
7306////////////////////////////////////////////////////////////////////////////////
7307/// Convert pixel to X/Y coordinates
7308
7310{
7311 x = PixeltoX(xpixel);
7312 y = PixeltoY(ypixel);
7313}
7314
7315////////////////////////////////////////////////////////////////////////////////
7316/// Convert X/Y into absolute pixel coordinates - integer
7317
7318void TPad::XYtoAbsPixel(Double_t x, Double_t y, Int_t &xpixel, Int_t &ypixel) const
7319{
7320 xpixel = XtoAbsPixel(x);
7321 ypixel = YtoAbsPixel(y);
7322}
7323
7324////////////////////////////////////////////////////////////////////////////////
7325/// Check value for valid range for pixel values
7326
7328{
7329 return v < -kMaxPixel ? -kMaxPixel : (v > kMaxPixel ? kMaxPixel : v);
7330}
7331
7332////////////////////////////////////////////////////////////////////////////////
7333/// Convert X/Y into absolute pixel coordinates - doble
7334/// Introduced to avoid pixel rounding problems
7335
7337{
7340}
7341
7342////////////////////////////////////////////////////////////////////////////////
7343/// Convert X/Y into pixel coordinates - integer
7344
7345void TPad::XYtoPixel(Double_t x, Double_t y, Int_t &xpixel, Int_t &ypixel) const
7346{
7347 xpixel = XtoPixel(x);
7348 ypixel = YtoPixel(y);
7349}
7350
7351////////////////////////////////////////////////////////////////////////////////
7352/// Convert X/Y into pixel coordinates - double
7353
7359
7360////////////////////////////////////////////////////////////////////////////////
7361/// Convert X NDC to pixel
7362
7367
7368////////////////////////////////////////////////////////////////////////////////
7369/// Convert Y NDC to pixel
7370
7375
7376////////////////////////////////////////////////////////////////////////////////
7377/// Convert X NDC to absolute pixel
7378
7383
7384////////////////////////////////////////////////////////////////////////////////
7385/// Convert Y NDC to absolute pixel
7386
7391
7392////////////////////////////////////////////////////////////////////////////////
7393/// Convert X coordinate to absolute pixel
7394
7399
7400////////////////////////////////////////////////////////////////////////////////
7401/// Convert X coordinate to pixel
7402
7407
7408////////////////////////////////////////////////////////////////////////////////
7409/// Convert Y coordinate to absolute pixel
7410
7415
7416////////////////////////////////////////////////////////////////////////////////
7417/// Convert a vertical distance [y1,y2] to pixel
7418
7420{
7421 double h1 = fYtoAbsPixelk + y1 * fYtoPixel;
7422 double h2 = fYtoAbsPixelk + y2 * fYtoPixel;
7423 return TMath::Nint(pixel_boundary(std::abs(h1 - h2)));
7424}
7425
7426////////////////////////////////////////////////////////////////////////////////
7427/// Convert a horizontal distance [x1,x2] to pixel
7428
7430{
7431 double w1 = fXtoAbsPixelk + x1 * fXtoPixel;
7432 double w2 = fXtoAbsPixelk + x2 * fXtoPixel;
7433 return TMath::Nint(pixel_boundary(std::abs(w1 - w2)));
7434}
7435
7436
7437////////////////////////////////////////////////////////////////////////////////
7438/// Convert Y coordinate to pixel
7439
EEventType
Definition Buttons.h:15
@ kMouseMotion
Definition Buttons.h:23
@ kWheelUp
Definition Buttons.h:18
@ kButton2Down
Definition Buttons.h:17
@ kKeyPress
Definition Buttons.h:20
@ kArrowKeyRelease
Definition Buttons.h:21
@ kButton1Double
Definition Buttons.h:24
@ kButton1Motion
Definition Buttons.h:20
@ kButton1Up
Definition Buttons.h:19
@ kWheelDown
Definition Buttons.h:18
@ kArrowKeyPress
Definition Buttons.h:21
@ kMouseLeave
Definition Buttons.h:23
@ kButton1Down
Definition Buttons.h:17
@ kButton1Locate
Definition Buttons.h:22
@ kMouseEnter
Definition Buttons.h:23
ECursor
Definition GuiTypes.h:373
@ kHand
Definition GuiTypes.h:375
const Int_t kMaxPixel
Max value for an int.
Definition GuiTypes.h:370
#define SafeDelete(p)
Definition RConfig.hxx:507
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define g(i)
Definition RSha256.hxx:105
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
cudaEvent_t event
short Style_t
Style number (short)
Definition RtypesCore.h:97
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
short Color_t
Color number (short)
Definition RtypesCore.h:100
float Size_t
Attribute size (float)
Definition RtypesCore.h:104
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:90
short Version_t
Class version identifier (short)
Definition RtypesCore.h:80
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:69
short Width_t
Line width (short)
Definition RtypesCore.h:99
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:54
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:132
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
@ kRed
Definition Rtypes.h:66
@ kBlack
Definition Rtypes.h:65
#define gDirectory
Definition TDirectory.h:385
R__EXTERN TEnv * gEnv
Definition TEnv.h:126
#define gFile
Definition TFile.h:441
winID h TVirtualViewer3D TVirtualGLPainter p
winID h TVirtualViewer3D vv
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t SetFillStyle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetCursor
Option_t Option_t SetFillColor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t style
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t button
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char mx
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:142
float xmin
float ymin
float xmax
float ymax
#define gInterpreter
Double_t pixel_boundary(Double_t v)
Check value for valid range for pixel values.
Definition TPad.cxx:7327
static Int_t gReadLevel
Definition TPad.cxx:71
#define NotFree(i, j)
Definition TPad.cxx:3130
R__EXTERN TPluginManager * gPluginMgr
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:417
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
#define gGLManager
Definition TVirtualGL.h:158
#define R__LOCKGUARD(mutex)
R__EXTERN TVirtualPS * gVirtualPS
Definition TVirtualPS.h:93
#define gPad
R__EXTERN Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
Draw all kinds of Arrows.
Definition TArrow.h:29
void Draw(Option_t *option="") override
Draw this arrow with its current attributes.
Definition TArrow.cxx:116
static TClass * Class()
Abstract base class for elements drawn in the editor.
Definition TAttBBox2D.h:19
virtual void SetBBoxCenterY(const Int_t y)=0
virtual void SetBBoxCenterX(const Int_t x)=0
virtual void SetBBoxX1(const Int_t x)=0
virtual void SetBBoxY1(const Int_t y)=0
virtual void SetBBoxX2(const Int_t x)=0
virtual void SetBBoxY2(const Int_t y)=0
virtual Rectangle_t GetBBox()=0
virtual TPoint GetBBoxCenter()
virtual void Streamer(TBuffer &)
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:32
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:33
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:40
static TClass * Class()
virtual Bool_t IsTransparent() const
Definition TAttFill.h:49
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:42
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
Definition TAttFill.cxx:240
Line Attributes class.
Definition TAttLine.h:21
virtual void Streamer(TBuffer &)
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:36
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:46
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:38
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:47
static TClass * Class()
Width_t fLineWidth
Line width.
Definition TAttLine.h:26
virtual void ModifyOn(TVirtualPad &pad)
Change current line attributes on specified pad.
Definition TAttLine.cxx:255
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:44
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:37
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
Definition TAttLine.cxx:176
static TClass * Class()
virtual void SetBottomMargin(Float_t bottommargin)
Set Pad bottom margin in fraction of the pad height.
Definition TAttPad.cxx:98
Color_t GetFrameFillColor() const
Definition TAttPad.h:53
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Definition TAttPad.cxx:108
Color_t GetFrameLineColor() const
Definition TAttPad.h:54
Style_t GetFrameLineStyle() const
Definition TAttPad.h:56
Float_t fRightMargin
RightMargin.
Definition TAttPad.h:22
Style_t GetFrameFillStyle() const
Definition TAttPad.h:55
Float_t fLeftMargin
LeftMargin.
Definition TAttPad.h:21
Float_t fTopMargin
TopMargin.
Definition TAttPad.h:24
Float_t GetLeftMargin() const
Definition TAttPad.h:44
Width_t GetFrameLineWidth() const
Definition TAttPad.h:57
Float_t GetBottomMargin() const
Definition TAttPad.h:43
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
Definition TAttPad.cxx:118
Float_t GetRightMargin() const
Definition TAttPad.h:45
Int_t GetFrameBorderMode() const
Definition TAttPad.h:59
virtual void SetTopMargin(Float_t topmargin)
Set Pad top margin in fraction of the pad height.
Definition TAttPad.cxx:128
Width_t GetFrameBorderSize() const
Definition TAttPad.h:58
Float_t fBottomMargin
BottomMargin.
Definition TAttPad.h:23
Float_t GetTopMargin() const
Definition TAttPad.h:46
virtual void Streamer(TBuffer &)
Stream an object of class TAttPad.
Definition TAttPad.cxx:149
virtual Float_t GetTextSize() const
Return the text size.
Definition TAttText.h:39
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition TAttText.h:48
virtual Short_t GetTextAlign() const
Return the text alignment.
Definition TAttText.h:35
virtual Font_t GetTextFont() const
Return the text font.
Definition TAttText.h:38
virtual Color_t GetTextColor() const
Return the text color.
Definition TAttText.h:37
virtual void SetTextAngle(Float_t tangle=0)
Set the text angle.
Definition TAttText.h:49
virtual Float_t GetTextAngle() const
Return the text angle.
Definition TAttText.h:36
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition TAttText.h:50
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition TAttText.h:52
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Definition TAttText.h:53
void PaintZoomBox(TPad &pad)
Definition TPad.cxx:2160
Double_t px1old
Definition TPad.cxx:2158
Double_t py1old
Definition TPad.cxx:2158
Double_t px2old
Definition TPad.cxx:2158
Double_t ratio2
Definition TPad.cxx:2157
Double_t py2old
Definition TPad.cxx:2158
Double_t ratio1
Definition TPad.cxx:2157
Class to manage histogram axis.
Definition TAxis.h:32
@ kAxisRange
Definition TAxis.h:66
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition TAxis.cxx:529
virtual Int_t FindFixBin(Double_t x) const
Find bin number corresponding to abscissa x
Definition TAxis.cxx:422
Int_t GetLast() const
Return last bin on the axis i.e.
Definition TAxis.cxx:480
virtual void SetLimits(Double_t xmin, Double_t xmax)
Definition TAxis.h:166
Int_t GetNbins() const
Definition TAxis.h:127
virtual TObject * GetParent() const
Definition TAxis.h:130
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis using bin numbers.
Definition TAxis.cxx:1068
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition TAxis.cxx:539
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition TAxis.cxx:469
Each class (see TClass) has a linked list of its base class(es).
Definition TBaseClass.h:33
TClass * GetClassPointer(Bool_t load=kTRUE)
Get pointer to the base class TClass.
void CalcPixelCoord(const TVirtualPad &parent, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Calculate pixel coordinates.
Create a Box.
Definition TBox.h:22
virtual void SetY2(Double_t y2)
Definition TBox.h:65
static TClass * Class()
virtual void SetX1(Double_t x1)
Definition TBox.h:62
virtual void SetX2(Double_t x2)
Definition TBox.h:63
virtual void SetY1(Double_t y1)
Definition TBox.h:64
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
Buffer base class used for serializing objects.
Definition TBuffer.h:43
A TButton object is a user interface object.
Definition TButton.h:18
static TClass * Class()
ABC describing GUI independent main window (with menubar, scrollbars and a drawing area).
Definition TCanvasImp.h:31
virtual Int_t RequestLocator(Int_t &x, Int_t &y)
Request current mouse pointer, redirect to gVirtualX.
The Canvas class.
Definition TCanvas.h:23
UInt_t GetWindowHeight() const
Definition TCanvas.h:167
TObject * GetClickSelected() const
Definition TCanvas.h:147
void ClearPadSave()
Definition TCanvas.h:145
TVirtualPad * GetClickSelectedPad() const
Definition TCanvas.h:152
void SetClickSelectedPad(TPad *pad)
Definition TCanvas.h:218
void SetSelectedPad(TPad *pad)
Definition TCanvas.h:217
void SetDoubleBuffer(Int_t mode=1) override
Set Double Buffer On/Off.
Definition TCanvas.cxx:1995
TCanvasImp * GetCanvasImp() const override
Definition TCanvas.h:163
Bool_t IsRetained() const override
Definition TCanvas.h:183
Int_t GetEventY() const override
Definition TCanvas.h:142
Bool_t IsBatch() const override
Definition TCanvas.h:178
TVirtualPadPainter * GetCanvasPainter()
Access and (probably) creation of pad painter.
Definition TCanvas.cxx:2678
Color_t GetHighLightColor() const override
Definition TCanvas.h:143
Bool_t EnsurePSPainter(Bool_t create, TVirtualPadPainter *&oldp)
Replace canvas painter For internal use only - when creating PS images.
Definition TCanvas.cxx:2688
Bool_t IsGrayscale()
Check whether this canvas is to be drawn in grayscale mode.
Definition TCanvas.cxx:2626
void SaveSource(const char *filename="", Option_t *option="")
Save primitives in this canvas as a C++ macro file.
Definition TCanvas.cxx:1834
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
Handle Input Events.
Definition TCanvas.cxx:1241
void UpdateAsync() override
Asynchronous canvas update.
Definition TCanvas.cxx:2599
TObject * GetSelected() const override
Definition TCanvas.h:146
Int_t GetEventX() const override
Definition TCanvas.h:141
void SetCanvasSize(UInt_t ww, UInt_t wh) override
Set Width and Height of canvas to ww and wh respectively.
Definition TCanvas.cxx:1972
TVirtualPad * GetSelectedPad() const override
Definition TCanvas.h:151
void SetCursor(ECursor cursor) override
Set cursor.
Definition TCanvas.cxx:1986
Int_t GetCanvasID() const override
Definition TCanvas.h:162
UInt_t GetWindowWidth() const
Definition TCanvas.h:166
void SetClickSelected(TObject *obj)
Definition TCanvas.h:216
TVirtualPad * GetPadSave() const override
Definition TCanvas.h:144
void Update() override
Update canvas pad buffers.
Definition TCanvas.cxx:2519
virtual void Cleared(TVirtualPad *pad)
Emit pad Cleared signal.
Definition TCanvas.cxx:783
UInt_t GetWw() const override
Definition TCanvas.h:168
Bool_t OpaqueMoving() const override
Definition TCanvas.h:187
UInt_t GetWh() const override
Definition TCanvas.h:169
void FeedbackMode(Bool_t set) override
Turn rubberband feedback mode on or off.
Definition TCanvas.cxx:1138
Int_t GetDoubleBuffer() const override
Definition TCanvas.h:139
static TClass * Class()
void SetSelected(TObject *obj) override
Set selected canvas.
Definition TCanvas.cxx:2144
Int_t GetEvent() const override
Definition TCanvas.h:140
Bool_t IsWeb() const override
Is web canvas.
Definition TCanvas.cxx:1516
void SetBatch(Bool_t batch=kTRUE) override
Toggle batch mode.
Definition TCanvas.cxx:1954
Bool_t UseGL() const
Definition TCanvas.h:235
TVirtualPad * fHilightPadBorder
! pad which border will be hilghlighrt when paint canvas
Definition TCanvas.h:70
Bool_t OpaqueResizing() const override
Definition TCanvas.h:188
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
TList * GetListOfMethods(Bool_t load=kTRUE)
Return list containing the TMethods of a class.
Definition TClass.cxx:3875
Int_t GetNmethods()
Return the number of methods of this class Note that in case the list of methods is not yet created,...
Definition TClass.cxx:4690
Int_t GetNdata()
Return the number of data members of this class Note that in case the list of data members is not yet...
Definition TClass.cxx:4671
TList * GetListOfDataMembers(Bool_t load=kTRUE)
Return list containing the TDataMembers of a class.
Definition TClass.cxx:3833
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
Definition TClass.cxx:3699
void ls(Option_t *option="") const override
List (ls) all objects in this collection.
void Browse(TBrowser *b) override
Browse this collection (called by TBrowser).
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
Definition TColor.cxx:1939
static TString SavePrimitiveColor(Int_t ci)
Convert color in C++ statement which can be used in SetColor directives Produced statement either inc...
Definition TColor.cxx:2569
static void SetGrayscale(Bool_t set=kTRUE)
Set whether all colors should return grayscale values.
Definition TColor.cxx:2617
static void ExecuteEvent(TPad &pad, Int_t edit_mode, Int_t event, Int_t px, Int_t py)
Handle edit mode in the TPad Executed when editmode is not 0.
All ROOT classes may have RTTI (run time type identification) support added.
Definition TDataMember.h:31
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition TDatime.h:37
const char * AsSQLString() const
Return the date & time in SQL compatible string format, like: 1997-01-15 20:16:28.
Definition TDatime.cxx:148
const char * AsString() const
Return the date & time as a string (ctime() format).
Definition TDatime.cxx:98
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:511
TExec is a utility class that can be used to execute a C++ command when some event happens in a pad.
Definition TExec.h:26
Define a Frame.
Definition TFrame.h:19
static TClass * Class()
void Paint(Option_t *option="") override
Paint this wbox with its current attributes.
Definition TFrame.cxx:127
void UseCurrentStyle() override
Replace current frame attributes by current style.
Definition TFrame.cxx:157
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
static TClass * Class()
@ kClipFrame
Clip to the frame boundary.
Definition TGraph.h:75
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:908
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:126
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
Definition TH1.cxx:9170
static TClass * Class()
virtual Double_t GetNormFactor() const
Definition TH1.h:575
virtual Int_t GetDimension() const
Definition TH1.h:557
@ kNoStats
Don't draw stats box.
Definition TH1.h:433
@ kIsZoomed
Bit set when zooming on Y axis.
Definition TH1.h:437
virtual Double_t GetMinimum(Double_t minval=-std::numeric_limits< float >::max()) const
Return minimum value larger than minval of bins in the range, unless the value has been overridden by...
Definition TH1.cxx:8868
virtual Double_t GetSumOfWeights() const
Return the sum of weights across all bins excluding under/overflows.
Definition TH1.h:589
virtual void SetMaximum(Double_t maximum=-1111)
Definition TH1.h:682
TAxis * GetYaxis()
Definition TH1.h:602
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3193
virtual void SetMinimum(Double_t minimum=-1111)
Definition TH1.h:683
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
Copy this histogram and Draw in the current pad.
Definition TH1.cxx:3258
static TClass * Class()
static TClass * Class()
The Histogram stack class.
Definition THStack.h:40
TH1 * GetHistogram() const
Returns a pointer to the histogram used to draw the axis.
Definition THStack.cxx:482
static TClass * Class()
EImageFileTypes
Definition TImage.h:37
@ kBmp
Definition TImage.h:46
@ kPng
Definition TImage.h:41
@ kPdf
Definition TImage.h:59
@ kJpeg
Definition TImage.h:42
@ kXpm
Definition TImage.h:38
@ kAnimGif
Definition TImage.h:56
@ kUnknown
Definition TImage.h:55
@ kSvg
Definition TImage.h:58
@ kHtml
Definition TImage.h:57
@ kTiff
Definition TImage.h:50
@ kGif
Definition TImage.h:49
Option_t * GetOption() const
This class displays a legend box (TPaveText) containing several legend entries.
Definition TLegend.h:23
Use the TLine constructor to create a simple line.
Definition TLine.h:22
Iterator of linked list.
Definition TList.h:196
Option_t * GetOption() const override
Returns the object option stored in the list.
Definition TList.cxx:1274
A doubly linked list.
Definition TList.h:38
TObject * After(const TObject *obj) const override
Returns the object after object obj.
Definition TList.cxx:460
void Clear(Option_t *option="") override
Remove all objects from the list.
Definition TList.cxx:532
virtual TObjLink * LastLink() const
Definition TList.h:110
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:708
void RecursiveRemove(TObject *obj) override
Remove object from this collection and recursively remove the object from all other objects (and coll...
Definition TList.cxx:894
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:952
void AddLast(TObject *obj) override
Add object at the end of the list.
Definition TList.cxx:149
TObject * Last() const override
Return the last object in the list. Returns 0 when list is empty.
Definition TList.cxx:823
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:789
virtual TObjLink * FirstLink() const
Definition TList.h:107
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:487
void AddFirst(TObject *obj) override
Add object at the beginning of the list.
Definition TList.cxx:97
Each ROOT class (see TClass) has a linked list of methods.
Definition TMethod.h:38
A TMultiGraph is a collection of TGraph (or derived) objects.
Definition TMultiGraph.h:34
TH1F * GetHistogram()
Returns a pointer to the histogram used to draw the axis.
static TClass * Class()
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:173
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
static TClass * Class()
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:149
Mother of all ROOT objects.
Definition TObject.h:42
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Computes distance from point (px,py) to the object.
Definition TObject.cxx:283
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:461
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
Definition TObject.cxx:995
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
virtual void UseCurrentStyle()
Set current style settings in this object This function is called when either TCanvas::UseCurrentStyl...
Definition TObject.cxx:907
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition TObject.cxx:444
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1082
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition TObject.cxx:424
virtual void Delete(Option_t *option="")
Delete this object.
Definition TObject.cxx:267
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:886
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:548
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1096
virtual const char * GetTitle() const
Returns title of object.
Definition TObject.cxx:506
void MakeZombie()
Definition TObject.h:55
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:292
virtual void Paint(Option_t *option="")
This method must be overridden if a class wants to paint itself.
Definition TObject.cxx:630
void ResetBit(UInt_t f)
Definition TObject.h:203
@ kCannotPick
if object in a pad cannot be picked
Definition TObject.h:76
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:71
@ kMustCleanup
if object destructor must call RecursiveRemove()
Definition TObject.h:73
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1070
std::vector< Double_t > fX
Definition TPad.cxx:189
void Draw(TPad &pad, TVirtualPadPainter *pp, Bool_t withXor)
Definition TPad.cxx:148
std::vector< Double_t > fY
Definition TPad.cxx:189
TPadDrawOperation(Int_t n, T *x, T *y, EKind kind, Int_t arg=1, Bool_t ndc=kFALSE)
Definition TPad.cxx:138
virtual ~TPadDrawOperation()=default
The most important graphics class in the ROOT system.
Definition TPad.h:32
Short_t GetBorderMode() const override
Definition TPad.h:209
Bool_t OpaqueMoving() const override
Is pad moving in opaque mode ?
Definition TPad.cxx:2713
void PaintTextNDC(Double_t u, Double_t v, const char *text) override
Paint text in CurrentPad NDC coordinates.
Definition TPad.cxx:4569
Int_t GetTicky() const override
Definition TPad.h:252
virtual Int_t Clip(Float_t *x, Float_t *y, Float_t xclipl, Float_t yclipb, Float_t xclipr, Float_t yclipt)
Clipping routine: Cohen Sutherland algorithm.
Definition TPad.cxx:835
virtual void HideToolTip(Int_t event)
Hide tool tip depending on the event type.
Definition TPad.cxx:2658
Double_t fAbsYlowNDC
Absolute Y top left corner of pad in NDC [0,1].
Definition TPad.h:76
std::map< std::string, std::unique_ptr< TPadDrawOperation > > fDrawOper
Definition TPad.h:39
Double_t fXtoAbsPixelk
Conversion coefficient for X World to absolute pixel.
Definition TPad.h:47
void SetAttMarkerPS(Color_t color, Style_t style, Size_t msize) override
Set postscript marker attributes.
Definition TPad.cxx:6113
virtual void DivideSquare(Int_t n, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
"n" is the total number of sub-pads.
Definition TPad.cxx:1556
void AbsCoordinates(Bool_t set) override
Definition TPad.h:175
static TClass * Class()
Bool_t IsBatch() const override
Is pad in batch mode ?
Definition TPad.cxx:2690
Double_t GetUymax() const override
Returns the maximum y-coordinate value visible on the pad. If log axis the returned value is in decad...
Definition TPad.h:247
void AddExec(const char *name, const char *command) override
Add a new TExec object to the list of Execs.
Definition TPad.cxx:565
Double_t fWNDC
Width of pad along X in Normalized Coordinates (NDC)
Definition TPad.h:72
Int_t NextPaletteColor() override
Get the next autocolor in the pad.
Definition TPad.cxx:2978
Int_t VtoPixel(Double_t v) const override
Convert Y NDC to pixel.
Definition TPad.cxx:7371
void PaintBorder(Color_t color, Bool_t tops)
Paint the pad border.
Definition TPad.cxx:3523
Double_t GetPhi() const override
Definition TPad.h:238
std::map< std::string, std::unique_ptr< TPadDrawOperation > > fDrawOperXor
! map of draw operations performed outside of normal paint
Definition TPad.h:39
Bool_t IsEditable() const override
Definition TPad.h:285
void FillCollideGrid(TObject *o)
Initialise the grid used to find empty space when adding a box (Legend) in a pad.
Definition TPad.cxx:2994
void SetView(TView *view=nullptr) override
Set the current TView. Delete previous view if view=0.
Definition TPad.cxx:6078
TVirtualViewer3D * GetViewer3D(Option_t *type="") override
Create/obtain handle to 3D viewer.
Definition TPad.cxx:7035
Double_t fPixeltoYk
Conversion coefficient for pixel to Y World.
Definition TPad.h:65
void PaintHatches(Double_t dy, Double_t angle, Int_t nn, Double_t *xx, Double_t *yy)
This routine draw hatches inclined with the angle "angle" and spaced of "dy" in normalized device coo...
Definition TPad.cxx:4010
void PaintLine3D(Float_t *p1, Float_t *p2) override
Paint 3-D line in the CurrentPad.
Definition TPad.cxx:4191
static Int_t fgMaxPickDistance
Maximum Pick Distance.
Definition TPad.h:121
void ResizePad(Option_t *option="") override
Compute pad conversion coefficients.
Definition TPad.cxx:5566
void PaintMarker3D(Double_t x, Double_t y, Double_t z) override
Paint 3-D marker in the CurrentPad.
Definition TPad.cxx:4227
void PaintPolyMarker(Int_t n, Float_t *x, Float_t *y, Option_t *option="") override
Paint polymarker in CurrentPad World coordinates.
Definition TPad.cxx:4404
Double_t fPhi
phi angle to view as lego/surface
Definition TPad.h:86
Double_t fPixeltoY
yworld = fPixeltoYk + fPixeltoY*ypixel
Definition TPad.h:66
virtual void RecordLatex(const TObject *obj)
Emit RecordLatex() signal.
Definition TPad.cxx:7138
Double_t fAbsXlowNDC
Absolute X top left corner of pad in NDC [0,1].
Definition TPad.h:75
Double_t fVtoPixelk
Conversion coefficient for V NDC to pixel.
Definition TPad.h:58
Bool_t fGridx
Set to true if grid along X.
Definition TPad.h:106
TObject * fPadView3D
! 3D View of this TPad
Definition TPad.h:120
Double_t GetUxmax() const override
Returns the maximum x-coordinate value visible on the pad. If log axis the returned value is in decad...
Definition TPad.h:245
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
Automatic pad generation by division.
Definition TPad.cxx:1362
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitives in this pad on the C++ source file out.
Definition TPad.cxx:5781
void CopyBackgroundPixmaps(TPad *stop, Int_t x, Int_t y)
Copy pixmaps of pads laying below pad "stop" into pad "stop".
Definition TPad.cxx:3852
Double_t fXtoPixel
xpixel = fXtoPixelk + fXtoPixel*xworld
Definition TPad.h:49
TList * fExecs
List of commands to be executed when a pad event occurs.
Definition TPad.h:114
Double_t PadtoY(Double_t y) const override
Convert y from pad to Y.
Definition TPad.cxx:3412
Int_t fTickx
Set to 1 if tick marks along X.
Definition TPad.h:95
void PaintOperations(Bool_t withXor=kFALSE)
Perform buffered paint operations Used for interactivity functionality immediately after normal paint...
Definition TPad.cxx:3754
void SetBBoxY1(const Int_t y) override
Set top of BoundingBox to a value (resize in y direction on top)
Definition TPad.cxx:7247
Int_t fTicky
Set to 1 if tick marks along Y.
Definition TPad.h:96
Int_t GetPixmapID() const override
Definition TPad.h:279
Bool_t GetGridx() const override
Definition TPad.h:248
Double_t fX2
X of upper X coordinate.
Definition TPad.h:44
Bool_t PlaceBox(TObject *o, Double_t w, Double_t h, Double_t &xl, Double_t &yb, Option_t *option="lb") override
Place a box in NDC space.
Definition TPad.cxx:3063
void SetLogz(Int_t value=1) override
Set Lin/Log scale for Z.
Definition TPad.cxx:5994
Bool_t fEmbeddedGL
!
Definition TPad.h:93
Int_t UtoAbsPixel(Double_t u) const override
Convert X NDC to absolute pixel.
Definition TPad.cxx:7379
void Browse(TBrowser *b) override
Browse pad.
Definition TPad.cxx:588
Int_t XtoPixel(Double_t x) const override
Convert X coordinate to pixel.
Definition TPad.cxx:7403
void SetAttFillPS(Color_t color, Style_t style) override
Set postscript fill area attributes.
Definition TPad.cxx:6089
Int_t fCGnx
! Size of the collide grid along x
Definition TPad.h:125
void SetBBoxCenterY(const Int_t y) override
Set Y coordinate of the center of the Pad.
Definition TPad.cxx:7211
Double_t fPixeltoX
xworld = fPixeltoXk + fPixeltoX*xpixel
Definition TPad.h:63
~TPad() override
Pad destructor.
Definition TPad.cxx:446
Bool_t fCopyGLDevice
!
Definition TPad.h:92
Double_t fYtoPixel
ypixel = fYtoPixelk + fYtoPixel*yworld
Definition TPad.h:52
Double_t GetY2() const override
Definition TPad.h:256
void DeleteToolTip(TObject *tip) override
Delete tool tip object.
Definition TPad.cxx:6985
void Close(Option_t *option="") override
Delete all primitives in pad and pad itself.
Definition TPad.cxx:1148
void AbsPixeltoXY(Double_t xpixel, Double_t ypixel, Double_t &x, Double_t &y) override
Convert absolute pixel into X/Y coordinates.
Definition TPad.cxx:7281
Double_t fAbsWNDC
Absolute Width of pad along X in NDC.
Definition TPad.h:77
TObject * Remove(TObject *obj, Bool_t modified=kTRUE) override
Remove object from list of primitives When.
Definition TPad.cxx:5349
UInt_t GetWw() const override
Get canvas width.
Definition TPad.cxx:2614
void PaintModified() override
Traverse pad hierarchy and (re)paint only modified pads.
Definition TPad.cxx:3658
void SetEditable(Bool_t mode=kTRUE) override
Set pad editable yes/no If a pad is not editable:
Definition TPad.cxx:5938
const char * GetTitle() const override
Returns title of object.
Definition TPad.h:274
void PaintDate()
Paint the current date and time if the option Date is set on via gStyle->SetOptDate() Paint the curre...
Definition TPad.cxx:3596
static void SetMaxPickDistance(Int_t maxPick=5)
static function to set the maximum Pick Distance fgMaxPickDistance This parameter is used in TPad::Pi...
Definition TPad.cxx:6564
void PixeltoXY(Double_t xpixel, Double_t ypixel, Double_t &x, Double_t &y) override
Convert pixel to X/Y coordinates.
Definition TPad.cxx:7309
void SetBBoxX2(const Int_t x) override
Set right hand side of BoundingBox to a value (resize in x direction on right)
Definition TPad.cxx:7236
void SetBBoxX1(const Int_t x) override
Set lefthandside of BoundingBox to a value (resize in x direction on left)
Definition TPad.cxx:7223
virtual Int_t ClippingCode(Double_t x, Double_t y, Double_t xcl1, Double_t ycl1, Double_t xcl2, Double_t ycl2)
Compute the endpoint codes for TPad::Clip.
Definition TPad.cxx:968
Double_t GetUymin() const override
Returns the minimum y-coordinate value visible on the pad. If log axis the returned value is in decad...
Definition TPad.h:243
Double_t fX1
X of lower X coordinate.
Definition TPad.h:42
TList * GetListOfPrimitives() const override
Definition TPad.h:258
void SetFillStyle(Style_t fstyle) override
Override TAttFill::FillStyle for TPad because we want to handle style=0 as style 4000.
Definition TPad.cxx:5957
Double_t AbsPixeltoY(Double_t py) override
Definition TPad.h:177
TH1F * DrawFrame(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, const char *title="") override
Draw an empty pad frame with X and Y axis.
Definition TPad.cxx:1899
Double_t fVtoPixel
ypixel = fVtoPixelk + fVtoPixel*vndc
Definition TPad.h:59
TCanvasImp * GetCanvasImp() const override
Get canvas implementation pointer if any.
Definition TPad.cxx:2515
Int_t GetEvent() const override
Get Event.
Definition TPad.cxx:2523
Double_t PadtoX(Double_t x) const override
Convert x from pad to X.
Definition TPad.cxx:3403
TInteractive * Interactive(TObject *obj=nullptr, TInteractive *init=nullptr) override
Internal method to create, provide or delete TInteractive instance It is allowed the only instance of...
Definition TPad.cxx:2943
virtual void DrawCrosshair()
Function called to draw a crosshair in the canvas.
Definition TPad.cxx:1820
Double_t YtoPad(Double_t y) const override
Convert y from Y to pad.
Definition TPad.cxx:3433
virtual void RangeChanged()
Definition TPad.h:334
Double_t fUymin
Minimum value on the Y axis.
Definition TPad.h:81
void SetPad(const char *name, const char *title, Double_t xlow, Double_t ylow, Double_t xup, Double_t yup, Color_t color=35, Short_t bordersize=5, Short_t bordermode=-1) override
Set all pad parameters.
Definition TPad.cxx:6054
void SetCursor(ECursor cursor) override
Set cursor type.
Definition TPad.cxx:2745
Int_t GetCanvasID() const override
Get canvas identifier.
Definition TPad.cxx:2507
Int_t fLogz
(=0 if Z linear scale, =1 if log scale)
Definition TPad.h:99
Int_t HtoAbsPixel(Double_t y1, Double_t y2) const override
Convert a vertical distance [y1,y2] to pixel.
Definition TPad.cxx:7419
void XYtoPixel(Double_t x, Double_t y, Int_t &xpixel, Int_t &ypixel) const override
Convert X/Y into pixel coordinates - integer.
Definition TPad.cxx:7345
Double_t fYtoPixelk
Conversion coefficient for Y World to pixel.
Definition TPad.h:51
void UpdateAsync() override
Asynchronous pad update.
Definition TPad.cxx:2781
TPad()
Pad default constructor.
Definition TPad.cxx:199
void UseCurrentStyle() override
Force a copy of current style for all objects in pad.
Definition TPad.cxx:6811
static Int_t GetMaxPickDistance()
Static function (see also TPad::SetMaxPickDistance)
Definition TPad.cxx:2571
Int_t VtoAbsPixel(Double_t v) const override
Convert Y NDC to absolute pixel.
Definition TPad.cxx:7387
void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Set world coordinate system for the pad.
Definition TPad.cxx:5273
Double_t fUtoPixelk
Conversion coefficient for U NDC to pixel.
Definition TPad.h:55
void XYtoAbsPixel(Double_t x, Double_t y, Int_t &xpixel, Int_t &ypixel) const override
Convert X/Y into absolute pixel coordinates - integer.
Definition TPad.cxx:7318
Double_t fPixeltoXk
Conversion coefficient for pixel to X World.
Definition TPad.h:62
Bool_t IsModified() const override
Definition TPad.h:287
Double_t fY1
Y of lower Y coordinate.
Definition TPad.h:43
Int_t GetEventY() const override
Get Y event.
Definition TPad.cxx:2539
Int_t fGLDevice
! OpenGL off-screen pixmap identifier
Definition TPad.h:91
Double_t fYlowNDC
Y bottom left corner of pad in NDC [0,1].
Definition TPad.h:69
TObject * WaitPrimitive(const char *pname="", const char *emode="") override
Loop and sleep until a primitive with name=pname is found in the pad.
Definition TPad.cxx:6931
void SetAttTextPS(Int_t align, Float_t angle, Color_t color, Style_t font, Float_t tsize) override
Set postscript text attributes.
Definition TPad.cxx:6125
Bool_t fModified
Set to true when pad is modified.
Definition TPad.h:105
Double_t PixeltoY(Double_t py) override
Convert pixel to Y coordinate.
Definition TPad.cxx:7300
TLegend * BuildLegend(Double_t x1=0.3, Double_t y1=0.21, Double_t x2=0.3, Double_t y2=0.21, const char *title="", Option_t *option="") override
Build a legend from the graphical objects in the pad.
Definition TPad.cxx:620
virtual TPad * Pick(Int_t px, Int_t py, TObjLink *&pickobj)
Search for an object at pixel position px,py.
Definition TPad.cxx:4605
void Update() override
Update pad.
Definition TPad.cxx:2769
virtual void SetNumber(Int_t number)
Definition TPad.h:360
Int_t fNumber
pad number identifier
Definition TPad.h:94
void PaintFillAreaNDC(Int_t n, Double_t *x, Double_t *y, Option_t *option="") override
Paint fill area in CurrentPad NDC coordinates.
Definition TPad.cxx:3933
Double_t fAbsPixeltoXk
Conversion coefficient for absolute pixel to X World.
Definition TPad.h:61
void Clear(Option_t *option="") override
Delete all pad primitives.
Definition TPad.cxx:787
Int_t YtoPixel(Double_t y) const override
Convert Y coordinate to pixel.
Definition TPad.cxx:7440
Int_t GetTickx() const override
Definition TPad.h:251
void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Paint line in CurrentPad World coordinates.
Definition TPad.cxx:4156
Int_t GetGLDevice() override
Get GL device.
Definition TPad.cxx:7122
Double_t fAspectRatio
ratio of w/h in case of fixed ratio
Definition TPad.h:88
virtual void RecordPave(const TObject *obj)
Emit RecordPave() signal.
Definition TPad.cxx:7130
void 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) override
Paint a frame border with Postscript - no longer used.
Definition TPad.cxx:3586
Double_t fUymax
Maximum value on the Y axis.
Definition TPad.h:83
void SetLogy(Int_t value=1) override
Set Lin/Log scale for Y.
Definition TPad.cxx:5983
virtual Int_t 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)
Clip polygon using the Sutherland-Hodgman algorithm.
Definition TPad.cxx:1017
void ExecuteEventAxis(Int_t event, Int_t px, Int_t py, TAxis *axis) override
Execute action corresponding to one event for a TAxis object (called by TAxis::ExecuteEvent....
Definition TPad.cxx:2213
void HighLight(Color_t col=kRed, Bool_t set=kTRUE) override
Highlight pad.
Definition TPad.cxx:2889
Double_t AbsPixeltoX(Double_t px) override
Definition TPad.h:176
void SetBatch(Bool_t batch=kTRUE) override
Set pad in batch mode.
Definition TPad.cxx:2729
TCanvas * fCanvas
! Pointer to mother canvas
Definition TPad.h:112
TVirtualPad * GetMother() const override
Definition TPad.h:272
TVirtualViewer3D * fViewer3D
! Current 3D viewer
Definition TPad.h:129
virtual void x3d(Option_t *type="")
Deprecated: use TPad::GetViewer3D() instead.
Definition TPad.cxx:7017
Bool_t HasCrosshair() const override
Return kTRUE if the crosshair has been activated (via SetCrosshair).
Definition TPad.cxx:6526
Bool_t IsRetained() const override
Is pad retained ?
Definition TPad.cxx:2698
Bool_t Collide(Int_t i, Int_t j, Int_t w, Int_t h)
Check if a box of size w and h collide some primitives in the pad at position i,j.
Definition TPad.cxx:3039
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a box.
Definition TPad.cxx:1258
Bool_t fFixedAspectRatio
True if fixed aspect ratio.
Definition TPad.h:110
void PaintFillArea(Int_t n, Float_t *x, Float_t *y, Option_t *option="") override
Definition TPad.cxx:3871
void Modified(Bool_t flag=true) override
Mark pad modified Will be repainted when TCanvas::Update() will be called next time.
Definition TPad.cxx:7272
void RecursiveRemove(TObject *obj) override
Recursively remove object from a pad and its sub-pads.
Definition TPad.cxx:5331
void DivideRatios(Int_t nrows, Int_t ncolumns, const std::vector< double > &widthRatios={}, const std::vector< double > &heightRatios={}, const double canvasTopMargin=0., const double canvasLeftMargin=0.)
Divide the canvas according to ratios.
Definition TPad.cxx:1461
Bool_t HasFixedAspectRatio() const override
Definition TPad.h:283
void CloseToolTip(TObject *tip) override
Hide tool tip.
Definition TPad.cxx:7007
Double_t GetUxmin() const override
Returns the minimum x-coordinate value visible on the pad. If log axis the returned value is in decad...
Definition TPad.h:241
void SetToolTipText(const char *text, Long_t delayms=1000) override
Set tool tip text associated with this pad.
Definition TPad.cxx:6574
void PaintPolyLine(Int_t n, Float_t *x, Float_t *y, Option_t *option="") override
Paint polyline in CurrentPad World coordinates.
Definition TPad.cxx:4253
Int_t WtoAbsPixel(Double_t x1, Double_t x2) const override
Convert a horizontal distance [x1,x2] to pixel.
Definition TPad.cxx:7429
void ls(Option_t *option="") const override
List all primitives in pad.
Definition TPad.cxx:2925
TView * GetView() const override
Definition TPad.h:267
void ModifiedUpdate() override
Short cut to call Modified() and Update() in a single call.
Definition TPad.cxx:3391
Double_t fVtoAbsPixelk
Conversion coefficient for V NDC to absolute pixel.
Definition TPad.h:57
UInt_t GetPadHeight() const override
Get pad height.
Definition TPad.cxx:2639
TVirtualPad * GetPadSave() const override
Get save pad.
Definition TPad.cxx:2597
void SetAttLinePS(Color_t color, Style_t style, Width_t lwidth) override
Set postscript line attributes.
Definition TPad.cxx:6101
TClass * IsA() const override
Definition TPad.h:441
virtual void Resized()
Definition TPad.h:341
TVirtualPad * GetVirtCanvas() const override
Get virtual canvas.
Definition TPad.cxx:2547
void DeleteExec(const char *name) override
Remove TExec name from the list of Execs.
Definition TPad.cxx:1242
void PaintSegments(Int_t n, Double_t *x, Double_t *y, Option_t *option="") override
Paint N individual segments Provided arrays should have 2*n elements IMPORTANT! Provided arrays can b...
Definition TPad.cxx:4475
void FeedbackMode(Bool_t set) override
Switch feedback mode for the canvas Only for internal use when implementing special painters.
Definition TPad.cxx:2458
UInt_t GetPadWidth() const override
Get pad width.
Definition TPad.cxx:2622
void Streamer(TBuffer &) override
Stream a class object.
Definition TPad.cxx:6597
void PaintSegmentsNDC(Int_t n, Double_t *u, Double_t *v) override
Paint N individual segments in NDC coordinates Provided arrays should have 2*n elements IMPORTANT!...
Definition TPad.cxx:4516
TString fTitle
Pad title.
Definition TPad.h:116
void CopyPixmaps() override
Copy the sub-pixmaps of the pad to the canvas.
Definition TPad.cxx:1223
void CopyPixmap() override
Copy the pixmap of the pad to the canvas.
Definition TPad.cxx:1207
Double_t GetY1() const override
Definition TPad.h:255
Int_t UtoPixel(Double_t u) const override
Convert X NDC to pixel.
Definition TPad.cxx:7363
TPoint GetBBoxCenter() override
Return the center of the Pad as TPoint in pixels.
Definition TPad.cxx:7172
void FillCollideGridTFrame(TObject *o)
Definition TPad.cxx:3195
Bool_t GetGridy() const override
Definition TPad.h:249
void LineNotFree(Int_t x1, Int_t x2, Int_t y1, Int_t y2)
Mark as "not free" the cells along a line.
Definition TPad.cxx:3135
Double_t fAbsHNDC
Absolute Height of pad along Y in NDC.
Definition TPad.h:78
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TPad.cxx:2005
TObject * fTip
! tool tip associated with box
Definition TPad.h:37
void SetCanvasSize(UInt_t ww, UInt_t wh) override
Set canvas size.
Definition TPad.cxx:2737
Int_t GetLogz() const override
Definition TPad.h:271
virtual void AutoExec()
Execute the list of Execs when a pad event occurs.
Definition TPad.cxx:575
Bool_t fAbsCoord
Use absolute coordinates.
Definition TPad.h:108
Int_t fNumPaletteColor
Number of objects with an automatic color.
Definition TPad.h:122
Int_t fCrosshairPos
Position of crosshair.
Definition TPad.h:102
void FillCollideGridTGraph(TObject *o)
Definition TPad.cxx:3221
void SetFixedAspectRatio(Bool_t fixed=kTRUE) override
Fix pad aspect ratio to current value if fixed is true.
Definition TPad.cxx:5914
Short_t GetBorderSize() const override
Definition TPad.h:210
void RedrawAxis(Option_t *option="") override
Redraw the frame axis.
Definition TPad.cxx:5392
void DrawDist(Rectangle_t aBBox, Rectangle_t bBBox, char mode)
Draw Arrows to indicated equal distances of Objects with given BBoxes.
Definition TPad.cxx:6150
Int_t fLogx
(=0 if X linear scale, =1 if log scale)
Definition TPad.h:97
Double_t GetAbsWNDC() const override
Definition TPad.h:235
Int_t YtoAbsPixel(Double_t y) const override
Convert Y coordinate to absolute pixel.
Definition TPad.cxx:7411
Double_t fUtoPixel
xpixel = fUtoPixelk + fUtoPixel*undc
Definition TPad.h:56
Int_t fCrosshair
Crosshair type (0 if no crosshair requested)
Definition TPad.h:101
void PaintFillAreaHatches(Int_t n, Double_t *x, Double_t *y, Int_t FillStyle)
This function paints hatched fill area according to the FillStyle value The convention for the Hatch ...
Definition TPad.cxx:3976
void RangeAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax) override
Set axis coordinate system for the pad.
Definition TPad.cxx:5311
@ kCannotMove
Fixed position.
Definition TPad.h:166
@ kClearAfterCR
Clear after CR.
Definition TPad.h:167
@ kHori
Pad is horizontal.
Definition TPad.h:163
@ kPrintingPS
PS Printing.
Definition TPad.h:165
@ kFraming
Frame is requested.
Definition TPad.h:162
Double_t fUtoAbsPixelk
Conversion coefficient for U NDC to absolute pixel.
Definition TPad.h:54
void ResetToolTip(TObject *tip) override
Reset tool tip, i.e.
Definition TPad.cxx:6996
Double_t GetTheta() const override
Definition TPad.h:239
TList * fPrimitives
->List of primitives (subpads)
Definition TPad.h:113
UInt_t GetWh() const override
Get canvas height.
Definition TPad.cxx:2606
TCanvas * GetCanvas() const override
Definition TPad.h:275
Short_t fBorderSize
pad bordersize in pixels
Definition TPad.h:103
void Add(TObject *obj, Option_t *opt="", Bool_t modified=kTRUE) override
Add an object to list of primitives with specified draw option When.
Definition TPad.cxx:485
TView * fView
! Pointer to 3-D view (if one exists)
Definition TPad.h:118
Rectangle_t GetBBox() override
Return the bounding Box of the Pad.
Definition TPad.cxx:7155
void Paint(Option_t *option="") override
Paint all primitives in pad.
Definition TPad.cxx:3445
void FillCollideGridTBox(TObject *o)
Definition TPad.cxx:3178
Double_t fTheta
theta angle to view as lego/surface
Definition TPad.h:85
void DrawCollideGrid()
This method draws the collide grid on top of the canvas.
Definition TPad.cxx:3334
TString fName
Pad name.
Definition TPad.h:115
void SetVertical(Bool_t vert=kTRUE) override
Set pad vertical (default) or horizontal.
Definition TPad.cxx:6588
void FillCollideGridTH1(TObject *o)
Definition TPad.cxx:3252
void GetPadPar(Double_t &xlow, Double_t &ylow, Double_t &xup, Double_t &yup) override
Return lower and upper bounds of the pad in NDC coordinates.
Definition TPad.cxx:2855
void PaintText(Double_t x, Double_t y, const char *text) override
Paint text in CurrentPad World coordinates.
Definition TPad.cxx:4530
Int_t fPadPaint
Set to 1 while painting the pad.
Definition TPad.h:100
static void DrawColorTable()
Static function to Display Color Table in a pad.
Definition TPad.cxx:1944
Double_t GetXlowNDC() const override
Definition TPad.h:223
void SaveAs(const char *filename="", Option_t *option="") const override
Save the pad content in a file.
Definition TPad.cxx:5726
Int_t fPixmapID
! Off-screen pixmap identifier
Definition TPad.h:90
Bool_t fEditable
True if canvas is editable.
Definition TPad.h:109
Double_t GetYlowNDC() const override
Definition TPad.h:224
TObject * FindObject(const char *name) const override
Search if object named name is inside this pad or in pads inside this pad.
Definition TPad.cxx:2469
Color_t GetHighLightColor() const override
Get highlight color.
Definition TPad.cxx:2563
Bool_t OpaqueResizing() const override
Is pad resizing in opaque mode ?
Definition TPad.cxx:2721
Double_t fXUpNDC
Definition TPad.h:70
std::vector< Bool_t > fCollideGrid
! Grid used to find empty space when adding a box (Legend) in a pad
Definition TPad.h:124
Int_t IsAnyNeedRepaint() const
Check if pad or any subpads need to be repaint Returns flag with following mask: 1 - some pad is modi...
Definition TPad.cxx:2671
TVirtualPad * cd(Int_t subpadnumber=0) override
Set Current pad.
Definition TPad.cxx:758
Int_t GetLogy() const override
Definition TPad.h:270
void PaintLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2) override
Paint line in normalized coordinates.
Definition TPad.cxx:4178
void Print(const char *filename="") const override
This method is equivalent to SaveAs("filename"). See TPad::SaveAs for details.
Definition TPad.cxx:4746
Int_t GetEventX() const override
Get X event.
Definition TPad.cxx:2531
TFrame * GetFrame() override
Get frame.
Definition TPad.cxx:2789
Double_t fYUpNDC
Definition TPad.h:71
Double_t fYtoAbsPixelk
Conversion coefficient for Y World to absolute pixel.
Definition TPad.h:50
Double_t fXtoPixelk
Conversion coefficient for X World to pixel.
Definition TPad.h:48
Int_t fLogy
(=0 if Y linear scale, =1 if log scale)
Definition TPad.h:98
TFrame * fFrame
! Pointer to 2-D frame (if one exists)
Definition TPad.h:117
TVirtualPadPainter * GetPainter() override
Get pad painter from TCanvas.
Definition TPad.cxx:7146
void Draw(Option_t *option="") override
Draw Pad in Current pad (re-parent pad if necessary).
Definition TPad.cxx:1579
virtual void Closed()
Definition TPad.h:192
Double_t fHNDC
Height of pad along Y in Normalized Coordinates (NDC)
Definition TPad.h:73
void ShowGuidelines(TObject *object, const Int_t event, const char mode='i', const bool cling=true) override
Shows lines to indicate if a TAttBBox2D object is aligned to the center or to another object,...
Definition TPad.cxx:6234
Int_t GetCrosshair() const
Return the crosshair type (from the mother canvas) crosshair type = 0 means no crosshair.
Definition TPad.cxx:6535
void GetRangeAxis(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) override
Return pad axis coordinates range.
Definition TPad.cxx:2877
void SetBorderMode(Short_t bordermode) override
Definition TPad.h:343
void PaintBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Option_t *option="") override
Paint box in CurrentPad World coordinates.
Definition TPad.cxx:3800
void DrawClassObject(const TObject *obj, Option_t *option="") override
Draw class inheritance tree of the class to which obj belongs.
Definition TPad.cxx:1618
Int_t fCGny
! Size of the collide grid along y
Definition TPad.h:126
Double_t fXlowNDC
X bottom left corner of pad in NDC [0,1].
Definition TPad.h:68
TObject * GetPrimitive(const char *name) const override
Get primitive.
Definition TPad.cxx:2817
Double_t fUxmin
Minimum value on the X axis.
Definition TPad.h:80
Double_t GetAbsHNDC() const override
Definition TPad.h:236
Int_t GetDoubleBuffer() const override
Get doublebuffer mode - 1 by default.
Definition TPad.cxx:2555
std::unique_ptr< TInteractive > fInteractive
! current interactive object
Definition TPad.h:38
void SetBBoxCenter(const TPoint &p) override
Set center of the Pad.
Definition TPad.cxx:7187
Bool_t IsWeb() const override
Is web ?
Definition TPad.cxx:2705
void SetSelected(TObject *obj) override
Set selected.
Definition TPad.cxx:2761
TObject * GetSelected() const override
Get selected.
Definition TPad.cxx:2579
void GetRange(Double_t &x1, Double_t &y1, Double_t &x2, Double_t &y2) override
Return pad world coordinates range.
Definition TPad.cxx:2866
Double_t PixeltoX(Double_t px) override
Convert pixel to X coordinate.
Definition TPad.cxx:7291
void PaintPolyLineNDC(Int_t n, Double_t *x, Double_t *y, Option_t *option="") override
Paint polyline in CurrentPad NDC coordinates.
Definition TPad.cxx:4368
Bool_t IsVertical() const override
Definition TPad.h:290
void PaintPadFrame(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax) override
Paint histogram/graph frame.
Definition TPad.cxx:3639
Double_t GetAbsYlowNDC() const override
Definition TPad.h:234
Double_t fUxmax
Maximum value on the X axis.
Definition TPad.h:82
void AddFirst(TObject *obj, Option_t *opt="", Bool_t modified=kTRUE) override
Add an object as first in list of primitives with specified draw option When.
Definition TPad.cxx:506
Double_t fY2
Y of upper Y coordinate.
Definition TPad.h:45
void PaintTextUrl(Double_t x, Double_t y, const char *text, const char *url) override
Paint text with URL in CurrentPad World coordinates.
Definition TPad.cxx:4556
Double_t fAbsPixeltoYk
Conversion coefficient for absolute pixel to Y World.
Definition TPad.h:64
TVirtualPad * GetSelectedPad() const override
Get selected pad.
Definition TPad.cxx:2588
void PaintPolyLine3D(Int_t n, Double_t *p) override
Paint 3-D polyline in the CurrentPad.
Definition TPad.cxx:4388
TVirtualPad * GetPad(Int_t subpadnumber) const override
Get a pointer to subpadnumber of this pad.
Definition TPad.cxx:2834
Short_t fBorderMode
Bordermode (-1=down, 0 = no border, 1=up)
Definition TPad.h:104
void SetLogx(Int_t value=1) override
Set Lin/Log scale for X.
Definition TPad.cxx:5969
void ReleaseViewer3D(Option_t *type="") override
Release current (external) viewer.
Definition TPad.cxx:7106
void SetCrosshair(Int_t crhair=1) override
Set crosshair active/inactive.
Definition TPad.cxx:6548
void SetDoubleBuffer(Int_t mode=1) override
Set double buffer mode ON or OFF.
Definition TPad.cxx:2753
Int_t fNextPaletteColor
Next automatic color.
Definition TPad.h:123
void SetBBoxCenterX(const Int_t x) override
Set X coordinate of the center of the Pad.
Definition TPad.cxx:7200
Int_t GetLogx() const override
Definition TPad.h:269
TObject * fPadPointer
! free pointer
Definition TPad.h:119
Double_t GetX2() const override
Definition TPad.h:254
TObject * CreateToolTip(const TBox *b, const char *text, Long_t delayms) override
Create a tool tip and return its pointer.
Definition TPad.cxx:6975
Double_t GetWNDC() const override
Get width of pad along X in Normalized Coordinates (NDC)
Definition TPad.h:226
void Pop() override
Pop pad to the top of the stack.
Definition TPad.cxx:4724
Double_t GetAbsXlowNDC() const override
Definition TPad.h:233
Int_t IncrementPaletteColor(Int_t i, const TString &opt) override
Increment (i==1) or set (i>1) the number of autocolor in the pad.
Definition TPad.cxx:2961
Double_t GetX1() const override
Definition TPad.h:253
Double_t GetHNDC() const override
Get height of pad along Y in Normalized Coordinates (NDC)
Definition TPad.h:228
TPad * fMother
! pointer to mother of the list
Definition TPad.h:111
const char * GetName() const override
Returns name of object.
Definition TPad.h:273
Int_t XtoAbsPixel(Double_t x) const override
Convert X coordinate to absolute pixel.
Definition TPad.cxx:7395
Bool_t fGridy
Set to true if grid along Y.
Definition TPad.h:107
void SetBBoxY2(const Int_t y) override
Set bottom of BoundingBox to a value (resize in y direction on bottom)
Definition TPad.cxx:7259
Double_t XtoPad(Double_t x) const override
Convert x from X to pad.
Definition TPad.cxx:3421
The histogram statistics painter class.
Definition TPaveStats.h:18
A Pave (see TPave) with text, lines or/and boxes inside.
Definition TPaveText.h:21
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
virtual TLine * AddLine(Double_t x1=0, Double_t y1=0, Double_t x2=0, Double_t y2=0)
Add a new graphics line to this pavetext.
virtual TBox * AddBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Add a new graphics box to this pavetext.
void Draw(Option_t *option="") override
Draw this pavetext with its current attributes.
Int_t GetBorderSize() const
Definition TPave.h:56
virtual void SetBorderSize(Int_t bordersize=4)
Sets the border size of the TPave box and shadow.
Definition TPave.h:79
static TClass * Class()
TPluginHandler * FindHandler(const char *base, const char *uri=nullptr)
Returns the handler if there exists a handler for the specified URI.
SCoord_t fY
Definition TPoint.h:36
SCoord_t fX
Definition TPoint.h:35
SCoord_t GetY() const
Definition TPoint.h:47
SCoord_t GetX() const
Definition TPoint.h:46
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition TROOT.cxx:3060
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:3068
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition TROOT.cxx:2917
Basic string class.
Definition TString.h:137
Ssiz_t Length() const
Definition TString.h:426
void ToLower()
Change string to lower-case.
Definition TString.cxx:1190
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2325
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1122
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Definition TString.h:704
const char * Data() const
Definition TString.h:385
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:714
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Definition TString.cxx:1160
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:633
TString & Prepend(const char *cs)
Definition TString.h:683
virtual void Streamer(TBuffer &)
Stream a string object.
Definition TString.cxx:1493
TString & Append(const char *cs)
Definition TString.h:582
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2460
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2438
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:642
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:661
Int_t GetOptLogy() const
Definition TStyle.h:250
void SetPadBorderMode(Int_t mode=1)
Definition TStyle.h:361
void SetPadTopMargin(Float_t margin=0.1)
Definition TStyle.h:363
void SetOptLogx(Int_t logx=1)
Definition TStyle.h:333
void SetPadBottomMargin(Float_t margin=0.1)
Definition TStyle.h:362
Int_t GetOptTitle() const
Definition TStyle.h:248
Int_t GetPadTickX() const
Definition TStyle.h:219
Bool_t IsReading() const
Definition TStyle.h:300
Color_t GetPadColor() const
Definition TStyle.h:210
void SetPadRightMargin(Float_t margin=0.1)
Definition TStyle.h:365
void SetTitleFont(Style_t font=62, Option_t *axis="X")
Definition TStyle.cxx:1776
Float_t GetPadRightMargin() const
Definition TStyle.h:216
void SetTitleBorderSize(Width_t size=2)
Definition TStyle.h:412
Float_t GetDateX() const
Definition TStyle.h:199
Style_t GetTitleFont(Option_t *axis="X") const
Return title font.
Definition TStyle.cxx:1217
void SetPadTickY(Int_t ticky)
Definition TStyle.h:369
Color_t GetTitleFillColor() const
Definition TStyle.h:273
void SetPadTickX(Int_t tickx)
Definition TStyle.h:368
Int_t GetOptDate() const
Definition TStyle.h:244
Bool_t GetPadGridY() const
Definition TStyle.h:218
void SetPadGridX(Bool_t gridx)
Definition TStyle.h:366
void SetTitleTextColor(Color_t color=1)
Definition TStyle.h:409
Float_t GetPadLeftMargin() const
Definition TStyle.h:215
Double_t GetHatchesSpacing() const
Definition TStyle.h:203
Bool_t GetPadGridX() const
Definition TStyle.h:217
void SetPadLeftMargin(Float_t margin=0.1)
Definition TStyle.h:364
void SetPadGridY(Bool_t gridy)
Definition TStyle.h:367
void SetOptLogy(Int_t logy=1)
Definition TStyle.h:334
Int_t GetOptFile() const
Definition TStyle.h:245
TAttText * GetAttDate()
Definition TStyle.h:170
Int_t GetPadTickY() const
Definition TStyle.h:220
Width_t GetPadBorderSize() const
Definition TStyle.h:211
Width_t GetTitleBorderSize() const
Definition TStyle.h:277
Int_t GetColorPalette(Int_t i) const
Return color number i in current palette.
Definition TStyle.cxx:1102
void SetTitleFillColor(Color_t color=1)
Definition TStyle.h:408
Float_t GetPadBottomMargin() const
Definition TStyle.h:213
void SetOptLogz(Int_t logz=1)
Definition TStyle.h:335
void SetPadColor(Color_t color=19)
Definition TStyle.h:359
Color_t GetTitleTextColor() const
Definition TStyle.h:274
Int_t GetOptLogx() const
Definition TStyle.h:249
Float_t GetDateY() const
Definition TStyle.h:200
Int_t GetPadBorderMode() const
Definition TStyle.h:212
Int_t GetNumberOfColors() const
Return number of colors in the color palette.
Definition TStyle.cxx:1176
Int_t GetOptLogz() const
Definition TStyle.h:251
void SetPadBorderSize(Width_t size=1)
Definition TStyle.h:360
Int_t GetHatchesLineWidth() const
Definition TStyle.h:202
Float_t GetPadTopMargin() const
Definition TStyle.h:214
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1296
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:656
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition TSystem.cxx:1318
virtual int Rename(const char *from, const char *to)
Rename a file.
Definition TSystem.cxx:1372
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:440
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:419
Base class for several text objects.
Definition TText.h:22
void Paint(Option_t *option="") override
Paint this text with its current attributes.
Definition TText.cxx:662
virtual void SetNDC(Bool_t isNDC=kTRUE)
Set NDC mode on if isNDC = kTRUE, off otherwise.
Definition TText.cxx:796
See TView3D.
Definition TView.h:25
virtual void WCtoNDC(const Float_t *pw, Float_t *pn)=0
virtual Int_t GetDistancetoAxis(Int_t axis, Int_t px, Int_t py, Double_t &ratio)=0
virtual void ResizePad()=0
virtual void GetRange(Float_t *min, Float_t *max)=0
Provides 3D viewer interface (TVirtualViewer3D) support on a pad.
TVirtualPS is an abstract interface to Postscript, PDF, SVG.
Definition TVirtualPS.h:32
virtual void NewPage()=0
virtual void Open(const char *filename, Int_t type=-111)=0
virtual void DrawFrame(Double_t xl, Double_t yl, Double_t xt, Double_t yt, Int_t mode, Int_t border, Int_t dark, Int_t light)=0
To make it possible to use GL for 2D graphic in a TPad/TCanvas.
virtual void SetAttFill(const TAttFill &att)
Set fill attributes.
virtual void DrawPolyLine(Int_t n, const Double_t *x, const Double_t *y)=0
virtual void DestroyDrawable(Int_t device)=0
virtual void DrawFillArea(Int_t n, const Double_t *x, const Double_t *y)=0
virtual void SetAttLine(const TAttLine &att)
Set line attributes.
virtual void DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v)=0
virtual void SelectDrawable(Int_t device)=0
virtual void InvalidateCS()
Empty definition.
small helper class to store/restore gPad context in TPad methods
Definition TVirtualPad.h:58
void PadDeleted(TVirtualPad *pad)
Inform context that pad deleted or will be deleted soon Reference on that pad should be cleared.
Helper class to store interactive parameters for individual objects Should be used via MakeInteractiv...
Definition TVirtualPad.h:72
void SetObject(TObject *obj)
Definition TVirtualPad.h:78
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:53
virtual Int_t YtoAbsPixel(Double_t y) const =0
virtual Double_t GetX2() const =0
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
virtual Int_t XtoAbsPixel(Double_t x) const =0
virtual Double_t GetY1() const =0
virtual Int_t GetNumber() const =0
T * GetInteractive(TObject *obj)
void Streamer(TBuffer &) override
Stream an object of class TVirtualPad.
static TClass * Class()
T * MakeInteractive(TObject *obj, Rest &&... rest)
virtual void ShowGuidelines(TObject *object, const Int_t event, const char mode='i', const bool cling=true)=0
virtual void RangeAxisChanged()
virtual Double_t GetY2() const =0
virtual void GetRange(Double_t &x1, Double_t &y1, Double_t &x2, Double_t &y2)=0
Bool_t fResizing
!true when resizing the pad
Definition TVirtualPad.h:84
virtual Bool_t IsEditable() const =0
void FreeInteractive(TObject *obj)
Release interactive instance for specified object.
virtual Double_t GetX1() const =0
Abstract 3D shapes viewer.
virtual Bool_t BuildingScene() const =0
virtual void EndScene()=0
static TVirtualViewer3D * Viewer3D(TVirtualPad *pad=nullptr, Option_t *type="")
Create a Viewer 3D of specified type.
virtual void PadPaint(TVirtualPad *)
virtual void BeginScene()=0
virtual Bool_t CanLoopOnPrimitives() const
A TBox with a bordersize and a bordermode.
Definition TWbox.h:20
Short_t GetBorderSize() const
Definition TWbox.h:41
Short_t GetBorderMode() const
Definition TWbox.h:40
virtual void SetBorderMode(Short_t bordermode)
Definition TWbox.h:54
virtual void SetBorderSize(Short_t bordersize)
Definition TWbox.h:55
TPaveText * pt
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition fillpatterns.C:1
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
TGraphErrors * gr
Definition legend1.C:25
Double_t ex[n]
Definition legend1.C:17
TH1F * h1
Definition legend1.C:5
leg
Definition legend1.C:34
R__ALWAYS_INLINE bool HasBeenDeleted(const TObject *obj)
Check if the TObject's memory has been deleted.
Definition TObject.h:409
void CallRecursiveRemoveIfNeeded(TObject &obj)
call RecursiveRemove for obj if gROOT is valid and obj.TestBit(kMustCleanup) is true.
Definition TROOT.h:406
Bool_t IsNaN(Double_t x)
Definition TMath.h:905
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition TMath.h:706
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
Double_t Exp(Double_t x)
Returns the base-e exponential function of x, which is e raised to the power x.
Definition TMath.h:722
Double_t Floor(Double_t x)
Rounds x downward, returning the largest integral value that is not greater than x.
Definition TMath.h:693
Double_t Ceil(Double_t x)
Rounds x upward, returning the smallest integral value that is not less than x.
Definition TMath.h:681
Int_t Finite(Double_t x)
Check if it is finite with a mask in order to be consistent in presence of fast math.
Definition TMath.h:783
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Definition TMath.h:769
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:675
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Definition TMath.h:734
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:607
constexpr Double_t Pi()
Definition TMath.h:40
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:601
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Definition TMath.h:775
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122
Rectangle structure (maps to the X11 XRectangle structure)
Definition GuiTypes.h:362
Short_t fX
Definition GuiTypes.h:363
UShort_t fHeight
Definition GuiTypes.h:364
Short_t fY
Definition GuiTypes.h:363
UShort_t fWidth
Definition GuiTypes.h:364
struct used by ShowGuidelines to store the distance Field between objects in the canvas.
Definition TPad.cxx:6203
TAttBBox2D * fb
Definition TPad.cxx:6205
dField()
Definition TPad.cxx:6210
char fdir
Definition TPad.cxx:6207
dField(TAttBBox2D *a, TAttBBox2D *b, Int_t dist, char direction)
Definition TPad.cxx:6214
TAttBBox2D * fa
Definition TPad.cxx:6204
Int_t fdist
Definition TPad.cxx:6206
TMarker m
Definition textangle.C:8