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 // if pave drawn with the arc option, goes through dedicated function
323 if (opt.Contains("arc")) {
324 PaintPaveArc(x1,y1,x2,y2,bordersize,option);
325 return;
326 }
327
328 // normal rectangular pave
329 if (opt.Length() == 0) opt ="br";
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 Double_t wy = gPad->PixeltoY(0) - gPad->PixeltoY(fBorderSize);
347 Double_t wx = gPad->PixeltoX(fBorderSize) - gPad->PixeltoX(0);
348 Int_t mode = 0;
349 //*-*- Draw the frame top right
350 if (opt.Contains("t") && opt.Contains("r")) {
351 mode = 1;
352 x[0] = x1 + 1.5*wx; y[0] = y2;
353 x[1] = x[0]; y[1] = y2 + wy;
354 x[2] = x2 + wx; y[2] = y[1];
355 x[3] = x[2]; y[3] = y1 + 1.5*wy;
356 x[4] = x2; y[4] = y[3];
357 x[5] = x[4]; y[5] = y2;
358 }
359 // Draw the frame top left
360 if (opt.Contains("t") && opt.Contains("l")) {
361 mode = 2;
362 x[0] = x1 - wx; y[0] = y1 + 1.5*wy;
363 x[1] = x[0]; y[1] = y2 + wy;
364 x[2] = x2 - 1.5*wx; y[2] = y[1];
365 x[3] = x[2]; y[3] = y2;
366 x[4] = x1; y[4] = y[3];
367 x[5] = x1; y[5] = y[0];
368 }
369 // Draw the frame bottom right
370 if (opt.Contains("b") && opt.Contains("r")) {
371 mode = 3;
372 x[0] = x1 + 1.5*wx; y[0] = y1;
373 x[1] = x[0]; y[1] = y1 - wy;
374 x[2] = x2 + wx; y[2] = y[1];
375 x[3] = x[2]; y[3] = y2 - 1.5*wy;
376 x[4] = x2; y[4] = y[3];
377 x[5] = x[4]; y[5] = y1;
378 }
379 // Draw the frame bottom left
380 if (opt.Contains("b") && opt.Contains("l")) {
381 mode = 4;
382 x[0] = x1 - wx; y[0] = y2 - 1.5*wy;
383 x[1] = x[0]; y[1] = y1 - wy;
384 x[2] = x2 - 1.5*wx; y[2] = y[1];
385 x[3] = x[2]; y[3] = y1;
386 x[4] = x1; y[4] = y[3];
387 x[5] = x[4]; y[5] = y[0];
388 }
389 if (!mode) return; // nop border mode option specified
390 for (Int_t i=0;i<6;i++) {
391 if (x[i] < gPad->GetX1()) x[i] = gPad->GetX1();
392 if (x[i] > gPad->GetX2()) x[i] = gPad->GetX2();
393 if (y[i] < gPad->GetY1()) y[i] = gPad->GetY1();
394 if (y[i] > gPad->GetY2()) y[i] = gPad->GetY2();
395 }
396 x[6] = x[0]; y[6] = y[0];
397 SetFillStyle(1001);
398 SetFillColor(shadowcolor);
400 gPad->PaintFillArea(6,x,y);
401 x[0] = x1; y[0] = y1;
402 x[1] = x1; y[1] = y2;
403 x[2] = x2; y[2] = y2;
404 x[3] = x2; y[3] = y1;
405 x[4] = x1; y[4] = y1;
406 gPad->PaintPolyLine(5,x,y);
407 SetFillStyle(fillstyle);
408 SetFillColor(fillcolor);
409}
410
411////////////////////////////////////////////////////////////////////////////////
412/// Draw this pave with rounded corners.
413
416{
417 if (!gPad) return;
418 const Int_t kNPARC = 10;
419 Double_t x[4*kNPARC+10], y[4*kNPARC+10];
420 Double_t px[4*kNPARC+10], py[4*kNPARC+10];
421 Int_t i;
422 TString opt = option;
423 opt.ToLower();
424 if (opt.Length() == 0) opt ="br";
425 Int_t fillstyle = GetFillStyle();
426 Int_t fillcolor = GetFillColor();
427 Int_t shadowcolor = GetShadowColor();
428
429 static Double_t cosa[kNPARC], sina[kNPARC];
430 static Bool_t done = kFALSE;
431 if (!done) {
432 done = kTRUE;
433 Double_t dtheta = 0.5*3.141592/(kNPARC+1);
434 Double_t theta = 0;
435 for (i=0;i<kNPARC;i++) {
436 theta += dtheta;
437 cosa[i] = TMath::Cos(theta);
438 sina[i] = TMath::Sin(theta);
439 }
440 }
441 Int_t px1 = gPad->XtoAbsPixel(x1);
442 Int_t py1 = gPad->YtoAbsPixel(y1);
443 Int_t px2 = gPad->XtoAbsPixel(x2);
444 Int_t py2 = gPad->YtoAbsPixel(y2);
445 // compute rounded corner radius
447 if (rad > 0 && rad < 0.5) rad = fCornerRadius;
448 else rad = 0.2;
449 Double_t r = rad*TMath::Abs(py1-py2);
450 if (r > 0.5*TMath::Abs(px2-px1)) r = 0.5*TMath::Abs(px2-px1);
451 if (r == 0) r = 1;
452
453 // Draw rounded box outline and fill area
454 px[0] = px2; py[0] = py1 - r; //starts at bottom right
455 px[1] = px2; py[1] = py2 + r;
456 Int_t np = 2;
457 for (i=0;i<kNPARC;i++) { //top right corner
458 px[np] = px2 - r + r*cosa[i];
459 py[np] = py2 + r - r*sina[i];
460 np++;
461 }
462 px[np] = px2 - r; py[np] = py2;
463 px[np+1] = px1 + r; py[np+1] = py2;
464 np += 2;
465 for (i=kNPARC-1;i>=0;i--) { //top left corner
466 px[np] = px1 + r - r*cosa[i];
467 py[np] = py2 + r - r*sina[i];
468 np++;
469 }
470 px[np] = px1; py[np] = py2 + r;
471 px[np+1] = px1; py[np+1] = py1 - r;
472 np += 2;
473 for (i=0;i<kNPARC;i++) { //bottom left corner
474 px[np] = px1 + r - r*cosa[i];
475 py[np] = py1 - r + r*sina[i];
476 np++;
477 }
478 px[np] = px1 + r; py[np] = py1;
479 px[np+1] = px2 - r; py[np+1] = py1;
480 np += 2;
481 for (i=kNPARC-1;i>=0;i--) { //bottom right corner
482 px[np] = px2 - r + r*cosa[i];
483 py[np] = py1 - r + r*sina[i];
484 np++;
485 }
486 px[np] = px[0]; py[np] =py[0];
489 for (i=0;i<=np;i++) {
490 x[i] = gPad->AbsPixeltoX(Int_t(px[i]));
491 y[i] = gPad->AbsPixeltoY(Int_t(py[i]));
492 }
493 gPad->PaintFillArea(np , x, y);
494 gPad->PaintPolyLine(np+1, x, y);
495
496
497 if (fBorderSize <= 0) return;
498
501 // Draw the frame top right
502 if (opt.Contains("tr")) {
503 px[0] = px2; py[0] = py1 - r;
504 px[1] = px2; py[1] = py2 + r;
505 np = 2;
506 for (i=0;i<kNPARC;i++) { //top right corner inside
507 px[np] = px2 - r + r*cosa[i];
508 py[np] = py2 + r - r*sina[i];
509 np++;
510 }
511 px[np] = px2 - r; py[np] = py2;
512 px[np+1] = px1 + r; py[np+1] = py2;
513 px[np+2] = px1 + r; py[np+2] = py2 - wy;
514 px[np+3] = px2 - r; py[np+3] = py2 - wy;
515 np += 4;
516 for (i=kNPARC-1;i>=0;i--) { //top right corner outside
517 px[np] = px2 - r + r*cosa[i]*(1+wx/r);
518 py[np] = py2 + r - r*sina[i]*(1+wy/r);
519 np++;
520 }
521 px[np] = px2 + wx; py[np] = py2 + r;
522 px[np+1] = px2 + wx; py[np+1] = py1 - r;
523 px[np+2] = px[0]; py[np+2] = py[0];
524 np += 3;
525 }
526 // Draw the frame top left
527 if (opt.Contains("tl")) {
528 px[0] = px2 - r; py[0] = py2;
529 px[1] = px1 + r; py[1] = py2;
530 np = 2;
531 for (i=kNPARC-1;i>=0;i--) { //top left corner inside
532 px[np] = px1 + r - r*cosa[i];
533 py[np] = py2 + r - r*sina[i];
534 np++;
535 }
536 px[np] = px1; py[np] = py2 + r;
537 px[np+1] = px1; py[np+1] = py1 - r;
538 px[np+2] = px1 - wx; py[np+2] = py1 - r;
539 px[np+3] = px1 - wx; py[np+3] = py2 + r;
540 np += 4;
541 for (i=0;i<kNPARC;i++) { //top left corner outside
542 px[np] = px1 + r - r*cosa[i]*(1+wx/r);
543 py[np] = py2 + r - r*sina[i]*(1+wy/r);
544 np++;
545 }
546 px[np] = px1 + r; py[np] = py2 - wy;
547 px[np+1] = px2 - r; py[np+1] = py2 - wy;
548 px[np+2] = px[0]; py[np+2] = y[0];
549 np += 3;
550 }
551 // Draw the frame bottom right
552 if (opt.Contains("br")) {
553 px[0] = px1 + r; py[0] = py1;
554 px[1] = px2 - r; py[1] = py1;
555 np = 2;
556 for (i=kNPARC-1;i>=0;i--) { //bottom right corner inside
557 px[np] = px2 - r + r*cosa[i];
558 py[np] = py1 - r + r*sina[i];
559 np++;
560 }
561 px[np] = px2; py[np] = py1 - r;
562 px[np+1] = px2; py[np+1] = py2 + r;
563 px[np+2] = px2 + wx; py[np+2] = py2 + r;
564 px[np+3] = px2 + wx; py[np+3] = py1 - r;
565 np += 4;
566 for (i=0;i<kNPARC;i++) { //bottom right corner outside
567 px[np] = px2 - r + r*cosa[i]*(1+wx/r);
568 py[np] = py1 - r + r*sina[i]*(1+wy/r);
569 np++;
570 }
571 px[np] = px2 - r; py[np] = py1 + wy;
572 px[np+1] = px[0]; py[np+1] = py[0] + wy;
573 px[np+2] = px[0]; py[np+2] = py[0];
574 np += 3;
575 }
576 // Draw the frame bottom left
577 if (opt.Contains("bl")) {
578 px[0] = px1; py[0] = py2 + r;
579 px[1] = px1; py[1] = py1 - r;
580 np = 2;
581 for (i=0;i<kNPARC;i++) { //bottom left corner inside
582 px[np] = px1 + r - r*cosa[i];
583 py[np] = py1 + r - r*sina[i];
584 np++;
585 }
586 px[np] = px1 + r; py[np] = py1;
587 px[np+1] = px2 - r; py[np+1] = py1;
588 px[np+2] = px2 - r; py[np+2] = py1 + wy;
589 px[np+3] = px1 + r; py[np+3] = py1 + wy;
590 np += 4;
591 for (i=kNPARC-1;i>=0;i--) { //bottom left corner outside
592 px[np] = px1 + r - r*cosa[i]*(1+wx/r);
593 py[np] = py1 - r + r*sina[i]*(1+wy/r);
594 np++;
595 }
596 px[np] = px1 - wx; py[np] = py1 - r;
597 px[np+1] = px1 - wx; py[np+1] = py[0];
598 px[np+2] = px[0]; py[np+2] = py[0];
599 np += 3;
600 }
601 SetFillStyle(1001);
602 SetFillColor(shadowcolor);
604 for (i=0;i<=np;i++) {
605 x[i] = gPad->AbsPixeltoX(Int_t(px[i]));
606 y[i] = gPad->AbsPixeltoY(Int_t(py[i]));
607 }
608 gPad->PaintFillArea(np,x,y);
609 SetFillStyle(fillstyle);
610 SetFillColor(fillcolor);
611}
612
613////////////////////////////////////////////////////////////////////////////////
614/// Dump this pave with its attributes.
615
617{
619}
620
621////////////////////////////////////////////////////////////////////////////////
622/// Save primitive as a C++ statement(s) on output stream out
623
624void TPave::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
625{
626 char quote = '"';
627 if (gROOT->ClassSaved(TPave::Class())) {
628 out<<" ";
629 } else {
630 out<<" TPave *";
631 }
632 if (fOption.Contains("NDC")) {
633 out<<"pave = new TPave("<<fX1NDC<<","<<fY1NDC<<","<<fX2NDC<<","<<fY2NDC
634 <<","<<fBorderSize<<","<<quote<<fOption<<quote<<");"<<std::endl;
635 } else {
636 out<<"pave = new TPave("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2
637 <<","<<fBorderSize<<","<<quote<<fOption<<quote<<");"<<std::endl;
638 }
639 if (strcmp(GetName(),"TPave")) {
640 out<<" pave->SetName("<<quote<<GetName()<<quote<<");"<<std::endl;
641 }
642 if (fCornerRadius) {
643 out<<" pave->SetCornerRadius("<<fCornerRadius<<");"<<std::endl;
644 }
645 SaveFillAttributes(out,"pave",19,1001);
646 SaveLineAttributes(out,"pave",1,1,1);
647 out<<" pave->Draw();"<<std::endl;
648}
649
650////////////////////////////////////////////////////////////////////////////////
651/// Set the X1 value
652
654{
655 fX1 = x1;
656 if (gPad) {
657 Double_t dpx = gPad->GetX2() - gPad->GetX1();
658 Double_t xp1 = gPad->GetX1();
659 fX1NDC = (fX1-xp1)/dpx;
660 }
661}
662
663////////////////////////////////////////////////////////////////////////////////
664/// Set the X2 value
665
667{
668 fX2 = x2;
669 if (gPad) {
670 Double_t dpx = gPad->GetX2() - gPad->GetX1();
671 Double_t xp1 = gPad->GetX1();
672 fX2NDC = (fX2-xp1)/dpx;
673 }
674}
675
676////////////////////////////////////////////////////////////////////////////////
677/// Set the Y1 value
678
680{
681 fY1 = y1;
682 if (gPad) {
683 Double_t dpy = gPad->GetY2() - gPad->GetY1();
684 Double_t yp1 = gPad->GetY1();
685 fY1NDC = (fY1-yp1)/dpy;
686 }
687}
688
689////////////////////////////////////////////////////////////////////////////////
690/// Set the Y2 value
691
693{
694 fY2 = y2;
695 if (gPad) {
696 Double_t dpy = gPad->GetY2() - gPad->GetY1();
697 Double_t yp1 = gPad->GetY1();
698 fY2NDC = (fY2-yp1)/dpy;
699 }
700}
701
702////////////////////////////////////////////////////////////////////////////////
703/// Stream an object of class TPave.
704
706{
707 if (R__b.IsReading()) {
708 UInt_t R__s, R__c;
709 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
710 if (R__v > 1) {
711 R__b.ReadClassBuffer(TPave::Class(), this, R__v, R__s, R__c);
712 return;
713 }
714 //====process old versions before automatic schema evolution
715 TBox::Streamer(R__b);
716 Float_t x1ndc,y1ndc,x2ndc,y2ndc,rad;
717 R__b >> x1ndc; fX1NDC = x1ndc;
718 R__b >> y1ndc; fY1NDC = y1ndc;
719 R__b >> x2ndc; fX2NDC = x2ndc;
720 R__b >> y2ndc; fY2NDC = y2ndc;
721 R__b >> fBorderSize;
722 R__b >> fInit;
723 R__b >> rad; fCornerRadius = rad;
724 fOption.Streamer(R__b);
725 fName.Streamer(R__b);
726 R__b.CheckByteCount(R__s, R__c, TPave::IsA());
727 //====end of old versions
728
729 } else {
730 R__b.WriteClassBuffer(TPave::Class(),this);
731 }
732}
@ 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:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
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 mode
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:433
#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:201
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:207
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:184
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:780
@ 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:616
void SetX2(Double_t x2) override
Set the X2 value.
Definition TPave.cxx:666
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:414
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:705
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:653
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:624
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:679
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:692
@ 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:2844
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
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:594
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:588
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Definition TMath.h:762
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123