AliRoot Core  a565103 (a565103)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONPainterRegistry.cxx
Go to the documentation of this file.
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 
20 #include "AliMpManuIterator.h"
21 #include "AliMUON2DMap.h"
22 #include "AliMUONCalibParamND.h"
23 #include "AliMUONPainterMatrix.h"
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 
38 
39 using std::cout;
40 using std::endl;
44 
46 
47 //_____________________________________________________________________________
49 fPainterMatrices(new TObjArray),
50 fHistoryMenu(0x0),
51 fMenuBar(0x0),
52 fHistoryCounter(0)
53 {
55  fPainterMatrices->SetOwner(kTRUE);
56 }
57 
58 //_____________________________________________________________________________
60 {
62  delete fPainterMatrices;
63 }
64 
65 //_____________________________________________________________________________
66 Int_t
68 {
70  return fPainterMatrices->IndexOf(group);
71 }
72 
73 //_____________________________________________________________________________
76 {
78  return static_cast<AliMUONPainterMatrix*>(fPainterMatrices->FindObject(name));
79 }
80 
81 //_____________________________________________________________________________
82 void
84 {
86 
87  TGMenuEntry* entry = fHistoryMenu->GetEntry(i);
88 
89  AliMUONPainterMatrix* group = reinterpret_cast<AliMUONPainterMatrix*>(entry->GetUserData());
90 
92 }
93 
94 //_____________________________________________________________________________
97 {
100  return fgInstance;
101 }
102 
103 //_____________________________________________________________________________
106 {
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 //_____________________________________________________________________________
120 void
122 {
124  Long_t param[] = { (Long_t)group };
125 
126  Emit("PainterMatrixWantToShow(AliMUONPainterMatrix*)",param);
127 }
128 
129 //_____________________________________________________________________________
130 void
132 {
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 
147  if ( fHistoryMenu )
148  {
149  TIter next(fHistoryMenu->GetListOfEntries());
150  TGMenuEntry* e(0x0);
151 
152  while ( ( e = static_cast<TGMenuEntry*>(next()) ) )
153  {
154  if ( e->GetUserData() == group )
155  {
156  fHistoryMenu->DeleteEntry(e);
157  break;
158  }
159  }
160 
161  e = static_cast<TGMenuEntry*>(fHistoryMenu->GetListOfEntries()->First());
162 
163  fHistoryMenu->AddEntry(group->GetName(),++fHistoryCounter,(void*)group,0x0,e);
164  }
165  else
166  {
167  AliError("fHistoryMenu is null. We probably did not find the relevant menu entry ?");
168  }
169 }
170 
171 //_____________________________________________________________________________
172 void
174 {
176  Long_t param[] = { (Long_t)group };
177 
178  Emit("PainterMatrixWasRegistered(AliMUONPainterMatrix*)",param);
179 }
180 
181 //_____________________________________________________________________________
182 void
184 {
186  Long_t param[] = { (Long_t)group };
187 
188  Emit("PainterMatrixWasUnregistered(AliMUONPainterMatrix*)",param);
189 }
190 
191 //_____________________________________________________________________________
192 void
193 AliMUONPainterRegistry::Print(Option_t* opt) const
194 {
196  TString sopt(opt);
197  sopt.ToUpper();
198 
199  cout << "Number of painter matrices = " << NumberOfPainterMatrices() << endl;
200 
201  if ( sopt.Contains("FULL") || sopt.Contains("MATRIX") )
202  {
203  TIter next(fPainterMatrices);
204  AliMUONPainterMatrix* matrix;
205 
206  while ( ( matrix = static_cast<AliMUONPainterMatrix*>(next()) ) )
207  {
208  matrix->Print();
209  }
210  }
211 
212 }
213 
214 //_____________________________________________________________________________
215 Int_t
217 {
219  fPainterMatrices->AddLast(group);
220 
222 
223  return fPainterMatrices->IndexOf(group);
224 }
225 
226 //_____________________________________________________________________________
227 Int_t
229 {
231  return fPainterMatrices->GetLast()+1;
232 }
233 
234 //_____________________________________________________________________________
235 Bool_t
237 {
239 
240  if (!group) return kFALSE;
241 
243 
244  TObject* o = fPainterMatrices->Remove(group);
245  if ( o )
246  {
247  delete o;
248  }
249  else
250  {
251  AliError(Form("Could not unregister group named %s",group->GetName()));
252  }
253  return ( o != 0x0 );
254 }
virtual const char * GetName() const
Get matrix name.
#define TObjArray
void Print(Option_t *opt) const
TObjArray * fPainterMatrices
painter matrices
AliMUONPainterRegistry()
Not implemented.
Int_t Register(AliMUONPainterMatrix *group)
void PainterMatrixWasUnregistered(const AliMUONPainterMatrix *group)
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
static AliMUONPainterRegistry * Instance()
static AliMUONPainterRegistry * fgInstance
unique instance
void PainterMatrixWantToShow(const AliMUONPainterMatrix *group)
Int_t FindIndexOf(AliMUONPainterMatrix *group) const
Int_t fHistoryCounter
index to get back history menu items
TGMenuBar * fMenuBar
Menu bar where to put the history menu.
Registry for a bunch of AliMUONVPainter related stuff.
TGPopupMenu * fHistoryMenu
history menu
void PainterMatrixWasRegistered(const AliMUONPainterMatrix *group)
void AddToHistory(AliMUONPainterMatrix *group)
AliMUONPainterMatrix * PainterMatrix(Int_t i) const
A matrix of AliMUONVPainter.
void Print(Option_t *opt="") const
Printout.
Bool_t Unregister(AliMUONPainterMatrix *group)