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