Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEveTextEditor.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Authors: Alja & Matevz Tadel 2008
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, 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 "TEveTextEditor.h"
13#include "TEveText.h"
14#include "TEveGValuators.h"
15
16#include "TGLFontManager.h"
17
18#include "TGLabel.h"
19#include "TGComboBox.h"
20#include "TGTextEntry.h"
21#include "TObjArray.h"
22#include "TObjString.h"
23#include "TG3DLine.h"
24
25
26/** \class TEveTextEditor
27\ingroup TEve
28GUI editor for TEveText.
29*/
30
32
33////////////////////////////////////////////////////////////////////////////////
34/// Constructor.
35
37 UInt_t options, Pixel_t back) :
38 TGedFrame(p, width, height, options | kVerticalFrame, back),
39 fM(nullptr),
40
41 fSize(nullptr),
42 fFile(nullptr),
43 fMode(nullptr),
44 fExtrude(nullptr),
45
46 fLighting(nullptr),
47 fAutoLighting(nullptr)
48{
49 MakeTitle("TEveText");
50
51 // Text entry
52 fText = new TGTextEntry(this);
54 AddFrame(fText, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
55 fText->Connect("TextChanged(const char *)", "TEveTextEditor", this, "DoText(const char *)");
56
57 // Face Size combo
58 fSize = MakeLabeledCombo("Size:");
59 Int_t* fsp = &TGLFontManager::GetFontSizeArray()->front();
61 for(Int_t i= 0; i< nums; i++)
62 {
63 fSize->AddEntry(Form("%-2d", fsp[i]), fsp[i]);
64 }
65 fSize->Connect("Selected(Int_t)", "TEveTextEditor", this, "DoFontSize()");
66
67 // Font File combo
68 fFile = MakeLabeledCombo("File:");
70 TIter next(farr);
71 TObjString* os;
72 Int_t cnt = 0;
73 while ((os = (TObjString*) next()) != nullptr)
74 {
75 fFile->AddEntry(Form("%s", os->GetString().Data()), cnt);
76 cnt++;
77 }
78 fFile->Connect("Selected(Int_t)", "TEveTextEditor", this, "DoFontFile()");
79
80 // Mode combo
81 fMode = MakeLabeledCombo("Mode:");
84 fMode->AddEntry("Texture", TGLFont::kTexture);
85 fMode->AddEntry("Outline", TGLFont::kOutline);
86 fMode->AddEntry("Polygon", TGLFont::kPolygon);
87 fMode->AddEntry("Extrude", TGLFont::kExtrude);
88 fMode->Connect("Selected(Int_t)", "TEveTextEditor", this, "DoFontMode()");
89
90 fExtrude = new TEveGValuator(this, "Depth:", 90, 0);
93 // fExtrude->SetShowSlider(kFALSE);
94 fExtrude->Build();
96 fExtrude->SetToolTip("Extrusion depth.");
97 fExtrude->Connect("ValueSet(Double_t)", "TEveTextEditor", this, "DoExtrude()");
98 AddFrame(fExtrude, new TGLayoutHints(kLHintsTop, 4, 1, 1, 1));
99
100 // GLConfig
102 f1->AddFrame(new TGLabel(f1, "GLConfig"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
103 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
104 AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 8, 0));
105
106 TGCompositeFrame *alf = new TGCompositeFrame(this, 145, 10, kHorizontalFrame );
107 fAutoLighting = new TGCheckButton(alf, "AutoLighting");
108 alf->AddFrame(fAutoLighting, new TGLayoutHints(kLHintsLeft, 1,2,0,0));
109 fAutoLighting->Connect("Toggled(Bool_t)", "TEveTextEditor", this, "DoAutoLighting()");
110 fLighting = new TGCheckButton(alf, "Lighting");
111 alf->AddFrame(fLighting, new TGLayoutHints(kLHintsLeft, 1,2,0,0));
112 fLighting->Connect("Toggled(Bool_t)", "TEveTextEditor", this, "DoLighting()");
113 AddFrame(alf, new TGLayoutHints(kLHintsTop, 0, 0, 0, 0));
114}
115
116////////////////////////////////////////////////////////////////////////////////
117/// Helper function. Creates TGComboBox with fixed size TGLabel.
118
120{
121 UInt_t labelW = 45;
122 UInt_t labelH = 20;
123 TGHorizontalFrame* hf = new TGHorizontalFrame(this);
124 // label
125 TGCompositeFrame *labfr = new TGHorizontalFrame(hf, labelW, labelH, kFixedSize);
126 TGLabel* label = new TGLabel(labfr, name);
127 labfr->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsBottom));
128 hf->AddFrame(labfr, new TGLayoutHints(kLHintsLeft));
129 // combo
130 TGLayoutHints* clh = new TGLayoutHints(kLHintsLeft, 0,0,0,0);
131 TGComboBox* combo = new TGComboBox(hf);
132 combo->Resize(90, 20);
133 hf->AddFrame(combo, clh);
134
135 AddFrame(hf, new TGLayoutHints(kLHintsTop, 4, 1, 1, 1));
136 return combo;
137}
138
139////////////////////////////////////////////////////////////////////////////////
140/// Set model object.
141
143{
144 fM = dynamic_cast<TEveText*>(obj);
145 if (strcmp(fM->GetText(), fText->GetText()))
146 fText->SetText(fM->GetText());
147
150
151 // mode
153
154 // lightning
156 if (fM->GetAutoLighting()) {
158 } else {
161 }
162
163 // extrude
165 {
168 }
169 else
170 {
172 }
173}
174
175////////////////////////////////////////////////////////////////////////////////
176/// Slot for setting text.
177
178void TEveTextEditor::DoText(const char* /*txt*/)
179{
180 fM->SetText(fText->GetText());
181 Update();
182}
183
184////////////////////////////////////////////////////////////////////////////////
185/// Slot for setting FTGL attributes.
186
188{
190 Update();
191}
192
193////////////////////////////////////////////////////////////////////////////////
194/// Slot for setting FTGL attributes.
195
197{
199 Update();
200}
201////////////////////////////////////////////////////////////////////////////////
202/// Slot for setting FTGL attributes.
203
205{
207 Update();
208}
209
210////////////////////////////////////////////////////////////////////////////////
211/// Slot for setting an extrude depth.
212
214{
216 Update();
217}
218
219////////////////////////////////////////////////////////////////////////////////
220/// Slot for enabling/disabling defaults.
221
223{
225 Update();
226}
227
228////////////////////////////////////////////////////////////////////////////////
229/// Slot for enabling/disabling GL lighting.
230
232{
234 Update();
235}
dim_t fSize
@ kVerticalFrame
Definition GuiTypes.h:381
@ kFixedWidth
Definition GuiTypes.h:387
@ kFitWidth
Definition GuiTypes.h:386
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kFixedSize
Definition GuiTypes.h:390
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
#define ClassImp(name)
Definition Rtypes.h:377
@ kButtonDown
Definition TGButton.h:54
@ kButtonUp
Definition TGButton.h:53
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
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
char name[80]
Definition TGX11.cxx:110
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
void SetLabelWidth(Int_t w)
void SetNELength(Int_t l)
Composite GUI element for single value selection (supports label, number-entry and slider).
void Build(Bool_t connect=kTRUE) override
Create sub-components (label, number entry, slider).
void SetToolTip(const char *tip)
Set the tooltip of the number-entry.
void SetLimits(Int_t min, Int_t max)
Set limits of the represented value for integer values.
Float_t GetValue() const
virtual void SetValue(Float_t v, Bool_t emit=kFALSE)
Set value, optionally emit signal.
GUI editor for TEveText.
void DoFontMode()
Slot for setting FTGL attributes.
TGCheckButton * fLighting
TGComboBox * fSize
void DoText(const char *)
Slot for setting text.
void DoFontFile()
Slot for setting FTGL attributes.
TGCheckButton * fAutoLighting
void DoLighting()
Slot for enabling/disabling GL lighting.
TGComboBox * fFile
TEveGValuator * fExtrude
TGTextEntry * fText
void DoAutoLighting()
Slot for enabling/disabling defaults.
void SetModel(TObject *obj) override
Set model object.
void DoFontSize()
Slot for setting FTGL attributes.
void DoExtrude()
Slot for setting an extrude depth.
TEveTextEditor(const TEveTextEditor &)
TGComboBox * MakeLabeledCombo(const char *name)
Helper function. Creates TGComboBox with fixed size TGLabel.
TGComboBox * fMode
TEveElement class used for displaying FreeType GL fonts.
Definition TEveText.h:25
Float_t GetExtrude() const
Definition TEveText.h:66
const char * GetText() const
Definition TEveText.h:57
void SetAutoLighting(Bool_t isOn)
Definition TEveText.h:64
void SetFontFile(Int_t file)
Definition TEveText.h:53
Bool_t GetAutoLighting() const
Definition TEveText.h:63
void SetFontMode(Int_t mode)
Set FTFont class ID.
Definition TEveText.cxx:93
void SetFontSize(Int_t size, Bool_t validate=kTRUE)
Set valid font size.
Definition TEveText.cxx:60
Bool_t GetLighting() const
Definition TEveText.h:60
void SetLighting(Bool_t isOn)
Definition TEveText.h:61
Int_t GetFontSize() const
Definition TEveText.h:49
Int_t GetFontFile() const
Definition TEveText.h:50
void SetText(const char *t)
Definition TEveText.h:58
void SetExtrude(Float_t x)
Definition TEveText.h:67
Int_t GetFontMode() const
Definition TEveText.h:51
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition TGButton.cxx:459
Selects different options.
Definition TGButton.h:264
virtual void SetDisabledAndSelected(Bool_t)
Set the state of a check button to disabled and either on or off.
Bool_t IsOn() const override
Definition TGButton.h:310
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set check button state.
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 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: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 void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1204
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1190
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:191
A horizontal 3D line is a line that typically separates a toolbar from the menubar.
Definition TG3DLine.h:18
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:385
static FontSizeVec_t * GetFontSizeArray()
Get valid font size vector.
static TObjArray * GetFontFileArray()
Get id to file name map.
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
@ kNESRealTwo
Fixed fraction real, two digit.
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
const char * GetText() const
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line.
ROOT GUI Window base class.
Definition TGWindow.h:23
Base frame for implementing GUI - a service class.
Definition TGedFrame.h:27
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
An array of TObjects.
Definition TObjArray.h:31
Collectable string class.
Definition TObjString.h:28
const TString & GetString() const
Definition TObjString.h:46
Mother of all ROOT objects.
Definition TObject.h:41
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
const char * Data() const
Definition TString.h:376
TF1 * f1
Definition legend1.C:11