Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEllipse.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 "TEllipse.h"
13
14#include <cstdlib>
15#include <iostream>
16
17#include "TROOT.h"
18#include "TBuffer.h"
19#include "TAttMarker.h"
20#include "TVirtualPad.h"
21#include "TBoxInteractive.h"
22#include "TMath.h"
23#include "TPoint.h"
24
25
26constexpr Double_t kPI = TMath::Pi();
27
28
29/** \class TEllipse
30\ingroup BasicGraphics
31
32Draw Ellipses.
33
34The ellipse can be truncated and rotated. It is defined by its center `(x1,y1)`
35and two radius `r1` and `r2`.
36
37A minimum and maximum angle may be specified `(phimin, phimax)`.
38The ellipse may be rotated with an angle `theta`. All these
39angles are in degrees.
40The attributes of the outline line are given via `TAttLine`.
41The attributes of the fill area are given via `TAttFill`.
42The picture below illustrates different types of ellipses.
43
44When an ellipse sector only is drawn, the lines connecting the center
45of the ellipse to the edges are drawn by default. One can specify
46the drawing option "only" to not draw these lines or alternatively
47call the function `SetNoEdges()`. To remove completely the ellipse
48outline it is enough to specify 0 as line style.
49
50Begin_Macro(source)
51../../../tutorials/visualisation/graphics/ellipse.C
52End_Macro
53*/
54
55////////////////////////////////////////////////////////////////////////////////
56/// Ellipse default constructor.
57
59{
60 fX1 = 0;
61 fY1 = 0;
62 fR1 = 1;
63 fR2 = 1;
64 fPhimin = 0;
65 fPhimax = 360;
66 fTheta = 0;
67}
68
69////////////////////////////////////////////////////////////////////////////////
70/// Ellipse normal constructor.
71
73 :TObject(), TAttLine(), TAttFill(0,1001)
74{
75 fX1 = x1;
76 fY1 = y1;
77 fR1 = r1;
78 fR2 = r2;
79 fPhimin = phimin;
80 fPhimax = phimax;
81 fTheta = theta;
82 if (r2 <= 0) fR2 = fR1;
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Ellipse default destructor.
87
91
92////////////////////////////////////////////////////////////////////////////////
93/// Copy constructor.
94
95TEllipse::TEllipse(const TEllipse &ellipse) : TObject(ellipse), TAttLine(ellipse), TAttFill(ellipse), TAttBBox2D(ellipse)
96{
97 fX1 = 0;
98 fY1 = 0;
99 fR1 = 1;
100 fR2 = 1;
101 fPhimin = 0;
102 fPhimax = 360;
103 fTheta = 0;
104
105 ellipse.TEllipse::Copy(*this);
106}
107
108////////////////////////////////////////////////////////////////////////////////
109/// Copy this ellipse to ellipse.
110
111void TEllipse::Copy(TObject &obj) const
112{
113 TObject::Copy(obj);
114 TAttLine::Copy(((TEllipse&)obj));
115 TAttFill::Copy(((TEllipse&)obj));
116 ((TEllipse&)obj).fX1 = fX1;
117 ((TEllipse&)obj).fY1 = fY1;
118 ((TEllipse&)obj).fR1 = fR1;
119 ((TEllipse&)obj).fR2 = fR2;
120 ((TEllipse&)obj).fPhimin = fPhimin;
121 ((TEllipse&)obj).fPhimax = fPhimax;
122 ((TEllipse&)obj).fTheta = fTheta;
123}
124
125////////////////////////////////////////////////////////////////////////////////
126/// Compute distance from point px,py to an ellipse.
127///
128/// Compute the closest distance of approach from point px,py to this
129/// ellipse. The distance is computed in pixels units.
130///
131/// In case of a filled ellipse the distance returned is 0 if the point
132/// (px,py) is inside the ellipse, and is huge if the point is outside.
133
135{
136 if (!gPad) return 9999;
137 Double_t x = gPad->PadtoX(gPad->AbsPixeltoX(px));
138 Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py));
139
140 Double_t dxnr = x - fX1;
141 Double_t dynr = y - fY1;
142
143 Double_t ct = TMath::Cos(kPI*GetTheta()/180.0);
144 Double_t st = TMath::Sin(kPI*GetTheta()/180.0);
145
146 Double_t dx = dxnr*ct + dynr*st;
147 Double_t dy = -dxnr*st + dynr*ct;
148
149 Double_t r1 = fR1;
150 Double_t r2 = fR2;
151
152 if (dx == 0 || r1 == 0 || r2 == 0) return 9999;
153 Double_t distp = TMath::Sqrt(dx*dx + dy*dy);
154
155 Double_t tana = dy/dx;
156 tana *= tana;
157 Double_t distr = TMath::Sqrt((1+tana)/(1.0/(r1*r1) + tana/(r2*r2)));
158 Int_t dist = 9999;
159 if (GetFillColor() && GetFillStyle()) {
160 if (distr > distp) dist = 0;
161 } else {
162 if (TMath::Abs(distr-distp)/(r1+r2) < 0.01) dist = 0;
163 }
164 return dist;
165}
166
167////////////////////////////////////////////////////////////////////////////////
168/// Draw this ellipse with its current attributes.
169
174
175////////////////////////////////////////////////////////////////////////////////
176/// Draw this ellipse with new coordinates.
177
179{
180 TEllipse *newellipse = new TEllipse(x1, y1, r1, r2, phimin, phimax,theta);
181 TAttLine::Copy(*newellipse);
182 TAttFill::Copy(*newellipse);
183 newellipse->SetBit(kCanDelete);
184 newellipse->AppendPad(option);
185 if (TestBit(kNoEdges)) newellipse->SetBit(kNoEdges);
186 return newellipse;
187}
188
189
191 public:
193 : TBoxInteractive(kFALSE, e->GetX1() - e->GetR1(), e->GetY1() - e->GetR2(), e->GetX1() + e->GetR1(),
194 e->GetY1() + e->GetR2())
195 {
196 }
197
198 void PaintOutline(TVirtualPad &parent) override
199 {
200 auto e = static_cast<TEllipse *> (GetObject());
201
202 std::vector<Double_t> x, y;
203 Bool_t fullcircle = e->FillPoints(parent, x, y, (newX1 + newX2) / 2, (newY1 + newY2) / 2, (newX2 - newX1) / 2, (newY2 - newY1) / 2, e->GetPhimin(), e->GetPhimax(), e->GetTheta());
204
205 // "i" is interactive painting, "diamond" is id
206 parent.PaintPolyLine(x.size(), x.data(), y.data(), "iellipse");
207
208 if(!fullcircle || e->GetTheta())
209 PaintDiamondCorners(parent, "iellipse");
210 }
211
212 void Apply(TEllipse *e, Bool_t usenew = kTRUE)
213 {
214 e->SetX1(usenew ? (newX1 + newX2) / 2 : (oldX1 + oldX2) / 2);
215 e->SetR1(usenew ? (newX2 - newX1) / 2 : (oldX2 - oldX1) / 2);
216 e->SetY1(usenew ? (newY1 + newY2) / 2 : (oldY1 + oldY2) / 2);
217 e->SetR2(usenew ? (newY2 - newY1) / 2 : (oldY2 - oldY1) / 2);
218 }
219};
220
221
222////////////////////////////////////////////////////////////////////////////////
223/// Execute action corresponding to one event.
224///
225/// This member function is called when a line is clicked with the locator
226///
227/// If Left button clicked on one of the line end points, this point
228/// follows the cursor until button is released.
229///
230/// if Middle button clicked, the line is moved parallel to itself
231/// until the button is released.
232///
233/// NOTE that support for log scale is not implemented
234
236{
237 if (!gPad || !gPad->IsEditable())
238 return;
239
240 auto &parent = *gPad;
241
242 auto inter = parent.GetInteractive<TEllipseInteractive>(this);
243
244 switch (event) {
245
246 case kArrowKeyPress:
247 case kButton1Down:
248 inter = parent.MakeInteractive<TEllipseInteractive>(this, this);
249 // No break !!!
250
251 case kMouseMotion: {
252 TEllipseInteractive dummy(this);
253 if (!inter) inter = &dummy;
254 inter->CalcPixelCoord(parent, dummy.oldX1, dummy.oldY1, dummy.oldX2, dummy.oldY2);
255
256 if (!inter->SelectDiamondCorner(px, py, kFALSE)) {
257 parent.FreeInteractive(this); // remove interactive objects
258 } else {
259 inter->SetCursor(parent, event == kButton1Down);
260 }
261 break;
262 }
263
264 case kArrowKeyRelease:
265 case kButton1Motion:
266 if (!inter)
267 return;
268
269 if (!inter->ProcessMouseMove(parent, px, py))
270 return;
271
272 inter->ApplyChanges(parent);
273
274 if (inter->IsOpaque(parent)) {
275 inter->Apply(this);
276 parent.ShowGuidelines(this, event, inter->GetGuideChar(), true);
277 parent.Modified(kTRUE);
278 }
279
280 break;
281
282 case kButton1Up:
283 if (inter && inter->IsOpaque(parent))
284 parent.ShowGuidelines(this, event);
285
286 if (gROOT->IsEscaped()) {
287 gROOT->SetEscape(kFALSE);
288 if (inter && inter->IsOpaque(parent)) {
289 inter->Apply(this, kFALSE);
290 }
291 } else if (inter && !inter->IsOpaque(parent)) {
292 inter->Apply(this);
293 }
294
295 parent.Modified();
296 parent.FreeInteractive(this);
297 break;
298 }
299}
300
301////////////////////////////////////////////////////////////////////////////////
302/// Return 1 if the point (x,y) is inside the polygon defined by
303/// the ellipse 0 otherwise.
304/// Author: Ole Hansen (ole@jlab.org)
306{
307 x -= fX1;
308 y -= fY1;
310 Double_t st = TMath::Sin(th);
311 Double_t ct = TMath::Cos(th);
312 Double_t xx = ct * x + st * y;
313 Double_t yy = -st * x + ct * y;
314
315 if (TMath::Abs(xx) > fR1 || TMath::Abs(yy) > fR2)
316 return 0;
317 Double_t xn = xx / fR1;
318 Double_t yn = yy / fR2;
319 if (xn * xn + yn * yn > 1.)
320 return 0;
321 if (fPhimax - fPhimin >= 360.)
322 return 1;
323 Double_t phimin = std::fmod(fPhimin, 360.);
324 Double_t phimax = std::fmod(fPhimax, 360.);
325 Double_t phi = TMath::RadToDeg()*(TMath::Pi() + TMath::ATan2(-yy * fR1 / fR2, -xx));
326 if (phi < phimin || phi > phimax)
327 return 0;
328
329 return 1;
330}
331
332
333////////////////////////////////////////////////////////////////////////////////
334/// List this ellipse with its attributes.
335
337{
339 printf("%s: X1= %f Y1=%f R1=%f R2=%f\n",GetName(),fX1,fY1,fR1,fR2);
340}
341
342////////////////////////////////////////////////////////////////////////////////
343/// Paint this ellipse with its current attributes.
344
349
350////////////////////////////////////////////////////////////////////////////////
351/// Fill points which can be used for the painting
352/// Return true if full 360 ellipse is created
353
354Bool_t TEllipse::FillPoints(TVirtualPad &pad, std::vector<Double_t> &x, std::vector<Double_t> &y,
355 Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, Double_t theta)
356{
357 const Int_t np = 200;
358
359 Double_t phi1 = TMath::Min(phimin, phimax);
360 Double_t phi2 = TMath::Max(phimin, phimax);
361
362 //set number of points approximatively proportional to the ellipse circumference
363 Double_t circ = kPI*(r1+r2)*(phi2-phi1)/360;
364 Int_t n = (Int_t)(np*circ/((pad.GetX2() - pad.GetX1())+(pad.GetY2()-pad.GetY1())));
365 Bool_t full_circle = phi2-phi1 >= 360;
366 n = TMath::Min(np, TMath::Max(n, (Int_t) (full_circle ? 36 : 8)));
367
368 x.resize(n + (full_circle ? 1 : 3));
369 y.resize(n + (full_circle ? 1 : 3));
370
371 Double_t dphi = (phi2-phi1)*kPI/(180*n);
372 Double_t ct = TMath::Cos(kPI*theta/180);
373 Double_t st = TMath::Sin(kPI*theta/180);
374 for (Int_t i = 0; i <= n; i++) {
375 Double_t angle = phi1*kPI/180 + i*dphi;
376 Double_t dx = r1*TMath::Cos(angle);
377 Double_t dy = r2*TMath::Sin(angle);
378 x[i] = pad.XtoPad(x1 + dx*ct - dy*st);
379 y[i] = pad.YtoPad(y1 + dx*st + dy*ct);
380 }
381 if (!full_circle) {
382 x[n+1] = pad.XtoPad(x1);
383 y[n+1] = pad.YtoPad(y1);
384 x[n+2] = x[0];
385 y[n+2] = y[0];
386 }
387
388 return full_circle;
389}
390
391
392////////////////////////////////////////////////////////////////////////////////
393/// Draw this ellipse with new coordinates.
394
396 Double_t phimin, Double_t phimax, Double_t theta,
398{
399 if (!gPad) return;
400
401 std::vector<Double_t> x, y;
402 Bool_t full_circle = FillPoints(*gPad, x, y, x1, y1, r1, r2, phimin, phimax, theta);
403
404 TAttFill::ModifyOn(*gPad); //Change fill attributes only if necessary
405 TAttLine::ModifyOn(*gPad); //Change line attributes only if necessary
406
407 if (GetFillStyle() > 0)
408 gPad->PaintFillArea(x.size() - 1, x.data(), y.data());
409
410 if (GetLineStyle() > 0) {
411 TString opt = option;
412 opt.ToLower();
413 Bool_t less_points = !full_circle && (TestBit(kNoEdges) || opt.Contains("only"));
414 gPad->PaintPolyLine(x.size() - (less_points ? 2 : 0), x.data(), y.data());
415 }
416}
417
418////////////////////////////////////////////////////////////////////////////////
419/// Dump this ellipse with its attributes.
420
422{
423 printf("Ellipse: X1=%f Y1=%f R1=%f R2=%f",fX1,fY1,fR1,fR2);
424 if (GetLineColor() != 1) printf(" Color=%d",GetLineColor());
425 if (GetLineStyle() != 1) printf(" Style=%d",GetLineStyle());
426 if (GetLineWidth() != 1) printf(" Width=%d",GetLineWidth());
427 printf("\n");
428}
429
430////////////////////////////////////////////////////////////////////////////////
431/// Save primitive as a C++ statement(s) on output stream out
432
433void TEllipse::SavePrimitive(std::ostream &out, Option_t *option)
434{
436 out, Class(), "ellipse",
437 TString::Format("%g, %g, %g, %g, %g, %g, %g", fX1, fY1, fR1, fR2, fPhimin, fPhimax, fTheta));
438
439 SaveFillAttributes(out, "ellipse", 0, 1001);
440 SaveLineAttributes(out, "ellipse", 1, 1, 1);
441
442 if (GetNoEdges())
443 out << " ellipse->SetNoEdges();\n";
444
445 SavePrimitiveDraw(out, "ellipse", option);
446}
447
448////////////////////////////////////////////////////////////////////////////////
449/// Return kTRUE if kNoEdges bit is set, kFALSE otherwise.
450
452{
453 return TestBit(kNoEdges) ? kTRUE : kFALSE;
454}
455
456////////////////////////////////////////////////////////////////////////////////
457/// if noEdges = kTRUE the lines connecting the center to the edges
458/// will not be drawn.
459/// default is to draw the edges.
460
462{
463 if (noEdges) SetBit(kNoEdges);
464 else ResetBit(kNoEdges);
465}
466
467////////////////////////////////////////////////////////////////////////////////
468/// Stream an object of class TEllipse.
469
471{
472 if (R__b.IsReading()) {
473 UInt_t R__s, R__c;
474 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
475 if (R__v > 1) {
476 R__b.ReadClassBuffer(TEllipse::Class(), this, R__v, R__s, R__c);
477 return;
478 }
479 //====process old versions before automatic schema evolution
480 TObject::Streamer(R__b);
481 TAttLine::Streamer(R__b);
482 TAttFill::Streamer(R__b);
483 Float_t x1,y1,r1,r2,phimin,phimax,theta;
484 R__b >> x1; fX1 = x1;
485 R__b >> y1; fY1 = y1;
486 R__b >> r1; fR1 = r1;
487 R__b >> r2; fR2 = r2;
488 R__b >> phimin; fPhimin = phimin;
489 R__b >> phimax; fPhimax = phimax;
490 R__b >> theta; fTheta = theta;
491 R__b.CheckByteCount(R__s, R__c, TEllipse::IsA());
492 //====end of old versions
493
494 } else {
496 }
497}
498
499////////////////////////////////////////////////////////////////////////////////
500/// Return the bounding Box of the Ellipse, currently not taking into
501/// account the rotating angle.
502
504{
505 Rectangle_t BBox{0, 0, 0, 0};
506 if (gPad) {
507 BBox.fX = gPad->XtoPixel(fX1 - fR1);
508 BBox.fY = gPad->YtoPixel(fY1 + fR2);
509 BBox.fWidth = gPad->XtoPixel(fX1 + fR1) - gPad->XtoPixel(fX1 - fR1);
510 BBox.fHeight = gPad->YtoPixel(fY1 - fR2) - gPad->YtoPixel(fY1 + fR2);
511 }
512 return BBox;
513}
514
515////////////////////////////////////////////////////////////////////////////////
516/// Return the center of the Ellipse as TPoint in pixels
517
519{
520 TPoint p(0, 0);
521 if (gPad) {
522 p.SetX(gPad->XtoPixel(fX1));
523 p.SetY(gPad->YtoPixel(fY1));
524 }
525 return p;
526}
527
528////////////////////////////////////////////////////////////////////////////////
529/// Set X coordinate of the center of the Ellipse
530
532{
533 SetX1(GetXCoord(x));
534}
535
536////////////////////////////////////////////////////////////////////////////////
537/// Set Y coordinate of the center of the Ellipse
538
540{
541 SetY1(GetYCoord(y));
542}
543
544////////////////////////////////////////////////////////////////////////////////
545/// Set left hand side of BoundingBox to a value
546/// (resize in x direction on left)
547
549{
551 if (x1 > fX1+fR1) return;
552
553 SetR1((fX1+fR1-x1)*0.5);
554 SetX1(x1 + fR1);
555}
556
557////////////////////////////////////////////////////////////////////////////////
558/// Set right hand side of BoundingBox to a value
559/// (resize in x direction on right)
560
562{
564 if (x2 < fX1-fR1) return;
565
566 SetR1((x2-fX1+fR1)*0.5);
567 SetX1(x2 - fR1);
568}
569
570////////////////////////////////////////////////////////////////////////////////
571/// Set top of BoundingBox to a value (resize in y direction on top)
572
574{
576 if (y1 < fY1-fR2) return;
577
578 SetR2((y1-fY1+fR2)*0.5);
579 SetY1(y1 - fR2);
580}
581
582////////////////////////////////////////////////////////////////////////////////
583/// Set bottom of BoundingBox to a value
584/// (resize in y direction on bottom)
585
587{
589 if (y2 > fY1+fR2) return;
590
591 SetR2((fY1+fR2-y2)*0.5);
592 SetY1(y2 + fR2);
593}
@ kMouseMotion
Definition Buttons.h:23
@ kArrowKeyRelease
Definition Buttons.h:21
@ kButton1Motion
Definition Buttons.h:20
@ kButton1Up
Definition Buttons.h:19
@ kArrowKeyPress
Definition Buttons.h:21
@ kButton1Down
Definition Buttons.h:17
#define e(i)
Definition RSha256.hxx:103
cudaEvent_t event
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
short Version_t
Class version identifier (short)
Definition RtypesCore.h:80
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
constexpr Double_t kPI
Definition TEllipse.cxx:26
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
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 x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
#define gROOT
Definition TROOT.h:417
#define gPad
Abstract base class for elements drawn in the editor.
Definition TAttBBox2D.h:19
Double_t GetYCoord(const Int_t y, Bool_t is_ndc=kFALSE, Bool_t is_absolute=kFALSE)
Can return ndc or normal values Also one can specify to use absolute coordinates for input parameter ...
Double_t GetXCoord(const Int_t x, Bool_t is_ndc=kFALSE, Bool_t is_absolute=kFALSE)
Return user X coordinate for pixel X value Can return ndc or normal values Also one can specify to us...
Fill Area Attributes class.
Definition TAttFill.h:21
virtual void Streamer(TBuffer &)
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:32
void Copy(TAttFill &attfill) const
Copy this fill attributes to a new TAttFill.
Definition TAttFill.cxx:203
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:33
virtual void ModifyOn(TVirtualPad &pad)
Change current fill area attributes on speicifed pad.
Definition TAttFill.cxx:221
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:240
Line Attributes class.
Definition TAttLine.h:21
virtual void Streamer(TBuffer &)
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:36
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:38
virtual void ModifyOn(TVirtualPad &pad)
Change current line attributes on specified pad.
Definition TAttLine.cxx:255
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:37
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
Definition TAttLine.cxx:176
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:289
void CalcPixelCoord(const TVirtualPad &parent, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Calculate pixel coordinates.
void PaintDiamondCorners(TVirtualPad &parent, const char *id="idiamond")
Paint diamond corners outline.
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
void PaintOutline(TVirtualPad &parent) override
Paint object outline.
Definition TEllipse.cxx:198
TEllipseInteractive(TEllipse *e)
Definition TEllipse.cxx:192
void Apply(TEllipse *e, Bool_t usenew=kTRUE)
Definition TEllipse.cxx:212
Draw Ellipses.
Definition TEllipse.h:25
TClass * IsA() const override
Definition TEllipse.h:86
virtual void SetR1(Double_t r1)
Definition TEllipse.h:72
void ls(Option_t *option="") const override
List this ellipse with its attributes.
Definition TEllipse.cxx:336
virtual void SetX1(Double_t x1)
Definition TEllipse.h:75
virtual void PaintEllipse(Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, Double_t theta, Option_t *option="")
Draw this ellipse with new coordinates.
Definition TEllipse.cxx:395
void SetBBoxCenterY(const Int_t y) override
Set Y coordinate of the center of the Ellipse.
Definition TEllipse.cxx:539
Double_t GetTheta() const
Definition TEllipse.h:62
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TEllipse.cxx:235
void SetBBoxY1(const Int_t y) override
Set top of BoundingBox to a value (resize in y direction on top)
Definition TEllipse.cxx:573
void SetBBoxX1(const Int_t x) override
Set left hand side of BoundingBox to a value (resize in x direction on left)
Definition TEllipse.cxx:548
void SetBBoxY2(const Int_t y) override
Set bottom of BoundingBox to a value (resize in y direction on bottom)
Definition TEllipse.cxx:586
@ kNoEdges
Definition TEllipse.h:44
Double_t fPhimax
Maximum angle (degrees)
Definition TEllipse.h:35
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to an ellipse.
Definition TEllipse.cxx:134
Double_t fX1
X coordinate of centre.
Definition TEllipse.h:30
void SetBBoxX2(const Int_t x) override
Set right hand side of BoundingBox to a value (resize in x direction on right)
Definition TEllipse.cxx:561
Bool_t GetNoEdges() const
Return kTRUE if kNoEdges bit is set, kFALSE otherwise.
Definition TEllipse.cxx:451
void Draw(Option_t *option="") override
Draw this ellipse with its current attributes.
Definition TEllipse.cxx:170
Rectangle_t GetBBox() override
Return the bounding Box of the Ellipse, currently not taking into account the rotating angle.
Definition TEllipse.cxx:503
void Paint(Option_t *option="") override
Paint this ellipse with its current attributes.
Definition TEllipse.cxx:345
Double_t fY1
Y coordinate of centre.
Definition TEllipse.h:31
Double_t fTheta
Rotation angle (degrees)
Definition TEllipse.h:36
Int_t IsInside(Double_t x, Double_t y) const
Return 1 if the point (x,y) is inside the polygon defined by the ellipse 0 otherwise.
Definition TEllipse.cxx:305
void SetBBoxCenterX(const Int_t x) override
Set X coordinate of the center of the Ellipse.
Definition TEllipse.cxx:531
Bool_t FillPoints(TVirtualPad &pad, std::vector< Double_t > &x, std::vector< Double_t > &y, Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, Double_t theta)
Fill points which can be used for the painting Return true if full 360 ellipse is created.
Definition TEllipse.cxx:354
virtual void SetY1(Double_t y1)
Definition TEllipse.h:76
~TEllipse() override
Ellipse default destructor.
Definition TEllipse.cxx:88
Double_t fR2
second radius
Definition TEllipse.h:33
void Streamer(TBuffer &) override
Stream an object of class TEllipse.
Definition TEllipse.cxx:470
virtual void SetNoEdges(Bool_t noEdges=kTRUE)
if noEdges = kTRUE the lines connecting the center to the edges will not be drawn.
Definition TEllipse.cxx:461
void Copy(TObject &ellipse) const override
Copy this ellipse to ellipse.
Definition TEllipse.cxx:111
Double_t fPhimin
Minimum angle (degrees)
Definition TEllipse.h:34
TPoint GetBBoxCenter() override
Return the center of the Ellipse as TPoint in pixels.
Definition TEllipse.cxx:518
TEllipse()
Ellipse default constructor.
Definition TEllipse.cxx:58
Double_t fR1
first radius
Definition TEllipse.h:32
static TClass * Class()
virtual TEllipse * DrawEllipse(Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, Double_t theta, Option_t *option="")
Draw this ellipse with new coordinates.
Definition TEllipse.cxx:178
virtual void SetR2(Double_t r2)
Definition TEllipse.h:73
void Print(Option_t *option="") const override
Dump this ellipse with its attributes.
Definition TEllipse.cxx:421
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition TEllipse.cxx:433
Mother of all ROOT objects.
Definition TObject.h:42
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:461
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
Definition TObject.cxx:995
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:203
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:886
virtual void Copy(TObject &object) const
Copy this to obj.
Definition TObject.cxx:158
static void SavePrimitiveDraw(std::ostream &out, const char *variable_name, Option_t *option=nullptr)
Save invocation of primitive Draw() method Skipped if option contains "nodraw" string.
Definition TObject.cxx:844
static void SavePrimitiveConstructor(std::ostream &out, TClass *cl, const char *variable_name, const char *constructor_agrs="", Bool_t empty_line=kTRUE)
Save object constructor in the output stream "out".
Definition TObject.cxx:776
void ResetBit(UInt_t f)
Definition TObject.h:203
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:71
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:3067
Basic string class.
Definition TString.h:137
void ToLower()
Change string to lower-case.
Definition TString.cxx:1190
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2460
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:642
TObject * GetObject() const
Definition TVirtualPad.h:79
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:53
virtual Double_t GetX2() const =0
virtual Double_t GetY1() const =0
virtual Double_t YtoPad(Double_t y) const =0
virtual void PaintPolyLine(Int_t n, Float_t *x, Float_t *y, Option_t *option="")=0
virtual Double_t XtoPad(Double_t x) const =0
virtual Double_t GetY2() const =0
virtual Double_t GetTheta() const =0
virtual Double_t GetX1() const =0
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:249
Double_t ATan2(Double_t y, Double_t x)
Returns the principal value of the arc tangent of y/x, expressed in radians.
Definition TMath.h:659
constexpr Double_t DegToRad()
Conversion from degree to radian: .
Definition TMath.h:82
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:675
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:607
constexpr Double_t Pi()
Definition TMath.h:40
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:601
constexpr Double_t RadToDeg()
Conversion from radian to degree: .
Definition TMath.h:75
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:122
Rectangle structure (maps to the X11 XRectangle structure)
Definition GuiTypes.h:362
Short_t fX
Definition GuiTypes.h:363