Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEveTextGL.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 "TEveTextGL.h"
13#include "TEveText.h"
14#include "TGLUtil.h"
15#include "TGLCamera.h"
16
17#include "TGLRnrCtx.h"
18#include "TGLIncludes.h"
19#include "TGLBoundingBox.h"
20
21/** \class TEveTextGL
22\ingroup TEve
23OpenGL renderer class for TEveText.
24*/
25
26
27////////////////////////////////////////////////////////////////////////////////
28/// Constructor.
29
31 TGLObject(),
32 fM(nullptr),
33 fFont()
34{
35 fDLCache = kFALSE; // Disable display list.
36}
37
38////////////////////////////////////////////////////////////////////////////////
39/// Set model object.
40
42{
44 return kTRUE;
45}
46
47////////////////////////////////////////////////////////////////////////////////
48/// Set bounding box.
49
54
55////////////////////////////////////////////////////////////////////////////////
56/// Actual rendering code.
57/// Virtual from TGLLogicalShape.
58
60{
61 static const TEveException eH("TEveTextGL::DirectDraw ");
62
65 rnrCtx.RegisterFont(fM->GetFontSize(), fM->GetFontFile(), fM->GetFontMode(), fFont);
66 else
67 rnrCtx.RegisterFontNoScale(fM->GetFontSize(), fM->GetFontFile(), fM->GetFontMode(), fFont);
68
70
71 // bbox initialisation
73 {
74 Float_t bbox[6];
75 fFont.BBox(fM->GetText(), bbox[0], bbox[1], bbox[2],
76 bbox[3], bbox[4], bbox[5]);
77
79 // Depth goes, the other z-way, swap.
80 Float_t tmp = bbox[2];
81 bbox[2] = bbox[5] * fM->GetExtrude();
82 bbox[5] = tmp * fM->GetExtrude();
83 } else {
84 bbox[2] = -0.005*(bbox[4] - bbox[1]);
85 bbox[5] = -0.005*(bbox[4] - bbox[1]);
86 }
87
88 TGLVertex3 low (bbox[0], bbox[1], bbox[2]);
89 TGLVertex3 high(bbox[3], bbox[4], bbox[5]);
90
91 TEveTextGL* ncthis = const_cast<TEveTextGL*>(this);
92 ncthis->fBoundingBox.SetAligned(low, high);
93 ncthis->UpdateBoundingBoxesOfPhysicals();
94 }
95
96 // rendering
99 switch (fFont.GetMode())
100 {
101 case TGLFont::kBitmap:
102 case TGLFont::kPixmap:
103 if (rnrCtx.Selection()) {
104 // calculate 3D coordinates for picking
105 const GLdouble *pm = rnrCtx.RefCamera().RefLastNoPickProjM().CArr();
106 GLdouble mm[16];
107 GLint vp[4];
110
111 fX[0][0] = fX[0][1] = fX[0][2] = 0;
112 GLdouble x, y, z;
113 gluProject(fX[0][0], fX[0][1], fX[0][2], mm, pm, vp, &x, &y, &z);
114 Float_t bbox[6];
115 fFont.BBox(fM->GetText(), bbox[0], bbox[1], bbox[2],
116 bbox[3], bbox[4], bbox[5]);
117 gluUnProject(x + bbox[0], y + bbox[1], z, mm, pm, vp, &fX[0][0], &fX[0][1], &fX[0][2]);
118 gluUnProject(x + bbox[3], y + bbox[1], z, mm, pm, vp, &fX[1][0], &fX[1][1], &fX[1][2]);
119 gluUnProject(x + bbox[3], y + bbox[4], z, mm, pm, vp, &fX[2][0], &fX[2][1], &fX[2][2]);
120 gluUnProject(x + bbox[0], y + bbox[4], z, mm, pm, vp, &fX[3][0], &fX[3][1], &fX[3][2]);
121
123 glVertex3dv(fX[0]);
124 glVertex3dv(fX[1]);
125 glVertex3dv(fX[2]);
126 glVertex3dv(fX[3]);
127 glEnd();
128 } else {
129 glRasterPos3i(0, 0, 0);
131 }
132 break;
137 if (fM->GetExtrude() != 1.0) {
138 glPushMatrix();
139 glScalef(1.0f, 1.0f, fM->GetExtrude());
141 glPopMatrix();
142 } else {
144 }
145 break;
149 break;
150 default:
151 throw(eH + "unsupported FTGL-type.");
152 }
154 glPopMatrix();
155}
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Exception class thrown by TEve classes and macros.
Definition TEveUtil.h:102
OpenGL renderer class for TEveText.
Definition TEveTextGL.h:21
Bool_t SetModel(TObject *obj, const Option_t *opt=nullptr) override
Set model object.
TGLFont fFont
Definition TEveTextGL.h:28
void DirectDraw(TGLRnrCtx &rnrCtx) const override
Actual rendering code.
void SetBBox() override
Set bounding box.
TEveText * fM
Definition TEveTextGL.h:27
TEveTextGL()
Constructor.
Double_t fX[4][3]
Definition TEveTextGL.h:29
Float_t GetExtrude() const
Definition TEveText.h:66
const char * GetText() const
Definition TEveText.h:57
Bool_t GetAutoLighting() const
Definition TEveText.h:63
Bool_t GetLighting() const
Definition TEveText.h:60
Int_t GetFontSize() const
Definition TEveText.h:49
Float_t GetPolygonOffset(Int_t i) const
Definition TEveText.h:69
Int_t GetFontFile() const
Definition TEveText.h:50
Int_t GetFontMode() const
Definition TEveText.h:51
void SetEmpty()
Set bounding box empty - all vertices at (0,0,0)
Bool_t IsEmpty() const
EMode GetMode() const
void BBox(const char *txt, Float_t &llx, Float_t &lly, Float_t &llz, Float_t &urx, Float_t &ury, Float_t &urz) const
Get bounding box.
void Render(const char *txt, Double_t x, Double_t y, Double_t angle, Double_t mgn) const
virtual void PostRender() const
Reset GL state after FTFont rendering.
void SetDepth(Float_t d)
virtual void PreRender(Bool_t autoLight=kTRUE, Bool_t lightOn=kFALSE) const
Set-up GL state before FTFont rendering.
TGLBoundingBox fBoundingBox
Also plays the role of ID.
Bool_t fDLCache
display-list validity bit-field
Base-class for direct OpenGL renderers.
Definition TGLObject.h:22
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition TGLRnrCtx.h:41
3 component (x/y/z) vertex class.
Definition TGLUtil.h:84
Mother of all ROOT objects.
Definition TObject.h:41
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17