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
24
25////////////////////////////////////////////////////////////////////////////////
26/// Constructor.
27
29{
30 // fDLCache = false; // Disable display list.
32}
33
34////////////////////////////////////////////////////////////////////////////////
35/// Set model object.
36
42
43////////////////////////////////////////////////////////////////////////////////
44/// Setup bounding box information.
45
50
51////////////////////////////////////////////////////////////////////////////////
52/// Override from TGLObject.
53/// To account for large point-sizes we modify the projection matrix
54/// during selection and thus we need a direct draw.
55
57{
58 if (rnrCtx.Selection()) return kFALSE;
60}
61
62////////////////////////////////////////////////////////////////////////////////
63/// Draw function for TEveStraightLineSetGL. Skips line-pass of outline mode.
64
66{
67 if (rnrCtx.IsDrawPassOutlineLine())
68 return;
69
71}
72
73////////////////////////////////////////////////////////////////////////////////
74/// Render the line-set with GL.
75
77{
78 // printf("TEveStraightLineSetGL::DirectDraw LOD %d\n", rnrCtx.ShapeLOD());
79
80 TEveStraightLineSet& mL = * fM;
81
82 // set depth range when selection is disabled, else can't pick camera center
83 if (mL.GetDepthTest() == kFALSE && rnrCtx.Selection() == kFALSE)
84 {
86 glDepthRange(0, 0.1);
87 }
88
89 // lines
90 if (mL.GetRnrLines() && mL.GetLinePlex().Size() > 0)
91 {
95 if (mL.GetLineStyle() > 1) {
96 // Int_t fac = 1;
97 UShort_t pat = 0xffff;
98 switch (mL.GetLineStyle()) {
99 case 2: pat = 0x3333; break;
100 case 3: pat = 0x5555; break;
101 case 4: pat = 0xf040; break;
102 case 5: pat = 0xf4f4; break;
103 case 6: pat = 0xf111; break;
104 case 7: pat = 0xf0f0; break;
105 case 8: pat = 0xff11; break;
106 case 9: pat = 0x3fff; break;
107 case 10: pat = 0x08ff; /* fac = 2; */ break;
108 }
109 glLineStipple(1, pat);
111 }
112
113 // During selection extend picking region for large line-widths.
114 Bool_t changePM = rnrCtx.Selection() && mL.GetLineWidth() > rnrCtx.GetPickRadius();
115 if (changePM)
117
119 if (rnrCtx.SecSelection())
120 {
121 glPushName(1);
122 glPushName(0);
123 while (li.next())
124 {
126 glLoadName(l.fId);
127 {
128 glBegin(GL_LINES);
129 glVertex3f(l.fV1[0], l.fV1[1], l.fV1[2]);
130 glVertex3f(l.fV2[0], l.fV2[1], l.fV2[2]);
131 glEnd();
132 }
133 }
134 glPopName();
135 glPopName();
136 }
137 else
138 {
139 glBegin(GL_LINES);
140 while (li.next())
141 {
143 glVertex3f(l.fV1[0], l.fV1[1], l.fV1[2]);
144 glVertex3f(l.fV2[0], l.fV2[1], l.fV2[2]);
145 }
146 glEnd();
147 }
148
149 if (changePM)
151
152 glPopAttrib();
153 }
154
155
156 // markers
157 if (mL.GetRnrMarkers() && mL.GetMarkerPlex().Size() > 0)
158 {
160 Float_t* pnts = new Float_t[mL.GetMarkerPlex().Size()*3];
161 Float_t* pnt = pnts;
162 while (mi.next())
163 {
165 pnt[0] = m.fV[0];
166 pnt[1] = m.fV[1];
167 pnt[2] = m.fV[2];
168 pnt += 3;
169 }
170 if (rnrCtx.SecSelection()) glPushName(2);
171 TGLUtil::RenderPolyMarkers((TAttMarker&)mL, mL.GetMainTransparency(),
172 pnts, mL.GetMarkerPlex().Size(),
173 rnrCtx.GetPickRadius(),
174 rnrCtx.Selection(),
175 rnrCtx.SecSelection());
176 if (rnrCtx.SecSelection()) glPopName();
177 delete [] pnts;
178 }
179
180 if (mL.GetDepthTest() == kFALSE && rnrCtx.Selection() == kFALSE)
181 glPopAttrib();
182}
183
184////////////////////////////////////////////////////////////////////////////////
185/// Process results of the secondary selection.
186
188 TGLSelectRecord& rec)
189{
190 if (rec.GetN() != 3) return;
191 if (rec.GetItem(1) == 1)
192 {
193 printf("selected line %d\n", rec.GetItem(2));
194 }
195 else
196 {
198 printf("Selected point %d on line %d\n", rec.GetItem(2), m.fLineId);
199 }
200}
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
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.
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:37
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:36
Marker Attributes class.
Definition TAttMarker.h:20
Char_t * Atom(Int_t idx) const
Int_t Size() const
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:85
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:40
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition TGLRnrCtx.h:41
Standard selection record including information about containing scene and details ob out selected ob...
static void BeginExtendPickRegion(Float_t scale)
Definition TGLUtil.cxx:1943
static void EndExtendPickRegion()
Definition TGLUtil.cxx:1958
static Float_t LineWidth()
Get the line-width, taking the global scaling into account.
Definition TGLUtil.cxx:1934
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:1971
Mother of all ROOT objects.
Definition TObject.h:41
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4