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;
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 if (!gPad) return 9999;
211 Int_t pxl, pyl, pxt, pyt;
212 Int_t px1 = gPad->XtoAbsPixel(fX1);
213 Int_t py1 = gPad->YtoAbsPixel(fY1);
214 Int_t px2 = gPad->XtoAbsPixel(fX2);
215 Int_t py2 = gPad->YtoAbsPixel(fY2);
216 if (px1 < px2) {pxl = px1; pxt = px2;}
217 else {pxl = px2; pxt = px1;}
218 if (py1 < py2) {pyl = py1; pyt = py2;}
219 else {pyl = py2; pyt = py1;}
220
221 // Are we inside the box?
222 if ( (px >= pxl && px <= pxt) && (py >= pyl && py <= pyt) ) return 0;
223 else return 9999;
224}
225
226////////////////////////////////////////////////////////////////////////////////
227/// Draw this pave with its current attributes.
228
230{
231 Option_t *opt;
232 if (option && strlen(option)) opt = option;
233 else opt = GetOption();
234
235 AppendPad(opt);
236}
237
238////////////////////////////////////////////////////////////////////////////////
239/// Draw this pave with new coordinates.
240
242 Int_t bordersize ,Option_t *option)
243{
244 TPave *newpave = new TPave(x1,y1,x2,y2,bordersize,option);
245 newpave->SetBit(kCanDelete);
246 newpave->AppendPad(option);
247 return newpave;
248}
249
250////////////////////////////////////////////////////////////////////////////////
251/// Execute action corresponding to one event.
252///
253/// This member function is called when a PAVE object is clicked.
254
256{
257 if (!gPad) return;
258
259 if (!gPad->IsEditable()) return;
260
261 TBox::ExecuteEvent(event, px, py);
262
263 // In case pave coordinates have been modified, recompute NDC coordinates
264 SetX1(fX1);
265 SetX2(fX2);
266 SetY1(fY1);
267 SetY2(fY2);
268
269 // In case the bit NameIsAction is activated, execute the action
270 // in name via the interpreter.
271 if (event == kButton1Double) {
272 if (TestBit(kNameIsAction)) gROOT->ProcessLine(GetName());
273 }
274}
275
276////////////////////////////////////////////////////////////////////////////////
277/// List this pave with its attributes.
278
279void TPave::ls(Option_t *) const
280{
282 printf("OBJ: %s\t%s \tX1= %f Y1=%f X2=%f Y2=%f\n",IsA()->GetName(),GetName(),fX1,fY1,fX2,fY2);
283}
284
285////////////////////////////////////////////////////////////////////////////////
286/// Paint this pave with its current attributes.
287///
288/// - option = "TR" Top and Right shadows are drawn.
289/// - option = "TL" Top and Left shadows are drawn.
290/// - option = "BR" Bottom and Right shadows are drawn.
291/// - option = "BL" Bottom and Left shadows are drawn.
292///
293/// If none of these four above options is specified the default the
294/// option "BR" will be used to draw the border. To produces a pave
295/// without any border it is enough to specify the option "NB" (no border).
296///
297/// - option = "NDC" x1,y1,x2,y2 are given in NDC
298/// - option = "ARC" corners are rounded
299///
300/// In case of option "ARC", the corner radius is specified
301/// via TPave::SetCornerRadius(rad) where rad is given in percent
302/// of the pave height (default value is 0.2).
303
305{
306 // Convert from NDC to pad coordinates
308
310}
311
312////////////////////////////////////////////////////////////////////////////////
313/// Draw this pave with new coordinates.
314
316 Int_t bordersize ,Option_t *option)
317{
318 if (!gPad) return;
319 Double_t x[7],y[7];
320 TString opt = option;
321 opt.ToLower();
322
323 // if pave drawn with the arc option, goes through dedicated function
324 if (opt.Contains("arc")) {
325 PaintPaveArc(x1,y1,x2,y2,bordersize,option);
326 return;
327 }
328
329 // normal rectangular pave
330 Int_t fillstyle = GetFillStyle();
331 Int_t fillcolor = GetFillColor();
332 Int_t shadowcolor = GetShadowColor();
333
334 // Draw first pave as a normal filled box
335 if (fBorderSize <= 0 && fillstyle <= 0) return;
337 if (fBorderSize <= 0) return;
338 if (fBorderSize == 1) {
339 gPad->PaintLine(x1,y1,x2,y1);
340 gPad->PaintLine(x2,y1,x2,y2);
341 gPad->PaintLine(x2,y2,x1,y2);
342 gPad->PaintLine(x1,y2,x1,y1);
343 return;
344 }
345
346 if (fBorderSize <= 0 || opt.Contains("nb")) return;
347
348 Double_t wy = gPad->PixeltoY(0) - gPad->PixeltoY(fBorderSize);
349 Double_t wx = gPad->PixeltoX(fBorderSize) - gPad->PixeltoX(0);
350
351 if (opt.Contains("tr")) {
352 // Draw the shadow top right
353 x[0] = x1 + 1.5*wx; y[0] = y2;
354 x[1] = x[0]; y[1] = y2 + wy;
355 x[2] = x2 + wx; y[2] = y[1];
356 x[3] = x[2]; y[3] = y1 + 1.5*wy;
357 x[4] = x2; y[4] = y[3];
358 x[5] = x[4]; y[5] = y2;
359 } else if (opt.Contains("tl")) {
360 // Draw the shadow top left
361 x[0] = x1 - wx; y[0] = y1 + 1.5*wy;
362 x[1] = x[0]; y[1] = y2 + wy;
363 x[2] = x2 - 1.5*wx; y[2] = y[1];
364 x[3] = x[2]; y[3] = y2;
365 x[4] = x1; y[4] = y[3];
366 x[5] = x1; y[5] = y[0];
367 } else if (opt.Contains("bl")) {
368 // Draw the shadow bottom left
369 x[0] = x1 - wx; y[0] = y2 - 1.5*wy;
370 x[1] = x[0]; y[1] = y1 - wy;
371 x[2] = x2 - 1.5*wx; y[2] = y[1];
372 x[3] = x[2]; y[3] = y1;
373 x[4] = x1; y[4] = y[3];
374 x[5] = x[4]; y[5] = y[0];
375 } else {
376 // Draw the shadow bottom right
377 x[0] = x1 + 1.5*wx; y[0] = y1;
378 x[1] = x[0]; y[1] = y1 - wy;
379 x[2] = x2 + wx; y[2] = y[1];
380 x[3] = x[2]; y[3] = y2 - 1.5*wy;
381 x[4] = x2; y[4] = y[3];
382 x[5] = x[4]; y[5] = y1;
383 }
384
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);
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
411{
412 if (!gPad) return;
413 const Int_t kNPARC = 10;
414 Double_t x[4*kNPARC+10], y[4*kNPARC+10];
415 Double_t px[4*kNPARC+10], py[4*kNPARC+10];
416 Int_t i;
417 TString opt = option;
418 opt.ToLower();
419
420 Int_t fillstyle = GetFillStyle();
421 Int_t fillcolor = GetFillColor();
422 Int_t shadowcolor = GetShadowColor();
423
424 static Double_t cosa[kNPARC], sina[kNPARC];
425 static Bool_t done = kFALSE;
426 if (!done) {
427 done = kTRUE;
428 Double_t dtheta = 0.5*3.141592/(kNPARC+1);
429 Double_t theta = 0;
430 for (i=0;i<kNPARC;i++) {
431 theta += dtheta;
432 cosa[i] = TMath::Cos(theta);
433 sina[i] = TMath::Sin(theta);
434 }
435 }
436 Int_t px1 = gPad->XtoAbsPixel(x1);
437 Int_t py1 = gPad->YtoAbsPixel(y1);
438 Int_t px2 = gPad->XtoAbsPixel(x2);
439 Int_t py2 = gPad->YtoAbsPixel(y2);
440 // compute rounded corner radius
442 if (rad > 0 && rad < 0.5) rad = fCornerRadius;
443 else rad = 0.2;
444 Double_t r = rad*TMath::Abs(py1-py2);
445 if (r > 0.5*TMath::Abs(px2-px1)) r = 0.5*TMath::Abs(px2-px1);
446 if (r == 0) r = 1;
447
448 // Draw rounded box outline and fill area
449 px[0] = px2; py[0] = py1 - r; //starts at bottom right
450 px[1] = px2; py[1] = py2 + r;
451 Int_t np = 2;
452 for (i=0;i<kNPARC;i++) { //top right corner
453 px[np] = px2 - r + r*cosa[i];
454 py[np] = py2 + r - r*sina[i];
455 np++;
456 }
457 px[np] = px2 - r; py[np] = py2;
458 px[np+1] = px1 + r; py[np+1] = py2;
459 np += 2;
460 for (i=kNPARC-1;i>=0;i--) { //top left corner
461 px[np] = px1 + r - r*cosa[i];
462 py[np] = py2 + r - r*sina[i];
463 np++;
464 }
465 px[np] = px1; py[np] = py2 + r;
466 px[np+1] = px1; py[np+1] = py1 - r;
467 np += 2;
468 for (i=0;i<kNPARC;i++) { //bottom left corner
469 px[np] = px1 + r - r*cosa[i];
470 py[np] = py1 - r + r*sina[i];
471 np++;
472 }
473 px[np] = px1 + r; py[np] = py1;
474 px[np+1] = px2 - r; py[np+1] = py1;
475 np += 2;
476 for (i=kNPARC-1;i>=0;i--) { //bottom right corner
477 px[np] = px2 - r + r*cosa[i];
478 py[np] = py1 - r + r*sina[i];
479 np++;
480 }
481 px[np] = px[0]; py[np] =py[0];
484 for (i=0;i<=np;i++) {
485 x[i] = gPad->AbsPixeltoX(Int_t(px[i]));
486 y[i] = gPad->AbsPixeltoY(Int_t(py[i]));
487 }
488 gPad->PaintFillArea(np , x, y);
489 gPad->PaintPolyLine(np+1, x, y);
490
491 if (fBorderSize <= 0 || opt.Contains("nb")) return;
492
495
496 if (opt.Contains("tr")) {
497 // Draw the shadow top right
498 px[0] = px2; py[0] = py1 - r;
499 px[1] = px2; py[1] = py2 + r;
500 np = 2;
501 for (i=0;i<kNPARC;i++) { //top right corner inside
502 px[np] = px2 - r + r*cosa[i];
503 py[np] = py2 + r - r*sina[i];
504 np++;
505 }
506 px[np] = px2 - r; py[np] = py2;
507 px[np+1] = px1 + r; py[np+1] = py2;
508 px[np+2] = px1 + r; py[np+2] = py2 - wy;
509 px[np+3] = px2 - r; py[np+3] = py2 - wy;
510 np += 4;
511 for (i=kNPARC-1;i>=0;i--) { //top right corner outside
512 px[np] = px2 - r + r*cosa[i]*(1+wx/r);
513 py[np] = py2 + r - r*sina[i]*(1+wy/r);
514 np++;
515 }
516 px[np] = px2 + wx; py[np] = py2 + r;
517 px[np+1] = px2 + wx; py[np+1] = py1 - r;
518 px[np+2] = px[0]; py[np+2] = py[0];
519 np += 3;
520 } else if (opt.Contains("tl")) {
521 // Draw the shadow top left
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 } else if (opt.Contains("bl")) {
545 // Draw the shadow bottom left
546 px[0] = px1; py[0] = py2 + r;
547 px[1] = px1; py[1] = py1 - r;
548 np = 2;
549 for (i=0;i<kNPARC;i++) { //bottom left corner inside
550 px[np] = px1 + r - r*cosa[i];
551 py[np] = py1 + r - r*sina[i];
552 np++;
553 }
554 px[np] = px1 + r; py[np] = py1;
555 px[np+1] = px2 - r; py[np+1] = py1;
556 px[np+2] = px2 - r; py[np+2] = py1 + wy;
557 px[np+3] = px1 + r; py[np+3] = py1 + wy;
558 np += 4;
559 for (i=kNPARC-1;i>=0;i--) { //bottom left corner outside
560 px[np] = px1 + r - r*cosa[i]*(1+wx/r);
561 py[np] = py1 - r + r*sina[i]*(1+wy/r);
562 np++;
563 }
564 px[np] = px1 - wx; py[np] = py1 - r;
565 px[np+1] = px1 - wx; py[np+1] = py[0];
566 px[np+2] = px[0]; py[np+2] = py[0];
567 np += 3;
568 } else {
569 // Draw the shadow bottom right (default)
570 px[0] = px1 + r; py[0] = py1;
571 px[1] = px2 - r; py[1] = py1;
572 np = 2;
573 for (i=kNPARC-1;i>=0;i--) { //bottom right corner inside
574 px[np] = px2 - r + r*cosa[i];
575 py[np] = py1 - r + r*sina[i];
576 np++;
577 }
578 px[np] = px2; py[np] = py1 - r;
579 px[np+1] = px2; py[np+1] = py2 + r;
580 px[np+2] = px2 + wx; py[np+2] = py2 + r;
581 px[np+3] = px2 + wx; py[np+3] = py1 - r;
582 np += 4;
583 for (i=0;i<kNPARC;i++) { //bottom right corner outside
584 px[np] = px2 - r + r*cosa[i]*(1+wx/r);
585 py[np] = py1 - r + r*sina[i]*(1+wy/r);
586 np++;
587 }
588 px[np] = px2 - r; py[np] = py1 + wy;
589 px[np+1] = px[0]; py[np+1] = py[0] + wy;
590 px[np+2] = px[0]; py[np+2] = py[0];
591 np += 3;
592 }
593
594 SetFillStyle(1001);
595 SetFillColor(shadowcolor);
597 for (i=0;i<=np;i++) {
598 x[i] = gPad->AbsPixeltoX(Int_t(px[i]));
599 y[i] = gPad->AbsPixeltoY(Int_t(py[i]));
600 }
601 gPad->PaintFillArea(np,x,y);
602 SetFillStyle(fillstyle);
603 SetFillColor(fillcolor);
604}
605
606////////////////////////////////////////////////////////////////////////////////
607/// Dump this pave with its attributes.
608
610{
612}
613
614////////////////////////////////////////////////////////////////////////////////
615/// Save primitive as a C++ statement(s) on output stream out
616
617void TPave::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
618{
619 char quote = '"';
620 if (gROOT->ClassSaved(TPave::Class())) {
621 out<<" ";
622 } else {
623 out<<" TPave *";
624 }
625 if (fOption.Contains("NDC")) {
626 out<<"pave = new TPave("<<fX1NDC<<","<<fY1NDC<<","<<fX2NDC<<","<<fY2NDC
627 <<","<<fBorderSize<<","<<quote<<fOption<<quote<<");"<<std::endl;
628 } else {
629 out<<"pave = new TPave("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2
630 <<","<<fBorderSize<<","<<quote<<fOption<<quote<<");"<<std::endl;
631 }
632 if (strcmp(GetName(),"TPave")) {
633 out<<" pave->SetName("<<quote<<GetName()<<quote<<");"<<std::endl;
634 }
635 if (fCornerRadius) {
636 out<<" pave->SetCornerRadius("<<fCornerRadius<<");"<<std::endl;
637 }
638 SaveFillAttributes(out,"pave",19,1001);
639 SaveLineAttributes(out,"pave",1,1,1);
640 out<<" pave->Draw();"<<std::endl;
641}
642
643////////////////////////////////////////////////////////////////////////////////
644/// Set the X1 value
645
647{
648 fX1 = x1;
649 if (gPad) {
650 Double_t dpx = gPad->GetX2() - gPad->GetX1();
651 Double_t xp1 = gPad->GetX1();
652 fX1NDC = (fX1-xp1)/dpx;
653 }
654}
655
656////////////////////////////////////////////////////////////////////////////////
657/// Set the X2 value
658
660{
661 fX2 = x2;
662 if (gPad) {
663 Double_t dpx = gPad->GetX2() - gPad->GetX1();
664 Double_t xp1 = gPad->GetX1();
665 fX2NDC = (fX2-xp1)/dpx;
666 }
667}
668
669////////////////////////////////////////////////////////////////////////////////
670/// Set the Y1 value
671
673{
674 fY1 = y1;
675 if (gPad) {
676 Double_t dpy = gPad->GetY2() - gPad->GetY1();
677 Double_t yp1 = gPad->GetY1();
678 fY1NDC = (fY1-yp1)/dpy;
679 }
680}
681
682////////////////////////////////////////////////////////////////////////////////
683/// Set the Y2 value
684
686{
687 fY2 = y2;
688 if (gPad) {
689 Double_t dpy = gPad->GetY2() - gPad->GetY1();
690 Double_t yp1 = gPad->GetY1();
691 fY2NDC = (fY2-yp1)/dpy;
692 }
693}
694
695////////////////////////////////////////////////////////////////////////////////
696/// Stream an object of class TPave.
697
699{
700 if (R__b.IsReading()) {
701 UInt_t R__s, R__c;
702 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
703 if (R__v > 1) {
704 R__b.ReadClassBuffer(TPave::Class(), this, R__v, R__s, R__c);
705 return;
706 }
707 //====process old versions before automatic schema evolution
708 TBox::Streamer(R__b);
709 Float_t x1ndc,y1ndc,x2ndc,y2ndc,rad;
710 R__b >> x1ndc; fX1NDC = x1ndc;
711 R__b >> y1ndc; fY1NDC = y1ndc;
712 R__b >> x2ndc; fX2NDC = x2ndc;
713 R__b >> y2ndc; fY2NDC = y2ndc;
714 R__b >> fBorderSize;
715 R__b >> fInit;
716 R__b >> rad; fCornerRadius = rad;
717 fOption.Streamer(R__b);
718 fName.Streamer(R__b);
719 R__b.CheckByteCount(R__s, R__c, TPave::IsA());
720 //====end of old versions
721
722 } else {
723 R__b.WriteClassBuffer(TPave::Class(),this);
724 }
725}
@ kButton1Double
Definition Buttons.h:24
int Int_t
Definition RtypesCore.h:45
short Version_t
Definition RtypesCore.h:65
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
Option_t Option_t option
Option_t Option_t SetFillStyle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t SetLineColor
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t SetFillColor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
Option_t Option_t TPoint TPoint const char y1
#define gROOT
Definition TROOT.h:406
R__EXTERN TStyle * gStyle
Definition TStyle.h:436
#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:216
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:239
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 Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:34
virtual void Modify()
Change current line attributes if necessary.
Definition TAttLine.cxx:247
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:275
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:678
void Streamer(TBuffer &) override
Stream an object of class TBox.
Definition TBox.cxx:751
Double_t fX1
X of 1st point.
Definition TBox.h:28
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TBox.cxx:232
void Print(Option_t *option="") const override
Dump this box with its attributes.
Definition TBox.cxx:698
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
void Copy(TObject &box) const override
Copy a Box.
Definition TBox.cxx:112
Buffer base class used for serializing objects.
Definition TBuffer.h:43
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=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:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:199
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:225
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:202
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:798
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:62
A TBox with a bordersize and a shadow option.
Definition TPave.h:19
TPave()
Pave default constructor.
Definition TPave.cxx:36
void Print(Option_t *option="") const override
Dump this pave with its attributes.
Definition TPave.cxx:609
void SetX2(Double_t x2) override
Set the X2 value.
Definition TPave.cxx:659
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 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:409
const char * GetName() const override
Returns name of object.
Definition TPave.h:56
void Copy(TObject &pave) const override
Copy this pave to pave.
Definition TPave.cxx:186
void Streamer(TBuffer &) override
Stream an object of class TPave.
Definition TPave.cxx:698
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TPave.cxx:255
Int_t fBorderSize
window box bordersize in pixels
Definition TPave.h:26
TClass * IsA() const override
Definition TPave.h:91
void Draw(Option_t *option="") override
Draw this pave with its current attributes.
Definition TPave.cxx:229
void ls(Option_t *option="") const override
List this pave with its attributes.
Definition TPave.cxx:279
virtual void SetName(const char *name="")
Definition TPave.h:79
void SetX1(Double_t x1) override
Set the X1 value.
Definition TPave.cxx:646
Double_t fX2NDC
X2 point in NDC coordinates.
Definition TPave.h:24
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition TPave.cxx:617
Int_t fShadowColor
Color of the pave's shadow.
Definition TPave.h:28
void SetY1(Double_t y1) override
Set the Y1 value.
Definition TPave.cxx:672
Int_t fInit
(=0 if transformation to NDC not yet done)
Definition TPave.h:27
TString fOption
Pave style.
Definition TPave.h:30
Double_t fY2NDC
Y2 point in NDC coordinates.
Definition TPave.h:25
static TClass * Class()
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a pave.
Definition TPave.cxx:208
Double_t fX1NDC
X1 point in NDC coordinates.
Definition TPave.h:22
TString fName
Pave name.
Definition TPave.h:31
void SetY2(Double_t y2) override
Set the Y2 value.
Definition TPave.cxx:685
@ kNameIsAction
double clicking on TPave will execute action
Definition TPave.h:36
Double_t fCornerRadius
Corner radius in case of option arc.
Definition TPave.h:29
Option_t * GetOption() const override
Definition TPave.h:57
Double_t fY1NDC
Y1 point in NDC coordinates.
Definition TPave.h:23
void Paint(Option_t *option="") override
Paint this pave with its current attributes.
Definition TPave.cxx:304
~TPave() override
Pave default destructor.
Definition TPave.cxx:103
virtual TPave * 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:241
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:315
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:2895
Basic string class.
Definition TString.h:139
void ToLower()
Change string to lower-case.
Definition TString.cxx:1182
virtual void Streamer(TBuffer &)
Stream a string object.
Definition TString.cxx:1412
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
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)
Returns the cosine of an angle of x radians.
Definition TMath.h:598
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:592
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Definition TMath.h:766
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123