#include "TEvePolygonSetProjectedGL.h"
#include "TEvePolygonSetProjected.h"
#include "TEveVector.h"
#include "TGLRnrCtx.h"
#include "TGLCamera.h"
#include "TGLPhysicalShape.h"
#include "TGLIncludes.h"
ClassImp(TEvePolygonSetProjectedGL);
TEvePolygonSetProjectedGL::TEvePolygonSetProjectedGL() : TGLObject()
{
fMultiColor = kTRUE;
}
Bool_t TEvePolygonSetProjectedGL::SetModel(TObject* obj, const Option_t* )
{
return SetModelCheckClass(obj, TEvePolygonSetProjected::Class());
}
void TEvePolygonSetProjectedGL::SetBBox()
{
SetAxisAlignedBBox(((TEvePolygonSetProjected*)fExternalObj)->AssertBBox());
}
void TEvePolygonSetProjectedGL::Draw(TGLRnrCtx& rnrCtx) const
{
if (rnrCtx.IsDrawPassOutlineLine())
return;
TGLObject::Draw(rnrCtx);
}
void TEvePolygonSetProjectedGL::DrawOutline() const
{
TEvePolygonSetProjected& refPS = * (TEvePolygonSetProjected*) fExternalObj;
if (refPS.fPols.size() == 0) return;
Int_t vi;
for (TEvePolygonSetProjected::vpPolygon_ci i = refPS.fPols.begin();
i != refPS.fPols.end(); ++i)
{
glBegin(GL_LINE_LOOP);
for(Int_t k = 0; k < (*i).fNPnts; ++k)
{
vi = (*i).fPnts[k];
glVertex3fv(refPS.fPnts[vi].Arr());
}
glEnd();
}
}
void TEvePolygonSetProjectedGL::DirectDraw(TGLRnrCtx& ) const
{
TEvePolygonSetProjected& refPS = * (TEvePolygonSetProjected*) fExternalObj;
if (refPS.fPols.size() == 0) return;
glPushAttrib(GL_ENABLE_BIT | GL_LINE_BIT | GL_POLYGON_BIT);
glDisable(GL_LIGHTING);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glDisable(GL_CULL_FACE);
fMultiColor = (refPS.fFillColor != refPS.fLineColor);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.,1.);
GLUtesselator *tessObj = TGLUtil::GetDrawTesselator3fv();
TEveVector* pnts = refPS.fPnts;
for (TEvePolygonSetProjected::vpPolygon_ci i = refPS.fPols.begin();
i != refPS.fPols.end(); ++i)
{
Int_t vi;
Int_t pntsN = (*i).fNPnts;
if (pntsN < 4)
{
glBegin(GL_POLYGON);
for (Int_t k = 0; k < pntsN; ++k)
{
vi = (*i).fPnts[k];
glVertex3fv(pnts[vi].Arr());
}
glEnd();
}
else
{
gluBeginPolygon(tessObj);
gluNextContour(tessObj, (GLenum)GLU_UNKNOWN);
glNormal3f(0., 0., 1.);
Double_t coords[3];
coords[2] = 0.;
for (Int_t k = 0; k < pntsN; ++k)
{
vi = (*i).fPnts[k];
coords[0] = pnts[vi].fX;
coords[1] = pnts[vi].fY;
gluTessVertex(tessObj, coords, pnts[vi].Arr());
}
gluEndPolygon(tessObj);
}
}
glDisable(GL_POLYGON_OFFSET_FILL);
TGLUtil::Color(refPS.fLineColor);
glEnable(GL_LINE_SMOOTH);
TGLUtil::LineWidth(refPS.fLineWidth);
DrawOutline();
glPopAttrib();
}
void TEvePolygonSetProjectedGL::DrawHighlight(TGLRnrCtx& rnrCtx, const TGLPhysicalShape* pshp) const
{
TEvePolygonSetProjected& refPS = * (TEvePolygonSetProjected*) fExternalObj;
if (refPS.GetHighlightFrame())
{
glPushAttrib(GL_ENABLE_BIT | GL_LINE_BIT);
glDisable(GL_LIGHTING);
glEnable(GL_LINE_SMOOTH);
glColor4ubv(rnrCtx.ColorSet().Selection(pshp->GetSelected()).CArr());
const TGLRect& vp = rnrCtx.RefCamera().RefViewport();
Int_t inner[4][2] = { { 0,-1}, { 1, 0}, { 0, 1}, {-1, 0} };
Int_t outer[8][2] = { {-1,-1}, { 1,-1}, { 1, 1}, {-1, 1},
{ 0,-2}, { 2, 0}, { 0, 2}, {-2, 0} };
rnrCtx.SetHighlightOutline(kTRUE);
TGLUtil::LockColor();
Int_t first_outer = (rnrCtx.CombiLOD() == TGLRnrCtx::kLODHigh) ? 0 : 4;
for (int i = first_outer; i < 8; ++i)
{
glViewport(vp.X() + outer[i][0], vp.Y() + outer[i][1], vp.Width(), vp.Height());
DrawOutline();
}
TGLUtil::UnlockColor();
rnrCtx.SetHighlightOutline(kFALSE);
TGLUtil::Color(refPS.fLineColor);
for (int i = 0; i < 4; ++i)
{
glViewport(vp.X() + inner[i][0], vp.Y() + inner[i][1], vp.Width(), vp.Height());
DrawOutline();
}
glViewport(vp.X(), vp.Y(), vp.Width(), vp.Height());
pshp->SetupGLColors(rnrCtx);
Float_t dr[2];
glGetFloatv(GL_DEPTH_RANGE,dr);
glDepthRange(dr[0], 0.5*dr[1]);
DrawOutline();
glDepthRange(dr[0], dr[1]);
glPopAttrib();
}
else
{
TGLLogicalShape::DrawHighlight(rnrCtx, pshp);
}
}
TEvePolygonSetProjectedGL.cxx:1 TEvePolygonSetProjectedGL.cxx:2 TEvePolygonSetProjectedGL.cxx:3 TEvePolygonSetProjectedGL.cxx:4 TEvePolygonSetProjectedGL.cxx:5 TEvePolygonSetProjectedGL.cxx:6 TEvePolygonSetProjectedGL.cxx:7 TEvePolygonSetProjectedGL.cxx:8 TEvePolygonSetProjectedGL.cxx:9 TEvePolygonSetProjectedGL.cxx:10 TEvePolygonSetProjectedGL.cxx:11 TEvePolygonSetProjectedGL.cxx:12 TEvePolygonSetProjectedGL.cxx:13 TEvePolygonSetProjectedGL.cxx:14 TEvePolygonSetProjectedGL.cxx:15 TEvePolygonSetProjectedGL.cxx:16 TEvePolygonSetProjectedGL.cxx:17 TEvePolygonSetProjectedGL.cxx:18 TEvePolygonSetProjectedGL.cxx:19 TEvePolygonSetProjectedGL.cxx:20 TEvePolygonSetProjectedGL.cxx:21 TEvePolygonSetProjectedGL.cxx:22 TEvePolygonSetProjectedGL.cxx:23 TEvePolygonSetProjectedGL.cxx:24 TEvePolygonSetProjectedGL.cxx:25 TEvePolygonSetProjectedGL.cxx:26 TEvePolygonSetProjectedGL.cxx:27 TEvePolygonSetProjectedGL.cxx:28 TEvePolygonSetProjectedGL.cxx:29 TEvePolygonSetProjectedGL.cxx:30 TEvePolygonSetProjectedGL.cxx:31 TEvePolygonSetProjectedGL.cxx:32 TEvePolygonSetProjectedGL.cxx:33 TEvePolygonSetProjectedGL.cxx:34 TEvePolygonSetProjectedGL.cxx:35 TEvePolygonSetProjectedGL.cxx:36 TEvePolygonSetProjectedGL.cxx:37 TEvePolygonSetProjectedGL.cxx:38 TEvePolygonSetProjectedGL.cxx:39 TEvePolygonSetProjectedGL.cxx:40 TEvePolygonSetProjectedGL.cxx:41 TEvePolygonSetProjectedGL.cxx:42 TEvePolygonSetProjectedGL.cxx:43 TEvePolygonSetProjectedGL.cxx:44 TEvePolygonSetProjectedGL.cxx:45 TEvePolygonSetProjectedGL.cxx:46 TEvePolygonSetProjectedGL.cxx:47 TEvePolygonSetProjectedGL.cxx:48 TEvePolygonSetProjectedGL.cxx:49 TEvePolygonSetProjectedGL.cxx:50 TEvePolygonSetProjectedGL.cxx:51 TEvePolygonSetProjectedGL.cxx:52 TEvePolygonSetProjectedGL.cxx:53 TEvePolygonSetProjectedGL.cxx:54 TEvePolygonSetProjectedGL.cxx:55 TEvePolygonSetProjectedGL.cxx:56 TEvePolygonSetProjectedGL.cxx:57 TEvePolygonSetProjectedGL.cxx:58 TEvePolygonSetProjectedGL.cxx:59 TEvePolygonSetProjectedGL.cxx:60 TEvePolygonSetProjectedGL.cxx:61 TEvePolygonSetProjectedGL.cxx:62 TEvePolygonSetProjectedGL.cxx:63 TEvePolygonSetProjectedGL.cxx:64 TEvePolygonSetProjectedGL.cxx:65 TEvePolygonSetProjectedGL.cxx:66 TEvePolygonSetProjectedGL.cxx:67 TEvePolygonSetProjectedGL.cxx:68 TEvePolygonSetProjectedGL.cxx:69 TEvePolygonSetProjectedGL.cxx:70 TEvePolygonSetProjectedGL.cxx:71 TEvePolygonSetProjectedGL.cxx:72 TEvePolygonSetProjectedGL.cxx:73 TEvePolygonSetProjectedGL.cxx:74 TEvePolygonSetProjectedGL.cxx:75 TEvePolygonSetProjectedGL.cxx:76 TEvePolygonSetProjectedGL.cxx:77 TEvePolygonSetProjectedGL.cxx:78 TEvePolygonSetProjectedGL.cxx:79 TEvePolygonSetProjectedGL.cxx:80 TEvePolygonSetProjectedGL.cxx:81 TEvePolygonSetProjectedGL.cxx:82 TEvePolygonSetProjectedGL.cxx:83 TEvePolygonSetProjectedGL.cxx:84 TEvePolygonSetProjectedGL.cxx:85 TEvePolygonSetProjectedGL.cxx:86 TEvePolygonSetProjectedGL.cxx:87 TEvePolygonSetProjectedGL.cxx:88 TEvePolygonSetProjectedGL.cxx:89 TEvePolygonSetProjectedGL.cxx:90 TEvePolygonSetProjectedGL.cxx:91 TEvePolygonSetProjectedGL.cxx:92 TEvePolygonSetProjectedGL.cxx:93 TEvePolygonSetProjectedGL.cxx:94 TEvePolygonSetProjectedGL.cxx:95 TEvePolygonSetProjectedGL.cxx:96 TEvePolygonSetProjectedGL.cxx:97 TEvePolygonSetProjectedGL.cxx:98 TEvePolygonSetProjectedGL.cxx:99 TEvePolygonSetProjectedGL.cxx:100 TEvePolygonSetProjectedGL.cxx:101 TEvePolygonSetProjectedGL.cxx:102 TEvePolygonSetProjectedGL.cxx:103 TEvePolygonSetProjectedGL.cxx:104 TEvePolygonSetProjectedGL.cxx:105 TEvePolygonSetProjectedGL.cxx:106 TEvePolygonSetProjectedGL.cxx:107 TEvePolygonSetProjectedGL.cxx:108 TEvePolygonSetProjectedGL.cxx:109 TEvePolygonSetProjectedGL.cxx:110 TEvePolygonSetProjectedGL.cxx:111 TEvePolygonSetProjectedGL.cxx:112 TEvePolygonSetProjectedGL.cxx:113 TEvePolygonSetProjectedGL.cxx:114 TEvePolygonSetProjectedGL.cxx:115 TEvePolygonSetProjectedGL.cxx:116 TEvePolygonSetProjectedGL.cxx:117 TEvePolygonSetProjectedGL.cxx:118 TEvePolygonSetProjectedGL.cxx:119 TEvePolygonSetProjectedGL.cxx:120 TEvePolygonSetProjectedGL.cxx:121 TEvePolygonSetProjectedGL.cxx:122 TEvePolygonSetProjectedGL.cxx:123 TEvePolygonSetProjectedGL.cxx:124 TEvePolygonSetProjectedGL.cxx:125 TEvePolygonSetProjectedGL.cxx:126 TEvePolygonSetProjectedGL.cxx:127 TEvePolygonSetProjectedGL.cxx:128 TEvePolygonSetProjectedGL.cxx:129 TEvePolygonSetProjectedGL.cxx:130 TEvePolygonSetProjectedGL.cxx:131 TEvePolygonSetProjectedGL.cxx:132 TEvePolygonSetProjectedGL.cxx:133 TEvePolygonSetProjectedGL.cxx:134 TEvePolygonSetProjectedGL.cxx:135 TEvePolygonSetProjectedGL.cxx:136 TEvePolygonSetProjectedGL.cxx:137 TEvePolygonSetProjectedGL.cxx:138 TEvePolygonSetProjectedGL.cxx:139 TEvePolygonSetProjectedGL.cxx:140 TEvePolygonSetProjectedGL.cxx:141 TEvePolygonSetProjectedGL.cxx:142 TEvePolygonSetProjectedGL.cxx:143 TEvePolygonSetProjectedGL.cxx:144 TEvePolygonSetProjectedGL.cxx:145 TEvePolygonSetProjectedGL.cxx:146 TEvePolygonSetProjectedGL.cxx:147 TEvePolygonSetProjectedGL.cxx:148 TEvePolygonSetProjectedGL.cxx:149 TEvePolygonSetProjectedGL.cxx:150 TEvePolygonSetProjectedGL.cxx:151 TEvePolygonSetProjectedGL.cxx:152 TEvePolygonSetProjectedGL.cxx:153 TEvePolygonSetProjectedGL.cxx:154 TEvePolygonSetProjectedGL.cxx:155 TEvePolygonSetProjectedGL.cxx:156 TEvePolygonSetProjectedGL.cxx:157 TEvePolygonSetProjectedGL.cxx:158 TEvePolygonSetProjectedGL.cxx:159 TEvePolygonSetProjectedGL.cxx:160 TEvePolygonSetProjectedGL.cxx:161 TEvePolygonSetProjectedGL.cxx:162 TEvePolygonSetProjectedGL.cxx:163 TEvePolygonSetProjectedGL.cxx:164 TEvePolygonSetProjectedGL.cxx:165 TEvePolygonSetProjectedGL.cxx:166 TEvePolygonSetProjectedGL.cxx:167 TEvePolygonSetProjectedGL.cxx:168 TEvePolygonSetProjectedGL.cxx:169 TEvePolygonSetProjectedGL.cxx:170 TEvePolygonSetProjectedGL.cxx:171 TEvePolygonSetProjectedGL.cxx:172 TEvePolygonSetProjectedGL.cxx:173 TEvePolygonSetProjectedGL.cxx:174 TEvePolygonSetProjectedGL.cxx:175 TEvePolygonSetProjectedGL.cxx:176 TEvePolygonSetProjectedGL.cxx:177 TEvePolygonSetProjectedGL.cxx:178 TEvePolygonSetProjectedGL.cxx:179 TEvePolygonSetProjectedGL.cxx:180 TEvePolygonSetProjectedGL.cxx:181 TEvePolygonSetProjectedGL.cxx:182 TEvePolygonSetProjectedGL.cxx:183 TEvePolygonSetProjectedGL.cxx:184 TEvePolygonSetProjectedGL.cxx:185 TEvePolygonSetProjectedGL.cxx:186 TEvePolygonSetProjectedGL.cxx:187 TEvePolygonSetProjectedGL.cxx:188 TEvePolygonSetProjectedGL.cxx:189 TEvePolygonSetProjectedGL.cxx:190 TEvePolygonSetProjectedGL.cxx:191 TEvePolygonSetProjectedGL.cxx:192 TEvePolygonSetProjectedGL.cxx:193 TEvePolygonSetProjectedGL.cxx:194 TEvePolygonSetProjectedGL.cxx:195 TEvePolygonSetProjectedGL.cxx:196 TEvePolygonSetProjectedGL.cxx:197 TEvePolygonSetProjectedGL.cxx:198 TEvePolygonSetProjectedGL.cxx:199 TEvePolygonSetProjectedGL.cxx:200 TEvePolygonSetProjectedGL.cxx:201 TEvePolygonSetProjectedGL.cxx:202 TEvePolygonSetProjectedGL.cxx:203 TEvePolygonSetProjectedGL.cxx:204 TEvePolygonSetProjectedGL.cxx:205 TEvePolygonSetProjectedGL.cxx:206 TEvePolygonSetProjectedGL.cxx:207 TEvePolygonSetProjectedGL.cxx:208 TEvePolygonSetProjectedGL.cxx:209 TEvePolygonSetProjectedGL.cxx:210 TEvePolygonSetProjectedGL.cxx:211 TEvePolygonSetProjectedGL.cxx:212 TEvePolygonSetProjectedGL.cxx:213 TEvePolygonSetProjectedGL.cxx:214