forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEveText.cxx
137 lines (112 loc) · 3.62 KB
/
TEveText.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// @(#)root/eve:$Id$
// Authors: Alja & Matevz Tadel 2008
/*************************************************************************
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "TEveText.h"
#include "TEveTrans.h"
#include "TGLFontManager.h"
#include "TObjArray.h"
#include "TObjString.h"
#include "TString.h"
#include "TMath.h"
/** \class TEveText
\ingroup TEve
TEveElement class used for displaying FreeType GL fonts. Holds a
set of parameters to define FTGL font and its rendering style.
*/
ClassImp(TEveText);
////////////////////////////////////////////////////////////////////////////////
/// Constructor.
TEveText::TEveText(const char* txt) :
TEveElement(fTextColor),
TNamed("TEveText", ""),
TAtt3D(),
TAttBBox(),
fText(txt),
fTextColor(0),
fFontSize(12),
fFontFile(4),
fFontMode(-1),
fExtrude(1.0f),
fAutoLighting(kTRUE),
fLighting(kFALSE)
{
fPolygonOffset[0] = 0;
fPolygonOffset[1] = 0;
fCanEditMainColor = kTRUE;
fCanEditMainTransparency = kTRUE;
InitMainTrans();
SetFontMode(TGLFont::kPixmap);
}
////////////////////////////////////////////////////////////////////////////////
/// Set valid font size.
void TEveText::SetFontSize(Int_t val, Bool_t validate)
{
if (validate) {
Int_t* fsp = &TGLFontManager::GetFontSizeArray()->front();
Int_t ns = TGLFontManager::GetFontSizeArray()->size();
Int_t idx = TMath::BinarySearch(ns, fsp, val);
fFontSize = fsp[idx];
} else {
fFontSize = val;
}
}
////////////////////////////////////////////////////////////////////////////////
/// Set font file regarding to static TGLFontManager fgFontFileArray.
void TEveText::SetFontFile(const char* name)
{
TObjArray* fa =TGLFontManager::GetFontFileArray();
TIter next_base(fa);
TObjString* os;
Int_t idx = 0;
while ((os = (TObjString*) next_base()) != nullptr) {
if (os->GetString() == name) {
SetFontFile(idx);
return;
}
idx++;
}
}
////////////////////////////////////////////////////////////////////////////////
/// Set FTFont class ID.
void TEveText::SetFontMode( Int_t mode)
{
fFontMode = mode;
Bool_t edit = (fFontMode > TGLFont::kPixmap);
TEveTrans& t = RefMainTrans();
t.SetEditRotation(edit);
t.SetEditScale(edit);
}
////////////////////////////////////////////////////////////////////////////////
/// Set the scale and units used to calculate depth values.
/// See glPolygonOffset manual page.
void TEveText::SetPolygonOffset(Float_t factor, Float_t units)
{
fPolygonOffset[0] = factor;
fPolygonOffset[1] = units;
}
////////////////////////////////////////////////////////////////////////////////
/// Paint this object. Only direct rendering is supported.
void TEveText::Paint(Option_t*)
{
PaintStandard(this);
}
////////////////////////////////////////////////////////////////////////////////
/// Fill bounding-box information. Virtual from TAttBBox.
/// If member 'TEveFrameBox* fFrame' is set, frame's corners are
/// used as bbox.
void TEveText::ComputeBBox()
{
BBoxZero();
}
////////////////////////////////////////////////////////////////////////////////
/// Return TEveText icon.
const TGPicture* TEveText::GetListTreeIcon(Bool_t)
{
return TEveElement::fgListTreeIcons[5];
}