forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEveArrowGL.cxx
87 lines (67 loc) · 2.56 KB
/
TEveArrowGL.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// @(#)root/eve:$Id$
// Author: Matevz Tadel 2007
/*************************************************************************
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "TEveArrowGL.h"
#include "TEveArrow.h"
#include "TGLRnrCtx.h"
#include "TGLIncludes.h"
#include "TGLUtil.h"
#include "TGLQuadric.h"
/** \class TEveArrowGL
\ingroup TEve
OpenGL renderer class for TEveArrow.
*/
ClassImp(TEveArrowGL);
////////////////////////////////////////////////////////////////////////////////
/// Constructor.
TEveArrowGL::TEveArrowGL() :
TGLObject(), fM(nullptr)
{
}
/******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
/// Set model object.
Bool_t TEveArrowGL::SetModel(TObject* obj, const Option_t* /*opt*/)
{
fM = SetModelDynCast<TEveArrow>(obj);
return kTRUE;
}
////////////////////////////////////////////////////////////////////////////////
/// Set bounding box.
void TEveArrowGL::SetBBox()
{
// !! This ok if master sub-classed from TAttBBox
SetAxisAlignedBBox(((TEveArrow*)fExternalObj)->AssertBBox());
}
/******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
/// Render with OpenGL.
void TEveArrowGL::DirectDraw(TGLRnrCtx& /*rnrCtx*/) const
{
static TGLQuadric quad;
glPushMatrix();
TGLVertex3 uo(fM->fOrigin.fX, fM->fOrigin.fY, fM->fOrigin.fZ);
TGLVector3 uv(fM->fVector.fX, fM->fVector.fY, fM->fVector.fZ);
TGLMatrix local(uo, uv);
glMultMatrixd(local.CArr());
Float_t size = fM->fVector.Mag();
// Line (tube) component
Float_t r = size*fM->fTubeR;
Float_t h = size*fM->fConeL;
gluCylinder(quad.Get(), r, r, size - h, fM->fDrawQuality, 1);
gluQuadricOrientation(quad.Get(), (GLenum)GLU_INSIDE);
gluDisk(quad.Get(), 0.0, r, fM->fDrawQuality, 1);
// Arrow cone
r = size*fM->fConeR;
glTranslated(0.0, 0.0, size - h);
gluDisk(quad.Get(), 0.0, r, fM->fDrawQuality, 1);
gluQuadricOrientation(quad.Get(), (GLenum)GLU_OUTSIDE);
gluCylinder(quad.Get(), r, 0., h , fM->fDrawQuality, 1);
glPopMatrix();
}