Logo ROOT  
Reference Guide
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
24};
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));
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
121 if (id != fOptionCombo->GetSelected())
122 fOptionCombo->Select(id);
123
126
129
132}
133
134////////////////////////////////////////////////////////////////////////////////
135/// Slot connected to the arrow opening angle setting.
136
138{
139 if (fAvoidSignal) return;
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);
186 Update();
187}
188
189
190////////////////////////////////////////////////////////////////////////////////
191/// Slot connected to the arrow size.
192
194{
195 if (fAvoidSignal) return;
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
const Bool_t kFALSE
Definition: RtypesCore.h:101
float Float_t
Definition: RtypesCore.h:57
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassImp(name)
Definition: Rtypes.h:375
EArrowWid
@ kARROW_SIZ
@ kARROW_ANG
@ kARROW_OPT
@ 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
Implements user interface for editing of arrow attributes: shape, size, angle.
Definition: TArrowEditor.h:24
virtual void ConnectSignals2Slots()
Connect signals to slots.
TArrow * fArrow
arrow object
Definition: TArrowEditor.h:27
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
Definition: TArrowEditor.h:30
virtual ~TArrowEditor()
Destructor of arrow editor.
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
Definition: TArrowEditor.h:29
TGComboBox * BuildOptionComboBox(TGFrame *parent, Int_t id)
Arrow shape combobox.
virtual void SetModel(TObject *obj)
Pick up the used arrow attributes.
TGComboBox * fOptionCombo
arrow shapes combo box
Definition: TArrowEditor.h:28
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:157
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...
Definition: TGComboBox.cxx:456
The base class for composite widgets (menu bars, list boxes, etc.).
Definition: TGFrame.h:287
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
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:605
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.
Definition: TGNumberEntry.h:42
@ kNESInteger
Style of number entry field.
Definition: TGNumberEntry.h:25
@ kNESRealTwo
Fixed fraction real, two digit.
Definition: TGNumberEntry.h:27
@ kNELLimitMinMax
Both lower and upper limits.
Definition: TGNumberEntry.h:50
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: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
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition: TObject.cxx:423
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition: TObject.cxx:758
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:869
Basic string class.
Definition: TString.h:136
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1171
static constexpr double deg