Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TPieSliceEditor.cxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
9#include "TPieSliceEditor.h"
10#include "TPieSlice.h"
11#include "TGTextEntry.h"
12#include "TGNumberEntry.h"
13#include "TGLabel.h"
14
15
16/** \class TPieSliceEditor
17\ingroup ged
18
19Editor for changing pie-chart's slice attributes.
20
21*/
22
23
24
25
29
30
31////////////////////////////////////////////////////////////////////////////////
32/// TPieSliceEditor constructor.
33
35 Int_t width, Int_t height,
36 UInt_t options, Pixel_t back)
37 : TGedFrame(p, width, height, options | kVerticalFrame, back)
38{
39 fPieSlice = 0;
40
41 // start initializing the window components
42 MakeTitle("Title");
43
44 fTitle = new TGTextEntry(this, new TGTextBuffer(50), kPieSlice_Title);
45 fTitle->Resize(135, fTitle->GetDefaultHeight());
46 fTitle->SetToolTipText("Enter the pie-slice label");
47 // better take kLHintsLeft and Right - Right is not working at the moment
48 AddFrame(fTitle, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
49
51 TGLabel *lbl1 = new TGLabel(f1,"Value");
53 //fValue->SetToolTipText("Set the slice absolute value")
54 fValue->Resize(50, 20);
55 f1->AddFrame(lbl1, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
56 f1->AddFrame(fValue, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
57 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
58
59 TGCompositeFrame *f2 = new TGCompositeFrame(this, 120, 20, kHorizontalFrame);
60 TGLabel *lbl2 = new TGLabel(f2,"Rad Offset");
62 //fOffset->SetToolTipText("Set the slice radial offset")
63 fOffset->Resize(50, 20);
64 f2->AddFrame(lbl2, new TGLayoutHints(kLHintsLeft,1, 1, 1, 1));
65 f2->AddFrame(fOffset, new TGLayoutHints(kLHintsLeft, 7, 1, 1, 1));
66 AddFrame(f2, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
67}
68
69
70////////////////////////////////////////////////////////////////////////////////
71/// TPieSliceEditor destructor.
72
76
77
78////////////////////////////////////////////////////////////////////////////////
79/// Set model.
80
82{
83 fPieSlice = (TPieSlice*) (obj);
84
86 fTitle->SetText(fPieSlice->GetTitle());
87 fValue->SetNumber(fPieSlice->GetValue());
88 fOffset->SetNumber(fPieSlice->GetRadiusOffset());
89
92}
93
94
95////////////////////////////////////////////////////////////////////////////////
96/// Connect signals to slots.
97
99{
100 fTitle->Connect("TextChanged(const char *)","TPieSliceEditor",this,"DoTitle(const char *)");
101 fValue->Connect("ValueSet(Long_t)", "TPieSliceEditor", this, "DoValue()");
102 fOffset->Connect("ValueSet(Long_t)", "TPieSliceEditor", this, "DoOffset()");
103
104 fInit = kFALSE; // connect the slots to the signals only once
105}
106
107
108////////////////////////////////////////////////////////////////////////////////
109/// Slot for setting the graph title.
110
112{
113 if (fAvoidSignal) return;
114 fPieSlice->SetTitle(text);
115 Update();
116}
117
118
119////////////////////////////////////////////////////////////////////////////////
120/// Slot for setting the graph title.
121
123{
124 if (fAvoidSignal) return;
125
126 fPieSlice->SetValue(fValue->GetNumber());
127 Update();
128}
129
130
131////////////////////////////////////////////////////////////////////////////////
132/// Slot for setting the graph title.
133
135{
136 if (fAvoidSignal) return;
137
138 fPieSlice->SetRadiusOffset(fOffset->GetNumber());
139 Update();
140}
141
@ kVerticalFrame
Definition GuiTypes.h:382
@ kHorizontalFrame
Definition GuiTypes.h:383
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ kLHintsLeft
Definition TGLayout.h:24
EPieSliceID
@ kPieSlice_Offset
@ kPieSlice_Title
@ kPieSlice_Value
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
TGCompositeFrame(const TGCompositeFrame &)=delete
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
TGNumberEntry is a number entry input widget with up/down buttons.
@ kNEANonNegative
Non-negative number.
@ kNESReal
Real number.
@ kNESRealTwo
Fixed fraction real, two digit.
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
ROOT GUI Window base class.
Definition TGWindow.h:23
TGedFrame(const TGedFrame &)=delete
Bool_t fInit
init flag for setting signals/slots
Definition TGedFrame.h:47
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:94
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition TGedFrame.cxx:71
Bool_t fAvoidSignal
flag for executing slots
Definition TGedFrame.h:50
Mother of all ROOT objects.
Definition TObject.h:42
void ConnectSignals2Slots()
Connect signals to slots.
void SetModel(TObject *) override
Set model.
void DoTitle(const char *)
Slot for setting the graph title.
TGNumberEntry * fOffset
Grafical offset in the radial direction.
TGNumberEntry * fValue
Value of the slice.
void DoValue()
Slot for setting the graph title.
TPieSliceEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
TPieSliceEditor constructor.
TPieSlice * fPieSlice
~TPieSliceEditor() override
TPieSliceEditor destructor.
TGTextEntry * fTitle
Slice label.
void DoOffset()
Slot for setting the graph title.
A slice of a piechart, see the TPie class.
Definition TPieSlice.h:18
TText * text
TF1 * f1
Definition legend1.C:11