]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONPainterRegistry.cxx
Removing usage of deprecated AliMUONRawStreamTracker
[u/mrichter/AliRoot.git] / MUON / AliMUONPainterRegistry.cxx
CommitLineData
0145e89a 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
7* Permission to use, copy, modify and distribute this software and its *
8* documentation strictly for non-commercial purposes is hereby granted *
9* without fee, provided that the above copyright notice appears in all *
10* copies and that both the copyright notice and this permission notice *
11* appear in the supporting documentation. The authors make no claims *
12* about the suitability of this software for any purpose. It is *
13* provided "as is" without express or implied warranty. *
14**************************************************************************/
15
16// $Id$
17
18#include "AliMUONPainterRegistry.h"
19
1ffbeb9d 20#include "AliMpManuIterator.h"
21#include "AliMUON2DMap.h"
22#include "AliMUONCalibParamND.h"
0145e89a 23#include "AliMUONPainterMatrix.h"
0145e89a 24#include "AliLog.h"
25#include <TGMenu.h>
26#include <TGWindow.h>
27#include <THashList.h>
28#include <TObjArray.h>
29#include <TString.h>
30#include <Riostream.h>
31
32///\class AliMUONPainterRegistry
33///
34/// Registry for AliMUONVPainter related stuff : painter data sources
35/// and painter matrices
36///
37///\author Laurent Aphecetche, Subatech
38
39///\cond CLASSIMP
40ClassImp(AliMUONPainterRegistry)
41///\endcond
42
43AliMUONPainterRegistry* AliMUONPainterRegistry::fgInstance(0x0);
44
45//_____________________________________________________________________________
4a3224ff 46AliMUONPainterRegistry::AliMUONPainterRegistry() : TObject(), TQObject(),
0145e89a 47fPainterMatrices(new TObjArray),
0145e89a 48fHistoryMenu(0x0),
49fMenuBar(0x0),
8f0acce4 50fHistoryCounter(0)
0145e89a 51{
52 /// ctor
0145e89a 53 fPainterMatrices->SetOwner(kTRUE);
0145e89a 54}
55
56//_____________________________________________________________________________
57AliMUONPainterRegistry::~AliMUONPainterRegistry()
58{
59 /// dtor
0145e89a 60 delete fPainterMatrices;
0145e89a 61}
62
63//_____________________________________________________________________________
64Int_t
65AliMUONPainterRegistry::FindIndexOf(AliMUONPainterMatrix* group) const
66{
67 /// Get the index of a given painterMatrix
68 return fPainterMatrices->IndexOf(group);
69}
70
0145e89a 71//_____________________________________________________________________________
72AliMUONPainterMatrix*
49419555 73AliMUONPainterRegistry::PainterMatrix(const char* name) const
0145e89a 74{
75 /// Get a painterMatrix by name
76 return static_cast<AliMUONPainterMatrix*>(fPainterMatrices->FindObject(name));
77}
78
79//_____________________________________________________________________________
80void
81AliMUONPainterRegistry::HistoryMenuActivated(Int_t i)
82{
83 /// A painterMatrix was chosen from the history menu
84
85 AliDebug(1,Form("i=%d",i));
86
87 TGMenuEntry* entry = fHistoryMenu->GetEntry(i);
88
89 AliMUONPainterMatrix* group = reinterpret_cast<AliMUONPainterMatrix*>(entry->GetUserData());
90
91 PainterMatrixWantToShow(group);
92}
93
94//_____________________________________________________________________________
95AliMUONPainterRegistry*
96AliMUONPainterRegistry::Instance()
97{
98 /// Get unique instance of this class
99 if ( !fgInstance ) fgInstance = new AliMUONPainterRegistry;
100 return fgInstance;
101}
102
103//_____________________________________________________________________________
104AliMUONPainterMatrix*
105AliMUONPainterRegistry::PainterMatrix(Int_t i) const
106{
107 /// Get one painter matrix
108 if ( i >= 0 && i <= fPainterMatrices->GetLast() )
109 {
110 return static_cast<AliMUONPainterMatrix*>(fPainterMatrices->At(i));
111 }
112 else
113 {
114 AliError(Form("Index out of bounds : %d / %d",i,fPainterMatrices->GetLast()+1));
115 return 0x0;
116 }
117}
118
119//_____________________________________________________________________________
120void
8f0acce4 121AliMUONPainterRegistry::PainterMatrixWantToShow(AliMUONPainterMatrix* group)
0145e89a 122{
123 /// A given paintermatrix want to appear on screen
124 Long_t param[] = { (Long_t)group };
125
126 Emit("PainterMatrixWantToShow(AliMUONPainterMatrix*)",param);
127}
128
129//_____________________________________________________________________________
130void
131AliMUONPainterRegistry::AddToHistory(AliMUONPainterMatrix* group)
132{
133 /// Add a matrix to the history
134
135 if ( !fHistoryMenu && fMenuBar )
136 {
137 fHistoryMenu = new TGPopupMenu(gClient->GetRoot());
138 TGPopupMenu* before = 0x0; //FIXME: could try to find a place where to put it (e.g. before Help ?)
139
140 fMenuBar->AddPopup("&History",fHistoryMenu, new TGLayoutHints(kLHintsNormal),before);
141
142 fHistoryMenu->Connect("Activated(Int_t)",
143 "AliMUONPainterRegistry",this,
144 "HistoryMenuActivated(Int_t)");
145
146 AliDebug(1,Form("HistoryMenu create at %x",fHistoryMenu));
147 }
148
149 if ( fHistoryMenu )
150 {
151 TIter next(fHistoryMenu->GetListOfEntries());
152 TGMenuEntry* e(0x0);
153
154 while ( ( e = static_cast<TGMenuEntry*>(next()) ) )
155 {
156 if ( e->GetUserData() == group )
157 {
158 fHistoryMenu->DeleteEntry(e);
159 break;
160 }
161 }
162
163 e = static_cast<TGMenuEntry*>(fHistoryMenu->GetListOfEntries()->First());
164
165 fHistoryMenu->AddEntry(group->GetName(),++fHistoryCounter,(void*)group,0x0,e);
166 }
167 else
168 {
169 AliError("fHistoryMenu is null. We probably did not find the relevant menu entry ?");
170 }
171}
172
173//_____________________________________________________________________________
174void
8f0acce4 175AliMUONPainterRegistry::PainterMatrixWasRegistered(AliMUONPainterMatrix* group)
0145e89a 176{
177 /// A new painter matrix was registered
178 Long_t param[] = { (Long_t)group };
179
180 Emit("PainterMatrixWasRegistered(AliMUONPainterMatrix*)",param);
181}
182
183//_____________________________________________________________________________
184void
8f0acce4 185AliMUONPainterRegistry::PainterMatrixWasUnregistered(AliMUONPainterMatrix* group)
0145e89a 186{
187 /// A painter matrix was unregistered
188 Long_t param[] = { (Long_t)group };
189
190 Emit("PainterMatrixWasUnregistered(AliMUONPainterMatrix*)",param);
191}
192
193//_____________________________________________________________________________
194void
195AliMUONPainterRegistry::Print(Option_t* opt) const
196{
197 /// Printout
198 TString sopt(opt);
199 sopt.ToUpper();
200
0145e89a 201 cout << "Number of painter matrices = " << NumberOfPainterMatrices() << endl;
202
0145e89a 203 if ( sopt.Contains("FULL") || sopt.Contains("MATRIX") )
204 {
205 TIter next(fPainterMatrices);
206 AliMUONPainterMatrix* matrix;
207
208 while ( ( matrix = static_cast<AliMUONPainterMatrix*>(next()) ) )
209 {
210 matrix->Print();
211 }
212 }
213
214}
215
216//_____________________________________________________________________________
217Int_t
218AliMUONPainterRegistry::Register(AliMUONPainterMatrix* group)
219{
220 /// group is adopted, i.e. the registry becomes the owner of it.
221 fPainterMatrices->AddLast(group);
222
223 PainterMatrixWasRegistered(group);
224
225 return fPainterMatrices->IndexOf(group);
226}
227
0145e89a 228//_____________________________________________________________________________
229Int_t
230AliMUONPainterRegistry::NumberOfPainterMatrices() const
231{
232 /// The number of painter matrices we handle
233 return fPainterMatrices->GetLast()+1;
234}
235
0145e89a 236//_____________________________________________________________________________
237Bool_t
238AliMUONPainterRegistry::Unregister(AliMUONPainterMatrix* group)
239{
240 /// Unregister some matrix
241
242 if (!group) return kFALSE;
243
244 PainterMatrixWasUnregistered(group);
245
246 TObject* o = fPainterMatrices->Remove(group);
247 if ( o )
248 {
249 delete o;
250 }
251 else
252 {
253 AliError(Form("Could not unregister group named %s",group->GetName()));
254 }
255 return ( o != 0x0 );
256}