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
18
24
25/** \class TArrowEditor
26 \ingroup ged
27
28Implements user interface for editing of arrow attributes:
29shape, size, angle.
30*/
31
32////////////////////////////////////////////////////////////////////////////////
33/// Constructor of arrow GUI.
34
36 Int_t height, UInt_t options, Pixel_t back)
37 : TGedFrame(p, width, height, options | kVerticalFrame, back)
38{
39 fArrow = 0;
40
41 MakeTitle("Arrow");
42
43 TGCompositeFrame *f2 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
44 AddFrame(f2, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
45
46 TGCompositeFrame *f2a = new TGCompositeFrame(f2, 80, 20);
47 f2->AddFrame(f2a, new TGLayoutHints(kLHintsTop, 10, 0, 0, 0));
48
49 TGLabel *fShapeLabel = new TGLabel(f2a, "Shape:");
50 f2a->AddFrame(fShapeLabel, new TGLayoutHints(kLHintsNormal, 0, 0, 1, 5));
51
52 TGLabel *fAngleLabel = new TGLabel(f2a, "Angle:");
53 f2a->AddFrame(fAngleLabel, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 5));
54
55 TGLabel *fSizeLabel = new TGLabel(f2a, "Size: ");
56 f2a->AddFrame(fSizeLabel, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 1));
57
59 f2->AddFrame(f2b, new TGLayoutHints(kLHintsTop, 10, 0, 0, 0));
60
62 fOptionCombo->Resize(80, 20);
63 f2b->AddFrame(fOptionCombo, new TGLayoutHints(kLHintsExpandX, 1, 1, 1, 1));
65
70 fAngleEntry->GetNumberEntry()->SetToolTipText("Set the arrow opening angle in degrees.");
71 f2b->AddFrame(fAngleEntry, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
72
73 fSizeEntry = new TGNumberEntry(f2b, 0.03, 8, kARROW_SIZ,
77 fSizeEntry->GetNumberEntry()->SetToolTipText("Set the size of arrow.");
78 f2b->AddFrame(fSizeEntry, new TGLayoutHints(kLHintsExpandX, 1, 1, 3, 1));
79
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// Destructor of arrow editor.
84
86{
88 TIter next(GetList());
89
90 while ((el = (TGFrameElement *)next())) {
91 if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame"))
92 ((TGCompositeFrame *)el->fFrame)->Cleanup();
93 }
94 Cleanup();
95}
96
97////////////////////////////////////////////////////////////////////////////////
98/// Connect signals to slots.
99
101{
102 fOptionCombo->Connect("Selected(Int_t)", "TArrowEditor", this, "DoOption(Int_t)");
103 fAngleEntry->Connect("ValueSet(Long_t)", "TArrowEditor", this, "DoAngle()");
104 (fAngleEntry->GetNumberEntry())->Connect("ReturnPressed()", "TArrowEditor", this, "DoAngle()");
105 fSizeEntry->Connect("ValueSet(Long_t)", "TArrowEditor", this, "DoSize()");
106 (fSizeEntry->GetNumberEntry())->Connect("ReturnPressed()", "TArrowEditor", this, "DoSize()");
107
108 fInit = kFALSE;
109}
110
111////////////////////////////////////////////////////////////////////////////////
112/// Pick up the used arrow attributes.
113
115{
116 fArrow = (TArrow *)obj;
118
120 if (id != fOptionCombo->GetSelected())
121 fOptionCombo->Select(id);
122
125
126 Int_t deg = (Int_t)fArrow->GetAngle();
128
131}
132
133////////////////////////////////////////////////////////////////////////////////
134/// Slot connected to the arrow opening angle setting.
135
143
144////////////////////////////////////////////////////////////////////////////////
145/// Slot connected to the arrow shape setting.
146
148{
149 if (fAvoidSignal) return;
150 const char* opt=0;
151 switch (id) {
152 case 1:
153 opt = "|>";
154 break;
155 case 2:
156 opt = "<|";
157 break;
158 case 3:
159 opt = ">";
160 break;
161 case 4:
162 opt = "<";
163 break;
164 case 5:
165 opt = "->-";
166 break;
167 case 6:
168 opt = "-<-";
169 break;
170 case 7:
171 opt = "-|>-";
172 break;
173 case 8:
174 opt = "-<|-";
175 break;
176 case 9:
177 opt = "<>";
178 break;
179 case 10:
180 opt = "<|>";
181 break;
182 }
183 fArrow->SetDrawOption(opt);
185 Update();
186}
187
188
189////////////////////////////////////////////////////////////////////////////////
190/// Slot connected to the arrow size.
191
199
200////////////////////////////////////////////////////////////////////////////////
201/// Arrow shape combobox.
202
204{
205 TGComboBox *cb = new TGComboBox(parent, id);
206
207 cb->AddEntry(" -------|>",1);
208 cb->AddEntry(" <|-------",2);
209 cb->AddEntry(" -------->",3);
210 cb->AddEntry(" <--------",4);
211 cb->AddEntry(" ---->----",5);
212 cb->AddEntry(" ----<----",6);
213 cb->AddEntry(" ----|>---",7);
214 cb->AddEntry(" ---<|----",8);
215 cb->AddEntry(" <------>", 9);
216 cb->AddEntry(" <|-----|>",10);
217 (cb->GetListBox())->Resize((cb->GetListBox())->GetWidth(), 136);
218 cb->Select(1);
219 return cb;
220}
221
222////////////////////////////////////////////////////////////////////////////////
223/// Return shape entry according to the arrow draw option.
224
226{
227 TString opt = option;
228 opt.ToLower();
229 Int_t id = 0;
230
231 if (opt == "|>") id = 1;
232 if (opt == "<|") id = 2;
233 if (opt == ">") id = 3;
234 if (opt == "<") id = 4;
235 if (opt == "->-") id = 5;
236 if (opt == "-<-") id = 6;
237 if (opt == "-|>-") id = 7;
238 if (opt == "-<|-") id = 8;
239 if (opt == "<>") id = 9;
240 if (opt == "<|>") id = 10;
241 return id;
242}
@ 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
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
EArrowWid
@ kARROW_SIZ
@ kARROW_ANG
@ kARROW_OPT
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kLHintsNormal
Definition TGLayout.h:32
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
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
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
Float_t GetAngle() const
Definition TArrow.h:51
virtual void SetArrowSize(Float_t arrowsize=0.05)
Definition TArrow.h:61
void Paint(Option_t *option="") override
Paint this arrow with its current attributes.
Definition TArrow.cxx:155
Float_t GetArrowSize() const
Definition TArrow.h:52
virtual void SetAngle(Float_t angle=60)
Definition TArrow.h:60
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 Int_t GetSelected() const
Definition TGComboBox.h:114
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...
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
virtual TList * GetList() const
Definition TGFrame.h:312
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:959
TGCompositeFrame(const TGCompositeFrame &)=delete
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
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.
TGNumberEntryField * GetNumberEntry() const
Get the number entry field.
virtual Double_t GetNumber() const
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
@ kNEANonNegative
Non-negative number.
@ kNESInteger
Style of number entry field.
@ kNESRealTwo
Fixed fraction real, two digit.
@ kNELLimitMinMax
Both lower and upper limits.
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
ROOT GUI Window base class.
Definition TGWindow.h:23
Base frame for implementing GUI - a service class.
Definition TGedFrame.h:27
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:41
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition TObject.cxx:441
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition TObject.cxx:848
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:865
Basic string class.
Definition TString.h:138
void ToLower()
Change string to lower-case.
Definition TString.cxx:1189