forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEveText.cxx
142 lines (116 loc) · 3.94 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
138
139
140
141
142
// @(#)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"
//==============================================================================
//==============================================================================
// TEveText
//==============================================================================
//______________________________________________________________________________
//
// TEveElement class used for displaying FreeType GL fonts. Holds a
// set of parameters to define FTGL font and its rendering style.
//
ClassImp(TEveText);
//______________________________________________________________________________
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)
{
// Constructor.
fPolygonOffset[0] = 0;
fPolygonOffset[1] = 0;
fCanEditMainColor = kTRUE;
fCanEditMainTransparency = kTRUE;
InitMainTrans();
SetFontMode(TGLFont::kPixmap);
}
//______________________________________________________________________________
void TEveText::SetFontSize(Int_t val, Bool_t validate)
{
// Set valid font size.
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;
}
}
//______________________________________________________________________________
void TEveText::SetFontFile(const char* name)
{
// Set font file regarding to static TGLFontManager fgFontFileArray.
TObjArray* fa =TGLFontManager::GetFontFileArray();
TIter next_base(fa);
TObjString* os;
Int_t idx = 0;
while ((os = (TObjString*) next_base()) != 0) {
if (os->GetString() == name) {
SetFontFile(idx);
return;
}
idx++;
}
}
//______________________________________________________________________________
void TEveText::SetFontMode( Int_t mode)
{
// Set FTFont class ID.
fFontMode = mode;
Bool_t edit = (fFontMode > TGLFont::kPixmap);
TEveTrans& t = RefMainTrans();
t.SetEditRotation(edit);
t.SetEditScale(edit);
}
//______________________________________________________________________________
void TEveText::SetPolygonOffset(Float_t factor, Float_t units)
{
// Set the scale and units used to calculate depth values.
// See glPolygonOffset manual page.
fPolygonOffset[0] = factor;
fPolygonOffset[1] = units;
}
//______________________________________________________________________________
void TEveText::Paint(Option_t*)
{
// Paint this object. Only direct rendering is supported.
PaintStandard(this);
}
//______________________________________________________________________________
void TEveText::ComputeBBox()
{
// Fill bounding-box information. Virtual from TAttBBox.
// If member 'TEveFrameBox* fFrame' is set, frame's corners are
// used as bbox.
BBoxZero();
}
//______________________________________________________________________________
const TGPicture* TEveText::GetListTreeIcon(Bool_t)
{
// Return TEveText icon.
return TEveElement::fgListTreeIcons[5];
}