Logo ROOT  
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
23TEveElement class used for displaying FreeType GL fonts. Holds a
24set of parameters to define FTGL font and its rendering style.
25*/
26
28
29////////////////////////////////////////////////////////////////////////////////
30/// Constructor.
31
32TEveText::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
55}
56
57////////////////////////////////////////////////////////////////////////////////
58/// Set valid font size.
59
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
75void 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
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}
const Bool_t kFALSE
Definition: RtypesCore.h:90
float Float_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:89
const char Option_t
Definition: RtypesCore.h:64
#define ClassImp(name)
Definition: Rtypes.h:361
char name[80]
Definition: TGX11.cxx:109
Use this attribute class when an object should have 3D capabilities.
Definition: TAtt3D.h:19
Helper for management of bounding-box information.
Definition: TAttBBox.h:18
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
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition: TEveElement.h:34
virtual void InitMainTrans(Bool_t can_edit=kTRUE)
Initialize the main transformation to identity matrix.
virtual TEveTrans & RefMainTrans()
Return reference to main transformation.
Bool_t fCanEditMainTransparency
Definition: TEveElement.h:93
Bool_t fCanEditMainColor
Definition: TEveElement.h:92
static const TGPicture * fgListTreeIcons[9]
Definition: TEveElement.h:63
virtual void PaintStandard(TObject *id)
Paint object – a generic implementation for EVE elements.
TEveElement class used for displaying FreeType GL fonts.
Definition: TEveText.h:25
virtual void ComputeBBox()
Fill bounding-box information.
Definition: TEveText.cxx:126
Float_t fPolygonOffset[2]
Definition: TEveText.h:43
void SetFontFile(Int_t file)
Definition: TEveText.h:53
void SetFontMode(Int_t mode)
Set FTFont class ID.
Definition: TEveText.cxx:93
virtual void Paint(Option_t *option="")
Paint this object. Only direct rendering is supported.
Definition: TEveText.cxx:116
void SetFontSize(Int_t size, Bool_t validate=kTRUE)
Set valid font size.
Definition: TEveText.cxx:60
TEveText(const TEveText &)
void SetPolygonOffset(Float_t factor, Float_t units)
Set the scale and units used to calculate depth values.
Definition: TEveText.cxx:107
Int_t fFontSize
Definition: TEveText.h:34
virtual const TGPicture * GetListTreeIcon(Bool_t open=kFALSE)
Return TEveText icon.
Definition: TEveText.cxx:134
Int_t fFontMode
Definition: TEveText.h:36
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition: TEveTrans.h:27
void SetEditRotation(Bool_t x)
Definition: TEveTrans.h:171
void SetEditScale(Bool_t x)
Definition: TEveTrans.h:172
static FontSizeVec_t * GetFontSizeArray()
Get valid font size vector.
static TObjArray * GetFontFileArray()
Get id to file name map.
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
An array of TObjects.
Definition: TObjArray.h:37
Collectable string class.
Definition: TObjString.h:28
const TString & GetString() const
Definition: TObjString.h:46
static constexpr double ns
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Definition: TMathBase.h:278