105 Init(1, 0, 0.5, 0.5, 0.4);
115 Init(npoints, 0, 0.5, 0.5, 0.4);
135 Init(npoints, 0, 0.5, 0.5, 0.4);
150 Init(npoints, 0, 0.5, 0.5, 0.4);
164 const TAxis *axis =
h->GetXaxis();
168 Init(
np, 0, 0.5, 0.5, 0.4);
170 for (i=first; i<=last; ++i)
fPieSlices[i-first]->SetValue(
h->GetBinContent(i));
213 if ((info.num >= 0) && (info.rad <=
fRadius))
249 Double_t phimax = angles[2 * i + 2];
300 if (soption.
Length() == 0)
304 gROOT->MakeDefCanvas();
308 gPad->Range(0.,0.,1.,1.);
340 std::vector<Double_t> xx, yy;
345 auto addPoint = [&parent, &xx, &yy, &x0, &y0](
double x1,
double y1) {
346 xx.emplace_back(parent.
XtoPad(x0 +
x1));
347 yy.emplace_back(parent.
YtoPad(y0 +
y1));
352 for (
Int_t loop3d =
fIs3D ? 1 : 0; loop3d >= 0; loop3d--)
356 Float_t minphi = angles[i * 2];
357 Float_t avgphi = angles[i * 2 + 1];
358 Float_t maxphi = angles[i * 2 + 2];
367 Int_t ndiv = dphi > 1.5 ? (
Int_t)(dphi / .15) : 10;
371 for (
Int_t j = 0; j <= ndiv; ++j) {
406 if (!
gPad || !
gPad->IsEditable())
return;
408 auto &parent = *
gPad;
410 Bool_t opaque = parent.OpaqueMoving();
414 const Double_t minRad = parent.PixeltoX(10);
429 auto inter =
dynamic_cast<TPieInteractive *
>(parent.Interactive(
this));
431 auto calcAngle = [
this, &parent,px,py]() {
432 Double_t xx = parent.AbsPixeltoX(px);
433 Double_t yy = parent.AbsPixeltoY(py);
449 parent.Interactive(
this, inter);
457 if (!inter) inter = &dummy;
459 if ((info.rad >= 1 - dr) && (info.rad <= 1 + dr)) {
460 if (info.ang >= angstep8 || info.ang < angstep1)
462 else if (info.ang >= angstep1 && info.ang < angstep2)
464 else if (info.ang >= angstep2 && info.ang < angstep3)
466 else if (info.ang >= angstep3 && info.ang < angstep4)
468 else if (info.ang >= angstep4 && info.ang <= angstep5)
470 else if (info.ang >= angstep5 && info.ang < angstep6)
472 else if (info.ang >= angstep6 && info.ang < angstep7)
474 else if (info.ang >= angstep7 && info.ang < angstep8)
477 }
else if ((info.rad > 0.6) && (info.rad < 1.)) {
480 inter->currentSlice = info.num;
481 inter->sliceAngle = info.cphi;
485 parent.Interactive();
486 }
else if ((info.rad >= 0.3) && (info.rad <= 0.6)) {
489 inter->angle0 = calcAngle();
490 }
else if (info.rad <= 0.3) {
491 parent.SetCursor(
kHand);
504 Int_t dx = px - inter->oldpx;
505 Int_t dy = py - inter->oldpy;
511 parent.SetCursor(
kMove);
515 parent.SetCursor(
kMove);
516 inter->sliceOffset +=
TMath::Cos(inter->sliceAngle)*mdx +
TMath::Sin(inter->sliceAngle)*mdy/radXY;
524 inter->angle0 = angle1;
532 parent.UpdateAsync();
541 if (
gROOT->IsEscaped()) {
545 }
else if (!opaque) {
549 parent.Interactive();
550 parent.UpdateAsync();
560 event = parent.GetCanvasImp()->RequestLocator(px, py);
763 if ( (idx=soption.
Index(
"same"))>=0 ) {
768 if ( (idx=soption.
Index(
"nol"))>=0 ) {
773 if ( (idx=soption.
Index(
"sc"))>=0 ) {
774 optionSameColor =
kTRUE;
779 if ( (idx=soption.
Index(
"3d"))>=0 ) {
787 if ( (idx=soption.
Index(
"t"))>=0 ) {
793 if ( (idx=soption.
Index(
"r"))>=0 ) {
799 if ( (idx=soption.
Index(
">"))>=0 ) {
805 if ( (idx=soption.
Index(
"<"))>=0 ) {
816 Warning(
"Paint",
"No valid arrays of values");
842 for (
Int_t pi = 0; pi < pixelHeight &&
fIs3D; ++pi) {
955 }
else if (lblor==2) {
976 if (rphi < 0 && fIs3D && label_off>=0.)
985 if (optionSame)
return;
989 if (
auto obj =
gPad->GetListOfPrimitives()->FindObject(
"title")) {
995 if (title)
delete title;
1003 if (ht<=0) ht = 0.05;
1025 if (talh < 1) talh = 1;
else if (talh > 3) talh = 3;
1027 if (talv < 1) talv = 1;
else if (talv > 3) talv = 3;
1061 out <<
" pie->SetCircle(" <<
fX <<
", " <<
fY <<
", " <<
fRadius <<
");\n";
1062 out <<
" pie->SetValueFormat(\"" <<
GetValueFormat() <<
"\");\n";
1063 out <<
" pie->SetLabelFormat(\"" <<
GetLabelFormat() <<
"\");\n";
1085 while (val>360.) val -= 360.;
1086 while (val<0) val += 360.;
1087 if (val>=90 && val<180) val = 180-val;
1088 else if (val>=180 && val<=360) val = 360-val;
1191 if (!colors)
return;
1269 "It's not possible set the radius to a negative value");
1304 std::vector<Float_t> angles(2 *
fNvals + 1, 0.);
1316 angles[2 * i + 1] = angles[2 * i] + dphi / 2.;
1317 angles[2 * i + 2] = angles[2 * i] + dphi;
1321 for (
auto &
v : angles)
1367 if (merge_threshold>0) {
1370 merged_slice->SetRadiusOffset(0.);
1386 delete merged_slice;
1392 new_array[0] = merged_slice;
1393 for (
Int_t i=0;i<old_fNvals;++i) {
1410 delete merged_slice;
1416 new_array[
fNvals-1] = merged_slice;
1417 for (
Int_t i=old_fNvals-1;i>=0;--i) {
int Int_t
Signed integer 4 bytes (int)
float Float_t
Float 4 bytes (float)
const char Option_t
Option string (const char)
Option_t Option_t SetTextSize
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 winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
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 x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t SetTextFont
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void xpos
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 ypos
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char y1
R__EXTERN TStyle * gStyle
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 ModifyOn(TVirtualPad &pad)
Change current line attributes on specified pad.
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 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)
Save text attributes as C++ statement(s) on output stream out.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
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)
Static function: Returns the dark color number corresponding to n If the TColor object does not exist...
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.
TH1 is the base class of all histogram classes in ROOT.
To draw Mathematical Formula.
Double_t GetXsize()
Return size of the formula along X in pad coordinates when the text precision is smaller than 3.
Double_t GetYsize()
Return size of the formula along Y in pad coordinates when the text precision is smaller than 3.
virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text)
Main drawing function.
This class displays a legend box (TPaveText) containing several legend entries.
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
Add a new entry to this legend.
void Draw(Option_t *option="") override
Draw this legend with its current attributes.
void Clear(Option_t *option="") override
Clear all entries in this legend, including the header.
Use the TLine constructor to create a simple line.
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.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
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 Pave (see TPave) with text, lines or/and boxes inside.
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
void Draw(Option_t *option="") override
Draw this pavetext with its current attributes.
void Paint(Option_t *option="") override
Paint this pavetext with its current attributes.
virtual TText * GetLine(Int_t number) const
Get Pointer to line number in this pavetext.
virtual void SetName(const char *name="")
virtual void SetBorderSize(Int_t bordersize=4)
Sets the border size of the TPave box and shadow.
Double_t GetX1NDC() const
virtual void SetX2NDC(Double_t x2)
enum TPieInteractive::EMode fMode
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 SavePrimitive(std::ostream &out, Option_t *opts="") override
Save as C++ macro, used directly from TPie.
void SetEntryVal(Int_t, Double_t)
Set the value of a slice.
Float_t fLabelsOffset
LabelsOffset offset of label.
Double_t GetEntryVal(Int_t) const
Return the value associated with the slice number "i".
void SetAngularOffset(Double_t)
Set the global angular offset for slices in degree [0,360].
void Paint(Option_t *) override
Paint a Pie chart in a canvas.
const char * GetLabelFormat() const
const char * GetEntryLabel(Int_t) const
Returns the label of the entry number "i".
TString fLabelFormat
Format format of the slices' label.
Int_t GetEntryLineColor(Int_t) const
Return the line color used to outline thi "i" slice.
void SetX(Double_t)
Set X value.
Double_t fAngularOffset
Offset angular offset for the first slice.
void SortSlices(Bool_t amode=kTRUE, Float_t merge_thresold=.0)
This method, mainly intended for internal use, ordered the slices according their values.
void SetEntryFillStyle(Int_t, Int_t)
Set the fill style for the "i" slice.
TPie()
Default constructor.
~TPie() override
Destructor.
TPieSlice * GetSlice(Int_t i) const
Return the reference to the slice of index 'id'.
Double_t GetSumOfEntriesValues() const
Return sum of all entries.
void SetFractionFormat(const char *)
Set numeric format in the label, is used if the label format there is the modifier frac,...
Float_t fAngle3D
The angle of the pseudo-3d view.
Double_t fHeight
Height of the slice in pixel.
Float_t GetLabelsOffset() const
Int_t GetEntryLineStyle(Int_t) const
Return the style used to outline thi "i" slice.
void SetPercentFormat(const char *)
Set the numeric format for the percent value of a slice, default: %3.1f.
void SetLabels(const char *[])
Set the labels for all the slices.
Double_t GetAngularOffset() const
void SetY(Double_t)
Set Y value.
Int_t DistancetoSlice(Int_t, Int_t) R__DEPRECATED(6
Returns the slice number at the pixel position (px,py).
Bool_t fIs3D
! true if the pseudo-3d is enabled
Int_t GetEntryFillStyle(Int_t) const
Return the style use to fill the slice number "i".
Int_t GetEntryFillColor(Int_t) const
Return the color of the slice number "i".
void Init(Int_t np, Double_t ao, Double_t x, Double_t y, Double_t r)
Common initialization for all constructors.
void SetLabelsOffset(Float_t)
Set the distance between the label end the external line of the TPie.
Double_t GetRadius() const
void SetEntryRadiusOffset(Int_t, Double_t)
Set the distance, in the direction of the radius of the slice.
void DrawGhost(TVirtualPad &)
This method is for internal use.
TLegend * fLegend
!Legend for this piechart
void SetLabelFormat(const char *)
This method is used to customize the label format.
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 the mouse events.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Evaluate the distance to the chart in gPad.
void SetEntryLineStyle(Int_t, Int_t)
Set the style for the slice's outline. "i" is the slice number.
void SetEntryFillColor(Int_t, Int_t)
Set the color for the slice "i".
void SetEntryLineWidth(Int_t, Int_t)
Set the width of the slice's outline. "i" is the slice number.
TLegend * GetLegend() const
If created before by Paint option or by MakeLegend method return the pointer to the legend,...
std::vector< Float_t > GetSlicesAngles() const
Return calculated angle for all slices Only for internal use.
void SetCircle(Double_t x=.5, Double_t y=.5, Double_t rad=.4)
Set the coordinates of the circle that describe the pie:
TString fValueFormat
Vform numeric format for the value.
const char * GetPercentFormat() const
TString fFractionFormat
Rform numeric format for the fraction of a slice.
void SetAngle3D(Float_t val=30.)
Set the value of for the pseudo 3D view angle, in degree.
const char * GetValueFormat() const
Int_t GetEntryLineWidth(Int_t) const
Return the line width used to outline thi "i" slice.
void SetRadius(Double_t)
Set the pie chart's radius' value.
void SavePrimitive(std::ostream &out, Option_t *opts="") override
Save 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="")
This method create a legend that explains the contents of the slice for this pie-chart.
Int_t fNvals
Number of elements.
void MakeSlices(Bool_t force=kFALSE) R__DEPRECATED(6
Make the slices.
Double_t fY
Y coordinate of the pie centre.
void SetEntryLabel(Int_t, const char *text="Slice")
Set slice number "i" label.
Double_t fX
X coordinate of the pie centre.
void SetHeight(Double_t val=.08)
Set the height, in pixel, for the piechart if is drawn using the pseudo-3d mode.
void Draw(Option_t *option="l") override
Draw the pie chart.
void SetValueFormat(const char *)
Set the numeric format the slices' values.
Double_t GetEntryRadiusOffset(Int_t) const
Return the radial offset's value for the slice number "i".
SliceInfo_t FindSlice(TVirtualPad &, Int_t, Int_t)
Find slice at given position.
void SetEntryLineColor(Int_t, Int_t)
Set the color for the slice's outline. "i" is the slice number.
void SetFillColors(Int_t *)
Set the fill colors for all the TPie's slices.
void ToLower()
Change string to lower-case.
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
void Clear()
Clear string without changing its capacity.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
TString & Remove(Ssiz_t pos)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Float_t GetTitleX() const
Int_t GetOptTitle() const
Float_t GetTitleY() const
Style_t GetTitleFont(Option_t *axis="X") const
Return title font.
Color_t GetTitleFillColor() const
Style_t GetTitleStyle() const
Float_t GetLabelOffset(Option_t *axis="X") const
Return label offset.
Width_t GetTitleBorderSize() const
Int_t GetColorPalette(Int_t i) const
Return color number i in current palette.
Color_t GetTitleTextColor() const
Float_t GetTitleH() const
Int_t GetNumberOfColors() const
Return number of colors in the color palette.
Float_t GetTitleFontSize() const
Int_t GetTitleAlign() const
Float_t GetTitleW() const
Base class for several text objects.
Helper class to store interactive parameters for individual objects Should be used via gPad->Interact...
TVirtualPad is an abstract base class for the Pad and Canvas classes.
virtual Double_t PixeltoY(Double_t py)=0
virtual Double_t AbsPixeltoX(Double_t px)=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 AbsPixeltoY(Double_t py)=0
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()
static uint64_t sum(uint64_t i)