Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
27 ClassImp(TEveText);
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 
51  fCanEditMainColor = kTRUE;
52  fCanEditMainTransparency = kTRUE;
53  InitMainTrans();
54  SetFontMode(TGLFont::kPixmap);
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();
64  Int_t ns = TGLFontManager::GetFontSizeArray()->size();
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 {
77  TObjArray* fa =TGLFontManager::GetFontFileArray();
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 
93 void TEveText::SetFontMode( Int_t mode)
94 {
95  fFontMode = mode;
96 
97  Bool_t edit = (fFontMode > TGLFont::kPixmap);
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 
107 void TEveText::SetPolygonOffset(Float_t factor, Float_t units)
108 {
109  fPolygonOffset[0] = factor;
110  fPolygonOffset[1] = units;
111 }
112 
113 ////////////////////////////////////////////////////////////////////////////////
114 /// Paint this object. Only direct rendering is supported.
115 
116 void TEveText::Paint(Option_t*)
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 
126 void TEveText::ComputeBBox()
127 {
128  BBoxZero();
129 }
130 
131 ////////////////////////////////////////////////////////////////////////////////
132 /// Return TEveText icon.
133 
134 const TGPicture* TEveText::GetListTreeIcon(Bool_t)
135 {
136  return TEveElement::fgListTreeIcons[5];
137 }