Logo ROOT   6.14/05
Reference Guide
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 
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 /// constructor
35 ///dynamic_cast because of multiple inheritance.
36 
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 
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 }
std::string GetName(const std::string &scope_name)
Definition: Cppyy.cxx:145
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:40
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const
Debug tracing.
Definition: TGLPolyLine.cxx:50
Short_t DrawPass() const
Definition: TGLRnrCtx.h:204
To draw a 3D polyline in a GL window.
Definition: TGLPolyLine.h:23
void Info(const char *location, const char *msgfmt,...)
Short_t ShapeLOD() const
Definition: TGLRnrCtx.h:177
unsigned int UInt_t
Definition: RtypesCore.h:42
Generic 3D primitive description class.
Definition: TBuffer3D.h:17
Double_t fLineWidth
Definition: TGLPolyLine.h:27
TObject * fID
Definition: TBuffer3D.h:87
Abstract logical shape - a GL &#39;drawable&#39; - base for all shapes - faceset sphere etc.
long Long_t
Definition: RtypesCore.h:50
#define ClassImp(name)
Definition: Rtypes.h:359
double Double_t
Definition: RtypesCore.h:55
std::vector< Double_t > fVertices
Definition: TGLPolyLine.h:26
R__EXTERN Int_t gDebug
Definition: Rtypes.h:86
static Float_t LineWidth()
Get the line-width, taking the global scaling into account.
Definition: TGLUtil.cxx:1904
TGLPolyLine(const TBuffer3D &buffer)
constructor dynamic_cast because of multiple inheritance.
Definition: TGLPolyLine.cxx:37
Line Attributes class.
Definition: TAttLine.h:18