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
27
28////////////////////////////////////////////////////////////////////////////////
29/// Constructor.
30
32 TGLObject(),
33 fM(nullptr),
34 fFont()
35{
36 fDLCache = kFALSE; // Disable display list.
37}
38
39////////////////////////////////////////////////////////////////////////////////
40/// Set model object.
41
43{
44 fM = SetModelDynCast<TEveText>(obj);
45 return kTRUE;
46}
47
48////////////////////////////////////////////////////////////////////////////////
49/// Set bounding box.
50
52{
54}
55
56////////////////////////////////////////////////////////////////////////////////
57/// Actual rendering code.
58/// Virtual from TGLLogicalShape.
59
61{
62 static const TEveException eH("TEveTextGL::DirectDraw ");
63
64 Int_t fm = fM->GetFontMode();
65 if (fm == TGLFont::kBitmap || fm == TGLFont::kPixmap || fm == TGLFont::kTexture)
67 else
69
71
72 // bbox initialisation
74 {
75 Float_t bbox[6];
76 fFont.BBox(fM->GetText(), bbox[0], bbox[1], bbox[2],
77 bbox[3], bbox[4], bbox[5]);
78
80 // Depth goes, the other z-way, swap.
81 Float_t tmp = bbox[2];
82 bbox[2] = bbox[5] * fM->GetExtrude();
83 bbox[5] = tmp * fM->GetExtrude();
84 } else {
85 bbox[2] = -0.005*(bbox[4] - bbox[1]);
86 bbox[5] = -0.005*(bbox[4] - bbox[1]);
87 }
88
89 TGLVertex3 low (bbox[0], bbox[1], bbox[2]);
90 TGLVertex3 high(bbox[3], bbox[4], bbox[5]);
91
92 TEveTextGL* ncthis = const_cast<TEveTextGL*>(this);
93 ncthis->fBoundingBox.SetAligned(low, high);
95 }
96
97 // rendering
98 glPushMatrix();
100 switch (fFont.GetMode())
101 {
102 case TGLFont::kBitmap:
103 case TGLFont::kPixmap:
104 if (rnrCtx.Selection()) {
105 // calculate 3D coordinates for picking
106 const GLdouble *pm = rnrCtx.RefCamera().RefLastNoPickProjM().CArr();
107 GLdouble mm[16];
108 GLint vp[4];
109 glGetDoublev(GL_MODELVIEW_MATRIX, mm);
110 glGetIntegerv(GL_VIEWPORT, vp);
111
112 fX[0][0] = fX[0][1] = fX[0][2] = 0;
113 GLdouble x, y, z;
114 gluProject(fX[0][0], fX[0][1], fX[0][2], mm, pm, vp, &x, &y, &z);
115 Float_t bbox[6];
116 fFont.BBox(fM->GetText(), bbox[0], bbox[1], bbox[2],
117 bbox[3], bbox[4], bbox[5]);
118 gluUnProject(x + bbox[0], y + bbox[1], z, mm, pm, vp, &fX[0][0], &fX[0][1], &fX[0][2]);
119 gluUnProject(x + bbox[3], y + bbox[1], z, mm, pm, vp, &fX[1][0], &fX[1][1], &fX[1][2]);
120 gluUnProject(x + bbox[3], y + bbox[4], z, mm, pm, vp, &fX[2][0], &fX[2][1], &fX[2][2]);
121 gluUnProject(x + bbox[0], y + bbox[4], z, mm, pm, vp, &fX[3][0], &fX[3][1], &fX[3][2]);
122
123 glBegin(GL_POLYGON);
124 glVertex3dv(fX[0]);
125 glVertex3dv(fX[1]);
126 glVertex3dv(fX[2]);
127 glVertex3dv(fX[3]);
128 glEnd();
129 } else {
130 glRasterPos3i(0, 0, 0);
132 }
133 break;
137 glPolygonOffset(fM->GetPolygonOffset(0), fM->GetPolygonOffset(1));
138 if (fM->GetExtrude() != 1.0) {
139 glPushMatrix();
140 glScalef(1.0f, 1.0f, fM->GetExtrude());
142 glPopMatrix();
143 } else {
145 }
146 break;
148 glPolygonOffset(fM->GetPolygonOffset(0), fM->GetPolygonOffset(1));
150 break;
151 default:
152 throw(eH + "unsupported FTGL-type.");
153 }
155 glPopMatrix();
156}
#define GL_POLYGON
Definition GL_glu.h:292
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
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
void SetAligned(const TGLVertex3 &lowVertex, const TGLVertex3 &highVertex)
Set ALIGNED box from two low/high vertices.
TGLMatrix & RefLastNoPickProjM() const
Definition TGLCamera.h:174
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.
void UpdateBoundingBoxesOfPhysicals()
Update bounding-boxed of all dependent physicals.
Bool_t fDLCache
display-list validity bit-field
const Double_t * CArr() const
Definition TGLUtil.h:664
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
void RegisterFontNoScale(Int_t size, Int_t file, Int_t mode, TGLFont &out)
Get font in the GL rendering context.
TGLCamera & RefCamera()
Definition TGLRnrCtx.h:157
void RegisterFont(Int_t size, Int_t file, Int_t mode, TGLFont &out)
Get font in the GL rendering context.
Bool_t Selection() const
Definition TGLRnrCtx.h:222
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