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 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 return newpave;
247}
248
249////////////////////////////////////////////////////////////////////////////////
250/// Execute action corresponding to one event.
251///
252/// This member function is called when a PAVE object is clicked.
253
255{
256 if (!gPad) return;
257
258 if (!gPad->IsEditable()) return;
259
260 TBox::ExecuteEvent(event, px, py);
261
262 // In case pave coordinates have been modified, recompute NDC coordinates
263 SetX1(fX1);
264 SetX2(fX2);
265 SetY1(fY1);
266 SetY2(fY2);
267
268 // In case the bit NameIsAction is activated, execute the action
269 // in name via the interpreter.
270 if (event == kButton1Double) {
271 if (TestBit(kNameIsAction)) gROOT->ProcessLine(GetName());
272 }
273}
274
275////////////////////////////////////////////////////////////////////////////////
276/// List this pave with its attributes.
277
278void TPave::ls(Option_t *) const
279{
281 printf("OBJ: %s\t%s \tX1= %f Y1=%f X2=%f Y2=%f\n",IsA()->GetName(),GetName(),fX1,fY1,fX2,fY2);
282}
283
284////////////////////////////////////////////////////////////////////////////////
285/// Paint this pave with its current attributes.
286///
287/// - option = "TR" Top and Right shadows are drawn.
288/// - option = "TL" Top and Left shadows are drawn.
289/// - option = "BR" Bottom and Right shadows are drawn.
290/// - option = "BL" Bottom and Left shadows are drawn.
291///
292/// If none of these four above options is specified the default the
293/// option "BR" will be used to draw the border. To produces a pave
294/// without any border it is enough to specify the option "NB" (no border).
295///
296/// - option = "NDC" x1,y1,x2,y2 are given in NDC
297/// - option = "ARC" corners are rounded
298///
299/// In case of option "ARC", the corner radius is specified
300/// via TPave::SetCornerRadius(rad) where rad is given in percent
301/// of the pave height (default value is 0.2).
302
304{
305 // Convert from NDC to pad coordinates
307
309}
310
311////////////////////////////////////////////////////////////////////////////////
312/// Draw this pave with new coordinates.
313
315 Int_t bordersize ,Option_t *option)
316{
317 if (!gPad) return;
318 Double_t x[7],y[7];
319 TString opt = option;
320 opt.ToLower();
321 // if pave drawn with the arc option, goes through dedicated function
322 if (opt.Contains("arc")) {
323 PaintPaveArc(x1,y1,x2,y2,bordersize,option);
324 return;
325 }
326
327 // normal rectangular pave
328 if (opt.Length() == 0) opt ="br";
329 Int_t fillstyle = GetFillStyle();
330 Int_t fillcolor = GetFillColor();
331 Int_t shadowcolor = GetShadowColor();
332
333 // Draw first pave as a normal filled box
334 if (fBorderSize <= 0 && fillstyle <= 0) return;
336 if (fBorderSize <= 0) return;
337 if (fBorderSize == 1) {
338 gPad->PaintLine(x1,y1,x2,y1);
339 gPad->PaintLine(x2,y1,x2,y2);
340 gPad->PaintLine(x2,y2,x1,y2);
341 gPad->PaintLine(x1,y2,x1,y1);
342 return;
343 }
344
345 Double_t wy = gPad->PixeltoY(0) - gPad->PixeltoY(fBorderSize);
346 Double_t wx = gPad->PixeltoX(fBorderSize) - gPad->PixeltoX(0);
347 Int_t mode = 0;
348 //*-*- Draw the frame top right
349 if (opt.Contains("t") && opt.Contains("r")) {
350 mode = 1;
351 x[0] = x1 + 1.5*wx; y[0] = y2;
352 x[1] = x[0]; y[1] = y2 + wy;
353 x[2] = x2 + wx; y[2] = y[1];
354 x[3] = x[2]; y[3] = y1 + 1.5*wy;
355 x[4] = x2; y[4] = y[3];
356 x[5] = x[4]; y[5] = y2;
357 }
358 // Draw the frame top left
359 if (opt.Contains("t") && opt.Contains("l")) {
360 mode = 2;
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 }
368 // Draw the frame bottom right
369 if (opt.Contains("b") && opt.Contains("r")) {
370 mode = 3;
371 x[0] = x1 + 1.5*wx; y[0] = y1;
372 x[1] = x[0]; y[1] = y1 - wy;
373 x[2] = x2 + wx; y[2] = y[1];
374 x[3] = x[2]; y[3] = y2 - 1.5*wy;
375 x[4] = x2; y[4] = y[3];
376 x[5] = x[4]; y[5] = y1;
377 }
378 // Draw the frame bottom left
379 if (opt.Contains("b") && opt.Contains("l")) {
380 mode = 4;
381 x[0] = x1 - wx; y[0] = y2 - 1.5*wy;
382 x[1] = x[0]; y[1] = y1 - wy;
383 x[2] = x2 - 1.5*wx; y[2] = y[1];
384 x[3] = x[2]; y[3] = y1;
385 x[4] = x1; y[4] = y[3];
386 x[5] = x[4]; y[5] = y[0];
387 }
388 if (!mode) return; // nop border mode option specified
389 for (Int_t i=0;i<6;i++) {
390 if (x[i] < gPad->GetX1()) x[i] = gPad->GetX1();
391 if (x[i] > gPad->GetX2()) x[i] = gPad->GetX2();
392 if (y[i] < gPad->GetY1()) y[i] = gPad->GetY1();
393 if (y[i] > gPad->GetY2()) y[i] = gPad->GetY2();
394 }
395 x[6] = x[0]; y[6] = y[0];
396 SetFillStyle(1001);
397 SetFillColor(shadowcolor);
399 gPad->PaintFillArea(6,x,y);
400 x[0] = x1; y[0] = y1;
401 x[1] = x1; y[1] = y2;
402 x[2] = x2; y[2] = y2;
403 x[3] = x2; y[3] = y1;
404 x[4] = x1; y[4] = y1;
405 gPad->PaintPolyLine(5,x,y);
406 SetFillStyle(fillstyle);
407 SetFillColor(fillcolor);
408}
409
410////////////////////////////////////////////////////////////////////////////////
411/// Draw this pave with rounded corners.
412
415{
416 if (!gPad) return;
417 const Int_t kNPARC = 10;
418 Double_t x[4*kNPARC+10], y[4*kNPARC+10];
419 Double_t px[4*kNPARC+10], py[4*kNPARC+10];
420 Int_t i;
421 TString opt = option;
422 opt.ToLower();
423 if (opt.Length() == 0) opt ="br";
424 Int_t fillstyle = GetFillStyle();
425 Int_t fillcolor = GetFillColor();
426 Int_t shadowcolor = GetShadowColor();
427
428 static Double_t cosa[kNPARC], sina[kNPARC];
429 static Bool_t done = kFALSE;
430 if (!done) {
431 done = kTRUE;
432 Double_t dtheta = 0.5*3.141592/(kNPARC+1);
433 Double_t theta = 0;
434 for (i=0;i<kNPARC;i++) {
435 theta += dtheta;
436 cosa[i] = TMath::Cos(theta);
437 sina[i] = TMath::Sin(theta);
438 }
439 }
440 Int_t px1 = gPad->XtoAbsPixel(x1);
441 Int_t py1 = gPad->YtoAbsPixel(y1);
442 Int_t px2 = gPad->XtoAbsPixel(x2);
443 Int_t py2 = gPad->YtoAbsPixel(y2);
444 // compute rounded corner radius
446 if (rad > 0 && rad < 0.5) rad = fCornerRadius;
447 else rad = 0.2;
448 Double_t r = rad*TMath::Abs(py1-py2);
449 if (r > 0.5*TMath::Abs(px2-px1)) r = 0.5*TMath::Abs(px2-px1);
450 if (r == 0) r = 1;
451
452 // Draw rounded box outline and fill area
453 px[0] = px2; py[0] = py1 - r; //starts at bottom right
454 px[1] = px2; py[1] = py2 + r;
455 Int_t np = 2;
456 for (i=0;i<kNPARC;i++) { //top right corner
457 px[np] = px2 - r + r*cosa[i];
458 py[np] = py2 + r - r*sina[i];
459 np++;
460 }
461 px[np] = px2 - r; py[np] = py2;
462 px[np+1] = px1 + r; py[np+1] = py2;
463 np += 2;
464 for (i=kNPARC-1;i>=0;i--) { //top left corner
465 px[np] = px1 + r - r*cosa[i];
466 py[np] = py2 + r - r*sina[i];
467 np++;
468 }
469 px[np] = px1; py[np] = py2 + r;
470 px[np+1] = px1; py[np+1] = py1 - r;
471 np += 2;
472 for (i=0;i<kNPARC;i++) { //bottom left corner
473 px[np] = px1 + r - r*cosa[i];
474 py[np] = py1 - r + r*sina[i];
475 np++;
476 }
477 px[np] = px1 + r; py[np] = py1;
478 px[np+1] = px2 - r; py[np+1] = py1;
479 np += 2;
480 for (i=kNPARC-1;i>=0;i--) { //bottom right corner
481 px[np] = px2 - r + r*cosa[i];
482 py[np] = py1 - r + r*sina[i];
483 np++;
484 }
485 px[np] = px[0]; py[np] =py[0];
488 for (i=0;i<=np;i++) {
489 x[i] = gPad->AbsPixeltoX(Int_t(px[i]));
490 y[i] = gPad->AbsPixeltoY(Int_t(py[i]));
491 }
492 gPad->PaintFillArea(np , x, y);
493 gPad->PaintPolyLine(np+1, x, y);
494
495
496 if (fBorderSize <= 0) return;
497
500 // Draw the frame top right
501 if (opt.Contains("tr")) {
502 px[0] = px2; py[0] = py1 - r;
503 px[1] = px2; py[1] = py2 + r;
504 np = 2;
505 for (i=0;i<kNPARC;i++) { //top right corner inside
506 px[np] = px2 - r + r*cosa[i];
507 py[np] = py2 + r - r*sina[i];
508 np++;
509 }
510 px[np] = px2 - r; py[np] = py2;
511 px[np+1] = px1 + r; py[np+1] = py2;
512 px[np+2] = px1 + r; py[np+2] = py2 - wy;
513 px[np+3] = px2 - r; py[np+3] = py2 - wy;
514 np += 4;
515 for (i=kNPARC-1;i>=0;i--) { //top right corner outside
516 px[np] = px2 - r + r*cosa[i]*(1+wx/r);
517 py[np] = py2 + r - r*sina[i]*(1+wy/r);
518 np++;
519 }
520 px[np] = px2 + wx; py[np] = py2 + r;
521 px[np+1] = px2 + wx; py[np+1] = py1 - r;
522 px[np+2] = px[0]; py[np+2] = py[0];
523 np += 3;
524 }
525 // Draw the frame top left
526 if (opt.Contains("tl")) {
527 px[0] = px2 - r; py[0] = py2;
528 px[1] = px1 + r; py[1] = py2;
529 np = 2;
530 for (i=kNPARC-1;i>=0;i--) { //top left corner inside
531 px[np] = px1 + r - r*cosa[i];
532 py[np] = py2 + r - r*sina[i];
533 np++;
534 }
535 px[np] = px1; py[np] = py2 + r;
536 px[np+1] = px1; py[np+1] = py1 - r;
537 px[np+2] = px1 - wx; py[np+2] = py1 - r;
538 px[np+3] = px1 - wx; py[np+3] = py2 + r;
539 np += 4;
540 for (i=0;i<kNPARC;i++) { //top left corner outside
541 px[np] = px1 + r - r*cosa[i]*(1+wx/r);
542 py[np] = py2 + r - r*sina[i]*(1+wy/r);
543 np++;
544 }
545 px[np] = px1 + r; py[np] = py2 - wy;
546 px[np+1] = px2 - r; py[np+1] = py2 - wy;
547 px[np+2] = px[0]; py[np+2] = y[0];
548 np += 3;
549 }
550 // Draw the frame bottom right
551 if (opt.Contains("br")) {
552 px[0] = px1 + r; py[0] = py1;
553 px[1] = px2 - r; py[1] = py1;
554 np = 2;
555 for (i=kNPARC-1;i>=0;i--) { //bottom right corner inside
556 px[np] = px2 - r + r*cosa[i];
557 py[np] = py1 - r + r*sina[i];
558 np++;
559 }
560 px[np] = px2; py[np] = py1 - r;
561 px[np+1] = px2; py[np+1] = py2 + r;
562 px[np+2] = px2 + wx; py[np+2] = py2 + r;
563 px[np+3] = px2 + wx; py[np+3] = py1 - r;
564 np += 4;
565 for (i=0;i<kNPARC;i++) { //bottom right corner outside
566 px[np] = px2 - r + r*cosa[i]*(1+wx/r);
567 py[np] = py1 - r + r*sina[i]*(1+wy/r);
568 np++;
569 }
570 px[np] = px2 - r; py[np] = py1 + wy;
571 px[np+1] = px[0]; py[np+1] = py[0] + wy;
572 px[np+2] = px[0]; py[np+2] = py[0];
573 np += 3;
574 }
575 // Draw the frame bottom left
576 if (opt.Contains("bl")) {
577 px[0] = px1; py[0] = py2 + r;
578 px[1] = px1; py[1] = py1 - r;
579 np = 2;
580 for (i=0;i<kNPARC;i++) { //bottom left corner inside
581 px[np] = px1 + r - r*cosa[i];
582 py[np] = py1 + r - r*sina[i];
583 np++;
584 }
585 px[np] = px1 + r; py[np] = py1;
586 px[np+1] = px2 - r; py[np+1] = py1;
587 px[np+2] = px2 - r; py[np+2] = py1 + wy;
588 px[np+3] = px1 + r; py[np+3] = py1 + wy;
589 np += 4;
590 for (i=kNPARC-1;i>=0;i--) { //bottom left corner outside
591 px[np] = px1 + r - r*cosa[i]*(1+wx/r);
592 py[np] = py1 - r + r*sina[i]*(1+wy/r);
593 np++;
594 }
595 px[np] = px1 - wx; py[np] = py1 - r;
596 px[np+1] = px1 - wx; py[np+1] = py[0];
597 px[np+2] = px[0]; py[np+2] = py[0];
598 np += 3;
599 }
600 SetFillStyle(1001);
601 SetFillColor(shadowcolor);
603 for (i=0;i<=np;i++) {
604 x[i] = gPad->AbsPixeltoX(Int_t(px[i]));
605 y[i] = gPad->AbsPixeltoY(Int_t(py[i]));
606 }
607 gPad->PaintFillArea(np,x,y);
608 SetFillStyle(fillstyle);
609 SetFillColor(fillcolor);
610}
611
612////////////////////////////////////////////////////////////////////////////////
613/// Dump this pave with its attributes.
614
616{
618}
619
620////////////////////////////////////////////////////////////////////////////////
621/// Save primitive as a C++ statement(s) on output stream out
622
623void TPave::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
624{
625 char quote = '"';
626 if (gROOT->ClassSaved(TPave::Class())) {
627 out<<" ";
628 } else {
629 out<<" TPave *";
630 }
631 if (fOption.Contains("NDC")) {
632 out<<"pave = new TPave("<<fX1NDC<<","<<fY1NDC<<","<<fX2NDC<<","<<fY2NDC
633 <<","<<fBorderSize<<","<<quote<<fOption<<quote<<");"<<std::endl;
634 } else {
635 out<<"pave = new TPave("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2
636 <<","<<fBorderSize<<","<<quote<<fOption<<quote<<");"<<std::endl;
637 }
638 if (strcmp(GetName(),"TPave")) {
639 out<<" pave->SetName("<<quote<<GetName()<<quote<<");"<<std::endl;
640 }
641 if (fCornerRadius) {
642 out<<" pave->SetCornerRadius("<<fCornerRadius<<");"<<std::endl;
643 }
644 SaveFillAttributes(out,"pave",19,1001);
645 SaveLineAttributes(out,"pave",1,1,1);
646 out<<" pave->Draw();"<<std::endl;
647}
648
649////////////////////////////////////////////////////////////////////////////////
650/// Set the X1 value
651
653{
654 fX1 = x1;
655 if (gPad) {
656 Double_t dpx = gPad->GetX2() - gPad->GetX1();
657 Double_t xp1 = gPad->GetX1();
658 fX1NDC = (fX1-xp1)/dpx;
659 }
660}
661
662////////////////////////////////////////////////////////////////////////////////
663/// Set the X2 value
664
666{
667 fX2 = x2;
668 if (gPad) {
669 Double_t dpx = gPad->GetX2() - gPad->GetX1();
670 Double_t xp1 = gPad->GetX1();
671 fX2NDC = (fX2-xp1)/dpx;
672 }
673}
674
675////////////////////////////////////////////////////////////////////////////////
676/// Set the Y1 value
677
679{
680 fY1 = y1;
681 if (gPad) {
682 Double_t dpy = gPad->GetY2() - gPad->GetY1();
683 Double_t yp1 = gPad->GetY1();
684 fY1NDC = (fY1-yp1)/dpy;
685 }
686}
687
688////////////////////////////////////////////////////////////////////////////////
689/// Set the Y2 value
690
692{
693 fY2 = y2;
694 if (gPad) {
695 Double_t dpy = gPad->GetY2() - gPad->GetY1();
696 Double_t yp1 = gPad->GetY1();
697 fY2NDC = (fY2-yp1)/dpy;
698 }
699}
700
701////////////////////////////////////////////////////////////////////////////////
702/// Stream an object of class TPave.
703
705{
706 if (R__b.IsReading()) {
707 UInt_t R__s, R__c;
708 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
709 if (R__v > 1) {
710 R__b.ReadClassBuffer(TPave::Class(), this, R__v, R__s, R__c);
711 return;
712 }
713 //====process old versions before automatic schema evolution
714 TBox::Streamer(R__b);
715 Float_t x1ndc,y1ndc,x2ndc,y2ndc,rad;
716 R__b >> x1ndc; fX1NDC = x1ndc;
717 R__b >> y1ndc; fY1NDC = y1ndc;
718 R__b >> x2ndc; fX2NDC = x2ndc;
719 R__b >> y2ndc; fY2NDC = y2ndc;
720 R__b >> fBorderSize;
721 R__b >> fInit;
722 R__b >> rad; fCornerRadius = rad;
723 fOption.Streamer(R__b);
724 fName.Streamer(R__b);
725 R__b.CheckByteCount(R__s, R__c, TPave::IsA());
726 //====end of old versions
727
728 } else {
729 R__b.WriteClassBuffer(TPave::Class(),this);
730 }
731}
@ 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:405
R__EXTERN TStyle * gStyle
Definition TStyle.h:414
#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:213
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:236
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:245
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:273
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
void Streamer(TBuffer &) override
Stream an object of class TBox.
Definition TBox.cxx:748
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:231
void Print(Option_t *option="") const override
Dump this box with its attributes.
Definition TBox.cxx:695
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:774
@ 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:615
virtual void SetX2(Double_t x2) override
Set the X2 value.
Definition TPave.cxx:665
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:413
const char * GetName() const override
Returns name of object.
Definition TPave.h:56
@ kNameIsAction
double clicking on TPave will execute action
Definition TPave.h:36
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:704
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TPave.cxx:254
Int_t fBorderSize
window box bordersize in pixels
Definition TPave.h:26
virtual ~TPave()
Pave default destructor.
Definition TPave.cxx:103
TClass * IsA() const override
Definition TPave.h:87
void Draw(Option_t *option="") override
Draw this pave with its current attributes.
Definition TPave.cxx:228
void ls(Option_t *option="") const override
List this pave with its attributes.
Definition TPave.cxx:278
virtual void SetName(const char *name="")
Definition TPave.h:75
virtual void SetX1(Double_t x1) override
Set the X1 value.
Definition TPave.cxx:652
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:623
Int_t fShadowColor
Color of the pave's shadow.
Definition TPave.h:28
virtual void SetY1(Double_t y1) override
Set the Y1 value.
Definition TPave.cxx:678
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
virtual void SetY2(Double_t y2) override
Set the Y2 value.
Definition TPave.cxx:691
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:303
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:240
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:314
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:2834
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:421
void ToLower()
Change string to lower-case.
Definition TString.cxx:1170
virtual void Streamer(TBuffer &)
Stream a string object.
Definition TString.cxx:1390
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:636
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:394
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:592
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:586
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Definition TMath.h:760
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123