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