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