Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEveStraightLineSetGL.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
13#include "TEveStraightLineSet.h"
14
15#include "TGLIncludes.h"
16#include "TGLRnrCtx.h"
17#include "TGLSelectRecord.h"
18
19/** \class TEveStraightLineSetGL
20\ingroup TEve
21GL-renderer for TEveStraightLineSet class.
22*/
23
25
26////////////////////////////////////////////////////////////////////////////////
27/// Constructor.
28
30{
31 // fDLCache = false; // Disable display list.
33}
34
35////////////////////////////////////////////////////////////////////////////////
36/// Set model object.
37
39{
40 fM = SetModelDynCast<TEveStraightLineSet>(obj);
41 return kTRUE;
42}
43
44////////////////////////////////////////////////////////////////////////////////
45/// Setup bounding box information.
46
48{
50}
51
52////////////////////////////////////////////////////////////////////////////////
53/// Override from TGLObject.
54/// To account for large point-sizes we modify the projection matrix
55/// during selection and thus we need a direct draw.
56
58{
59 if (rnrCtx.Selection()) return kFALSE;
60 return TGLObject::ShouldDLCache(rnrCtx);
61}
62
63////////////////////////////////////////////////////////////////////////////////
64/// Draw function for TEveStraightLineSetGL. Skips line-pass of outline mode.
65
67{
68 if (rnrCtx.IsDrawPassOutlineLine())
69 return;
70
71 TGLObject::Draw(rnrCtx);
72}
73
74////////////////////////////////////////////////////////////////////////////////
75/// Render the line-set with GL.
76
78{
79 // printf("TEveStraightLineSetGL::DirectDraw LOD %d\n", rnrCtx.ShapeLOD());
80
81 TEveStraightLineSet& mL = * fM;
82
83 // set depth range when selection is disabled, else can't pick camera center
84 if (mL.GetDepthTest() == kFALSE && rnrCtx.Selection() == kFALSE)
85 {
86 glPushAttrib(GL_VIEWPORT_BIT);
87 glDepthRange(0, 0.1);
88 }
89
90 // lines
91 if (mL.GetRnrLines() && mL.GetLinePlex().Size() > 0)
92 {
93 glPushAttrib(GL_LINE_BIT | GL_ENABLE_BIT);
94 glDisable(GL_LIGHTING);
96 if (mL.GetLineStyle() > 1) {
97 // Int_t fac = 1;
98 UShort_t pat = 0xffff;
99 switch (mL.GetLineStyle()) {
100 case 2: pat = 0x3333; break;
101 case 3: pat = 0x5555; break;
102 case 4: pat = 0xf040; break;
103 case 5: pat = 0xf4f4; break;
104 case 6: pat = 0xf111; break;
105 case 7: pat = 0xf0f0; break;
106 case 8: pat = 0xff11; break;
107 case 9: pat = 0x3fff; break;
108 case 10: pat = 0x08ff; /* fac = 2; */ break;
109 }
110 glLineStipple(1, pat);
111 glEnable(GL_LINE_STIPPLE);
112 }
113
114 // During selection extend picking region for large line-widths.
115 Bool_t changePM = rnrCtx.Selection() && mL.GetLineWidth() > rnrCtx.GetPickRadius();
116 if (changePM)
118
120 if (rnrCtx.SecSelection())
121 {
122 glPushName(1);
123 glPushName(0);
124 while (li.next())
125 {
127 glLoadName(l.fId);
128 {
129 glBegin(GL_LINES);
130 glVertex3f(l.fV1[0], l.fV1[1], l.fV1[2]);
131 glVertex3f(l.fV2[0], l.fV2[1], l.fV2[2]);
132 glEnd();
133 }
134 }
135 glPopName();
136 glPopName();
137 }
138 else
139 {
140 glBegin(GL_LINES);
141 while (li.next())
142 {
144 glVertex3f(l.fV1[0], l.fV1[1], l.fV1[2]);
145 glVertex3f(l.fV2[0], l.fV2[1], l.fV2[2]);
146 }
147 glEnd();
148 }
149
150 if (changePM)
152
153 glPopAttrib();
154 }
155
156
157 // markers
158 if (mL.GetRnrMarkers() && mL.GetMarkerPlex().Size() > 0)
159 {
161 Float_t* pnts = new Float_t[mL.GetMarkerPlex().Size()*3];
162 Float_t* pnt = pnts;
163 while (mi.next())
164 {
166 pnt[0] = m.fV[0];
167 pnt[1] = m.fV[1];
168 pnt[2] = m.fV[2];
169 pnt += 3;
170 }
171 if (rnrCtx.SecSelection()) glPushName(2);
172 TGLUtil::RenderPolyMarkers((TAttMarker&)mL, mL.GetMainTransparency(),
173 pnts, mL.GetMarkerPlex().Size(),
174 rnrCtx.GetPickRadius(),
175 rnrCtx.Selection(),
176 rnrCtx.SecSelection());
177 if (rnrCtx.SecSelection()) glPopName();
178 delete [] pnts;
179 }
180
181 if (mL.GetDepthTest() == kFALSE && rnrCtx.Selection() == kFALSE)
182 glPopAttrib();
183}
184
185////////////////////////////////////////////////////////////////////////////////
186/// Process results of the secondary selection.
187
189 TGLSelectRecord& rec)
190{
191 if (rec.GetN() != 3) return;
192 if (rec.GetItem(1) == 1)
193 {
194 printf("selected line %d\n", rec.GetItem(2));
195 }
196 else
197 {
199 printf("Selected point %d on line %d\n", rec.GetItem(2), m.fLineId);
200 }
201}
#define GL_LINES
Definition GL_glu.h:284
unsigned short UShort_t
Definition RtypesCore.h:40
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:35
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:34
Marker Attributes class.
Definition TAttMarker.h:19
Char_t * Atom(Int_t idx) const
Int_t Size() const
GL-renderer for TEveStraightLineSet class.
void ProcessSelection(TGLRnrCtx &rnrCtx, TGLSelectRecord &rec) override
Process results of the secondary selection.
Bool_t ShouldDLCache(const TGLRnrCtx &rnrCtx) const override
Override from TGLObject.
TEveStraightLineSet * fM
void SetBBox() override
Setup bounding box information.
Bool_t SetModel(TObject *obj, const Option_t *opt=nullptr) override
Set model object.
void Draw(TGLRnrCtx &rnrCtx) const override
Draw function for TEveStraightLineSetGL. Skips line-pass of outline mode.
void DirectDraw(TGLRnrCtx &rnrCtx) const override
Render the line-set with GL.
Set of straight lines with optional markers along the lines.
virtual Bool_t GetDepthTest()
TEveChunkManager & GetMarkerPlex()
virtual Bool_t GetRnrLines()
TEveChunkManager & GetLinePlex()
virtual Bool_t GetRnrMarkers()
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw the GL drawable, using draw flags.
TObject * fExternalObj
first replica
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:86
Bool_t ShouldDLCache(const TGLRnrCtx &rnrCtx) const override
Decide if display-list should be used for this pass rendering, as determined by rnrCtx.
Definition TGLObject.cxx:41
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition TGLRnrCtx.h:41
Int_t GetPickRadius()
Return pick radius. If selection is not active it returns 0.
Bool_t SecSelection() const
Definition TGLRnrCtx.h:224
Bool_t IsDrawPassOutlineLine() const
Definition TGLRnrCtx.h:207
Bool_t Selection() const
Definition TGLRnrCtx.h:222
Standard selection record including information about containing scene and details ob out selected ob...
static void BeginExtendPickRegion(Float_t scale)
Definition TGLUtil.cxx:1952
static void EndExtendPickRegion()
Definition TGLUtil.cxx:1967
static Float_t LineWidth()
Get the line-width, taking the global scaling into account.
Definition TGLUtil.cxx:1943
static void RenderPolyMarkers(const TAttMarker &marker, Char_t transp, Float_t *p, Int_t n, Int_t pick_radius=0, Bool_t selection=kFALSE, Bool_t sec_selection=kFALSE)
Render polymarkers at points specified by p-array.
Definition TGLUtil.cxx:1980
Mother of all ROOT objects.
Definition TObject.h:41
Bool_t next()
Go to next atom.
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4