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