TGLPolyLine.cxx

Go to the documentation of this file.
00001 // @(#)root/gl:$Id: TGLPolyLine.cxx 34245 2010-06-30 13:36:29Z brun $
00002 // Author:  Timur Pocheptsov  03/08/2004
00003 // NOTE: This code moved from obsoleted TGLSceneObject.h / .cxx - see these
00004 // attic files for previous CVS history
00005 
00006 /*************************************************************************
00007  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers.               *
00008  * All rights reserved.                                                  *
00009  *                                                                       *
00010  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00011  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00012  *************************************************************************/
00013 #include "TGLPolyLine.h"
00014 #include "TGLRnrCtx.h"
00015 #include "TGLIncludes.h"
00016 #include "TGLUtil.h"
00017 
00018 #include "TBuffer3D.h"
00019 #include "TBuffer3DTypes.h"
00020 #include "TAttLine.h"
00021 
00022 // For debug tracing
00023 #include "TClass.h"
00024 #include "TError.h"
00025 
00026 //______________________________________________________________________________
00027 /* Begin_Html
00028 <center><h2>GL Polyline</h2></center>
00029 To draw a 3D polyline in a GL window.
00030 End_Html */
00031 
00032 ClassImp(TGLPolyLine)
00033 
00034 //______________________________________________________________________________
00035 TGLPolyLine::TGLPolyLine(const TBuffer3D & buffer) :
00036    TGLLogicalShape(buffer),
00037    fVertices(buffer.fPnts, buffer.fPnts + 3 * buffer.NbPnts()),
00038    fLineWidth(1.)
00039 {
00040    // constructor
00041    //dynamic_cast because of multiple inheritance.
00042    if (TAttLine *lineAtt = dynamic_cast<TAttLine *>(buffer.fID))
00043       fLineWidth = lineAtt->GetLineWidth();
00044 }
00045 
00046 
00047 //______________________________________________________________________________
00048 void TGLPolyLine::DirectDraw(TGLRnrCtx & rnrCtx) const
00049 {
00050    // Debug tracing
00051    if (gDebug > 4) {
00052       Info("TGLPolyLine::DirectDraw", "this %ld (class %s) LOD %d", (Long_t)this, IsA()->GetName(), rnrCtx.ShapeLOD());
00053    }
00054 
00055    if (rnrCtx.DrawPass() == TGLRnrCtx::kPassOutlineLine)
00056       return;
00057 
00058    Double_t oldWidth = 1.;
00059    glGetDoublev(GL_LINE_WIDTH, &oldWidth);
00060 
00061    TGLUtil::LineWidth(fLineWidth);
00062 
00063    glBegin(GL_LINE_STRIP);
00064 
00065    for (UInt_t i = 0; i < fVertices.size(); i += 3)
00066       glVertex3d(fVertices[i], fVertices[i + 1], fVertices[i + 2]);
00067 
00068    glEnd();
00069 
00070    glLineWidth(oldWidth);
00071 }

Generated on Tue Jul 5 14:18:08 2011 for ROOT_528-00b_version by  doxygen 1.5.1