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
31
32////////////////////////////////////////////////////////////////////////////////
33/// Constructor.
34
36 UInt_t options, Pixel_t back) :
37 TGedFrame(p, width, height, options | kVerticalFrame, back),
38 fM(nullptr),
39
40 fSize(nullptr),
41 fFile(nullptr),
42 fMode(nullptr),
43 fExtrude(nullptr),
44
45 fLighting(nullptr),
46 fAutoLighting(nullptr)
47{
48 MakeTitle("TEveText");
49
50 // Text entry
51 fText = new TGTextEntry(this);
52 fText->Resize(135, fText->GetDefaultHeight());
53 AddFrame(fText, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
54 fText->Connect("TextChanged(const char *)", "TEveTextEditor", this, "DoText(const char *)");
55
56 // Face Size combo
57 fSize = MakeLabeledCombo("Size:");
58 Int_t* fsp = &TGLFontManager::GetFontSizeArray()->front();
60 for(Int_t i= 0; i< nums; i++)
61 {
62 fSize->AddEntry(Form("%-2d", fsp[i]), fsp[i]);
63 }
64 fSize->Connect("Selected(Int_t)", "TEveTextEditor", this, "DoFontSize()");
65
66 // Font File combo
67 fFile = MakeLabeledCombo("File:");
69 TIter next(farr);
70 TObjString* os;
71 Int_t cnt = 0;
72 while ((os = (TObjString*) next()) != nullptr)
73 {
74 fFile->AddEntry(Form("%s", os->GetString().Data()), cnt);
75 cnt++;
76 }
77 fFile->Connect("Selected(Int_t)", "TEveTextEditor", this, "DoFontFile()");
78
79 // Mode combo
80 fMode = MakeLabeledCombo("Mode:");
81 fMode->AddEntry("Bitmap", TGLFont::kBitmap);
82 fMode->AddEntry("Pixmap", TGLFont::kPixmap);
83 fMode->AddEntry("Texture", TGLFont::kTexture);
84 fMode->AddEntry("Outline", TGLFont::kOutline);
85 fMode->AddEntry("Polygon", TGLFont::kPolygon);
86 fMode->AddEntry("Extrude", TGLFont::kExtrude);
87 fMode->Connect("Selected(Int_t)", "TEveTextEditor", this, "DoFontMode()");
88
89 fExtrude = new TEveGValuator(this, "Depth:", 90, 0);
90 fExtrude->SetLabelWidth(45);
91 fExtrude->SetNELength(5);
92 // fExtrude->SetShowSlider(kFALSE);
93 fExtrude->Build();
94 fExtrude->SetLimits(0.01, 10, 100, TGNumberFormat::kNESRealTwo);
95 fExtrude->SetToolTip("Extrusion depth.");
96 fExtrude->Connect("ValueSet(Double_t)", "TEveTextEditor", this, "DoExtrude()");
97 AddFrame(fExtrude, new TGLayoutHints(kLHintsTop, 4, 1, 1, 1));
98
99 // GLConfig
101 f1->AddFrame(new TGLabel(f1, "GLConfig"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
102 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
103 AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 8, 0));
104
105 TGCompositeFrame *alf = new TGCompositeFrame(this, 145, 10, kHorizontalFrame );
106 fAutoLighting = new TGCheckButton(alf, "AutoLighting");
107 alf->AddFrame(fAutoLighting, new TGLayoutHints(kLHintsLeft, 1,2,0,0));
108 fAutoLighting->Connect("Toggled(Bool_t)", "TEveTextEditor", this, "DoAutoLighting()");
109 fLighting = new TGCheckButton(alf, "Lighting");
110 alf->AddFrame(fLighting, new TGLayoutHints(kLHintsLeft, 1,2,0,0));
111 fLighting->Connect("Toggled(Bool_t)", "TEveTextEditor", this, "DoLighting()");
112 AddFrame(alf, new TGLayoutHints(kLHintsTop, 0, 0, 0, 0));
113}
114
115////////////////////////////////////////////////////////////////////////////////
116/// Helper function. Creates TGComboBox with fixed size TGLabel.
117
119{
120 UInt_t labelW = 45;
121 UInt_t labelH = 20;
122 TGHorizontalFrame* hf = new TGHorizontalFrame(this);
123 // label
124 TGCompositeFrame *labfr = new TGHorizontalFrame(hf, labelW, labelH, kFixedSize);
125 TGLabel* label = new TGLabel(labfr, name);
126 labfr->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsBottom));
127 hf->AddFrame(labfr, new TGLayoutHints(kLHintsLeft));
128 // combo
129 TGLayoutHints* clh = new TGLayoutHints(kLHintsLeft, 0,0,0,0);
130 TGComboBox* combo = new TGComboBox(hf);
131 combo->Resize(90, 20);
132 hf->AddFrame(combo, clh);
133
134 AddFrame(hf, new TGLayoutHints(kLHintsTop, 4, 1, 1, 1));
135 return combo;
136}
137
138////////////////////////////////////////////////////////////////////////////////
139/// Set model object.
140
142{
143 fM = dynamic_cast<TEveText*>(obj);
144 if (strcmp(fM->GetText(), fText->GetText()))
145 fText->SetText(fM->GetText());
146
147 fSize->Select(fM->GetFontSize(), kFALSE);
148 fFile->Select(fM->GetFontFile(), kFALSE);
149
150 // mode
151 fMode->Select(fM->GetFontMode(), kFALSE);
152
153 // lightning
154 fAutoLighting->SetState(fM->GetAutoLighting() ? kButtonDown : kButtonUp);
155 if (fM->GetAutoLighting()) {
156 fLighting->SetDisabledAndSelected(fM->GetLighting() ? kButtonDown : kButtonUp);
157 } else {
158 fLighting->SetEnabled();
159 fLighting->SetState(fM->GetLighting() ? kButtonDown : kButtonUp);
160 }
161
162 // extrude
163 if (fM->GetFontMode() == TGLFont::kExtrude)
164 {
166 fExtrude->SetValue(fM->GetExtrude());
167 }
168 else
169 {
171 }
172}
173
174////////////////////////////////////////////////////////////////////////////////
175/// Slot for setting text.
176
177void TEveTextEditor::DoText(const char* /*txt*/)
178{
179 fM->SetText(fText->GetText());
180 Update();
181}
182
183////////////////////////////////////////////////////////////////////////////////
184/// Slot for setting FTGL attributes.
185
187{
188 fM->SetFontSize(fSize->GetSelected(), kFALSE);
189 Update();
190}
191
192////////////////////////////////////////////////////////////////////////////////
193/// Slot for setting FTGL attributes.
194
196{
197 fM->SetFontFile(fFile->GetSelected());
198 Update();
199}
200////////////////////////////////////////////////////////////////////////////////
201/// Slot for setting FTGL attributes.
202
204{
205 fM->SetFontMode(fMode->GetSelected());
206 Update();
207}
208
209////////////////////////////////////////////////////////////////////////////////
210/// Slot for setting an extrude depth.
211
213{
214 fM->SetExtrude(fExtrude->GetValue());
215 Update();
216}
217
218////////////////////////////////////////////////////////////////////////////////
219/// Slot for enabling/disabling defaults.
220
222{
223 fM->SetAutoLighting(fAutoLighting->IsOn());
224 Update();
225}
226
227////////////////////////////////////////////////////////////////////////////////
228/// Slot for enabling/disabling GL lighting.
229
231{
232 fM->SetLighting(fLighting->IsOn());
233 Update();
234}
@ kVerticalFrame
Definition GuiTypes.h:382
@ kFixedWidth
Definition GuiTypes.h:388
@ kFitWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:383
@ kFixedSize
Definition GuiTypes.h:391
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
@ 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
char name[80]
Definition TGX11.cxx:148
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2496
Composite GUI element for single value selection (supports label, number-entry and slider).
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
Selects different options.
Definition TGButton.h:264
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 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
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1196
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1182
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
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:387
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
ROOT GUI Window base class.
Definition TGWindow.h:23
TGedFrame(const TGedFrame &)=delete
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
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:42
const char * Data() const
Definition TString.h:384
TF1 * f1
Definition legend1.C:11