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