Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEvePolygonSetProjectedGL.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
14#include "TEveVector.h"
15
16#include "TGLRnrCtx.h"
17#include "TGLCamera.h"
18#include "TGLPhysicalShape.h"
19#include "TGLIncludes.h"
20
21/** \class TEvePolygonSetProjectedGL
22\ingroup TEve
23GL-renderer for TEvePolygonSetProjected class.
24*/
25
26
27////////////////////////////////////////////////////////////////////////////////
28/// Constructor
29
31{
32 // fDLCache = kFALSE; // Disable DL.
33 fMultiColor = kTRUE; // Potentially false, reset in DirectDraw().
34}
35
36////////////////////////////////////////////////////////////////////////////////
37/// Set model object.
38
44
45////////////////////////////////////////////////////////////////////////////////
46/// Setup bounding-box information.
47
52
53////////////////////////////////////////////////////////////////////////////////
54/// Draw function for TEvePolygonSetProjectedGL.
55/// Skips line-pass of outline mode.
56
58{
59 if (rnrCtx.IsDrawPassOutlineLine())
60 return;
61
63}
64
65////////////////////////////////////////////////////////////////////////////////
66/// Draw polygons outline.
67
69{
70 if (fM->fPols.empty()) return;
71
73
74 if (fM->GetMiniFrame())
75 {
76 std::map<Edge_t, Int_t> edges;
77
79 i != fM->fPols.end(); ++i)
80 {
81 for(Int_t k = 0; k < i->fNPnts - 1; ++k)
82 {
83 ++edges[Edge_t(i->fPnts[k], i->fPnts[k+1])];
84 }
85 ++edges[Edge_t(i->fPnts[0], i->fPnts[i->fNPnts - 1])];
86 }
87
88 glBegin(GL_LINES);
89 for (std::map<Edge_t, Int_t>::iterator i = edges.begin(); i != edges.end(); ++i)
90 {
91 if (i->second == 1)
92 {
93 glVertex3fv(fM->fPnts[i->first.fI].Arr());
94 glVertex3fv(fM->fPnts[i->first.fJ].Arr());
95 done_p = kTRUE;
96 }
97 }
98 glEnd();
99 }
100
101 if ( ! done_p)
102 {
104 i != fM->fPols.end(); ++i)
105 {
106 glBegin(GL_LINE_LOOP);
107 for(Int_t k = 0; k < i->fNPnts; ++k)
108 {
109 glVertex3fv(fM->fPnts[i->fPnts[k]].Arr());
110 }
111 glEnd();
112 }
113 }
114}
115
116////////////////////////////////////////////////////////////////////////////////
117/// Do GL rendering.
118
120{
121 if (fM->fPols.empty()) return;
122
124
130
131 // This tells TGLObject we don't want display-lists in some cases.
133
134 // polygons
136 glPolygonOffset(1, 1);
138
141 i != fM->fPols.end(); ++i)
142 {
143 Int_t vi; //current vertex index of curent polygon
144 Int_t pntsN = (*i).fNPnts; // number of points in current polygon
145 if (pntsN < 4)
146 {
148 for (Int_t k = 0; k < pntsN; ++k)
149 {
150 vi = (*i).fPnts[k];
151 glVertex3fv(pnts[vi].Arr());
152 }
153 glEnd();
154 }
155 else
156 {
159 glNormal3f(0, 0, 1);
160 Double_t coords[3];
161 coords[2] = 0;
162 for (Int_t k = 0; k < pntsN; ++k)
163 {
164 vi = (*i).fPnts[k];
165 coords[0] = pnts[vi].fX;
166 coords[1] = pnts[vi].fY;
167 gluTessVertex(tessObj, coords, pnts[vi].Arr());
168 }
170 }
171 }
173
174 // Outline
175 if (fM->fDrawFrame)
176 {
180 DrawOutline();
181 }
182
183 glPopAttrib();
184}
185
186////////////////////////////////////////////////////////////////////////////////
187/// Draw polygons in highlight mode.
188
190{
191 if (lvl < 0) lvl = pshp->GetSelected();
192
193 glColor4ubv(rnrCtx.ColorSet().Selection(lvl).CArr());
195
196 if (fM->GetHighlightFrame())
197 {
198 DrawOutline();
199 }
200 else
201 {
202 Draw(rnrCtx);
203 }
204
206}
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Float_t * AssertBBox()
Definition TAttBBox.h:56
void DrawOutline() const
Draw polygons outline.
void DrawHighlight(TGLRnrCtx &rnrCtx, const TGLPhysicalShape *pshp, Int_t lvl=-1) const override
Draw polygons in highlight mode.
void SetBBox() override
Setup bounding-box information.
void Draw(TGLRnrCtx &rnrCtx) const override
Draw function for TEvePolygonSetProjectedGL.
void DirectDraw(TGLRnrCtx &rnrCtx) const override
Do GL rendering.
Bool_t SetModel(TObject *obj, const Option_t *opt=nullptr) override
Set model object.
vpPolygon_t::const_iterator vpPolygon_ci
virtual Bool_t GetMiniFrame() const
Definition TEveShape.h:58
Bool_t fDrawFrame
Definition TEveShape.h:42
virtual Bool_t GetHighlightFrame() const
Definition TEveShape.h:57
Float_t fLineWidth
Definition TEveShape.h:40
Color_t fLineColor
Definition TEveShape.h:39
const TT * Arr() const
Definition TEveVector.h:58
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw the GL drawable, using draw flags.
Base-class for direct OpenGL renderers.
Definition TGLObject.h:22
Bool_t fMultiColor
Definition TGLObject.h:28
void SetAxisAlignedBBox(Float_t xmin, Float_t xmax, Float_t ymin, Float_t ymax, Float_t zmin, Float_t zmax)
Set axis-aligned bounding-box.
Definition TGLObject.cxx:85
Concrete physical shape - a GL drawable.
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition TGLRnrCtx.h:41
static UInt_t LockColor()
Prevent further color changes.
Definition TGLUtil.cxx:1660
static UInt_t UnlockColor()
Allow color changes.
Definition TGLUtil.cxx:1668
static void Color(const TGLColor &color)
Set color from TGLColor.
Definition TGLUtil.cxx:1688
static GLUtesselator * GetDrawTesselator3fv()
Returns a tesselator for direct drawing when using 3-vertices with single precision.
Definition TGLUtil.cxx:1489
static Float_t LineWidth()
Get the line-width, taking the global scaling into account.
Definition TGLUtil.cxx:1934
Mother of all ROOT objects.
Definition TObject.h:41
th1 Draw()