CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWTextProjected.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWTextProjected
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Alja Mrak-Tadel
10 // Created: Fri Aug 12 01:12:18 CEST 2011
11 // $Id: FWTextProjected.cc,v 1.3 2011/08/16 21:43:27 amraktad Exp $
12 //
13 
14 // system include files
15 
16 // user include files
17 #include <iostream>
18 
20 #include "TEveProjectionManager.h"
21 #include "TEveTrans.h"
22 #include "TGLBoundingBox.h"
23 
24 #include "TGLIncludes.h"
25 
26 #include "TGLRnrCtx.h"
27 #include "TGLUtil.h"
28 #include "TGLCamera.h"
29 //______________________________________________________________________________
30 TClass* FWEveText::ProjectedClass(const TEveProjection*) const
31 {
32  // Virtual from TEveProjectable, returns TEvePointSetProjected class.
33 
34  return FWEveTextProjected::Class();
35 }
36 
37 
38 //______________________________________________________________________________
40 {
41  // printf("update projection \n");
42 
43  FWEveText & als = * dynamic_cast<FWEveText*>(fProjectable);
44  TEveTrans *tr = als.PtrMainTrans(kFALSE);
45 
46  fText = als.GetText();
47  *fMainColorPtr = als.GetMainColor();
48  float pos[3];
49  tr->GetPos(pos);
50 
51  TEveProjection& proj = * fManager->GetProjection();
52  proj.ProjectPoint(pos[0],pos[1], pos[2], fDepth);
53 
54  RefMainTrans().SetPos(pos[0], pos[1], pos[2] + als.m_offsetZ);
55 }
56 //==============================================================================
57 
58 
59 void FWEveTextGL::DirectDraw(TGLRnrCtx & rnrCtx) const
60 {
61 
62  Int_t fm = fM->GetFontMode();
63  if (fm == TGLFont::kBitmap || fm == TGLFont::kPixmap || fm == TGLFont::kTexture)
64  rnrCtx.RegisterFont(fM->GetFontSize(), fM->GetFontFile(), fM->GetFontMode(), fFont);
65  else
66  rnrCtx.RegisterFontNoScale(fM->GetFontSize(), fM->GetFontFile(), fM->GetFontMode(), fFont);
67 
68 
69  // rendering
70  glPushMatrix();
71  fFont.PreRender(fM->GetAutoLighting(), fM->GetLighting());
72 
73 
74  const GLdouble *pm = rnrCtx.RefCamera().RefLastNoPickProjM().CArr();
75 
76  GLdouble mm[16];
77  GLint vp[4];
78  glGetDoublev(GL_MODELVIEW_MATRIX, mm);
79  glGetIntegerv(GL_VIEWPORT, vp);
80 
81  fX[0][0] = fX[0][1] = fX[0][2] = 0;
82  GLdouble x, y, z;
83  gluProject(fX[0][0], fX[0][1], fX[0][2], mm, pm, vp, &x, &y, &z);
84  Float_t bbox[6];
85  fFont.BBox(fM->GetText(), bbox[0], bbox[1], bbox[2],
86  bbox[3], bbox[4], bbox[5]);
87 
88 
89  gluUnProject(x + bbox[0], y + bbox[1], z, mm, pm, vp, &fX[0][0], &fX[0][1], &fX[0][2]);
90  gluUnProject(x + bbox[3], y + bbox[1], z, mm, pm, vp, &fX[1][0], &fX[1][1], &fX[1][2]);
91  gluUnProject(x + bbox[3], y + bbox[4], z, mm, pm, vp, &fX[2][0], &fX[2][1], &fX[2][2]);
92  gluUnProject(x + bbox[0], y + bbox[4], z, mm, pm, vp, &fX[3][0], &fX[3][1], &fX[3][2]);
93  glEnable(GL_POLYGON_OFFSET_FILL);
94 
95  FWEveText* model = (FWEveText*)fM;
96  double xm = fX[0][0] - model->m_textPad;
97  double xM = fX[2][0] + model->m_textPad;
98  double ym = fX[0][1] - model->m_textPad;
99  double yM = fX[2][1] + model->m_textPad;
100 
101 
102  // TGLUtil::Color(1016);
103  if (rnrCtx.ColorSet().Background().GetRed())
104  TGLUtil::Color(kWhite);
105  else
106  TGLUtil::Color(kBlack);
107 
108  glPolygonOffset(1,1 );
109  glBegin(GL_POLYGON);
110  glVertex2d(xm, ym);
111  glVertex2d(xM, ym);
112  glVertex2d(xM, yM);
113  glVertex2d(xm, yM);
114 
115  glEnd();
116 
117  TGLUtil::Color(fM->GetMainColor());
118  if (1) {
119  glPolygonOffset(0, 0 );
120  glBegin(GL_LINE_LOOP);
121  glVertex2d(xm, ym);
122  glVertex2d(xM, ym);
123  glVertex2d(xM, yM);
124  glVertex2d(xm, yM);
125  glEnd();
126  }
127 
128  glPolygonOffset(0, 0 );
129 
130  glRasterPos3i(0, 0, 0);
131  fFont.Render(fM->GetText());
132  fFont.PostRender();
133  glPopMatrix();
134 }
virtual void UpdateProjection()
float m_offsetZ
float float float z
float m_textPad
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const
virtual TClass * ProjectedClass(const TEveProjection *p) const
Definition: DDAxes.h:10