106Int_t gCurrent_slice = -1;
121 Init(1, 0, 0.5, 0.5, 0.4);
131 Init(npoints, 0, 0.5, 0.5, 0.4);
151 Init(npoints, 0, 0.5, 0.5, 0.4);
152 for (
Int_t i=0; i<fNvals; ++i) fPieSlices[i]->SetValue(vals[i]);
166 Init(npoints, 0, 0.5, 0.5, 0.4);
167 for (
Int_t i=0; i<fNvals; ++i) fPieSlices[i]->SetValue(vals[i]);
180 const TAxis *axis =
h->GetXaxis();
183 Int_t np = last-first+1;
184 Init(np, 0, 0.5, 0.5, 0.4);
186 for (i=first; i<=last; ++i) fPieSlices[i-first]->SetValue(
h->GetBinContent(i));
188 for (i=first; i<=last; ++i) fPieSlices[i-first]->SetTitle(axis->
GetBinLabel(i));
190 SetLabelFormat(
"%val");
204 for (
Int_t i=0;i<fNvals;++i)
230 if ( gCurrent_slice>=0 ) {
247 if (!
gPad)
return 9999;
273 if (gIsUptSlice && gCurrent_slice!=i)
continue;
292 if ( ((ang>=phimin && ang <= phimax) || (phimax>
TMath::TwoPi() &&
299 gCurrent_phi1 = phimin;
300 gCurrent_phi2 = phimax;
303 if (dist<.95 && dist>.65) {
312 if (lang/range<.25 || rang/range<.25) {
334 TString soption(option);
337 if (soption.Length()==0) soption =
"l";
340 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
341 if (!soption.Contains(
"same")) {
343 gPad->Range(0.,0.,1.,1.);
370 Double_t radOffset = (i == gCurrent_slice ? gRadiusOffset :
fPieSlices[i]->GetRadiusOffset());
379 Double_t dphi = (maxphi-minphi)/ndiv;
381 if (dphi>.15) ndiv = (
Int_t) ((maxphi-minphi)/.15);
382 dphi = (maxphi-minphi)/ndiv;
385 for (
Int_t j=0;j<ndiv;++j) {
395 gPad->XtoAbsPixel(x0),
gPad->YtoAbsPixel(y0) );
398 gPad->YtoAbsPixel(y0),
399 gPad->XtoAbsPixel(x0),
418 Double_t radOffset = (i == gCurrent_slice ? gRadiusOffset :
fPieSlices[i]->GetRadiusOffset());
428 Double_t dphi = (maxphi-minphi)/ndiv;
430 if (dphi>.15) ndiv = (
Int_t) ((maxphi-minphi)/.15);
431 dphi = (maxphi-minphi)/ndiv;
434 for (
Int_t j=0;j<ndiv;++j) {
444 gPad->XtoAbsPixel(x0),
gPad->YtoAbsPixel(y0) );
456 if (gCurrent_slice<=-10) {
463 static bool isMovingPie(
kFALSE);
464 static bool isMovingSlice(
kFALSE);
465 static bool isResizing(
kFALSE);
466 static bool isRotating(
kFALSE);
467 static bool onBorder(
kFALSE);
469 static Int_t prev_event(-1);
470 static Int_t oldpx, oldpy;
506 gRadiusOffset =
fPieSlices[gCurrent_slice]->GetRadiusOffset();
514 && !isMovingPie && !isMovingSlice && !isResizing) {
515 if (gCurrent_ang>=angstep8 || gCurrent_ang<angstep1)
517 else if (gCurrent_ang>=angstep1 && gCurrent_ang<angstep2)
519 else if (gCurrent_ang>=angstep2 && gCurrent_ang<angstep3)
521 else if (gCurrent_ang>=angstep3 && gCurrent_ang<angstep4)
523 else if (gCurrent_ang>=angstep4 && gCurrent_ang<=angstep5)
525 else if (gCurrent_ang>=angstep5 && gCurrent_ang<angstep6)
527 else if (gCurrent_ang>=angstep6 && gCurrent_ang<angstep7)
529 else if (gCurrent_ang>=angstep7 && gCurrent_ang<angstep8)
536 }
else if (gCurrent_rad<=
fRadius*.3) {
538 }
else if (gCurrent_rad<=fRadius*.6 && gCurrent_rad>=
fRadius*.3) {
544 if (isMovingPie || isMovingSlice)
gPad->SetCursor(
kMove);
549 if (!isMovingSlice || !isMovingPie || !isResizing || !isRotating) {
553 }
else if (gCurrent_rad>=
fRadius*.6 && gCurrent_slice>=0) {
554 isMovingSlice =
kTRUE;
555 }
else if (gCurrent_rad<=
fRadius*.3) {
557 }
else if (gCurrent_rad<fRadius*.6 && gCurrent_rad>
fRadius*.3) {
566 mdx =
gPad->PixeltoX(dx);
567 mdy =
gPad->PixeltoY(dy);
569 if (isMovingPie || isMovingSlice) {
577 if (gRadiusOffset<0) gRadiusOffset = .0;
589 }
else if (isResizing) {
593 if (gRadius+dr1>=minRad) {
600 }
else if (isRotating) {
612 gAngularOffset = (ang-gCurrent_ang)*180/
TMath::Pi();
620 if ( ((isMovingPie || isMovingSlice || isRotating) &&
gPad->OpaqueMoving()) ||
621 (isResizing &&
gPad->OpaqueResizing()) ) {
634 if (
gROOT->IsEscaped()) {
643 fPieSlices[gCurrent_slice]->SetRadiusOffset(gRadiusOffset);
646 if (isRedrawing && (isMovingPie || isMovingSlice))
gPad->SetCursor(
kMove);
648 if (isMovingPie) isMovingPie =
kFALSE;
649 if (isMovingSlice) isMovingSlice =
kFALSE;
650 if (isResizing) isResizing =
kFALSE;
654 gCurrent_ang += gAngularOffset/180.*
TMath::Pi();
672 event =
gVirtualX->RequestLocator(1, 1, px, py);
801 TString tmplbl =
"Slice";
850 TString soption(option);
869 if ( (idx=soption.Index(
"same"))>=0 ) {
871 soption.Remove(idx,4);
874 if ( (idx=soption.Index(
"nol"))>=0 ) {
876 soption.Remove(idx,3);
879 if ( (idx=soption.Index(
"sc"))>=0 ) {
880 optionSameColor =
kTRUE;
881 soption.Remove(idx,2);
885 if ( (idx=soption.Index(
"3d"))>=0 ) {
887 soption.Remove(idx,2);
893 if ( (idx=soption.Index(
"t"))>=0 ) {
895 soption.Remove(idx,1);
899 if ( (idx=soption.Index(
"r"))>=0 ) {
901 soption.Remove(idx,1);
905 if ( (idx=soption.Index(
">"))>=0 ) {
907 soption.Remove(idx,1);
911 if ( (idx=soption.Index(
"<"))>=0 ) {
913 soption.Remove(idx,1);
922 Warning(
"Paint",
"No valid arrays of values");
946 for (
Int_t pi = 0; pi < pixelHeight &&
fIs3D; ++pi) {
1060 }
else if (lblor==2) {
1077 if (aphi<0) ly -=
h;
1081 if (rphi < 0 && fIs3D && label_off>=0.)
1090 if (optionSame)
return;
1093 TPaveText *title =
nullptr;
1094 if (
auto obj =
gPad->GetListOfPrimitives()->FindObject(
"title")) {
1095 title =
dynamic_cast<TPaveText*
>(obj);
1100 if (title)
delete title;
1107 if (ht<=0) ht = 1.1*
gStyle->GetTitleFontSize();
1108 if (ht<=0) ht = 0.05;
1120 TText *t0 = (TText*)title->GetLine(0);
1130 if (talh < 1) talh = 1;
else if (talh > 3) talh = 3;
1132 if (talv < 1) talv = 1;
else if (talv > 3) talv = 3;
1134 xpos =
gStyle->GetTitleX();
1135 ypos =
gStyle->GetTitleY();
1136 if (talh == 2) xpos = xpos-wt/2.;
1137 if (talh == 3) xpos = xpos-wt;
1138 if (talv == 2) ypos = ypos+ht/2.;
1139 if (talv == 1) ypos = ypos+ht;
1141 title =
new TPaveText(xpos,ypos-ht,xpos+wt,ypos,
"blNDC");
1144 title->SetName(
"title");
1149 if (
gStyle->GetTitleFont(
"")%10 > 2)
1166 out <<
" pie->SetCircle(" <<
fX <<
", " <<
fY <<
", " <<
fRadius <<
");\n";
1167 out <<
" pie->SetValueFormat(\"" <<
GetValueFormat() <<
"\");\n";
1168 out <<
" pie->SetLabelFormat(\"" <<
GetLabelFormat() <<
"\");\n";
1178 fPieSlices[i]->SavePrimitive(out, slice_name.Data());
1181 out <<
" gPad->Add(pie, \"" << TString(option).ReplaceSpecialCppChars() <<
"\");\n";
1190 while (val>360.) val -= 360.;
1191 while (val<0) val += 360.;
1192 if (val>=90 && val<180) val = 180-val;
1193 else if (val>=180 && val<=360) val = 360-val;
1376 "It's not possible set the radius to a negative value");
1411 if (
fSlices && !force)
return;
1418 "Negative values in TPie, absolute value will be used");
1424 if (
fSum<=.0)
return;
1468 if (merge_threshold>0) {
1470 TPieSlice *merged_slice =
new TPieSlice(
"merged",
"other",
this);
1481 for (;iMerged<
fNvals&&
fPieSlices[iMerged]->GetValue()<merge_threshold;++iMerged) {
1487 delete merged_slice;
1492 TPieSlice **new_array =
new TPieSlice*[
fNvals];
1493 new_array[0] = merged_slice;
1494 for (
Int_t i=0;i<old_fNvals;++i) {
1504 for (;iMerged>=0&&
fPieSlices[iMerged]->GetValue()<merge_threshold;--iMerged) {
1511 delete merged_slice;
1516 TPieSlice **new_array =
new TPieSlice*[
fNvals];
1517 new_array[
fNvals-1] = merged_slice;
1518 for (
Int_t i=old_fNvals-1;i>=0;--i) {
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
const char Option_t
Option string (const char).
virtual Color_t GetLabelColor() const
virtual Style_t GetLabelFont() const
virtual Float_t GetLabelSize() const
virtual Color_t GetFillColor() const
Return the fill area color.
virtual Style_t GetFillStyle() const
Return the fill area style.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual Color_t GetLineColor() const
Return the line color.
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
virtual Width_t GetLineWidth() const
Return the line width.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual Style_t GetLineStyle() const
Return the line style.
virtual Float_t GetTextSize() const
Return the text size.
virtual Font_t GetTextFont() const
Return the text font.
virtual Color_t GetTextColor() const
Return the text color.
virtual Float_t GetTextAngle() const
Return the text angle.
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
virtual void SaveTextAttributes(std::ostream &out, const char *name, Int_t alidef=12, Float_t angdef=0, Int_t coldef=1, Int_t fondef=61, Float_t sizdef=1)
Class to manage histogram axis.
const char * GetBinLabel(Int_t bin) const
Return label for bin.
Int_t GetLast() const
Return last bin on the axis i.e.
Int_t GetFirst() const
Return first bin on the axis i.e.
THashList * GetLabels() const
static Int_t GetColorDark(Int_t color)
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="")
TH1 is the base class of all histogram classes in ROOT.
virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
virtual void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
The TNamed class is the base class for all named ROOT classes.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
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".
@ kCanDelete
if object in a list can be deleted
A slice of a piechart, see the TPie class.
void SetValue(Double_t)
Set the value for this slice.
Double_t GetRadiusOffset() const
return the value of the offset in radial direction for this slice.
void Copy(TObject &slice) const override
Copy TPieSlice.
Double_t GetValue() const
Return the value of this slice.
void SetRadiusOffset(Double_t)
Set the radial offset of this slice.
void SetEntryVal(Int_t, Double_t)
TPieSlice * GetSlice(Int_t i)
Float_t fLabelsOffset
LabelsOffset offset of label.
void SetAngularOffset(Double_t)
void Paint(Option_t *) override
This method must be overridden if a class wants to paint itself.
Double_t GetEntryVal(Int_t)
TString fLabelFormat
Format format of the slices' label.
Float_t * fSlices
!Subdivisions of the slices
Double_t fAngularOffset
Offset angular offset for the first slice.
void SortSlices(Bool_t amode=kTRUE, Float_t merge_thresold=.0)
void SetEntryFillStyle(Int_t, Int_t)
void SetFractionFormat(const char *)
Float_t fAngle3D
The angle of the pseudo-3d view.
Double_t fHeight
Height of the slice in pixel.
const char * GetPercentFormat()
void SetPercentFormat(const char *)
void SetLabels(const char *[])
Bool_t fIs3D
! true if the pseudo-3d is enabled
void Init(Int_t np, Double_t ao, Double_t x, Double_t y, Double_t r)
Int_t GetEntryFillColor(Int_t)
void SetLabelsOffset(Float_t)
void SetEntryRadiusOffset(Int_t, Double_t)
Double_t GetAngularOffset()
Float_t GetLabelsOffset()
TLegend * fLegend
!Legend for this piechart
void SetLabelFormat(const char *)
Double_t fRadius
Radius Pie radius.
TPieSlice ** fPieSlices
[fNvals] Slice array of this pie-chart
void ExecuteEvent(Int_t, Int_t, Int_t) override
Execute action corresponding to an event at (px,py).
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Computes distance from point (px,py) to the object.
void SetEntryLineStyle(Int_t, Int_t)
void MakeSlices(Bool_t force=kFALSE)
void SetEntryFillColor(Int_t, Int_t)
void SetEntryLineWidth(Int_t, Int_t)
const char * GetLabelFormat()
void SetCircle(Double_t x=.5, Double_t y=.5, Double_t rad=.4)
const char * GetEntryLabel(Int_t)
TString fValueFormat
Vform numeric format for the value.
TString fFractionFormat
Rform numeric format for the fraction of a slice.
void SetAngle3D(Float_t val=30.)
Double_t GetEntryRadiusOffset(Int_t)
Int_t GetEntryFillStyle(Int_t)
const char * GetValueFormat()
void SavePrimitive(std::ostream &out, Option_t *opts="") override
Save a primitive as a C++ statement(s) on output stream "out".
TString fPercentFormat
Pfrom numeric format for the percent of a slice.
TLegend * MakeLegend(Double_t x1=.65, Double_t y1=.65, Double_t x2=.95, Double_t y2=.95, const char *leg_header="")
Int_t fNvals
Number of elements.
Int_t DistancetoSlice(Int_t, Int_t)
Int_t GetEntryLineStyle(Int_t)
Float_t fSum
!Sum for the slice values
Double_t fY
Y coordinate of the pie centre.
void SetEntryLabel(Int_t, const char *text="Slice")
Double_t fX
X coordinate of the pie centre.
void SetHeight(Double_t val=.08)
Int_t GetEntryLineWidth(Int_t)
Int_t GetEntryLineColor(Int_t)
void Draw(Option_t *option="l") override
Default Draw method for all objects.
void SetValueFormat(const char *)
void SetEntryLineColor(Int_t, Int_t)
void SetFillColors(Int_t *)
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
double dist(Rotation3D const &r1, Rotation3D const &r2)
void Init(TClassEdit::TInterpreterLookupHelper *helper)
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
constexpr Double_t PiOver2()
Double_t ATan2(Double_t y, Double_t x)
Returns the principal value of the arc tangent of y/x, expressed in radians.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
constexpr Double_t PiOver4()
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
constexpr Double_t TwoPi()