Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGLPolyLine.cxx
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Timur Pocheptsov 03/08/2004
3 // NOTE: This code moved from obsoleted TGLSceneObject.h / .cxx - see these
4 // attic files for previous CVS history
5 
6 /*************************************************************************
7  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
8  * All rights reserved. *
9  * *
10  * For the licensing terms see $ROOTSYS/LICENSE. *
11  * For the list of contributors see $ROOTSYS/README/CREDITS. *
12  *************************************************************************/
13 #include "TGLPolyLine.h"
14 #include "TGLRnrCtx.h"
15 #include "TGLIncludes.h"
16 #include "TGLUtil.h"
17 
18 #include "TBuffer3D.h"
19 #include "TBuffer3DTypes.h"
20 #include "TAttLine.h"
21 
22 // For debug tracing
23 #include "TClass.h"
24 #include "TError.h"
25 
26 /** \class TGLPolyLine
27 \ingroup opengl
28 To draw a 3D polyline in a GL window.
29 */
30 
31 ClassImp(TGLPolyLine);
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 /// constructor
35 ///dynamic_cast because of multiple inheritance.
36 
37 TGLPolyLine::TGLPolyLine(const TBuffer3D & buffer) :
38  TGLLogicalShape(buffer),
39  fVertices(buffer.fPnts, buffer.fPnts + 3 * buffer.NbPnts()),
40  fLineWidth(1.)
41 {
42  if (TAttLine *lineAtt = dynamic_cast<TAttLine *>(buffer.fID))
43  fLineWidth = lineAtt->GetLineWidth();
44 }
45 
46 
47 ////////////////////////////////////////////////////////////////////////////////
48 /// Debug tracing
49 
50 void TGLPolyLine::DirectDraw(TGLRnrCtx & rnrCtx) const
51 {
52  if (gDebug > 4) {
53  Info("TGLPolyLine::DirectDraw", "this %ld (class %s) LOD %d", (Long_t)this, IsA()->GetName(), rnrCtx.ShapeLOD());
54  }
55 
56  if (rnrCtx.DrawPass() == TGLRnrCtx::kPassOutlineLine)
57  return;
58 
59  Double_t oldWidth = 1.;
60  glGetDoublev(GL_LINE_WIDTH, &oldWidth);
61 
62  TGLUtil::LineWidth(fLineWidth);
63 
64  glBegin(GL_LINE_STRIP);
65 
66  for (UInt_t i = 0; i < fVertices.size(); i += 3)
67  glVertex3d(fVertices[i], fVertices[i + 1], fVertices[i + 2]);
68 
69  glEnd();
70 
71  glLineWidth(oldWidth);
72 }