Logo ROOT   6.08/07
Reference Guide
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 
12 #include "TEveStraightLineSetGL.h"
13 #include "TEveStraightLineSet.h"
14 
15 #include "TGLIncludes.h"
16 #include "TGLRnrCtx.h"
17 #include "TGLSelectRecord.h"
18 
19 /** \class TEveStraightLineSetGL
20 \ingroup TEve
21 GL-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  GLuint name = 0;
123  glPushName(1);
124  glPushName(0);
125  while (li.next())
126  {
128  glLoadName(l.fId);
129  {
130  glBegin(GL_LINES);
131  glVertex3f(l.fV1[0], l.fV1[1], l.fV1[2]);
132  glVertex3f(l.fV2[0], l.fV2[1], l.fV2[2]);
133  glEnd();
134  }
135  name ++;
136  }
137  glPopName();
138  glPopName();
139  }
140  else
141  {
142  glBegin(GL_LINES);
143  while (li.next())
144  {
146  glVertex3f(l.fV1[0], l.fV1[1], l.fV1[2]);
147  glVertex3f(l.fV2[0], l.fV2[1], l.fV2[2]);
148  }
149  glEnd();
150  }
151 
152  if (changePM)
154 
155  glPopAttrib();
156  }
157 
158 
159  // markers
160  if (mL.GetRnrMarkers() && mL.GetMarkerPlex().Size() > 0)
161  {
163  Float_t* pnts = new Float_t[mL.GetMarkerPlex().Size()*3];
164  Float_t* pnt = pnts;
165  while (mi.next())
166  {
168  pnt[0] = m.fV[0];
169  pnt[1] = m.fV[1];
170  pnt[2] = m.fV[2];
171  pnt += 3;
172  }
173  if (rnrCtx.SecSelection()) glPushName(2);
174  TGLUtil::RenderPolyMarkers((TAttMarker&)mL, mL.GetMainTransparency(),
175  pnts, mL.GetMarkerPlex().Size(),
176  rnrCtx.GetPickRadius(),
177  rnrCtx.Selection(),
178  rnrCtx.SecSelection());
179  if (rnrCtx.SecSelection()) glPopName();
180  delete [] pnts;
181  }
182 
183  if (mL.GetDepthTest() == kFALSE && rnrCtx.Selection() == kFALSE)
184  glPopAttrib();
185 }
186 
187 ////////////////////////////////////////////////////////////////////////////////
188 /// Process results of the secondary selection.
189 
191  TGLSelectRecord& rec)
192 {
193  if (rec.GetN() != 3) return;
194  if (rec.GetItem(1) == 1)
195  {
196  printf("selected line %d\n", rec.GetItem(2));
197  }
198  else
199  {
201  printf("Selected point %d on line %d\n", rec.GetItem(2), m.fLineId);
202  }
203 }
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:40
Bool_t SecSelection() const
Definition: TGLRnrCtx.h:224
virtual Bool_t GetDepthTest()
Int_t GetPickRadius()
Return pick radius. If selection is not active it returns 0.
Definition: TGLRnrCtx.cxx:257
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
Bool_t Selection() const
Definition: TGLRnrCtx.h:222
virtual Bool_t ShouldDLCache(const TGLRnrCtx &rnrCtx) const
Override from TGLObject.
unsigned short UShort_t
Definition: RtypesCore.h:36
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 Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
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:1941
TEveStraightLineSetGL()
Constructor.
Bool_t IsDrawPassOutlineLine() const
Definition: TGLRnrCtx.h:207
virtual Width_t GetLineWidth() const
Return the line width.
Definition: TAttLine.h:41
TEveChunkManager & GetLinePlex()
Marker Attributes class.
Definition: TAttMarker.h:24
virtual Style_t GetLineStyle() const
Return the line style.
Definition: TAttLine.h:40
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const
Render the line-set with GL.
Base-class for direct OpenGL renderers.
Definition: TGLObject.h:21
TEveStraightLineSet * fM
Int_t Size() const
TEveChunkManager & GetMarkerPlex()
TObject * fExternalObj
first replica
Char_t * Atom(Int_t idx) const
Standard selection record including information about containing scene and details ob out selected ob...
TMarker * m
Definition: textangle.C:8
virtual void ProcessSelection(TGLRnrCtx &rnrCtx, TGLSelectRecord &rec)
Process results of the secondary selection.
TLine * l
Definition: textangle.C:4
virtual void SetBBox()
Setup bounding box information.
GL-renderer for TEveStraightLineSet class.
virtual Bool_t ShouldDLCache(const TGLRnrCtx &rnrCtx) const
Decide if display-list should be used for this pass rendering, as determined by rnrCtx.
Definition: TGLObject.cxx:41
#define ClassImp(name)
Definition: Rtypes.h:279
UInt_t GetItem(Int_t i) const
static void BeginExtendPickRegion(Float_t scale)
Definition: TGLUtil.cxx:1913
static void EndExtendPickRegion()
Definition: TGLUtil.cxx:1928
Bool_t fMultiColor
Definition: TGLObject.h:28
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw the GL drawable, using draw flags.
virtual Bool_t GetRnrLines()
Int_t GetN() const
static Float_t LineWidth()
Get the line-width, taking the global scaling into account.
Definition: TGLUtil.cxx:1904
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual Bool_t GetRnrMarkers()
virtual Bool_t SetModel(TObject *obj, const Option_t *opt=0)
Set model object.
virtual void Draw(TGLRnrCtx &rnrCtx) const
Draw function for TEveStraightLineSetGL. Skips line-pass of outline mode.
char name[80]
Definition: TGX11.cxx:109
Set of straight lines with optional markers along the lines.