Logo ROOT   6.14/05
Reference Guide
TEveText.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 "TEveText.h"
13 #include "TEveTrans.h"
14 
15 #include "TGLFontManager.h"
16 #include "TObjArray.h"
17 #include "TObjString.h"
18 #include "TString.h"
19 #include "TMath.h"
20 
21 /** \class TEveText
22 \ingroup TEve
23 TEveElement class used for displaying FreeType GL fonts. Holds a
24 set of parameters to define FTGL font and its rendering style.
25 */
26 
28 
29 ////////////////////////////////////////////////////////////////////////////////
30 /// Constructor.
31 
32 TEveText::TEveText(const char* txt) :
33  TEveElement(fTextColor),
34  TNamed("TEveText", ""),
35  TAtt3D(),
36  TAttBBox(),
37  fText(txt),
38  fTextColor(0),
39 
40  fFontSize(12),
41  fFontFile(4),
42  fFontMode(-1),
43  fExtrude(1.0f),
44 
45  fAutoLighting(kTRUE),
46  fLighting(kFALSE)
47 {
48  fPolygonOffset[0] = 0;
49  fPolygonOffset[1] = 0;
50 
53  InitMainTrans();
55 }
56 
57 ////////////////////////////////////////////////////////////////////////////////
58 /// Set valid font size.
59 
60 void TEveText::SetFontSize(Int_t val, Bool_t validate)
61 {
62  if (validate) {
63  Int_t* fsp = &TGLFontManager::GetFontSizeArray()->front();
65  Int_t idx = TMath::BinarySearch(ns, fsp, val);
66  fFontSize = fsp[idx];
67  } else {
68  fFontSize = val;
69  }
70 }
71 
72 ////////////////////////////////////////////////////////////////////////////////
73 /// Set font file regarding to static TGLFontManager fgFontFileArray.
74 
75 void TEveText::SetFontFile(const char* name)
76 {
78  TIter next_base(fa);
79  TObjString* os;
80  Int_t idx = 0;
81  while ((os = (TObjString*) next_base()) != 0) {
82  if (os->GetString() == name) {
83  SetFontFile(idx);
84  return;
85  }
86  idx++;
87  }
88 }
89 
90 ////////////////////////////////////////////////////////////////////////////////
91 /// Set FTFont class ID.
92 
94 {
95  fFontMode = mode;
96 
98  TEveTrans& t = RefMainTrans();
99  t.SetEditRotation(edit);
100  t.SetEditScale(edit);
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// Set the scale and units used to calculate depth values.
105 /// See glPolygonOffset manual page.
106 
108 {
109  fPolygonOffset[0] = factor;
110  fPolygonOffset[1] = units;
111 }
112 
113 ////////////////////////////////////////////////////////////////////////////////
114 /// Paint this object. Only direct rendering is supported.
115 
117 {
118  PaintStandard(this);
119 }
120 
121 ////////////////////////////////////////////////////////////////////////////////
122 /// Fill bounding-box information. Virtual from TAttBBox.
123 /// If member 'TEveFrameBox* fFrame' is set, frame's corners are
124 /// used as bbox.
125 
127 {
128  BBoxZero();
129 }
130 
131 ////////////////////////////////////////////////////////////////////////////////
132 /// Return TEveText icon.
133 
135 {
137 }
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition: TEveTrans.h:26
An array of TObjects.
Definition: TObjArray.h:37
Int_t fFontSize
Definition: TEveText.h:34
Collectable string class.
Definition: TObjString.h:28
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
void SetPolygonOffset(Float_t factor, Float_t units)
Set the scale and units used to calculate depth values.
Definition: TEveText.cxx:107
Bool_t fCanEditMainColor
Definition: TEveElement.h:92
static const TGPicture * fgListTreeIcons[9]
Definition: TEveElement.h:63
Use this attribute class when an object should have 3D capabilities.
Definition: TAtt3D.h:19
virtual void PaintStandard(TObject *id)
Paint object – a generic implementation for EVE elements.
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TEveText(const TEveText &)
Bool_t fCanEditMainTransparency
Definition: TEveElement.h:93
void SetEditScale(Bool_t x)
Definition: TEveTrans.h:172
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual void ComputeBBox()
Fill bounding-box information.
Definition: TEveText.cxx:126
Int_t fFontMode
Definition: TEveText.h:36
void SetEditRotation(Bool_t x)
Definition: TEveTrans.h:171
virtual void Paint(Option_t *option="")
Paint this object. Only direct rendering is supported.
Definition: TEveText.cxx:116
virtual void InitMainTrans(Bool_t can_edit=kTRUE)
Initialize the main transformation to identity matrix.
const TString & GetString() const
Definition: TObjString.h:47
Float_t fPolygonOffset[2]
Definition: TEveText.h:43
virtual const TGPicture * GetListTreeIcon(Bool_t open=kFALSE)
Return TEveText icon.
Definition: TEveText.cxx:134
void BBoxZero(Float_t epsilon=0, Float_t x=0, Float_t y=0, Float_t z=0)
Create cube of volume (2*epsilon)^3 at (x,y,z).
Definition: TAttBBox.cxx:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
#define ClassImp(name)
Definition: Rtypes.h:359
void SetFontSize(Int_t size, Bool_t validate=kTRUE)
Set valid font size.
Definition: TEveText.cxx:60
TEveElement class used for displaying FreeType GL fonts.
Definition: TEveText.h:21
void SetFontMode(Int_t mode)
Set FTFont class ID.
Definition: TEveText.cxx:93
void SetFontFile(Int_t file)
Definition: TEveText.h:53
Helper for management of bounding-box information.
Definition: TAttBBox.h:17
virtual TEveTrans & RefMainTrans()
Return reference to main transformation.
static FontSizeVec_t * GetFontSizeArray()
Get valid font size vector.
static TObjArray * GetFontFileArray()
Get id to file name map.
const Bool_t kTRUE
Definition: RtypesCore.h:87
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition: TEveElement.h:33
static constexpr double ns
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Binary search in an array of n values to locate value.
Definition: TMath.h:1221
char name[80]
Definition: TGX11.cxx:109