ROOT logo
// @(#)root/eve:$Id: TEveTrackProjectedGL.cxx 30840 2009-10-23 09:03:14Z matevz $
// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 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 "TEveTrackProjectedGL.h"
#include "TEveTrackProjected.h"
#include "TEveTrackPropagator.h"
#include "TEveProjectionManager.h"

#include "TGLIncludes.h"
#include "TGLRnrCtx.h"

//==============================================================================
// TEveTrackProjectedGL
//==============================================================================

//______________________________________________________________________________
//
// GL-renderer for TEveTrackProjected class.

ClassImp(TEveTrackProjectedGL);

//______________________________________________________________________________
TEveTrackProjectedGL::TEveTrackProjectedGL() : TEveTrackGL(), fM(0)
{
   // Constructor.

   // fDLCache = kFALSE; // Disable display list.
}

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

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

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

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

//______________________________________________________________________________
void TEveTrackProjectedGL::DirectDraw(TGLRnrCtx& rnrCtx) const
{
   // Draw track with GL.

   // printf("TEveTrackProjectedGL::DirectDraw Style %d, LOD %d\n", flags.Style(), flags.LOD());
   if (fM->Size() == 0)
      return;

   // lines
   if (fM->fRnrLine)
   {
      TGLCapabilitySwitch sw_smooth(GL_LINE_SMOOTH, fM->fSmooth);
      TGLCapabilitySwitch sw_blend(GL_BLEND, fM->fSmooth);
      Int_t start = 0;
      Float_t* p  = fM->GetP();
      TGLUtil::LockColor(); // Keep color from TGLPhysicalShape.
      for (std::vector<Int_t>::iterator bpi = fM->fBreakPoints.begin();
           bpi != fM->fBreakPoints.end(); ++bpi)
      {
         Int_t size = *bpi - start;
         TGLUtil::RenderPolyLine(*fM, p, size);
         p     += 3*size;
         start +=   size;
      }
      TGLUtil::UnlockColor();
   }

   // markers on lines
   if (fM->fRnrPoints)
   {
      TGLUtil::RenderPolyMarkers(*fM, fM->GetP(), fM->Size(),
                                 rnrCtx.GetPickRadius(),
                                 rnrCtx.Selection());
   }

   // path-marks
   const TEveTrack::vPathMark_t& pms = fTrack->RefPathMarks();
   TEveTrackPropagator& rTP = *fM->GetPropagator();
   if (pms.size())
   {
      Float_t* pnts = new Float_t[3*pms.size()]; // maximum
      Float_t*  pnt = pnts;
      Int_t   pntsN = 0;
      Bool_t accept;
      for (TEveTrack::vPathMark_ci pm = pms.begin(); pm != pms.end(); ++pm)
      {
         accept = kFALSE;
         switch (pm->fType)
         {
            case TEvePathMark::kDaughter:
               if (rTP.GetRnrDaughters())  accept = kTRUE;
               break;
            case TEvePathMark::kReference:
               if (rTP.GetRnrReferences()) accept = kTRUE;
               break;
            case TEvePathMark::kDecay:
               if (rTP.GetRnrDecay())      accept = kTRUE;
               break;
            case TEvePathMark::kCluster2D:
               if (rTP.GetRnrCluster2Ds()) accept = kTRUE;
               break;
         }
         if (accept)
         {
            if ((TMath::Abs(pm->fV.fZ) < rTP.GetMaxZ()) && (pm->fV.Perp() < rTP.GetMaxR()))
            {
               pnt[0] = pm->fV.fX;
               pnt[1] = pm->fV.fY;
               pnt[2] = pm->fV.fZ;
               fM->fProjection->ProjectPointfv(pnt, fM->fDepth);
               pnt += 3;
               ++pntsN;
            }
         }
      }
      TGLUtil::RenderPolyMarkers(rTP.RefPMAtt(), pnts, pntsN,
                                 rnrCtx.GetPickRadius(),
                                 rnrCtx.Selection());
      delete [] pnts;
   }

   // fist vertex
   if (rTP.GetRnrFV() && fTrack->GetLastPoint())
      TGLUtil::RenderPolyMarkers(rTP.RefFVAtt(), fTrack->GetP(), 1,
                                 rnrCtx.GetPickRadius(),
                                 rnrCtx.Selection());
}
 TEveTrackProjectedGL.cxx:1
 TEveTrackProjectedGL.cxx:2
 TEveTrackProjectedGL.cxx:3
 TEveTrackProjectedGL.cxx:4
 TEveTrackProjectedGL.cxx:5
 TEveTrackProjectedGL.cxx:6
 TEveTrackProjectedGL.cxx:7
 TEveTrackProjectedGL.cxx:8
 TEveTrackProjectedGL.cxx:9
 TEveTrackProjectedGL.cxx:10
 TEveTrackProjectedGL.cxx:11
 TEveTrackProjectedGL.cxx:12
 TEveTrackProjectedGL.cxx:13
 TEveTrackProjectedGL.cxx:14
 TEveTrackProjectedGL.cxx:15
 TEveTrackProjectedGL.cxx:16
 TEveTrackProjectedGL.cxx:17
 TEveTrackProjectedGL.cxx:18
 TEveTrackProjectedGL.cxx:19
 TEveTrackProjectedGL.cxx:20
 TEveTrackProjectedGL.cxx:21
 TEveTrackProjectedGL.cxx:22
 TEveTrackProjectedGL.cxx:23
 TEveTrackProjectedGL.cxx:24
 TEveTrackProjectedGL.cxx:25
 TEveTrackProjectedGL.cxx:26
 TEveTrackProjectedGL.cxx:27
 TEveTrackProjectedGL.cxx:28
 TEveTrackProjectedGL.cxx:29
 TEveTrackProjectedGL.cxx:30
 TEveTrackProjectedGL.cxx:31
 TEveTrackProjectedGL.cxx:32
 TEveTrackProjectedGL.cxx:33
 TEveTrackProjectedGL.cxx:34
 TEveTrackProjectedGL.cxx:35
 TEveTrackProjectedGL.cxx:36
 TEveTrackProjectedGL.cxx:37
 TEveTrackProjectedGL.cxx:38
 TEveTrackProjectedGL.cxx:39
 TEveTrackProjectedGL.cxx:40
 TEveTrackProjectedGL.cxx:41
 TEveTrackProjectedGL.cxx:42
 TEveTrackProjectedGL.cxx:43
 TEveTrackProjectedGL.cxx:44
 TEveTrackProjectedGL.cxx:45
 TEveTrackProjectedGL.cxx:46
 TEveTrackProjectedGL.cxx:47
 TEveTrackProjectedGL.cxx:48
 TEveTrackProjectedGL.cxx:49
 TEveTrackProjectedGL.cxx:50
 TEveTrackProjectedGL.cxx:51
 TEveTrackProjectedGL.cxx:52
 TEveTrackProjectedGL.cxx:53
 TEveTrackProjectedGL.cxx:54
 TEveTrackProjectedGL.cxx:55
 TEveTrackProjectedGL.cxx:56
 TEveTrackProjectedGL.cxx:57
 TEveTrackProjectedGL.cxx:58
 TEveTrackProjectedGL.cxx:59
 TEveTrackProjectedGL.cxx:60
 TEveTrackProjectedGL.cxx:61
 TEveTrackProjectedGL.cxx:62
 TEveTrackProjectedGL.cxx:63
 TEveTrackProjectedGL.cxx:64
 TEveTrackProjectedGL.cxx:65
 TEveTrackProjectedGL.cxx:66
 TEveTrackProjectedGL.cxx:67
 TEveTrackProjectedGL.cxx:68
 TEveTrackProjectedGL.cxx:69
 TEveTrackProjectedGL.cxx:70
 TEveTrackProjectedGL.cxx:71
 TEveTrackProjectedGL.cxx:72
 TEveTrackProjectedGL.cxx:73
 TEveTrackProjectedGL.cxx:74
 TEveTrackProjectedGL.cxx:75
 TEveTrackProjectedGL.cxx:76
 TEveTrackProjectedGL.cxx:77
 TEveTrackProjectedGL.cxx:78
 TEveTrackProjectedGL.cxx:79
 TEveTrackProjectedGL.cxx:80
 TEveTrackProjectedGL.cxx:81
 TEveTrackProjectedGL.cxx:82
 TEveTrackProjectedGL.cxx:83
 TEveTrackProjectedGL.cxx:84
 TEveTrackProjectedGL.cxx:85
 TEveTrackProjectedGL.cxx:86
 TEveTrackProjectedGL.cxx:87
 TEveTrackProjectedGL.cxx:88
 TEveTrackProjectedGL.cxx:89
 TEveTrackProjectedGL.cxx:90
 TEveTrackProjectedGL.cxx:91
 TEveTrackProjectedGL.cxx:92
 TEveTrackProjectedGL.cxx:93
 TEveTrackProjectedGL.cxx:94
 TEveTrackProjectedGL.cxx:95
 TEveTrackProjectedGL.cxx:96
 TEveTrackProjectedGL.cxx:97
 TEveTrackProjectedGL.cxx:98
 TEveTrackProjectedGL.cxx:99
 TEveTrackProjectedGL.cxx:100
 TEveTrackProjectedGL.cxx:101
 TEveTrackProjectedGL.cxx:102
 TEveTrackProjectedGL.cxx:103
 TEveTrackProjectedGL.cxx:104
 TEveTrackProjectedGL.cxx:105
 TEveTrackProjectedGL.cxx:106
 TEveTrackProjectedGL.cxx:107
 TEveTrackProjectedGL.cxx:108
 TEveTrackProjectedGL.cxx:109
 TEveTrackProjectedGL.cxx:110
 TEveTrackProjectedGL.cxx:111
 TEveTrackProjectedGL.cxx:112
 TEveTrackProjectedGL.cxx:113
 TEveTrackProjectedGL.cxx:114
 TEveTrackProjectedGL.cxx:115
 TEveTrackProjectedGL.cxx:116
 TEveTrackProjectedGL.cxx:117
 TEveTrackProjectedGL.cxx:118
 TEveTrackProjectedGL.cxx:119
 TEveTrackProjectedGL.cxx:120
 TEveTrackProjectedGL.cxx:121
 TEveTrackProjectedGL.cxx:122
 TEveTrackProjectedGL.cxx:123
 TEveTrackProjectedGL.cxx:124
 TEveTrackProjectedGL.cxx:125
 TEveTrackProjectedGL.cxx:126
 TEveTrackProjectedGL.cxx:127
 TEveTrackProjectedGL.cxx:128
 TEveTrackProjectedGL.cxx:129
 TEveTrackProjectedGL.cxx:130
 TEveTrackProjectedGL.cxx:131
 TEveTrackProjectedGL.cxx:132
 TEveTrackProjectedGL.cxx:133
 TEveTrackProjectedGL.cxx:134
 TEveTrackProjectedGL.cxx:135
 TEveTrackProjectedGL.cxx:136
 TEveTrackProjectedGL.cxx:137
 TEveTrackProjectedGL.cxx:138
 TEveTrackProjectedGL.cxx:139
 TEveTrackProjectedGL.cxx:140
 TEveTrackProjectedGL.cxx:141
 TEveTrackProjectedGL.cxx:142