ROOT  6.06/09
Reference Guide
TPave.cxx
Go to the documentation of this file.
1 // @(#)root/graf:$Id$
2 // Author: Rene Brun 16/10/95
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 "Riostream.h"
13 #include "TROOT.h"
14 #include "TPave.h"
15 #include "TStyle.h"
16 #include "TVirtualPad.h"
17 #include "TClass.h"
18 #include "TMath.h"
19 
21 
22 /** \class TPave
23 \ingroup BasicGraphics
24 
25 A TBox with a bordersize and a shadow option.
26 The corners of a TPave can be rounded (option "arc")
27 More functional objects like TPavelabel, TPaveText derive from TPave.
28 
29 \image html graf_pave.png
30 */
31 
32 ////////////////////////////////////////////////////////////////////////////////
33 /// Pave default constructor.
34 
35 TPave::TPave(): TBox()
36 {
37  fBorderSize = 4;
38  fOption = "brNDC";
39  fName = "";
40  fInit = 1;
41  fCornerRadius = 0;
42  fX1NDC = 0;
43  fY1NDC = 0;
44  fX2NDC = 0;
45  fY2NDC = 0;
50  fShadowColor = GetLineColor();
51 }
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 /// Pave normal constructor.
55 ///
56 /// a PAVE is a box with a bordersize and a shadow option the border
57 /// size is in pixels.
58 ///
59 /// - option = "TR" Top and Right shadows are drawn.
60 /// - option = "TL" Top and Left shadows are drawn.
61 /// - option = "BR" Bottom and Right shadows are drawn.
62 /// - option = "BL" Bottom and Left shadows are drawn.
63 ///
64 /// If none of these four above options is specified the default the
65 /// option "BR" will be used to draw the border. To produces a pave
66 /// without any border it is enough to specify the option "NB" (no border).
67 ///
68 /// - option = "NDC" x1,y1,x2,y2 are given in NDC
69 /// - option = "ARC" corners are rounded
70 ///
71 /// In case of option "ARC", the corner radius is specified
72 /// via TPave::SetCornerRadius(rad) where rad is given in percent
73 /// of the pave height (default value is 0.2).
74 
76  Int_t bordersize ,Option_t *option)
77  :TBox(x1,y1,x2,y2)
78 {
79  fBorderSize = bordersize;
80  fOption = option;
81  fName = "";
82  fInit = 0;
83  fCornerRadius = 0;
84  if (fOption == "NDC" || fOption == "ndc") fOption = "brNDC";
85 
90  SetName((char*)ClassName());
92 }
93 
94 ////////////////////////////////////////////////////////////////////////////////
95 /// Pave default destructor.
96 
98 {
99 }
100 
101 ////////////////////////////////////////////////////////////////////////////////
102 /// Pave copy constructor.
103 
104 TPave::TPave(const TPave &pave) : TBox(pave)
105 {
106  fX1NDC = 0.;
107  fY1NDC = 0.;
108  fX2NDC = 0.;
109  fY2NDC = 0.;
110  fCornerRadius = 0.;
111  fBorderSize = 0;
112  fInit = 0;
113  fShadowColor = 0;
114 
115  ((TPave&)pave).TPave::Copy(*this);
116 }
117 
118 ////////////////////////////////////////////////////////////////////////////////
119 /// Convert pave coordinates from NDC to Pad coordinates.
120 
122 {
123  Double_t dpx = gPad->GetX2() - gPad->GetX1();
124  Double_t dpy = gPad->GetY2() - gPad->GetY1();
125  Double_t xp1 = gPad->GetX1();
126  Double_t yp1 = gPad->GetY1();
127 
128  // Check if pave initialisation has been done.
129  // This operation cannot take place in the Pave constructor because
130  // the Pad range may not be known at this time.
131  if (!fInit) {
132  fInit = 1;
133  if (fOption.Contains("NDC")) {
134  fX1NDC = fX1;
135  fY1NDC = fY1;
136  fX2NDC = fX2;
137  fY2NDC = fY2;
138  fX1 = xp1 + fX1NDC*dpx;
139  fY1 = yp1 + fY1NDC*dpy;
140  fX2 = xp1 + fX2NDC*dpx;
141  fY2 = yp1 + fY2NDC*dpy;
142  } else {
143  if (gPad->GetLogx()) {
144  if (fX1 > 0) fX1 = TMath::Log10(fX1);
145  if (fX2 > 0) fX2 = TMath::Log10(fX2);
146  }
147  if (gPad->GetLogy()) {
148  if (fY1 > 0) fY1 = TMath::Log10(fY1);
149  if (fY2 > 0) fY2 = TMath::Log10(fY2);
150  }
151  fX1NDC = (fX1-xp1)/dpx;
152  fY1NDC = (fY1-yp1)/dpy;
153  fX2NDC = (fX2-xp1)/dpx;
154  fY2NDC = (fY2-yp1)/dpy;
155  }
156  } else {
157  fX1 = xp1 + fX1NDC*dpx;
158  fY1 = yp1 + fY1NDC*dpy;
159  fX2 = xp1 + fX2NDC*dpx;
160  fY2 = yp1 + fY2NDC*dpy;
161  }
162 }
163 
164 ////////////////////////////////////////////////////////////////////////////////
165 /// Copy this pave to pave.
166 
167 void TPave::Copy(TObject &obj) const
168 {
169  TBox::Copy(obj);
170  ((TPave&)obj).fX1NDC = fX1NDC;
171  ((TPave&)obj).fY1NDC = fY1NDC;
172  ((TPave&)obj).fX2NDC = fX2NDC;
173  ((TPave&)obj).fY2NDC = fY2NDC;
174  ((TPave&)obj).fBorderSize = fBorderSize;
175  ((TPave&)obj).fInit = fInit;
176  ((TPave&)obj).fOption = fOption;
177  ((TPave&)obj).fName = fName;
178  ((TPave&)obj).fCornerRadius= fCornerRadius;
179  ((TPave&)obj).fShadowColor = fShadowColor;
180 }
181 
182 ////////////////////////////////////////////////////////////////////////////////
183 /// Compute distance from point px,py to a pave.
184 ///
185 /// Compute the closest distance of approach from point px,py to the
186 /// edges of this pave.
187 /// The distance is computed in pixels units.
188 
190 {
191  Int_t pxl, pyl, pxt, pyt;
192  Int_t px1 = gPad->XtoAbsPixel(fX1);
193  Int_t py1 = gPad->YtoAbsPixel(fY1);
194  Int_t px2 = gPad->XtoAbsPixel(fX2);
195  Int_t py2 = gPad->YtoAbsPixel(fY2);
196  if (px1 < px2) {pxl = px1; pxt = px2;}
197  else {pxl = px2; pxt = px1;}
198  if (py1 < py2) {pyl = py1; pyt = py2;}
199  else {pyl = py2; pyt = py1;}
200 
201  // Are we inside the box?
202  if ( (px >= pxl && px <= pxt) && (py >= pyl && py <= pyt) ) return 0;
203  else return 9999;
204 }
205 
206 ////////////////////////////////////////////////////////////////////////////////
207 /// Draw this pave with its current attributes.
208 
209 void TPave::Draw(Option_t *option)
210 {
211  Option_t *opt;
212  if (option && strlen(option)) opt = option;
213  else opt = GetOption();
214 
215  AppendPad(opt);
216 }
217 
218 ////////////////////////////////////////////////////////////////////////////////
219 /// Draw this pave with new coordinates.
220 
222  Int_t bordersize ,Option_t *option)
223 {
224  TPave *newpave = new TPave(x1,y1,x2,y2,bordersize,option);
225  newpave->SetBit(kCanDelete);
226  newpave->AppendPad(option);
227 }
228 
229 ////////////////////////////////////////////////////////////////////////////////
230 /// Execute action corresponding to one event.
231 ///
232 /// This member function is called when a PAVE object is clicked.
233 
235 {
236  if (!gPad) return;
237 
238  if (!gPad->IsEditable()) return;
239 
240  TBox::ExecuteEvent(event, px, py);
241 
242  // In case pave coordinates have been modified, recompute NDC coordinates
243  SetX1(fX1);
244  SetX2(fX2);
245  SetY1(fY1);
246  SetY2(fY2);
247 
248  // In case the bit NameIsAction is activated, execute the action
249  // in name via the interpreter.
250  if (event == kButton1Double) {
251  if (TestBit(kNameIsAction)) gROOT->ProcessLine(GetName());
252  }
253 }
254 
255 ////////////////////////////////////////////////////////////////////////////////
256 /// List this pave with its attributes.
257 
258 void TPave::ls(Option_t *) const
259 {
261  printf("OBJ: %s\t%s \tX1= %f Y1=%f X2=%f Y2=%f\n",IsA()->GetName(),GetName(),fX1,fY1,fX2,fY2);
262 }
263 
264 ////////////////////////////////////////////////////////////////////////////////
265 /// Paint this pave with its current attributes.
266 ///
267 /// - option = "TR" Top and Right shadows are drawn.
268 /// - option = "TL" Top and Left shadows are drawn.
269 /// - option = "BR" Bottom and Right shadows are drawn.
270 /// - option = "BL" Bottom and Left shadows are drawn.
271 ///
272 /// If none of these four above options is specified the default the
273 /// option "BR" will be used to draw the border. To produces a pave
274 /// without any border it is enough to specify the option "NB" (no border).
275 ///
276 /// - option = "NDC" x1,y1,x2,y2 are given in NDC
277 /// - option = "ARC" corners are rounded
278 ///
279 /// In case of option "ARC", the corner radius is specified
280 /// via TPave::SetCornerRadius(rad) where rad is given in percent
281 /// of the pave height (default value is 0.2).
282 
283 void TPave::Paint(Option_t *option)
284 {
285  // Convert from NDC to pad coordinates
286  ConvertNDCtoPad();
287 
288  PaintPave(fX1, fY1, fX2, fY2, fBorderSize, option);
289 }
290 
291 ////////////////////////////////////////////////////////////////////////////////
292 /// Draw this pave with new coordinates.
293 
295  Int_t bordersize ,Option_t *option)
296 {
297  Double_t x[7],y[7];
298  TString opt = option;
299  opt.ToLower();
300  // if pave drawn with the arc option, goes through dedicated function
301  if (opt.Contains("arc")) {
302  PaintPaveArc(x1,y1,x2,y2,bordersize,option);
303  return;
304  }
305 
306  // normal rectangular pave
307  if (opt.Length() == 0) opt ="br";
308  Int_t fillstyle = GetFillStyle();
309  Int_t fillcolor = GetFillColor();
310  Int_t shadowcolor = GetShadowColor();
311 
312  // Draw first pave as a normal filled box
313  if (fBorderSize <= 0 && fillstyle <= 0) return;
314  TBox::PaintBox(x1,y1,x2,y2);
315  if (fBorderSize <= 0) return;
316  if (fBorderSize == 1) {
317  gPad->PaintLine(x1,y1,x2,y1);
318  gPad->PaintLine(x2,y1,x2,y2);
319  gPad->PaintLine(x2,y2,x1,y2);
320  gPad->PaintLine(x1,y2,x1,y1);
321  return;
322  }
323 
324  Double_t wy = gPad->PixeltoY(0) - gPad->PixeltoY(fBorderSize);
325  Double_t wx = gPad->PixeltoX(fBorderSize) - gPad->PixeltoX(0);
326  Int_t mode = 0;
327  //*-*- Draw the frame top right
328  if (opt.Contains("t") && opt.Contains("r")) {
329  mode = 1;
330  x[0] = x1 + 1.5*wx; y[0] = y2;
331  x[1] = x[0]; y[1] = y2 + wy;
332  x[2] = x2 + wx; y[2] = y[1];
333  x[3] = x[2]; y[3] = y1 + 1.5*wy;
334  x[4] = x2; y[4] = y[3];
335  x[5] = x[4]; y[5] = y2;
336  }
337  // Draw the frame top left
338  if (opt.Contains("t") && opt.Contains("l")) {
339  mode = 2;
340  x[0] = x1 - wx; y[0] = y1 + 1.5*wy;
341  x[1] = x[0]; y[1] = y2 + wy;
342  x[2] = x2 - 1.5*wx; y[2] = y[1];
343  x[3] = x[2]; y[3] = y2;
344  x[4] = x1; y[4] = y[3];
345  x[5] = x1; y[5] = y[0];
346  }
347  // Draw the frame bottom right
348  if (opt.Contains("b") && opt.Contains("r")) {
349  mode = 3;
350  x[0] = x1 + 1.5*wx; y[0] = y1;
351  x[1] = x[0]; y[1] = y1 - wy;
352  x[2] = x2 + wx; y[2] = y[1];
353  x[3] = x[2]; y[3] = y2 - 1.5*wy;
354  x[4] = x2; y[4] = y[3];
355  x[5] = x[4]; y[5] = y1;
356  }
357  // Draw the frame bottom left
358  if (opt.Contains("b") && opt.Contains("l")) {
359  mode = 4;
360  x[0] = x1 - wx; y[0] = y2 - 1.5*wy;
361  x[1] = x[0]; y[1] = y1 - wy;
362  x[2] = x2 - 1.5*wx; y[2] = y[1];
363  x[3] = x[2]; y[3] = y1;
364  x[4] = x1; y[4] = y[3];
365  x[5] = x[4]; y[5] = y[0];
366  }
367  if (!mode) return; // nop border mode option specified
368  for (Int_t i=0;i<6;i++) {
369  if (x[i] < gPad->GetX1()) x[i] = gPad->GetX1();
370  if (x[i] > gPad->GetX2()) x[i] = gPad->GetX2();
371  if (y[i] < gPad->GetY1()) y[i] = gPad->GetY1();
372  if (y[i] > gPad->GetY2()) y[i] = gPad->GetY2();
373  }
374  x[6] = x[0]; y[6] = y[0];
375  SetFillStyle(1001);
376  SetFillColor(shadowcolor);
378  gPad->PaintFillArea(6,x,y);
379  x[0] = x1; y[0] = y1;
380  x[1] = x1; y[1] = y2;
381  x[2] = x2; y[2] = y2;
382  x[3] = x2; y[3] = y1;
383  x[4] = x1; y[4] = y1;
384  gPad->PaintPolyLine(5,x,y);
385  SetFillStyle(fillstyle);
386  SetFillColor(fillcolor);
387 }
388 
389 ////////////////////////////////////////////////////////////////////////////////
390 /// Draw this pave with rounded corners.
391 
393  Int_t, Option_t *option)
394 {
395  const Int_t kNPARC = 10;
396  Double_t x[4*kNPARC+10], y[4*kNPARC+10];
397  Double_t px[4*kNPARC+10], py[4*kNPARC+10];
398  Int_t i;
399  TString opt = option;
400  opt.ToLower();
401  if (opt.Length() == 0) opt ="br";
402  Int_t fillstyle = GetFillStyle();
403  Int_t fillcolor = GetFillColor();
404  Int_t shadowcolor = GetShadowColor();
405 
406  static Double_t cosa[kNPARC], sina[kNPARC];
407  static Bool_t done = kFALSE;
408  if (!done) {
409  done = kTRUE;
410  Double_t dtheta = 0.5*3.141592/(kNPARC+1);
411  Double_t theta = 0;
412  for (i=0;i<kNPARC;i++) {
413  theta += dtheta;
414  cosa[i] = TMath::Cos(theta);
415  sina[i] = TMath::Sin(theta);
416  }
417  }
418  Int_t px1 = gPad->XtoAbsPixel(x1);
419  Int_t py1 = gPad->YtoAbsPixel(y1);
420  Int_t px2 = gPad->XtoAbsPixel(x2);
421  Int_t py2 = gPad->YtoAbsPixel(y2);
422  // compute rounded corner radius
423  Double_t rad = fCornerRadius;
424  if (rad > 0 && rad < 0.5) rad = fCornerRadius;
425  else rad = 0.2;
426  Double_t r = rad*TMath::Abs(py1-py2);
427  if (r > 0.5*TMath::Abs(px2-px1)) r = 0.5*TMath::Abs(px2-px1);
428  if (r == 0) r = 1;
429 
430  // Draw rounded box outline and fill area
431  px[0] = px2; py[0] = py1 - r; //starts at bottom right
432  px[1] = px2; py[1] = py2 + r;
433  Int_t np = 2;
434  for (i=0;i<kNPARC;i++) { //top right corner
435  px[np] = px2 - r + r*cosa[i];
436  py[np] = py2 + r - r*sina[i];
437  np++;
438  }
439  px[np] = px2 - r; py[np] = py2;
440  px[np+1] = px1 + r; py[np+1] = py2;
441  np += 2;
442  for (i=kNPARC-1;i>=0;i--) { //top left corner
443  px[np] = px1 + r - r*cosa[i];
444  py[np] = py2 + r - r*sina[i];
445  np++;
446  }
447  px[np] = px1; py[np] = py2 + r;
448  px[np+1] = px1; py[np+1] = py1 - r;
449  np += 2;
450  for (i=0;i<kNPARC;i++) { //bottom left corner
451  px[np] = px1 + r - r*cosa[i];
452  py[np] = py1 - r + r*sina[i];
453  np++;
454  }
455  px[np] = px1 + r; py[np] = py1;
456  px[np+1] = px2 - r; py[np+1] = py1;
457  np += 2;
458  for (i=kNPARC-1;i>=0;i--) { //bottom right corner
459  px[np] = px2 - r + r*cosa[i];
460  py[np] = py1 - r + r*sina[i];
461  np++;
462  }
463  px[np] = px[0]; py[np] =py[0];
466  for (i=0;i<=np;i++) {
467  x[i] = gPad->AbsPixeltoX(Int_t(px[i]));
468  y[i] = gPad->AbsPixeltoY(Int_t(py[i]));
469  }
470  gPad->PaintFillArea(np , x, y);
471  gPad->PaintPolyLine(np+1, x, y);
472 
473 
474  if (fBorderSize <= 0) return;
475 
476  Double_t wy = fBorderSize;
477  Double_t wx = fBorderSize;
478  // Draw the frame top right
479  if (opt.Contains("tr")) {
480  px[0] = px2; py[0] = py1 - r;
481  px[1] = px2; py[1] = py2 + r;
482  np = 2;
483  for (i=0;i<kNPARC;i++) { //top right corner inside
484  px[np] = px2 - r + r*cosa[i];
485  py[np] = py2 + r - r*sina[i];
486  np++;
487  }
488  px[np] = px2 - r; py[np] = py2;
489  px[np+1] = px1 + r; py[np+1] = py2;
490  px[np+2] = px1 + r; py[np+2] = py2 - wy;
491  px[np+3] = px2 - r; py[np+3] = py2 - wy;
492  np += 4;
493  for (i=kNPARC-1;i>=0;i--) { //top right corner outside
494  px[np] = px2 - r + r*cosa[i]*(1+wx/r);
495  py[np] = py2 + r - r*sina[i]*(1+wy/r);
496  np++;
497  }
498  px[np] = px2 + wx; py[np] = py2 + r;
499  px[np+1] = px2 + wx; py[np+1] = py1 - r;
500  px[np+2] = px[0]; py[np+2] = py[0];
501  np += 3;
502  }
503  // Draw the frame top left
504  if (opt.Contains("tl")) {
505  px[0] = px2 - r; py[0] = py2;
506  px[1] = px1 + r; py[1] = py2;
507  np = 2;
508  for (i=kNPARC-1;i>=0;i--) { //top left corner inside
509  px[np] = px1 + r - r*cosa[i];
510  py[np] = py2 + r - r*sina[i];
511  np++;
512  }
513  px[np] = px1; py[np] = py2 + r;
514  px[np+1] = px1; py[np+1] = py1 - r;
515  px[np+2] = px1 - wx; py[np+2] = py1 - r;
516  px[np+3] = px1 - wx; py[np+3] = py2 + r;
517  np += 4;
518  for (i=0;i<kNPARC;i++) { //top left corner outside
519  px[np] = px1 + r - r*cosa[i]*(1+wx/r);
520  py[np] = py2 + r - r*sina[i]*(1+wy/r);
521  np++;
522  }
523  px[np] = px1 + r; py[np] = py2 - wy;
524  px[np+1] = px2 - r; py[np+1] = py2 - wy;
525  px[np+2] = px[0]; py[np+2] = y[0];
526  np += 3;
527  }
528  // Draw the frame bottom right
529  if (opt.Contains("br")) {
530  px[0] = px1 + r; py[0] = py1;
531  px[1] = px2 - r; py[1] = py1;
532  np = 2;
533  for (i=kNPARC-1;i>=0;i--) { //bottom right corner inside
534  px[np] = px2 - r + r*cosa[i];
535  py[np] = py1 - r + r*sina[i];
536  np++;
537  }
538  px[np] = px2; py[np] = py1 - r;
539  px[np+1] = px2; py[np+1] = py2 + r;
540  px[np+2] = px2 + wx; py[np+2] = py2 + r;
541  px[np+3] = px2 + wx; py[np+3] = py1 - r;
542  np += 4;
543  for (i=0;i<kNPARC;i++) { //bottom right corner outside
544  px[np] = px2 - r + r*cosa[i]*(1+wx/r);
545  py[np] = py1 - r + r*sina[i]*(1+wy/r);
546  np++;
547  }
548  px[np] = px2 - r; py[np] = py1 + wy;
549  px[np+1] = px[0]; py[np+1] = py[0] + wy;
550  px[np+2] = px[0]; py[np+2] = py[0];
551  np += 3;
552  }
553  // Draw the frame bottom left
554  if (opt.Contains("bl")) {
555  px[0] = px1; py[0] = py2 + r;
556  px[1] = px1; py[1] = py1 - r;
557  np = 2;
558  for (i=0;i<kNPARC;i++) { //bottom left corner inside
559  px[np] = px1 + r - r*cosa[i];
560  py[np] = py1 + r - r*sina[i];
561  np++;
562  }
563  px[np] = px1 + r; py[np] = py1;
564  px[np+1] = px2 - r; py[np+1] = py1;
565  px[np+2] = px2 - r; py[np+2] = py1 + wy;
566  px[np+3] = px1 + r; py[np+3] = py1 + wy;
567  np += 4;
568  for (i=kNPARC-1;i>=0;i--) { //bottom left corner outside
569  px[np] = px1 + r - r*cosa[i]*(1+wx/r);
570  py[np] = py1 - r + r*sina[i]*(1+wy/r);
571  np++;
572  }
573  px[np] = px1 - wx; py[np] = py1 - r;
574  px[np+1] = px1 - wx; py[np+1] = py[0];
575  px[np+2] = px[0]; py[np+2] = py[0];
576  np += 3;
577  }
578  SetFillStyle(1001);
579  SetFillColor(shadowcolor);
581  for (i=0;i<=np;i++) {
582  x[i] = gPad->AbsPixeltoX(Int_t(px[i]));
583  y[i] = gPad->AbsPixeltoY(Int_t(py[i]));
584  }
585  gPad->PaintFillArea(np,x,y);
586  SetFillStyle(fillstyle);
587  SetFillColor(fillcolor);
588 }
589 
590 ////////////////////////////////////////////////////////////////////////////////
591 /// Dump this pave with its attributes.
592 
593 void TPave::Print(Option_t *option) const
594 {
595  TBox::Print(option);
596 }
597 
598 ////////////////////////////////////////////////////////////////////////////////
599 /// Save primitive as a C++ statement(s) on output stream out
600 
601 void TPave::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
602 {
603  char quote = '"';
604  if (gROOT->ClassSaved(TPave::Class())) {
605  out<<" ";
606  } else {
607  out<<" TPave *";
608  }
609  if (fOption.Contains("NDC")) {
610  out<<"pave = new TPave("<<fX1NDC<<","<<fY1NDC<<","<<fX2NDC<<","<<fY2NDC
611  <<","<<fBorderSize<<","<<quote<<fOption<<quote<<");"<<std::endl;
612  } else {
613  out<<"pave = new TPave("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2
614  <<","<<fBorderSize<<","<<quote<<fOption<<quote<<");"<<std::endl;
615  }
616  if (strcmp(GetName(),"TPave")) {
617  out<<" pave->SetName("<<quote<<GetName()<<quote<<");"<<std::endl;
618  }
619  if (fCornerRadius) {
620  out<<" pave->SetCornerRadius("<<fCornerRadius<<");"<<std::endl;
621  }
622  SaveFillAttributes(out,"pave",19,1001);
623  SaveLineAttributes(out,"pave",1,1,1);
624  out<<" pave->Draw();"<<std::endl;
625 }
626 
627 ////////////////////////////////////////////////////////////////////////////////
628 /// Set the X1 value
629 
631 {
632  fX1 = x1;
633  if (gPad) {
634  Double_t dpx = gPad->GetX2() - gPad->GetX1();
635  Double_t xp1 = gPad->GetX1();
636  fX1NDC = (fX1-xp1)/dpx;
637  }
638 }
639 
640 ////////////////////////////////////////////////////////////////////////////////
641 /// Set the X2 value
642 
644 {
645  fX2 = x2;
646  if (gPad) {
647  Double_t dpx = gPad->GetX2() - gPad->GetX1();
648  Double_t xp1 = gPad->GetX1();
649  fX2NDC = (fX2-xp1)/dpx;
650  }
651 }
652 
653 ////////////////////////////////////////////////////////////////////////////////
654 /// Set the Y1 value
655 
657 {
658  fY1 = y1;
659  if (gPad) {
660  Double_t dpy = gPad->GetY2() - gPad->GetY1();
661  Double_t yp1 = gPad->GetY1();
662  fY1NDC = (fY1-yp1)/dpy;
663  }
664 }
665 
666 ////////////////////////////////////////////////////////////////////////////////
667 /// Set the Y2 value
668 
670 {
671  fY2 = y2;
672  if (gPad) {
673  Double_t dpy = gPad->GetY2() - gPad->GetY1();
674  Double_t yp1 = gPad->GetY1();
675  fY2NDC = (fY2-yp1)/dpy;
676  }
677 }
678 
679 ////////////////////////////////////////////////////////////////////////////////
680 /// Stream an object of class TPave.
681 
682 void TPave::Streamer(TBuffer &R__b)
683 {
684  if (R__b.IsReading()) {
685  UInt_t R__s, R__c;
686  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
687  if (R__v > 1) {
688  R__b.ReadClassBuffer(TPave::Class(), this, R__v, R__s, R__c);
689  return;
690  }
691  //====process old versions before automatic schema evolution
692  TBox::Streamer(R__b);
693  Float_t x1ndc,y1ndc,x2ndc,y2ndc,rad;
694  R__b >> x1ndc; fX1NDC = x1ndc;
695  R__b >> y1ndc; fY1NDC = y1ndc;
696  R__b >> x2ndc; fX2NDC = x2ndc;
697  R__b >> y2ndc; fY2NDC = y2ndc;
698  R__b >> fBorderSize;
699  R__b >> fInit;
700  R__b >> rad; fCornerRadius = rad;
701  fOption.Streamer(R__b);
702  fName.Streamer(R__b);
703  R__b.CheckByteCount(R__s, R__c, TPave::IsA());
704  //====end of old versions
705 
706  } else {
707  R__b.WriteClassBuffer(TPave::Class(),this);
708  }
709 }
void Copy(TObject &box) const
Copy a Box.
Definition: TBox.cxx:111
virtual Style_t GetLineStyle() const
Definition: TAttLine.h:48
virtual Style_t GetFillStyle() const
Definition: TAttFill.h:44
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual void SetName(const char *name="")
Definition: TPave.h:84
Bool_t IsReading() const
Definition: TBuffer.h:81
short Version_t
Definition: RtypesCore.h:61
Ssiz_t Length() const
Definition: TString.h:390
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TBox.cxx:216
TString fName
Definition: TPave.h:43
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
Int_t GetShadowColor() const
Definition: TPave.h:67
Double_t fY2
Definition: TBox.h:53
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
#define gROOT
Definition: TROOT.h:340
Basic string class.
Definition: TString.h:137
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1088
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void SetFillStyle(Style_t fstyle)
Definition: TAttFill.h:52
void Copy(TObject &pave) const
Copy this pave to pave.
Definition: TPave.cxx:167
virtual void Modify()
Change current line attributes if necessary.
Definition: TAttLine.cxx:229
Short_t Abs(Short_t d)
Definition: TMathBase.h:110
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:732
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:164
A TBox with a bordersize and a shadow option.
Definition: TPave.h:31
virtual void ConvertNDCtoPad()
Convert pave coordinates from NDC to Pad coordinates.
Definition: TPave.cxx:121
Double_t fY1
Definition: TBox.h:51
virtual void SetY2(Double_t y2)
Set the Y2 value.
Definition: TPave.cxx:669
static const double x2[5]
Double_t x[n]
Definition: legend1.C:17
Double_t fX1NDC
Definition: TPave.h:34
void Class()
Definition: Class.C:29
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
Definition: TAttLine.cxx:257
virtual void Modify()
Change current fill area attributes if necessary.
Definition: TAttFill.cxx:206
Double_t Log10(Double_t x)
Definition: TMath.h:529
virtual ~TPave()
Pave default destructor.
Definition: TPave.cxx:97
lv SetLineColor(kBlue)
char * out
Definition: TBase64.cxx:29
virtual void PaintPaveArc(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Int_t bordersize=4, Option_t *option="br")
Draw this pave with rounded corners.
Definition: TPave.cxx:392
Option_t * GetOption() const
Definition: TPave.h:66
virtual void ls(Option_t *option="") const
List this pave with its attributes.
Definition: TPave.cxx:258
virtual void SetLineColor(Color_t lcolor)
Definition: TAttLine.h:54
ROOT::R::TRInterface & r
Definition: Object.C:4
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
a SetFillStyle(0)
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:187
Double_t fX2
Definition: TBox.h:52
virtual void SetX1(Double_t x1)
Set the X1 value.
Definition: TPave.cxx:630
virtual Color_t GetFillColor() const
Definition: TAttFill.h:43
h1 SetFillColor(kGreen)
TClass * IsA() const
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
Definition: TAttFill.cxx:229
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:173
Double_t fX1
tool tip associated with box
Definition: TBox.h:50
virtual void Paint(Option_t *option="")
Paint this pave with its current attributes.
Definition: TPave.cxx:283
Option_t * GetName() const
Returns name of object.
Definition: TPave.h:65
virtual Color_t GetLineColor() const
Definition: TAttLine.h:47
Int_t fBorderSize
Definition: TPave.h:38
virtual void Print(Option_t *option="") const
Dump this box with its attributes.
Definition: TBox.cxx:645
virtual void PaintBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Option_t *option="")
Draw this box with new coordinates.
Definition: TBox.cxx:627
Double_t Cos(Double_t)
Definition: TMath.h:424
Double_t fCornerRadius
Definition: TPave.h:41
virtual void Draw(Option_t *option="")
Draw this pave with its current attributes.
Definition: TPave.cxx:209
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual void SetY1(Double_t y1)
Set the Y1 value.
Definition: TPave.cxx:656
Double_t fY2NDC
Definition: TPave.h:37
static const double x1[5]
#define ClassImp(name)
Definition: Rtypes.h:279
Int_t fShadowColor
Definition: TPave.h:40
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TPave.cxx:234
double Double_t
Definition: RtypesCore.h:55
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a pave.
Definition: TPave.cxx:189
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
virtual void Print(Option_t *option="") const
Dump this pave with its attributes.
Definition: TPave.cxx:593
Double_t y[n]
Definition: legend1.C:17
Double_t fX2NDC
Definition: TPave.h:36
virtual void SetLineStyle(Style_t lstyle)
Definition: TAttLine.h:56
virtual void SetX2(Double_t x2)
Set the X2 value.
Definition: TPave.cxx:643
Mother of all ROOT objects.
Definition: TObject.h:58
virtual void DrawPave(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Int_t bordersize=4, Option_t *option="br")
Draw this pave with new coordinates.
Definition: TPave.cxx:221
lv SetLineStyle(3)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
Int_t fInit
Definition: TPave.h:39
Double_t Sin(Double_t)
Definition: TMath.h:421
#define gPad
Definition: TVirtualPad.h:288
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition: TROOT.cxx:2461
Double_t fY1NDC
Definition: TPave.h:35
virtual void PaintPave(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Int_t bordersize=4, Option_t *option="br")
Draw this pave with new coordinates.
Definition: TPave.cxx:294
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TPave.cxx:601
TString fOption
Definition: TPave.h:42
const Bool_t kTRUE
Definition: Rtypes.h:91
TObject * obj
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0