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