ROOT logo
// @(#)root/eve:$Id: TEveText.cxx 27157 2009-01-15 14:05:12Z brun $
// 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 "TBuffer3D.h"
#include "TBuffer3DTypes.h"
#include "TVirtualPad.h"
#include "TVirtualViewer3D.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.

   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::Paint(Option_t* )
{
   // Paint this object. Only direct rendering is supported.

   static const TEveException eH("TEveText::Paint ");

   TBuffer3D buff(TBuffer3DTypes::kGeneric);

   // Section kCore
   buff.fID           = this;
   buff.fColor        = GetMainColor();
   buff.fTransparency = GetMainTransparency();
   if (HasMainTrans())
      RefMainTrans().SetBuffer3D(buff);
   buff.SetSectionsValid(TBuffer3D::kCore);

   Int_t reqSections = gPad->GetViewer3D()->AddObject(buff);
   if (reqSections != TBuffer3D::kNone)
      Error(eH, "only direct GL rendering supported.");
}

//______________________________________________________________________________
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];
}
 TEveText.cxx:1
 TEveText.cxx:2
 TEveText.cxx:3
 TEveText.cxx:4
 TEveText.cxx:5
 TEveText.cxx:6
 TEveText.cxx:7
 TEveText.cxx:8
 TEveText.cxx:9
 TEveText.cxx:10
 TEveText.cxx:11
 TEveText.cxx:12
 TEveText.cxx:13
 TEveText.cxx:14
 TEveText.cxx:15
 TEveText.cxx:16
 TEveText.cxx:17
 TEveText.cxx:18
 TEveText.cxx:19
 TEveText.cxx:20
 TEveText.cxx:21
 TEveText.cxx:22
 TEveText.cxx:23
 TEveText.cxx:24
 TEveText.cxx:25
 TEveText.cxx:26
 TEveText.cxx:27
 TEveText.cxx:28
 TEveText.cxx:29
 TEveText.cxx:30
 TEveText.cxx:31
 TEveText.cxx:32
 TEveText.cxx:33
 TEveText.cxx:34
 TEveText.cxx:35
 TEveText.cxx:36
 TEveText.cxx:37
 TEveText.cxx:38
 TEveText.cxx:39
 TEveText.cxx:40
 TEveText.cxx:41
 TEveText.cxx:42
 TEveText.cxx:43
 TEveText.cxx:44
 TEveText.cxx:45
 TEveText.cxx:46
 TEveText.cxx:47
 TEveText.cxx:48
 TEveText.cxx:49
 TEveText.cxx:50
 TEveText.cxx:51
 TEveText.cxx:52
 TEveText.cxx:53
 TEveText.cxx:54
 TEveText.cxx:55
 TEveText.cxx:56
 TEveText.cxx:57
 TEveText.cxx:58
 TEveText.cxx:59
 TEveText.cxx:60
 TEveText.cxx:61
 TEveText.cxx:62
 TEveText.cxx:63
 TEveText.cxx:64
 TEveText.cxx:65
 TEveText.cxx:66
 TEveText.cxx:67
 TEveText.cxx:68
 TEveText.cxx:69
 TEveText.cxx:70
 TEveText.cxx:71
 TEveText.cxx:72
 TEveText.cxx:73
 TEveText.cxx:74
 TEveText.cxx:75
 TEveText.cxx:76
 TEveText.cxx:77
 TEveText.cxx:78
 TEveText.cxx:79
 TEveText.cxx:80
 TEveText.cxx:81
 TEveText.cxx:82
 TEveText.cxx:83
 TEveText.cxx:84
 TEveText.cxx:85
 TEveText.cxx:86
 TEveText.cxx:87
 TEveText.cxx:88
 TEveText.cxx:89
 TEveText.cxx:90
 TEveText.cxx:91
 TEveText.cxx:92
 TEveText.cxx:93
 TEveText.cxx:94
 TEveText.cxx:95
 TEveText.cxx:96
 TEveText.cxx:97
 TEveText.cxx:98
 TEveText.cxx:99
 TEveText.cxx:100
 TEveText.cxx:101
 TEveText.cxx:102
 TEveText.cxx:103
 TEveText.cxx:104
 TEveText.cxx:105
 TEveText.cxx:106
 TEveText.cxx:107
 TEveText.cxx:108
 TEveText.cxx:109
 TEveText.cxx:110
 TEveText.cxx:111
 TEveText.cxx:112
 TEveText.cxx:113
 TEveText.cxx:114
 TEveText.cxx:115
 TEveText.cxx:116
 TEveText.cxx:117
 TEveText.cxx:118
 TEveText.cxx:119
 TEveText.cxx:120
 TEveText.cxx:121
 TEveText.cxx:122
 TEveText.cxx:123
 TEveText.cxx:124
 TEveText.cxx:125
 TEveText.cxx:126
 TEveText.cxx:127
 TEveText.cxx:128
 TEveText.cxx:129
 TEveText.cxx:130
 TEveText.cxx:131
 TEveText.cxx:132
 TEveText.cxx:133
 TEveText.cxx:134
 TEveText.cxx:135
 TEveText.cxx:136
 TEveText.cxx:137
 TEveText.cxx:138
 TEveText.cxx:139
 TEveText.cxx:140
 TEveText.cxx:141
 TEveText.cxx:142
 TEveText.cxx:143
 TEveText.cxx:144
 TEveText.cxx:145