TEveArrowGL.cxx

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEveArrowGL.cxx 36384 2010-10-20 14:26:41Z matevz $
00002 // Author: Matevz Tadel 2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "TEveArrowGL.h"
00013 #include "TEveArrow.h"
00014 
00015 #include "TGLRnrCtx.h"
00016 #include "TGLIncludes.h"
00017 #include "TGLUtil.h"
00018 #include "TGLQuadric.h"
00019 
00020 //______________________________________________________________________________
00021 // OpenGL renderer class for TEveArrow.
00022 //
00023 
00024 ClassImp(TEveArrowGL);
00025 
00026 //______________________________________________________________________________
00027 TEveArrowGL::TEveArrowGL() :
00028    TGLObject(), fM(0)
00029 {
00030    // Constructor.
00031 }
00032 
00033 /******************************************************************************/
00034 
00035 //______________________________________________________________________________
00036 Bool_t TEveArrowGL::SetModel(TObject* obj, const Option_t* /*opt*/)
00037 {
00038    // Set model object.
00039 
00040    fM = SetModelDynCast<TEveArrow>(obj);
00041    return kTRUE;
00042 }
00043 
00044 //______________________________________________________________________________
00045 void TEveArrowGL::SetBBox()
00046 {
00047    // Set bounding box.
00048 
00049    // !! This ok if master sub-classed from TAttBBox
00050    SetAxisAlignedBBox(((TEveArrow*)fExternalObj)->AssertBBox());
00051 }
00052 
00053 /******************************************************************************/
00054 
00055 //______________________________________________________________________________
00056 void TEveArrowGL::DirectDraw(TGLRnrCtx& /*rnrCtx*/) const
00057 {
00058    // Render with OpenGL.
00059 
00060    static TGLQuadric quad;
00061 
00062    glPushMatrix();
00063 
00064    TGLVertex3 uo(fM->fOrigin.fX, fM->fOrigin.fY, fM->fOrigin.fZ);
00065    TGLVector3 uv(fM->fVector.fX, fM->fVector.fY, fM->fVector.fZ);
00066    TGLMatrix local(uo, uv);
00067    glMultMatrixd(local.CArr());
00068    Float_t size = fM->fVector.Mag();
00069 
00070    // Line (tube) component
00071    Float_t r = size*fM->fTubeR;
00072    Float_t h = size*fM->fConeL;
00073    gluCylinder(quad.Get(), r, r, size - h, fM->fDrawQuality, 1);
00074    gluQuadricOrientation(quad.Get(), (GLenum)GLU_INSIDE);
00075    gluDisk(quad.Get(), 0.0, r, fM->fDrawQuality, 1);
00076 
00077    // Arrow cone
00078    r = size*fM->fConeR;
00079    glTranslated(0.0, 0.0, size -h );
00080    gluDisk(quad.Get(), 0.0, r, fM->fDrawQuality, 1);
00081    gluQuadricOrientation(quad.Get(), (GLenum)GLU_OUTSIDE);
00082    gluCylinder(quad.Get(), r, 0., h , fM->fDrawQuality, 1);
00083 
00084    glPopMatrix();
00085 }

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