TEveTrackGL.cxx

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEveTrackGL.cxx 36384 2010-10-20 14:26:41Z matevz $
00002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 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 "TEveTrackGL.h"
00013 #include "TEveTrack.h"
00014 #include "TEveTrackPropagator.h"
00015 
00016 #include "TGLIncludes.h"
00017 #include "TGLRnrCtx.h"
00018 #include "TGLSelectRecord.h"
00019 
00020 //==============================================================================
00021 // TEveTrackGL
00022 //==============================================================================
00023 
00024 //______________________________________________________________________________
00025 //
00026 // GL-renderer for TEveTrack class.
00027 
00028 ClassImp(TEveTrackGL);
00029 
00030 //______________________________________________________________________________
00031 TEveTrackGL::TEveTrackGL() : TEveLineGL()
00032 {
00033    // Default constructor.
00034 
00035    // fDLCache = false; // Disable display list.
00036 }
00037 
00038 /******************************************************************************/
00039 
00040 //______________________________________________________________________________
00041 Bool_t TEveTrackGL::SetModel(TObject* obj, const Option_t* /*opt*/)
00042 {
00043    // Set model object.
00044 
00045    TEveLineGL::SetModel(obj);
00046    fTrack = DynCast<TEveTrack>(obj);
00047    return kTRUE;
00048 }
00049 
00050 //______________________________________________________________________________
00051 void TEveTrackGL::ProcessSelection(TGLRnrCtx & /*rnrCtx*/, TGLSelectRecord & rec)
00052 {
00053    // Processes secondary selection from TGLViewer.
00054    // Just calls SecSelected(track) in model object which emits a signal.
00055    // This is used in user code for alternate selection of good / bad tracks.
00056 
00057    if (gDebug > 0)
00058    {
00059       printf("TEveTrackGL::ProcessSelection %d names on the stack (z1=%g, z2=%g).\n",
00060              rec.GetN(), rec.GetMinZ(), rec.GetMaxZ());
00061       printf("  Names: ");
00062       for (Int_t j=0; j<rec.GetN(); ++j) printf ("%d ", rec.GetItem(j));
00063       printf("\n");
00064    }
00065 
00066    fTrack->SecSelected(fTrack);
00067 }
00068 
00069 //______________________________________________________________________________
00070 void TEveTrackGL::DirectDraw(TGLRnrCtx & rnrCtx) const
00071 {
00072    // GL rendering code.
00073    // Virtual from TGLLogicalShape.
00074 
00075    TEveLineGL::DirectDraw(rnrCtx);
00076 
00077    RenderPathMarksAndFirstVertex(rnrCtx);
00078 }
00079 
00080 //______________________________________________________________________________
00081 void TEveTrackGL::RenderPathMarksAndFirstVertex(TGLRnrCtx& rnrCtx) const
00082 {
00083    // Render path-marks and the first vertex, if required.
00084 
00085    TEveTrackPropagator          &rTP = *fTrack->GetPropagator();
00086    const TEveTrack::vPathMark_t &pms =  fTrack->RefPathMarks();
00087    if ( ! pms.empty())
00088    {
00089       Float_t *pnts = new Float_t[3*pms.size()]; // maximum
00090       Int_t    cnt  = 0;
00091       Int_t    n    = 0;
00092       for (Int_t i = 0; i < fTrack->fLastPMIdx; ++i)
00093       {
00094          const TEvePathMark &pm = pms[i];
00095          if ((pm.fType == TEvePathMark::kDaughter  && rTP.GetRnrDaughters())  ||
00096              (pm.fType == TEvePathMark::kReference && rTP.GetRnrReferences()) ||
00097              (pm.fType == TEvePathMark::kDecay     && rTP.GetRnrDecay())      ||
00098              (pm.fType == TEvePathMark::kCluster2D && rTP.GetRnrCluster2Ds()))
00099          {
00100             pnts[n  ] = pm.fV.fX;
00101             pnts[n+1] = pm.fV.fY;
00102             pnts[n+2] = pm.fV.fZ;
00103             n += 3;
00104             ++cnt;
00105          }
00106       }
00107       TGLUtil::RenderPolyMarkers(rTP.RefPMAtt(), 0, pnts, cnt,
00108                                  rnrCtx.GetPickRadius(),
00109                                  rnrCtx.Selection());
00110       delete [] pnts;
00111    }
00112 
00113    // fist vertex
00114    if (rTP.GetRnrFV() && fTrack->GetLastPoint())
00115       TGLUtil::RenderPolyMarkers(rTP.RefFVAtt(), 0, fTrack->GetP(), 1,
00116                                  rnrCtx.GetPickRadius(),
00117                                  rnrCtx.Selection());
00118 }

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