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