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