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);
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:");
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:");
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);
92 // fExtrude->SetShowSlider(kFALSE);
93 fExtrude->Build();
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
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;
123 // label
125 TGLabel* label = new TGLabel(labfr, name);
126 labfr->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsBottom));
127 hf->AddFrame(labfr, new TGLayoutHints(kLHintsLeft));
128 // combo
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
149
150 // mode
152
153 // lightning
155 if (fM->GetAutoLighting()) {
157 } else {
160 }
161
162 // extrude
164 {
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
191
192////////////////////////////////////////////////////////////////////////////////
193/// Slot for setting FTGL attributes.
194
200////////////////////////////////////////////////////////////////////////////////
201/// Slot for setting FTGL attributes.
202
208
209////////////////////////////////////////////////////////////////////////////////
210/// Slot for setting an extrude depth.
211
217
218////////////////////////////////////////////////////////////////////////////////
219/// Slot for enabling/disabling defaults.
220
226
227////////////////////////////////////////////////////////////////////////////////
228/// Slot for enabling/disabling GL lighting.
229
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:108
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ 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:2495
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.
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:92
void SetFontSize(Int_t size, Bool_t validate=kTRUE)
Set valid font size.
Definition TEveText.cxx:59
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:453
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:289
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
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
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
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: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
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:865
TF1 * f1
Definition legend1.C:11