TEveText.cxx

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEveText.cxx 33864 2010-06-14 09:47:19Z matevz $
00002 // Authors: Alja & Matevz Tadel 2008
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "TEveText.h"
00013 #include "TEveTrans.h"
00014 
00015 #include "TGLFontManager.h"
00016 #include "TObjArray.h"
00017 #include "TObjString.h"
00018 #include "TString.h"
00019 #include "TMath.h"
00020 
00021 //==============================================================================
00022 //==============================================================================
00023 // TEveText
00024 //==============================================================================
00025 
00026 //______________________________________________________________________________
00027 //
00028 // TEveElement class used for displaying FreeType GL fonts. Holds a
00029 // set of parameters to define FTGL font and its rendering style.
00030 //
00031 
00032 ClassImp(TEveText);
00033 
00034 //______________________________________________________________________________
00035 TEveText::TEveText(const char* txt) :
00036    TEveElement(fTextColor),
00037    TNamed("TEveText", ""),
00038    TAtt3D(),
00039    TAttBBox(),
00040    fText(txt),
00041    fTextColor(0),
00042 
00043    fFontSize(12),
00044    fFontFile(4),
00045    fFontMode(-1),
00046    fExtrude(1.0f),
00047 
00048    fAutoLighting(kTRUE),
00049    fLighting(kFALSE)
00050 {
00051    // Constructor.
00052 
00053    fPolygonOffset[0] = 0;
00054    fPolygonOffset[1] = 0;
00055 
00056    fCanEditMainColor        = kTRUE;
00057    fCanEditMainTransparency = kTRUE;
00058    InitMainTrans();
00059    SetFontMode(TGLFont::kPixmap);
00060 }
00061 
00062 //______________________________________________________________________________
00063 void TEveText::SetFontSize(Int_t val, Bool_t validate)
00064 {
00065    // Set valid font size.
00066 
00067    if (validate) {
00068       Int_t* fsp = &TGLFontManager::GetFontSizeArray()->front();
00069       Int_t  ns  = TGLFontManager::GetFontSizeArray()->size();
00070       Int_t  idx = TMath::BinarySearch(ns, fsp, val);
00071       fFontSize = fsp[idx];
00072    } else {
00073       fFontSize = val;
00074    }
00075 }
00076 
00077 //______________________________________________________________________________
00078 void TEveText::SetFontFile(const char* name)
00079 {
00080    // Set font file regarding to static TGLFontManager fgFontFileArray.
00081 
00082    TObjArray* fa =TGLFontManager::GetFontFileArray();
00083    TIter  next_base(fa);
00084    TObjString* os;
00085    Int_t idx = 0;
00086    while ((os = (TObjString*) next_base()) != 0) {
00087       if (os->GetString() == name) {
00088          SetFontFile(idx);
00089          return;
00090       }
00091       idx++;
00092    }
00093 }
00094 
00095 //______________________________________________________________________________
00096 void TEveText::SetFontMode( Int_t mode)
00097 {
00098    // Set FTFont class ID.
00099 
00100    fFontMode = mode;
00101 
00102    Bool_t edit = (fFontMode > TGLFont::kPixmap);
00103    TEveTrans& t = RefMainTrans();
00104    t.SetEditRotation(edit);
00105    t.SetEditScale(edit);
00106 }
00107 
00108 //______________________________________________________________________________
00109 void TEveText::SetPolygonOffset(Float_t factor, Float_t units)
00110 {
00111    // Set the scale and units used to calculate depth values.
00112    // See glPolygonOffset manual page.
00113 
00114    fPolygonOffset[0] = factor;
00115    fPolygonOffset[1] = units;
00116 }
00117 
00118 //______________________________________________________________________________
00119 void TEveText::Paint(Option_t*)
00120 {
00121    // Paint this object. Only direct rendering is supported.
00122 
00123    PaintStandard(this);
00124 }
00125 
00126 //______________________________________________________________________________
00127 void TEveText::ComputeBBox()
00128 {
00129    // Fill bounding-box information. Virtual from TAttBBox.
00130    // If member 'TEveFrameBox* fFrame' is set, frame's corners are
00131    // used as bbox.
00132 
00133    BBoxZero();
00134 }
00135 
00136 //______________________________________________________________________________
00137 const TGPicture* TEveText::GetListTreeIcon(Bool_t)
00138 {
00139    // Return TEveText icon.
00140 
00141    return TEveElement::fgListTreeIcons[5];
00142 }

Generated on Tue Jul 5 14:16:14 2011 for ROOT_528-00b_version by  doxygen 1.5.1