a1735bce96f6ef05349cbf4e53ddf557fdf43993
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveHOMERSourceList.cxx
1 // $Id$
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 #include "AliEveHOMERSourceList.h"
11 #include "AliEveHOMERSourceMap.h"
12 #include "AliEveHOMERManager.h"
13
14 //______________________________________________________________________________
15 // AliEveHOMERSourceList
16 //
17
18 ClassImp(AliEveHOMERSourceList)
19
20 AliEveHOMERSourceList::AliEveHOMERSourceList(const Text_t* n, const Text_t* t) :
21   TEveElementList(n, t),
22   fManager (0),
23   fSrcMap  (0)
24 {
25
26 }
27
28 AliEveHOMERSourceList::~AliEveHOMERSourceList()
29 {
30   // !!!!! delete maps
31 }
32
33 /******************************************************************************/
34
35 void AliEveHOMERSourceList::CreateByDet()
36 {
37   delete fSrcMap;
38   fSrcMap = AliEveHOMERSourceMap::Create(AliEveHOMERSourceMap::kSG_ByDet);
39   RebuildSourceReps();
40 }
41
42 void AliEveHOMERSourceList::CreateByType()
43 {
44   delete fSrcMap;
45   fSrcMap = AliEveHOMERSourceMap::Create(AliEveHOMERSourceMap::kSG_ByType);
46   RebuildSourceReps();
47 }
48
49 void AliEveHOMERSourceList::RebuildSourceReps()
50 {
51   DestroyElements();
52   // !!!! if fManager ?
53   // ???? fManager->CreateHOMERSourcesList();
54   TList* srcList = fManager->GetSourceList();
55   fSrcMap->FillMap(srcList, 1);
56
57   List_t parentStack;
58   parentStack.push_back(this);
59   Int_t parentLvl = 1;
60   for (AliEveHOMERSourceMap::iterator i=fSrcMap->begin(); i!=fSrcMap->end(); ++i)
61   {
62     while (parentLvl > i.level()) { parentStack.pop_back(); --parentLvl; }
63
64     AliEveHOMERSource* src = new AliEveHOMERSource(i.description());
65     src->SetSource(&i.id(), &i.state());
66
67     parentStack.back()->AddElement(src);
68
69     parentStack.push_back(src); ++parentLvl;
70
71     printf("%*s%s [state=%d, handle=0x%lx] {ssdet='%s'}\n", 4*i.level(), "",
72            i.description().Data(), i.state().fState,
73            (ULong_t) i.state().fHandle,
74            i.id().fSSDet.Data());
75   }
76 }
77
78 /******************************************************************************/
79 /*
80 void AliEveHOMERSourceList::SelectAll()
81 {
82   EnableListElements(kTRUE, kTRUE);
83 }
84
85 void AliEveHOMERSourceList::DeselectAll()
86 {
87   DisableListElements (kFALSE, kFALSE);
88 }
89 */