Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TArrowEditor.cxx
Go to the documentation of this file.
1// @(#)root/ged:$Id$
2// Author: Ilka Antcheva 20/10/04
3
4/*************************************************************************
5 * Copyright (C) 1995-2004, 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 "TArrowEditor.h"
13#include "TGComboBox.h"
14#include "TGLabel.h"
15#include "TGNumberEntry.h"
16#include "TArrow.h"
17
19
25
26/** \class TArrowEditor
27 \ingroup ged
28
29Implements user interface for editing of arrow attributes:
30shape, size, angle.
31*/
32
33////////////////////////////////////////////////////////////////////////////////
34/// Constructor of arrow GUI.
35
37 Int_t height, UInt_t options, Pixel_t back)
38 : TGedFrame(p, width, height, options | kVerticalFrame, back)
39{
40 fArrow = 0;
41
42 MakeTitle("Arrow");
43
44 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
45 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
46
47 TGCompositeFrame *f2a = new TGCompositeFrame(f2, 80, 20);
48 f2->AddFrame(f2a, new TGLayoutHints(kLHintsTop, 10, 0, 0, 0));
49
50 TGLabel *fShapeLabel = new TGLabel(f2a, "Shape:");
51 f2a->AddFrame(fShapeLabel, new TGLayoutHints(kLHintsNormal, 0, 0, 1, 5));
52
53 TGLabel *fAngleLabel = new TGLabel(f2a, "Angle:");
54 f2a->AddFrame(fAngleLabel, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 5));
55
56 TGLabel *fSizeLabel = new TGLabel(f2a, "Size: ");
57 f2a->AddFrame(fSizeLabel, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 1));
58
59 TGCompositeFrame *f2b = new TGCompositeFrame(f2, 80, 20, kFixedWidth);
60 f2->AddFrame(f2b, new TGLayoutHints(kLHintsTop, 10, 0, 0, 0));
61
63 fOptionCombo->Resize(80, 20);
64 f2b->AddFrame(fOptionCombo, new TGLayoutHints(kLHintsExpandX, 1, 1, 1, 1));
65 fOptionCombo->Associate(this);
66
67 fAngleEntry = new TGNumberEntry(f2b, 30, 8, kARROW_ANG,
71 fAngleEntry->GetNumberEntry()->SetToolTipText("Set the arrow opening angle in degrees.");
72 f2b->AddFrame(fAngleEntry, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
73
74 fSizeEntry = new TGNumberEntry(f2b, 0.03, 8, kARROW_SIZ,
78 fSizeEntry->GetNumberEntry()->SetToolTipText("Set the size of arrow.");
79 f2b->AddFrame(fSizeEntry, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
80
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// Destructor of arrow editor.
85
87{
89 TIter next(GetList());
90
91 while ((el = (TGFrameElement *)next())) {
92 if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame"))
93 ((TGCompositeFrame *)el->fFrame)->Cleanup();
94 }
95 Cleanup();
96}
97
98////////////////////////////////////////////////////////////////////////////////
99/// Connect signals to slots.
100
102{
103 fOptionCombo->Connect("Selected(Int_t)", "TArrowEditor", this, "DoOption(Int_t)");
104 fAngleEntry->Connect("ValueSet(Long_t)", "TArrowEditor", this, "DoAngle()");
105 (fAngleEntry->GetNumberEntry())->Connect("ReturnPressed()", "TArrowEditor", this, "DoAngle()");
106 fSizeEntry->Connect("ValueSet(Long_t)", "TArrowEditor", this, "DoSize()");
107 (fSizeEntry->GetNumberEntry())->Connect("ReturnPressed()", "TArrowEditor", this, "DoSize()");
108
109 fInit = kFALSE;
110}
111
112////////////////////////////////////////////////////////////////////////////////
113/// Pick up the used arrow attributes.
114
116{
117 fArrow = (TArrow *)obj;
119
120 Int_t id = GetShapeEntry(fArrow->GetDrawOption());
121 if (id != fOptionCombo->GetSelected())
122 fOptionCombo->Select(id);
123
124 Float_t sz = fArrow->GetArrowSize();
125 fSizeEntry->SetNumber(sz);
126
127 Int_t deg = (Int_t)fArrow->GetAngle();
128 fAngleEntry->SetNumber(deg);
129
132}
133
134////////////////////////////////////////////////////////////////////////////////
135/// Slot connected to the arrow opening angle setting.
136
138{
139 if (fAvoidSignal) return;
140 fArrow->SetAngle((Float_t)fAngleEntry->GetNumber());
141 fArrow->Paint(fArrow->GetDrawOption());
142 Update();
143}
144
145////////////////////////////////////////////////////////////////////////////////
146/// Slot connected to the arrow shape setting.
147
149{
150 if (fAvoidSignal) return;
151 const char* opt=0;
152 switch (id) {
153 case 1:
154 opt = "|>";
155 break;
156 case 2:
157 opt = "<|";
158 break;
159 case 3:
160 opt = ">";
161 break;
162 case 4:
163 opt = "<";
164 break;
165 case 5:
166 opt = "->-";
167 break;
168 case 6:
169 opt = "-<-";
170 break;
171 case 7:
172 opt = "-|>-";
173 break;
174 case 8:
175 opt = "-<|-";
176 break;
177 case 9:
178 opt = "<>";
179 break;
180 case 10:
181 opt = "<|>";
182 break;
183 }
184 fArrow->SetDrawOption(opt);
185 fArrow->Paint(fArrow->GetDrawOption());
186 Update();
187}
188
189
190////////////////////////////////////////////////////////////////////////////////
191/// Slot connected to the arrow size.
192
194{
195 if (fAvoidSignal) return;
196 fArrow->SetArrowSize(fSizeEntry->GetNumber());
197 fArrow->Paint(fArrow->GetDrawOption());
198 Update();
199}
200
201////////////////////////////////////////////////////////////////////////////////
202/// Arrow shape combobox.
203
205{
206 TGComboBox *cb = new TGComboBox(parent, id);
207
208 cb->AddEntry(" -------|>",1);
209 cb->AddEntry(" <|-------",2);
210 cb->AddEntry(" -------->",3);
211 cb->AddEntry(" <--------",4);
212 cb->AddEntry(" ---->----",5);
213 cb->AddEntry(" ----<----",6);
214 cb->AddEntry(" ----|>---",7);
215 cb->AddEntry(" ---<|----",8);
216 cb->AddEntry(" <------>", 9);
217 cb->AddEntry(" <|-----|>",10);
218 (cb->GetListBox())->Resize((cb->GetListBox())->GetWidth(), 136);
219 cb->Select(1);
220 return cb;
221}
222
223////////////////////////////////////////////////////////////////////////////////
224/// Return shape entry according to the arrow draw option.
225
227{
228 TString opt = option;
229 opt.ToLower();
230 Int_t id = 0;
231
232 if (opt == "|>") id = 1;
233 if (opt == "<|") id = 2;
234 if (opt == ">") id = 3;
235 if (opt == "<") id = 4;
236 if (opt == "->-") id = 5;
237 if (opt == "-<-") id = 6;
238 if (opt == "-|>-") id = 7;
239 if (opt == "-<|-") id = 8;
240 if (opt == "<>") id = 9;
241 if (opt == "<|>") id = 10;
242 return id;
243}
@ kVerticalFrame
Definition GuiTypes.h:381
@ kFixedWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:382
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
EArrowWid
@ kARROW_SIZ
@ kARROW_ANG
@ kARROW_OPT
@ kLHintsNormal
Definition TGLayout.h:32
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Implements user interface for editing of arrow attributes: shape, size, angle.
virtual void ConnectSignals2Slots()
Connect signals to slots.
TArrow * fArrow
arrow object
Int_t GetShapeEntry(Option_t *opt)
Return shape entry according to the arrow draw option.
virtual void DoOption(Int_t id)
Slot connected to the arrow shape setting.
TGNumberEntry * fSizeEntry
size entry
TArrowEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor of arrow GUI.
virtual void DoSize()
Slot connected to the arrow size.
TGNumberEntry * fAngleEntry
opening angle entry
TGComboBox * BuildOptionComboBox(TGFrame *parent, Int_t id)
Arrow shape combobox.
TGComboBox * fOptionCombo
arrow shapes combo box
void SetModel(TObject *obj) override
Pick up the used arrow attributes.
~TArrowEditor() override
Destructor of arrow editor.
virtual void DoAngle()
Slot connected to the arrow opening angle setting.
Draw all kinds of Arrows.
Definition TArrow.h:29
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
Definition TGComboBox.h:47
virtual void AddEntry(TGString *s, Int_t id)
Definition TGComboBox.h:86
virtual TGListBox * GetListBox() const
Definition TGComboBox.h:110
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual TList * GetList() const
Definition TGFrame.h:310
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:967
TGCompositeFrame(const TGCompositeFrame &)=delete
TGFrame * fFrame
Definition TGLayout.h:112
TGFrame(const TGFrame &)=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.
@ kNESInteger
Style of number entry field.
@ kNESRealTwo
Fixed fraction real, two digit.
@ kNELLimitMinMax
Both lower and upper limits.
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:95
virtual void Update()
Update the current pad when an attribute is changed via GUI.
Definition TGedFrame.cxx:72
Bool_t fAvoidSignal
flag for executing slots
Definition TGedFrame.h:50
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:207
Basic string class.
Definition TString.h:139
void ToLower()
Change string to lower-case.
Definition TString.cxx:1182