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