File indexing completed on 2024-04-06 12:11:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <iostream>
0017
0018 #include "Fireworks/Core/interface/FWTextProjected.h"
0019 #include "TEveProjectionManager.h"
0020 #include "TEveTrans.h"
0021 #include "TGLBoundingBox.h"
0022
0023 #include "TGLIncludes.h"
0024
0025 #include "TGLRnrCtx.h"
0026 #include "TGLUtil.h"
0027 #include "TGLCamera.h"
0028
0029 TClass* FWEveText::ProjectedClass(const TEveProjection*) const {
0030
0031
0032 return FWEveTextProjected::Class();
0033 }
0034
0035
0036 void FWEveTextProjected::UpdateProjection() {
0037
0038
0039 FWEveText& als = *dynamic_cast<FWEveText*>(fProjectable);
0040 TEveTrans* tr = als.PtrMainTrans(kFALSE);
0041
0042 fText = als.GetText();
0043 *fMainColorPtr = als.GetMainColor();
0044 float pos[3];
0045 tr->GetPos(pos);
0046
0047 TEveProjection& proj = *fManager->GetProjection();
0048 proj.ProjectPoint(pos[0], pos[1], pos[2], fDepth);
0049
0050 RefMainTrans().SetPos(pos[0], pos[1], pos[2] + als.m_offsetZ);
0051 }
0052
0053
0054 void FWEveTextGL::DirectDraw(TGLRnrCtx& rnrCtx) const {
0055 Int_t fm = fM->GetFontMode();
0056 if (fm == TGLFont::kBitmap || fm == TGLFont::kPixmap || fm == TGLFont::kTexture)
0057 rnrCtx.RegisterFont(fM->GetFontSize(), fM->GetFontFile(), fM->GetFontMode(), fFont);
0058 else
0059 rnrCtx.RegisterFontNoScale(fM->GetFontSize(), fM->GetFontFile(), fM->GetFontMode(), fFont);
0060
0061
0062 glPushMatrix();
0063 fFont.PreRender(fM->GetAutoLighting(), fM->GetLighting());
0064
0065 const GLdouble* pm = rnrCtx.RefCamera().RefLastNoPickProjM().CArr();
0066
0067 GLdouble mm[16];
0068 GLint vp[4];
0069 glGetDoublev(GL_MODELVIEW_MATRIX, mm);
0070 glGetIntegerv(GL_VIEWPORT, vp);
0071
0072 fX[0][0] = fX[0][1] = fX[0][2] = 0;
0073 GLdouble x, y, z;
0074 gluProject(fX[0][0], fX[0][1], fX[0][2], mm, pm, vp, &x, &y, &z);
0075 Float_t bbox[6];
0076 fFont.BBox(fM->GetText(), bbox[0], bbox[1], bbox[2], bbox[3], bbox[4], bbox[5]);
0077
0078 gluUnProject(x + bbox[0], y + bbox[1], z, mm, pm, vp, &fX[0][0], &fX[0][1], &fX[0][2]);
0079 gluUnProject(x + bbox[3], y + bbox[1], z, mm, pm, vp, &fX[1][0], &fX[1][1], &fX[1][2]);
0080 gluUnProject(x + bbox[3], y + bbox[4], z, mm, pm, vp, &fX[2][0], &fX[2][1], &fX[2][2]);
0081 gluUnProject(x + bbox[0], y + bbox[4], z, mm, pm, vp, &fX[3][0], &fX[3][1], &fX[3][2]);
0082 glEnable(GL_POLYGON_OFFSET_FILL);
0083
0084 FWEveText* model = (FWEveText*)fM;
0085 double xm = fX[0][0] - model->m_textPad;
0086 double xM = fX[2][0] + model->m_textPad;
0087 double ym = fX[0][1] - model->m_textPad;
0088 double yM = fX[2][1] + model->m_textPad;
0089
0090
0091 if (rnrCtx.ColorSet().Background().GetRed())
0092 TGLUtil::Color(kWhite);
0093 else
0094 TGLUtil::Color(kBlack);
0095
0096 glPolygonOffset(1, 1);
0097 glBegin(GL_POLYGON);
0098 glVertex2d(xm, ym);
0099 glVertex2d(xM, ym);
0100 glVertex2d(xM, yM);
0101 glVertex2d(xm, yM);
0102
0103 glEnd();
0104
0105 TGLUtil::Color(fM->GetMainColor());
0106 if (true) {
0107 glPolygonOffset(0, 0);
0108 glBegin(GL_LINE_LOOP);
0109 glVertex2d(xm, ym);
0110 glVertex2d(xM, ym);
0111 glVertex2d(xM, yM);
0112 glVertex2d(xm, yM);
0113 glEnd();
0114 }
0115
0116 glPolygonOffset(0, 0);
0117
0118 glRasterPos3i(0, 0, 0);
0119 fFont.Render(fM->GetText());
0120 fFont.PostRender();
0121 glPopMatrix();
0122 }