Logo ROOT  
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
28To 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
51{
52 if (gDebug > 4) {
53 Info("TGLPolyLine::DirectDraw", "this %ld (class %s) LOD %d", (Long_t)this, IsA()->GetName(), rnrCtx.ShapeLOD());
54 }
55
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}
#define GL_LINE_STRIP
Definition: GL_glu.h:286
long Long_t
Definition: RtypesCore.h:52
double Double_t
Definition: RtypesCore.h:57
R__EXTERN Int_t gDebug
Definition: RtypesCore.h:117
#define ClassImp(name)
Definition: Rtypes.h:361
void Info(const char *location, const char *msgfmt,...)
Line Attributes class.
Definition: TAttLine.h:18
Generic 3D primitive description class.
Definition: TBuffer3D.h:18
TObject * fID
Definition: TBuffer3D.h:87
Abstract logical shape - a GL 'drawable' - base for all shapes - faceset sphere etc.
To draw a 3D polyline in a GL window.
Definition: TGLPolyLine.h:24
std::vector< Double_t > fVertices
Definition: TGLPolyLine.h:26
TGLPolyLine(const TBuffer3D &buffer)
constructor dynamic_cast because of multiple inheritance.
Definition: TGLPolyLine.cxx:37
Double_t fLineWidth
Definition: TGLPolyLine.h:27
virtual void DirectDraw(TGLRnrCtx &rnrCtx) const
Debug tracing.
Definition: TGLPolyLine.cxx:50
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition: TGLRnrCtx.h:41
Short_t DrawPass() const
Definition: TGLRnrCtx.h:204
@ kPassOutlineLine
Definition: TGLRnrCtx.h:57
Short_t ShapeLOD() const
Definition: TGLRnrCtx.h:177
static Float_t LineWidth()
Get the line-width, taking the global scaling into account.
Definition: TGLUtil.cxx:1938