CMS 3D CMS Logo

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