Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGraphPolargram.cxx
Go to the documentation of this file.
1// @(#)root/graf:$Id$
2// Author: Sebastian Boser, Mathieu Demaret 02/02/06
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/** \class TGraphPolargram
13\ingroup BasicGraphics
14
15To draw polar axis
16
17TGraphPolargram draw the polar axis of the TGraphPolar.
18
19Example:
20
21Begin_Macro(source)
22{
23 TCanvas * CPol = new TCanvas("CPol","TGraphPolar Examples",500,500);
24
25 Double_t rmin=0;
26 Double_t rmax=TMath::Pi()*2;
27 Double_t r[1000];
28 Double_t theta[1000];
29
30 TF1 * fp1 = new TF1("fplot","cos(x)",rmin,rmax);
31 for (Int_t ipt = 0; ipt < 1000; ipt++) {
32 r[ipt] = ipt*(rmax-rmin)/1000+rmin;
33 theta[ipt] = fp1->Eval(r[ipt]);
34 }
35 TGraphPolar * grP1 = new TGraphPolar(1000,r,theta);
36 grP1->SetTitle("");
37 grP1->SetLineColor(2);
38 grP1->Draw("AOL");
39}
40End_Macro
41*/
42
43#include "TGraphPolar.h"
44#include "TGraphPolargram.h"
45#include "TGaxis.h"
46#include "THLimitsFinder.h"
47#include "TVirtualPad.h"
48#include "TLatex.h"
49#include "TEllipse.h"
50#include "TMath.h"
51
52
53////////////////////////////////////////////////////////////////////////////////
54/// TGraphPolargram Constructor.
55
57 Double_t tmin, Double_t tmax, const char *opt):
58 TNamed(name, "Polargram")
59{
60 Init();
61 fNdivRad = 508;
62 fNdivPol = 508;
63 fPolarLabels = nullptr;
64 fRwrmax = rmax;
65 fRwrmin = rmin;
66 fRwtmin = tmin;
67 fRwtmax = tmax;
68
69 TString s = opt;
70 s.ToUpper();
71 if (s.Contains("R")) {
72 fRadian = kTRUE;
73 fRwtmin = 0;
74 fRwtmax = 2*TMath::Pi();
75 } else if (s.Contains("D")) {
76 fDegree = kTRUE;
77 fRwtmin = 0;
78 fRwtmax = 360;
79 } else if (s.Contains("G")) {
80 fGrad = kTRUE;
81 fRwtmin = 0;
82 fRwtmax = 200;
83 }
84}
85
86////////////////////////////////////////////////////////////////////////////////
87/// Short constructor used in the case of a spider plot.
88
90 TNamed(name,"Polargram")
91{
92 Init();
93 fNdivRad = 0;
94 fNdivPol = 0;
95 fPolarLabels = nullptr;
96 fRwrmax = 1;
97 fRwrmin = 0;
98 fRwtmax = 0;
99 fRwtmin = 0;
100}
101
102////////////////////////////////////////////////////////////////////////////////
103/// TGraphPolargram destructor.
104
109
110////////////////////////////////////////////////////////////////////////////////
111/// Set the Polar range.
112/// \param[in] tmin the start number.
113/// \param[in] tmax the end number.
114
116{
117 if (tmin < tmax) {
118 fRwtmin = tmin;
119 fRwtmax = tmax;
120 }
121 if (gPad) gPad->Modified();
122}
123
124////////////////////////////////////////////////////////////////////////////////
125/// Everything within the circle belongs to the TGraphPolargram.
126
128{
129 if (!gPad) return 9999;
130 Int_t i;
131 Double_t x = gPad->AbsPixeltoX(px);
132 Double_t y = gPad->AbsPixeltoY(py);
133
134 // Check if close to a (major) radial line.
135 Double_t rad = TMath::Sqrt(x*x+y*y);
136 Int_t div = (Int_t)rad*(fNdivRad%100);
138 TMath::Abs(rad-(div+1)*1./(fNdivRad%100)));
139 Int_t drad = gPad->XtoPixel(dr)-gPad->XtoPixel(0);
140
141 // Check if close to a (major) Polar line.
142 // This is not a proper calculation, but rather fast.
144 for (i=0; i<(fNdivPol%100); i++) {
145 Double_t theta = i*2*TMath::Pi()/(fNdivPol%100);
146
147 // Attention: px,py in pixel units, line given in user coordinates.
148 Int_t dthis = DistancetoLine(px,py,0.,0.,TMath::Cos(theta),
149 TMath::Sin(theta));
150
151 // Fails if we are outside box described by the line.
152 // (i.e for all hor/vert lines)
153 if (dthis==9999) {
154
155 // Outside -> Get distance to endpoint of line.
156 if (rad>1) {
158 TMath::Power(px-gPad->XtoPixel(TMath::Cos(theta)),2)+
159 TMath::Power(py-gPad->YtoPixel(TMath::Sin(theta)),2));
160 } else {
161
162 // Check for horizontal line.
163 if (((TMath::Abs(theta-TMath::Pi())<0.1) &&
164 ((px-gPad->XtoPixel(0))<0)) ||
165 ((TMath::Abs(theta)<0.1) &&
166 ((px-gPad->XtoPixel(0))>0))) {
167 dthis = TMath::Abs(py-gPad->YtoPixel(0.));
168 }
169
170 //Check for vertical line.
171 if (((TMath::Abs(theta-TMath::PiOver2())<0.1) &&
172 ((py-gPad->YtoPixel(0))>0)) ||
173 ((TMath::Abs(theta-3*TMath::PiOver2())<0.1) &&
174 (py-gPad->YtoPixel(0))<0)) {
175 dthis = TMath::Abs(px-gPad->XtoPixel(0.));
176 }
177 if (dthis==9999) {
178
179 // Inside, but out of box for nonorthogonal line ->
180 // get distance to start point.
182 TMath::Power(px-gPad->XtoPixel(0.),2)+
183 TMath::Power(py-gPad->YtoPixel(0.),2));
184 }
185 }
186 }
187
188 // Take distance to closes line.
190 }
191 return TMath::Min(drad, dt);
192}
193
194////////////////////////////////////////////////////////////////////////////////
195/// Draw Polargram.
196
198{
199 Paint(options);
200 AppendPad(options);
201}
202
203////////////////////////////////////////////////////////////////////////////////
204/// Indicate that there is something to click here.
205
207{
208 if (!gPad) return;
209
210 Int_t kMaxDiff = 20;
211 static Int_t d1, d2, d3, px1, py1, px3, py3;
212 static Bool_t p1, p2, p3, p4, p5, p6, p7, p8;
213 Double_t px2, py2;
214 p2 = p3 = p4 = p5 = p6 = p7 = p8 = kFALSE;
215 if (!gPad->IsEditable()) return;
216 switch (event) {
217 case kMouseMotion:
218 px1 = gPad->XtoAbsPixel(TMath::Cos(GetAngle()));
219 py1 = gPad->YtoAbsPixel(TMath::Sin(GetAngle()));
220 d1 = TMath::Abs(px1 - px) + TMath::Abs(py1-py); //simply take sum of pixels differences
221 p1 = kFALSE;
222 px2 = gPad->XtoAbsPixel(-1);
223 py2 = gPad->YtoAbsPixel(1);
224 d2 = (Int_t)(TMath::Abs(px2 - px) + TMath::Abs(py2 - py)) ;
225 px3 = gPad->XtoAbsPixel(-1);
226 py3 = gPad->YtoAbsPixel(-1);
227 d3 = TMath::Abs(px3 - px) + TMath::Abs(py3 - py) ; //simply take sum of pixels differences
228 // check if point is close to the radial axis
229 if (d1 < kMaxDiff) {
230 gPad->SetCursor(kMove);
231 p1 = kTRUE;
232 }
233 // check if point is close to the left high axis
234 if ( d2 < kMaxDiff) {
235 gPad->SetCursor(kHand);
236 p7 = kTRUE;
237 }
238 // check if point is close to the left down axis
239 if ( d3 < kMaxDiff) {
240 gPad->SetCursor(kHand);
241 p8 = kTRUE;
242 }
243 // check if point is close to a main circle
244 if (!p1 && !p7 ) {
245 p6 = kTRUE;
246 gPad->SetCursor(kHand);
247 }
248 break;
249
250 case kButton1Down:
251 // Record initial coordinates
252 //px4 = px;
253 //py4 = py;
254
255 case kButton1Motion:
256 if (p1) {
257 px2 = gPad->AbsPixeltoX(px);
258 py2 = gPad->AbsPixeltoY(py);
259 if ( px2 < 0 && py2 < 0) {p2 = kTRUE;};
260 if ( px2 < 0 && py2 > 0 ) {p3 = kTRUE;};
261 if ( px2 > 0 && py2 > 0 ) {p4 = kTRUE;};
262 if ( px2 > 0 && py2 < 0 ) {p5 = kTRUE;};
263 px2 = TMath::ACos(TMath::Abs(px2));
264 py2 = TMath::ASin(TMath::Abs(py2));
265 if (p2) {
266 fAxisAngle = TMath::Pi()+(px2+py2)/2;
267 p2 = kFALSE;
268 };
269 if (p3) {
270 fAxisAngle = TMath::Pi()-(px2+py2)/2;
271 p3 = kFALSE;
272 };
273 if (p4) {
274 fAxisAngle = (px2+py2)/2;
275 p4 = kFALSE;
276 };
277 if (p5) {
278 fAxisAngle = -(px2+py2)/2;
279 p5 = kFALSE;
280 };
281 }
282 break;
283
284 case kButton1Up:
285 Paint();
286 }
287}
288
289////////////////////////////////////////////////////////////////////////////////
290/// Find the alignement rule to apply for TText::SetTextAlign(Short_t).
291
293{
294 Double_t pi = TMath::Pi();
295
296 while(angle < 0 || angle > 2*pi){
297 if(angle < 0) angle+=2*pi;
298 if(angle > 2*pi) angle-=2*pi;
299 }
301 if(angle > 0 && angle < pi/2) return 11;
302 else if(angle > pi/2 && angle < pi) return 31;
303 else if(angle > pi && angle < 3*pi/2) return 33;
304 else if(angle > 3*pi/2 && angle < 2*pi) return 13;
305 else if(angle == 0 || angle == 2*pi) return 12;
306 else if(angle == pi/2) return 21;
307 else if(angle == pi) return 32;
308 else if(angle == 3*pi/2) return 23;
309 else return 0;
310 }
311 else{
312 if(angle >= 0 && angle <= pi/2) return 12;
313 else if((angle > pi/2 && angle <= pi) || (angle > pi && angle <= 3*pi/2)) return 32;
314 else if(angle > 3*pi/2 && angle <= 2*pi) return 12;
315 else return 0;
316 }
317}
318
319////////////////////////////////////////////////////////////////////////////////
320/// Determine the orientation of the polar labels according to their angle.
321
323{
324 Double_t pi = TMath::Pi();
325 Double_t convraddeg = 180.0/pi;
326
327 while(angle < 0 || angle > 2*pi){
328 if(angle < 0) angle+=2*pi;
329 if(angle > 2*pi) angle-=2*pi;
330 }
331
332 if(angle >= 0 && angle <= pi/2) return angle*convraddeg;
333 else if(angle > pi/2 && angle <= pi) return (angle + pi)*convraddeg;
334 else if(angle > pi && angle <= 3*pi/2) return (angle - pi)*convraddeg;
335 else if(angle > 3*pi/2 && angle <= 2*pi) return angle*convraddeg;
336 else return 0;
337}
338
339////////////////////////////////////////////////////////////////////////////////
340/// Initialize some of the fields of TGraphPolargram.
341
343{
344 fAxisAngle = 0;
345 fCutRadial = 0;
346 fDegree = kFALSE;
347 fGrad = kFALSE;
348 fLineStyle = 3;
350 fPolarLabelFont = 62;
351 fPolarOffset = 0.04;
352 fPolarTextSize = 0.04;
353 fRadialOffset = 0.025;
354 fRadian = kTRUE;
356 fRadialLabelFont = 62;
357 fRadialTextSize = 0.035;
358 fTickpolarSize = 0.02;
359}
360
361////////////////////////////////////////////////////////////////////////////////
362/// Paint TGraphPolargram.
363
382
383////////////////////////////////////////////////////////////////////////////////
384/// This is simplified from TEllipse::PaintEllipse.
385/// Draw this ellipse with new coordinates.
386
389{
390 if (!gPad) return;
391
392 Int_t i;
393 const Int_t np = 200; // Number of point to draw circle
394 static Double_t x[np+3], y[np+3];
395
396 // Set number of points approximatively proportional to the ellipse
397 // circumference.
398
400 Int_t n = (Int_t)(np*circ/((gPad->GetX2()-gPad->GetX1())+
401 (gPad->GetY2()-gPad->GetY1())));
402 if (n < 8) n = 8;
403 if (n > np) n = np;
405 Double_t dphi = (phimax-phimin)*TMath::Pi()/(180*n);
406 Double_t ct = TMath::Cos(TMath::Pi()*theta/180);
407 Double_t st = TMath::Sin(TMath::Pi()*theta/180);
408 for (i=0; i<=n; i++) {
409 angle = phimin*TMath::Pi()/180 + Double_t(i)*dphi;
410 dx = r*TMath::Cos(angle);
411 dy = r*TMath::Sin(angle);
412 x[i] = x1 + dx*ct - dy*st;
413 y[i] = y1 + dx*st + dy*ct;
414 }
415 gPad->PaintPolyLine(n+1,x,y);
416}
417
418////////////////////////////////////////////////////////////////////////////////
419/// Draw Polar divisions.
420/// Check for editable pad or create default.
421
423{
424 if (!gPad) return ;
425 Int_t i, j, rnum, rden, first, last;
426
427 gPad->RangeAxis(-1,-1,1,1);
428 gPad->Range(-1.25,-1.25,1.25,1.25);
431
432 if (!gPad->GetLogy()) {
433 for (i=0; i<ndivMajor; i++) {
435 Double_t theta = i*2*TMath::Pi()/ndivMajor;
441 Double_t corr = 0.01;
442
444 textangular.SetTextColor(GetPolarColorLabel());
445 textangular.SetTextFont(GetPolarLabelFont());
446
447 TString form = " ";
448 TGaxis axis;
450 // Polar numbers are aligned with their axis.
451 if(!fPolarLabels && optionLabels){;
452 if (fRadian) {
453 // Radian case.
454 ReduceFraction(2*i, ndivMajor, rnum, rden); // Reduces the fraction.
455 if (rnum == 0) form.Form("%d",rnum);
456 if (rnum == 1 && rden == 1) form = "#pi";
457 if (rnum == 1 && rden != 1) form.Form("#frac{#pi}{%d}",rden);
458 if (rnum != 1 && rden == 1 && i !=0) form.Form("%d#pi",rnum);
459 if (rnum != 1 && rden != 1) form.Form("#frac{%d#pi}{%d}",rnum,rden);
460 textangular.SetTextAlign(FindAlign(theta));
461 textangular.PaintLatex(costhetas,
462 sinthetas, FindTextAngle(theta),
463 GetPolarLabelSize(), form.Data());
464 } else {
465 // Any other cases: numbers are aligned with their axis.
466 form.Form("%5.3g",txtval);
467 axis.LabelsLimits(form.Data(),first,last);
468 TString s = form;
469 if (first != 0) s.Remove(0, first);
470 textangular.SetTextAlign(FindAlign(theta));
471 textangular.PaintLatex(costhetas,
472 sinthetas, FindTextAngle(theta),
473 GetPolarLabelSize(), s);
474 }
475 } else if (fPolarLabels){
476 // print the specified polar labels
477 textangular.SetTextAlign(FindAlign(theta));
480 }
481 } else {
482 // Polar numbers are shown horizontally.
484 if (fRadian) {
485 // Radian case
487 if (rnum == 0) form.Form("%d",rnum);
488 if (rnum == 1 && rden == 1) form = "#pi";
489 if (rnum == 1 && rden != 1) form.Form("#frac{#pi}{%d}",rden);
490 if (rnum != 1 && rden == 1 && i !=0) form.Form("%d#pi",rnum);
491 if (rnum != 1 && rden != 1) form.Form("#frac{%d#pi}{%d}",rnum,rden);
492 if(theta >= 3*TMath::Pi()/12.0 && theta < 2*TMath::Pi()/3.0) corr=0.04;
493 textangular.SetTextAlign(FindAlign(theta));
494 textangular.PaintLatex(costhetas,corr+sinthetas,0,
495 GetPolarLabelSize(),form.Data());
496 } else {
497 // Any other cases where numbers are shown horizontally.
498 form.Form("%5.3g",txtval);
499 axis.LabelsLimits(form.Data(),first,last);
500 TString s = form;
501 if (first != 0) s.Remove(0, first);
502 if(theta >= 3*TMath::Pi()/12.0 && theta < 2*TMath::Pi()/3.0) corr=0.04;
503 textangular.SetTextAlign(FindAlign(theta));
504 textangular.PaintLatex(costhetas, //j'ai efface des offset la
505 corr+sinthetas,0,GetPolarLabelSize(),s);
506 }
507 } else if (fPolarLabels) {
508 // print the specified polar labels
509 textangular.SetTextAlign(FindAlign(theta));
511 }
512 }
514 //Check if SetTickPolar is activated, and draw tick marks
515 Bool_t issettickpolar = gPad->GetTicky();
516
517 if (issettickpolar) {
518 if (theta != 0 && theta !=TMath::Pi()) {
521 }
522 if (theta == 0 || theta ==TMath::Pi()) {
523 gPad->PaintLine(1-GetTickpolarSize(),0,1+GetTickpolarSize(),0);
524 gPad->PaintLine(-1+GetTickpolarSize(),0,-1-GetTickpolarSize(),0);
525 }
526 }
529 gPad->PaintLine(0.,0.,costheta,sintheta);
530 // Add minor lines w/o text.
532 TAttLine::SetLineStyle(2); //Minor lines always in this style.
533 TAttLine::Modify(); //Changes line attributes apart from style.
534 for (j=1; j<ndivMinor; j++) {
536 gPad->PaintLine(0.,0.,TMath::Cos(thetamin),TMath::Sin(thetamin));
537 }
540 }
541 } else {
543 Int_t test= 1;
544 while (big >= 10) {
545 big = big/10;
546 test++;
547 }
548 for (i=1; i<=test; i++) {
549 Double_t txtval = pow((double)10,(double)(i-1));
550 Double_t theta = (i-1)*2*TMath::Pi()/(double)(test);
556 Double_t corr = 0.01;
557
559 textangular.SetTextColor(GetPolarColorLabel());
560 textangular.SetTextFont(GetPolarLabelFont());
561
562 TString form = " ";
563 TGaxis axis;
564
567 // Polar numbers are aligned with their axis.
568 form.Form("%5.3g",txtval);
569 axis.LabelsLimits(form.Data(),first,last);
570 TString s = form;
571 if (first != 0) s.Remove(0, first);
572 textangular.SetTextAlign(FindAlign(theta));
573 textangular.PaintLatex(costhetas,
575 }
576 else if (fPolarLabels){
577 // print the specified polar labels
578 textangular.SetTextAlign(FindAlign(theta));
580 }
581
582 } else {
584 // Polar numbers are shown horizontally.
585 form.Form("%5.3g",txtval);
586 axis.LabelsLimits(form.Data(),first,last);
587 TString s = form;
588 if (first != 0) s.Remove(0, first);
589 if(theta >= 3*TMath::Pi()/12.0 && theta < 2*TMath::Pi()/3.0) corr=0.04;
590 textangular.SetTextAlign(FindAlign(theta));
591 textangular.PaintLatex(costhetas,
592 corr+sinthetas,0,GetPolarLabelSize(),s);
593 } else if (fPolarLabels){
594 // print the specified polar labels
595 textangular.SetTextAlign(FindAlign(theta));
597 }
598 }
599
601 //Check if SetTickPolar is activated, and draw tick marks
602 Bool_t issettickpolar = gPad->GetTicky();
603 if (issettickpolar) {
604 if (theta != 0 && theta !=TMath::Pi()) {
607 }
608 if (theta == 0 || theta ==TMath::Pi()) {
609 gPad->PaintLine(1-GetTickpolarSize(),0,1+GetTickpolarSize(),0);
610 gPad->PaintLine(-1+GetTickpolarSize(),0,-1-GetTickpolarSize(),0);
611 }
612 }
615 gPad->PaintLine(0.,0.,costheta,sintheta);
616 // Add minor lines w/o text.
618 TAttLine::SetLineStyle(2); //Minor lines always in this style.
619 TAttLine::Modify(); //Changes line attributes apart from style.
620 Double_t a=0;
621 Double_t b,c,d;
622 b = TMath::Log(10)*test;
623 d= 2*TMath::Pi()/(double)test;
624 for (j=1; j<9; j++) {
626 c=a/b*6.28+d*(i-1);
627 gPad->PaintLine(0.,0.,TMath::Cos(c),TMath::Sin(c));
628 }
631 }
632 }
633}
634
635////////////////////////////////////////////////////////////////////////////////
636/// Paint radial divisions.
637/// Check for editable pad or create default.
638
640{
641 if (!gPad) return ;
642
643 static char chopt[8] = "";
644 Int_t i,j;
645 Int_t ndiv = TMath::Abs(fNdivRad);
646 Int_t ndivMajor = ndiv%100;
647 Int_t ndivMinor = ndiv/100;
648 Int_t ndivmajor = 0;
649 Double_t frwrmin = 0., frwrmax = 0., binWidth = 0;
650
652 frwrmax, ndivmajor,binWidth,"");
653
654 if (!gPad->GetLogx()) {
655 gPad->RangeAxis(-1,-1,1,1);
656 gPad->Range(-1.25,-1.25,1.25,1.25);
662 Int_t ndivminor = 0;
663
664 chopt[0] = 0;
665 strncat(chopt, "SDH", 4);
666 if (fNdivRad < 0) strncat(chopt, "N",2);
667 if(drawaxis){
668 // Paint axis.
669 TGaxis axis;
675 umin, umax, ndiv, chopt, 0., kFALSE);
676 }
677
678 // Paint Circles.
679 // First paint main circle.
680 PaintCircle(0.,0.,1,0.,360,0);
681 // Optimised case.
682 if (fNdivRad>0 ) {
683 Double_t frwrmini = 0., frwrmaxi = 0., binWidth2 =0;
686 Double_t dist2 = dist/(ndivminor);
687 // Paint major circles.
688 for (i=1; i<=ndivmajor+2; i++) {
691 PaintCircle(0.,0.,rmajmin,0.,360,0);
692
693 //Paint minor circles.
696 for (j=1; j<ndivminor+1; j++) {
697 if (rmajmin+j*dist2<=1) PaintCircle(0.,0.,rmajmin+j*dist2,0.,360,0);
698 }
699 rmajmin = (frwrmin-fRwrmin)/(fRwrmax-fRwrmin)+(i-1)*dist;
700 }
701 // Non-optimized case.
702 } else {
703
704 // Paint major circles.
705 for (i=1; i<=ndivMajor; i++) {
708 Double_t rmaj = i*1./ndivMajor;
709 PaintCircle(0.,0.,rmaj,0.,360,0);
710
711 // Paint minor circles.
712 for (j=1; j<ndivMinor; j++) {
715 PaintCircle(0.,0.,rmaj- j*1./(ndivMajor*ndivMinor),0.,360,0);
716 }
717 }
718 }
719 } else {
720 // Draw Log scale on radial axis if option activated.
722 Int_t test= 0;
723 while (big >= 10) {
724 big = big/10;
725 test++;
726 }
727 for (i=1; i<=test; i++) {
731 ecart = ((double) i)/ ((double) test);
732 PaintCircle(0.,0.,ecart,0,360,0);
735 Double_t a=0;
736 Double_t b,c,d;
737 b = TMath::Log(10)*test;
738 d = 1/(double)test;
739 for (j=1; j<9; j++) {
740 a = TMath::Log(j+1)-TMath::Log(j)+a;
741 c = a/b+d*(i-1);
742 PaintCircle(0,0.,c,0.,360,0);
743 }
744 }
745 }
748}
749
750////////////////////////////////////////////////////////////////////////////////
751/// Reduce fractions.
752
754{
755 Int_t a = 0;
756 Int_t b = 0;
757 Int_t i = 0;
758 Int_t j = 0;
759 a = den;
760 b = num;
761 if (b > a) {
762 j = b;
763 } else {
764 j = a;
765 }
766 for (i=j; i > 1; i--) {
767 if ((a % i == 0) && (b % i == 0)) {
768 a = a/i;
769 b = b/i;
770 }
771 }
772 rden = a;
773 rnum = b;
774}
775
776////////////////////////////////////////////////////////////////////////////////
777/// Set axis angle.
778
783
784////////////////////////////////////////////////////////////////////////////////
785/// Set the number of Polar divisions: enter a number ij with 0<i<99 and 0<j<99
786/// - i sets the major Polar divisions.
787/// - j sets the minor Polar divisions.
788
790{
791 if (ndiv > 0)
792 fNdivPol = ndiv;
793 if (gPad) gPad->Modified();
794}
795
796////////////////////////////////////////////////////////////////////////////////
797/// Set the number of radial divisions: enter a number ij with 0<i<99 and 0<j<99
798/// - i sets the major radial divisions.
799/// - j sets the minor radial divisions.
800
802{
803 fNdivRad = ndiv;
804 if (gPad) gPad->Modified();
805}
806
807////////////////////////////////////////////////////////////////////////////////
808/// Set some specified polar labels, used in the case of a spider plot.
809
811{
812 if(!fPolarLabels)
814 fPolarLabels[div] = label;
815 if (gPad) gPad->Modified();
816}
817
818////////////////////////////////////////////////////////////////////////////////
819/// Set Polar labels color.
820
825
826////////////////////////////////////////////////////////////////////////////////
827
829{
830 // Set Polar label font.
831
833}
834
835////////////////////////////////////////////////////////////////////////////////
836/// Set angular labels size.
837
842
843////////////////////////////////////////////////////////////////////////////////
844/// Set the labels offset.
845
851
852////////////////////////////////////////////////////////////////////////////////
853/// Set radial labels color.
854
859
860////////////////////////////////////////////////////////////////////////////////
861/// Set radial label font.
862
867
868////////////////////////////////////////////////////////////////////////////////
869/// Set radial labels size.
870
875
876////////////////////////////////////////////////////////////////////////////////
877/// Set the labels offset.
878
884
885////////////////////////////////////////////////////////////////////////////////
886/// Allows to change range Polar.
887/// \param[in] tmin the start number.
888/// \param[in] tmax the end number.
889
891{
892 fDegree = kFALSE;
893 fGrad = kFALSE;
894 fRadian = kFALSE;
895
896 if (tmin < tmax) {
897 fRwtmin = tmin;
898 fRwtmax = tmax;
899 }
900 if (gPad) gPad->Modified();
901}
902
903////////////////////////////////////////////////////////////////////////////////
904/// Set the radial range.
905/// \param[in] rmin radius at center of the circle.
906/// \param[in] rmax radius at the intersection of the right X axis part and the circle.
907
909{
910 if (rmin < rmax) {
911 fRwrmin = rmin;
912 fRwrmax = rmax;
913 }
914 if (gPad) gPad->Modified();
915}
916
917////////////////////////////////////////////////////////////////////////////////
918/// Set polar ticks size.
919
924
925////////////////////////////////////////////////////////////////////////////////
926/// The Polar circle is labelled using degree.
927
929{
930 fDegree = kTRUE;
931 fGrad = kFALSE;
932 fRadian = kFALSE;
933 ChangeRangePolar(0,360);
934}
935
936////////////////////////////////////////////////////////////////////////////////
937/// The Polar circle is labelled using gradian.
938
940{
941 fGrad = kTRUE;
942 fRadian = kFALSE;
943 fDegree = kFALSE;
944 ChangeRangePolar(0,200);
945}
946
947////////////////////////////////////////////////////////////////////////////////
948/// The Polar circle is labelled using radian.
949
957
958////////////////////////////////////////////////////////////////////////////////
959/// Set range from 0 to 2*pi
960
@ kMouseMotion
Definition Buttons.h:23
@ kButton1Motion
Definition Buttons.h:20
@ kButton1Up
Definition Buttons.h:19
@ kButton1Down
Definition Buttons.h:17
@ kMove
Definition GuiTypes.h:374
@ kHand
Definition GuiTypes.h:374
const Int_t kMaxPixel
Max value for an int.
Definition GuiTypes.h:369
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
short Color_t
Color number (short)
Definition RtypesCore.h:99
short Font_t
Font number (short)
Definition RtypesCore.h:95
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 TPoint TPoint const char x1
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:110
#define gPad
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:44
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:36
virtual void Modify()
Change current line attributes if necessary.
Definition TAttLine.cxx:246
Style_t fLineStyle
Line style.
Definition TAttLine.h:24
Int_t DistancetoLine(Int_t px, Int_t py, Double_t xp1, Double_t yp1, Double_t xp2, Double_t yp2)
Compute distance from point px,py to a line.
Definition TAttLine.cxx:210
The axis painter class.
Definition TGaxis.h:26
virtual void PaintAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, Double_t &wmin, Double_t &wmax, Int_t &ndiv, Option_t *chopt="", Double_t gridlength=0, Bool_t drawGridOnly=kFALSE)
Control function to draw an axis.
Definition TGaxis.cxx:1007
void SetLabelFont(Int_t labelfont)
Definition TGaxis.h:107
void SetLabelOffset(Float_t labeloffset)
Definition TGaxis.h:108
void SetLabelColor(Int_t labelcolor)
Definition TGaxis.h:106
void SetLabelSize(Float_t labelsize)
Definition TGaxis.h:109
void LabelsLimits(const char *label, Int_t &first, Int_t &last)
Internal method to find first and last character of a label.
Definition TGaxis.cxx:2532
Double_t fRwrmin
Minimal radial value (real world)
void ReduceFraction(Int_t Num, Int_t Denom, Int_t &rnum, Int_t &rden)
Reduce fractions.
Double_t GetPolarLabelSize()
Color_t fRadialLabelColor
Set color of the radial labels.
void SetPolarLabelColor(Color_t tcolorangular=1)
Set Polar labels color.
void PaintPolarDivisions(Bool_t noLabels)
Draw Polar divisions.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Everything within the circle belongs to the TGraphPolargram.
void SetRangePolar(Double_t tmin, Double_t tmax)
Allows to change range Polar.
Double_t fPolarTextSize
Set Polar text size.
Double_t fRwtmin
Minimal angular value (real world)
Double_t GetRadialOffset()
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Indicate that there is something to click here.
void Init()
Initialize some of the fields of TGraphPolargram.
TGraphPolargram(const char *name="")
Short constructor used in the case of a spider plot.
Double_t fRadialTextSize
Double_t GetTickpolarSize()
void SetPolarOffset(Double_t PolarOffset=0.04)
Set the labels offset.
void SetTwoPi()
Set range from 0 to 2*pi.
Double_t FindTextAngle(Double_t theta)
Determine the orientation of the polar labels according to their angle.
void SetRadialLabelColor(Color_t tcolorradial=1)
Set radial labels color.
void PaintCircle(Double_t x, Double_t y, Double_t r, Double_t phimin, Double_t phimax, Double_t theta)
This is simplified from TEllipse::PaintEllipse.
void SetRangeRadial(Double_t rmin, Double_t rmax)
Set the radial range.
void SetTickpolarSize(Double_t tickpolarsize=0.02)
Set polar ticks size.
void SetAxisAngle(Double_t angle=0)
Set axis angle.
void SetToDegree()
The Polar circle is labelled using degree.
void SetNdivPolar(Int_t Ndiv=508)
Set the number of Polar divisions: enter a number ij with 0<i<99 and 0<j<99.
Int_t fNdivRad
Number of radial divisions.
Font_t GetPolarLabelFont()
void Draw(Option_t *options="") override
Draw Polargram.
Double_t fTickpolarSize
Set size of Tickmarks.
void SetRadialLabelSize(Double_t radialsize=0.035)
Set radial labels size.
Font_t fPolarLabelFont
Set font of angular labels.
TString * fPolarLabels
! [fNdivPol] Specified polar labels
void PaintRadialDivisions(Bool_t drawaxis)
Paint radial divisions.
void SetToGrad()
The Polar circle is labelled using gradian.
Double_t GetAngle()
~TGraphPolargram() override
TGraphPolargram destructor.
void ChangeRangePolar(Double_t tmin, Double_t tmax)
Set the Polar range.
void SetPolarLabelSize(Double_t angularsize=0.04)
Set angular labels size.
void SetRadialLabelFont(Font_t tfontradial=62)
Set radial label font.
Double_t fAxisAngle
Set angle of the radial axis.
void SetToRadian()
The Polar circle is labelled using radian.
Double_t fRwtmax
Minimal angular value (real world)
Double_t fRwrmax
Maximal radial value (real world)
void SetPolarLabel(Int_t div, const TString &label)
Set some specified polar labels, used in the case of a spider plot.
Font_t fRadialLabelFont
Set font of radial labels.
Int_t fNdivPol
Number of polar divisions.
Font_t GetRadialLabelFont()
Int_t fCutRadial
if fCutRadial = 0, circles are cut by radial axis if fCutRadial = 1, circles are not cut
Color_t fPolarLabelColor
Set color of the angular labels.
Double_t fPolarOffset
Offset for Polar labels.
void Paint(Option_t *options="") override
Paint TGraphPolargram.
void SetPolarLabelFont(Font_t tfontangular=62)
void SetRadialOffset(Double_t RadialOffset=0.025)
Set the labels offset.
Color_t GetRadialColorLabel()
Int_t FindAlign(Double_t angle)
Find the alignement rule to apply for TText::SetTextAlign(Short_t).
void SetNdivRadial(Int_t Ndiv=508)
Set the number of radial divisions: enter a number ij with 0<i<99 and 0<j<99.
Double_t GetRadialLabelSize()
Color_t GetPolarColorLabel()
Double_t fRadialOffset
Offset for radial labels.
static void Optimize(Double_t A1, Double_t A2, Int_t nold, Double_t &BinLow, Double_t &BinHigh, Int_t &nbins, Double_t &BWID, Option_t *option="")
Static function to compute reasonable axis limits.
To draw Mathematical Formula.
Definition TLatex.h:18
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:202
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:864
Basic string class.
Definition TString.h:138
void ToUpper()
Change string to upper case.
Definition TString.cxx:1202
TString & Remove(Ssiz_t pos)
Definition TString.h:693
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:640
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Double_t ACos(Double_t)
Returns the principal value of the arc cosine of x, expressed in radians.
Definition TMath.h:643
Double_t ASin(Double_t)
Returns the principal value of the arc sine of x, expressed in radians.
Definition TMath.h:635
constexpr Double_t PiOver2()
Definition TMath.h:54
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Definition TMath.h:767
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:673
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Definition TMath.h:732
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:199
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:605
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:599
Double_t Tan(Double_t)
Returns the tangent of an angle of x radians.
Definition TMath.h:611
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:124