// @(#)root/eve:$Id: TEveArrowGL.cxx 25947 2008-10-24 14:49:20Z matevz $
// Author: Matevz Tadel 2007

/*************************************************************************
 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TEveArrowGL.h"
#include "TEveArrow.h"

#include "TGLRnrCtx.h"
#include "TGLIncludes.h"
#include "TGLUtil.h"
#include "TGLQuadric.h"

//______________________________________________________________________________
// OpenGL renderer class for TEveArrow.
//

ClassImp(TEveArrowGL);

//______________________________________________________________________________
TEveArrowGL::TEveArrowGL() :
   TGLObject(), fM(0)
{
   // Constructor.
}

/******************************************************************************/

//______________________________________________________________________________
Bool_t TEveArrowGL::SetModel(TObject* obj, const Option_t* /*opt*/)
{
   // Set model object.

   if (SetModelCheckClass(obj, TEveArrow::Class())) {
      fM = dynamic_cast<TEveArrow*>(obj);
      return kTRUE;
   }
   return kFALSE;
}

//______________________________________________________________________________
void TEveArrowGL::SetBBox()
{
   // Set bounding box.

   // !! This ok if master sub-classed from TAttBBox
   SetAxisAlignedBBox(((TEveArrow*)fExternalObj)->AssertBBox());
}

/******************************************************************************/

//______________________________________________________________________________
void TEveArrowGL::DirectDraw(TGLRnrCtx& /*rnrCtx*/) const
{
   // Render with OpenGL.

   // printf("TEveArrowGL::DirectDraw LOD \n");

   static TGLQuadric quad;
   UInt_t drawQuality = 10;
   // Draw 3D line (tube) with optional head shape

   glPushMatrix();

   TGLVertex3 uo(fM->fOrigin.fX, fM->fOrigin.fY, fM->fOrigin.fZ);
   TGLVector3 uv(fM->fVector.fX, fM->fVector.fY, fM->fVector.fZ);
   TGLMatrix local(uo, uv);
   glMultMatrixd(local.CArr());
   Float_t size = fM->fVector.Mag();

   // Line (tube) component
   Float_t r = size*fM->fTubeR;
   Float_t h = size*fM->fConeL;
   gluCylinder(quad.Get(), r, r, size - h, drawQuality, 1);
   gluQuadricOrientation(quad.Get(), (GLenum)GLU_INSIDE);
   gluDisk(quad.Get(), 0.0, r, drawQuality, 1);

   // Arrow cone
   r = size*fM->fConeR;
   glTranslated(0.0, 0.0, size -h );
   gluDisk(quad.Get(), 0.0, r, drawQuality, 1);
   gluQuadricOrientation(quad.Get(), (GLenum)GLU_OUTSIDE);
   gluCylinder(quad.Get(), r, 0., h , drawQuality, 1);

   glPopMatrix();
}

Last change: Fri Oct 24 16:54:01 2008
Last generated: 2008-10-24 16:54

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.