00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <iostream>
00018
00019 #include "Fireworks/Core/interface/FWTextProjected.h"
00020 #include "TEveProjectionManager.h"
00021 #include "TEveTrans.h"
00022 #include "TGLBoundingBox.h"
00023
00024 #include "TGLIncludes.h"
00025
00026 #include "TGLRnrCtx.h"
00027 #include "TGLUtil.h"
00028 #include "TGLCamera.h"
00029
00030 TClass* FWEveText::ProjectedClass(const TEveProjection*) const
00031 {
00032
00033
00034 return FWEveTextProjected::Class();
00035 }
00036
00037
00038
00039 void FWEveTextProjected::UpdateProjection()
00040 {
00041
00042
00043 FWEveText & als = * dynamic_cast<FWEveText*>(fProjectable);
00044 TEveTrans *tr = als.PtrMainTrans(kFALSE);
00045
00046 fText = als.GetText();
00047 *fMainColorPtr = als.GetMainColor();
00048 float pos[3];
00049 tr->GetPos(pos);
00050
00051 TEveProjection& proj = * fManager->GetProjection();
00052 proj.ProjectPoint(pos[0],pos[1], pos[2], fDepth);
00053
00054 RefMainTrans().SetPos(pos[0], pos[1], pos[2] + als.m_offsetZ);
00055 }
00056
00057
00058
00059 void FWEveTextGL::DirectDraw(TGLRnrCtx & rnrCtx) const
00060 {
00061
00062 Int_t fm = fM->GetFontMode();
00063 if (fm == TGLFont::kBitmap || fm == TGLFont::kPixmap || fm == TGLFont::kTexture)
00064 rnrCtx.RegisterFont(fM->GetFontSize(), fM->GetFontFile(), fM->GetFontMode(), fFont);
00065 else
00066 rnrCtx.RegisterFontNoScale(fM->GetFontSize(), fM->GetFontFile(), fM->GetFontMode(), fFont);
00067
00068
00069
00070 glPushMatrix();
00071 fFont.PreRender(fM->GetAutoLighting(), fM->GetLighting());
00072
00073
00074 const GLdouble *pm = rnrCtx.RefCamera().RefLastNoPickProjM().CArr();
00075
00076 GLdouble mm[16];
00077 GLint vp[4];
00078 glGetDoublev(GL_MODELVIEW_MATRIX, mm);
00079 glGetIntegerv(GL_VIEWPORT, vp);
00080
00081 fX[0][0] = fX[0][1] = fX[0][2] = 0;
00082 GLdouble x, y, z;
00083 gluProject(fX[0][0], fX[0][1], fX[0][2], mm, pm, vp, &x, &y, &z);
00084 Float_t bbox[6];
00085 fFont.BBox(fM->GetText(), bbox[0], bbox[1], bbox[2],
00086 bbox[3], bbox[4], bbox[5]);
00087
00088
00089 gluUnProject(x + bbox[0], y + bbox[1], z, mm, pm, vp, &fX[0][0], &fX[0][1], &fX[0][2]);
00090 gluUnProject(x + bbox[3], y + bbox[1], z, mm, pm, vp, &fX[1][0], &fX[1][1], &fX[1][2]);
00091 gluUnProject(x + bbox[3], y + bbox[4], z, mm, pm, vp, &fX[2][0], &fX[2][1], &fX[2][2]);
00092 gluUnProject(x + bbox[0], y + bbox[4], z, mm, pm, vp, &fX[3][0], &fX[3][1], &fX[3][2]);
00093 glEnable(GL_POLYGON_OFFSET_FILL);
00094
00095 FWEveText* model = (FWEveText*)fM;
00096 double xm = fX[0][0] - model->m_textPad;
00097 double xM = fX[2][0] + model->m_textPad;
00098 double ym = fX[0][1] - model->m_textPad;
00099 double yM = fX[2][1] + model->m_textPad;
00100
00101
00102
00103 if (rnrCtx.ColorSet().Background().GetRed())
00104 TGLUtil::Color(kWhite);
00105 else
00106 TGLUtil::Color(kBlack);
00107
00108 glPolygonOffset(1,1 );
00109 glBegin(GL_POLYGON);
00110 glVertex2d(xm, ym);
00111 glVertex2d(xM, ym);
00112 glVertex2d(xM, yM);
00113 glVertex2d(xm, yM);
00114
00115 glEnd();
00116
00117 TGLUtil::Color(fM->GetMainColor());
00118 if (1) {
00119 glPolygonOffset(0, 0 );
00120 glBegin(GL_LINE_LOOP);
00121 glVertex2d(xm, ym);
00122 glVertex2d(xM, ym);
00123 glVertex2d(xM, yM);
00124 glVertex2d(xm, yM);
00125 glEnd();
00126 }
00127
00128 glPolygonOffset(0, 0 );
00129
00130 glRasterPos3i(0, 0, 0);
00131 fFont.Render(fM->GetText());
00132 fFont.PostRender();
00133 glPopMatrix();
00134 }