2 // Author: Matevz Tadel 2007
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 **************************************************************************/
10 #include "AliEveEventManagerEditor.h"
11 #include "AliEveEventManager.h"
13 #include <AliESDEvent.h>
15 #include <TVirtualPad.h>
18 #include <TEveGValuators.h>
20 #include <TGTextView.h>
23 //______________________________________________________________________________
24 // GUI editor for AliEveEventManager.
27 ClassImp(AliEveEventManagerEditor)
29 //______________________________________________________________________________
30 AliEveEventManagerEditor::AliEveEventManagerEditor(const TGWindow *p, Int_t width, Int_t height,
31 UInt_t options, Pixel_t back) :
32 TGedFrame(p, width, height, options | kVerticalFrame, back),
39 MakeTitle("AliEveEventManager");
42 TGHorizontalFrame* f = new TGHorizontalFrame(this);
43 fNextEvent = new TGTextButton(f, "Next Event");
44 fNextEvent->SetWidth(100);
45 fNextEvent->ChangeOptions(fNextEvent->GetOptions() | kFixedWidth);
46 f->AddFrame(fNextEvent, new TGLayoutHints(kLHintsNormal, 4,0,0,0));
47 fNextEvent->Connect("Clicked()",
48 "AliEveEventManagerEditor", this, "DoNextEvent()");
49 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 8,8,8,0));
52 TGVerticalFrame* f = new TGVerticalFrame(this);
54 TGLabel *eventInfoLabel = new TGLabel(f, "Event Information:");
55 f->AddFrame(eventInfoLabel, new TGLayoutHints(kLHintsNormal, 0,0,6,2));
57 fEventInfo = new TGTextView(f, 200, 300);
58 f->AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
60 AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
64 /******************************************************************************/
66 //______________________________________________________________________________
67 void AliEveEventManagerEditor::SetModel(TObject* obj)
71 fM = dynamic_cast<AliEveEventManager*>(obj);
73 fEventInfo->LoadBuffer(fM->GetEventInfoVertical());
76 /******************************************************************************/
78 //______________________________________________________________________________
79 void AliEveEventManagerEditor::DoNextEvent()
87 //==============================================================================
88 // AliEveEventManagerWindow
89 //==============================================================================
91 //______________________________________________________________________________
93 // Horizontal GUI for AliEveEventManager, to be placed in the
94 // bottom part of ROOT browser.
96 ClassImp(AliEveEventManagerWindow)
98 AliEveEventManagerWindow::AliEveEventManagerWindow(AliEveEventManager* mgr) :
99 TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame),
115 const TString cls("AliEveEventManagerWindow");
120 TGHorizontalFrame* f = new TGHorizontalFrame(this);
121 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
123 fFirstEvent = b = MkTxtButton(f, "First", width);
124 b->Connect("Clicked()", cls, this, "DoFirstEvent()");
125 fPrevEvent = b = MkTxtButton(f, "Prev", width);
126 b->Connect("Clicked()", cls, this, "DoPrevEvent()");
128 fEventId = new TGNumberEntry(f, 0, 5, -1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
129 TGNumberFormat::kNELLimitMinMax, 0, 10000);
130 f->AddFrame(fEventId, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
131 fEventId->Connect("ValueSet(Long_t)", cls, this, "DoSetEvent()");
132 fInfoLabel = new TGLabel(f);
133 f->AddFrame(fInfoLabel, new TGLayoutHints(kLHintsNormal, 5, 10, 4, 0));
135 fNextEvent = b = MkTxtButton(f, "Next", width);
136 b->Connect("Clicked()", cls, this, "DoNextEvent()");
137 fLastEvent = b = MkTxtButton(f, "Last", width);
138 b->Connect("Clicked()", cls, this, "DoLastEvent()");
140 MkLabel(f, "||", 0, 8, 8);
142 fRefresh = b = MkTxtButton(f, "Refresh", width + 8);
143 b->Connect("Clicked()",cls, this, "DoRefresh()");
145 MkLabel(f, "||", 0, 8, 8);
147 fAutoLoad = new TGCheckButton(f, "Autoload");
148 f->AddFrame(fAutoLoad, new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0));
149 fAutoLoad->SetToolTipText("Automatic event loading.");
150 fAutoLoad->Connect("Toggled(Bool_t)", cls, this, "DoSetAutoLoad()");
152 fAutoLoadTime = new TEveGValuator(f, "Time: ", 110, 0);
153 f->AddFrame(fAutoLoadTime);
154 fAutoLoadTime->SetShowSlider(kFALSE);
155 fAutoLoadTime->SetNELength(4);
156 fAutoLoadTime->Build();
157 fAutoLoadTime->SetLimits(0, 1000);
158 fAutoLoadTime->SetToolTip("Automatic event loading time in seconds.");
159 fAutoLoadTime->Connect("ValueSet(Double_t)", cls, this, "DoSetAutoLoadTime()");
161 fTrigSel = new TGComboBox(f);
162 fTrigSel->Resize(4*width,b->GetDefaultHeight());
163 fTrigSel->AddEntry("No trigger selection",-1);
164 fTrigSel->Select(-1,kFALSE);
165 f->AddFrame(fTrigSel, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
166 fTrigSel->Connect("Selected(char*)", cls, this, "DoSetTrigSel()");
169 fEventInfo = new TGTextView(this, 400, 600);
170 AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
172 fM->Connect("NewEventLoaded()", cls, this, "Update()");
174 SetCleanup(kDeepCleanup);
180 //______________________________________________________________________________
181 AliEveEventManagerWindow::~AliEveEventManagerWindow()
185 fM->Disconnect("NewEventLoaded()", this);
188 //______________________________________________________________________________
189 void AliEveEventManagerWindow::DoFirstEvent()
191 // Load previous event
195 //______________________________________________________________________________
196 void AliEveEventManagerWindow::DoPrevEvent()
198 // Load previous event
202 //______________________________________________________________________________
203 void AliEveEventManagerWindow::DoNextEvent()
209 //______________________________________________________________________________
210 void AliEveEventManagerWindow::DoLastEvent()
212 // Load previous event
216 //______________________________________________________________________________
217 void AliEveEventManagerWindow::DoSetEvent()
220 fM->GotoEvent((Int_t) fEventId->GetNumber());
223 //______________________________________________________________________________
224 void AliEveEventManagerWindow::DoRefresh()
226 // Refresh event status.
228 Int_t ev = fM->GetEventId();
234 //______________________________________________________________________________
235 void AliEveEventManagerWindow::DoSetAutoLoad()
237 // Set the auto-load flag
239 fM->SetAutoLoad(fAutoLoad->IsOn());
243 //______________________________________________________________________________
244 void AliEveEventManagerWindow::DoSetAutoLoadTime()
246 // Set the auto-load time in seconds
248 fM->SetAutoLoadTime(fAutoLoadTime->GetValue());
251 //______________________________________________________________________________
252 void AliEveEventManagerWindow::DoSetTrigSel()
254 // Set the trigger selection
256 fM->SetTrigSel(fTrigSel->GetSelectedEntry()->EntryId());
259 //______________________________________________________________________________
260 void AliEveEventManagerWindow::Update()
262 // Update current event, number of available events, list of active triggers
264 Bool_t autoLoad = fM->GetAutoLoad();
265 Bool_t extCtrl = fM->IsUnderExternalControl();
266 Bool_t evNavOn = !autoLoad && !extCtrl;
268 fFirstEvent->SetEnabled(evNavOn);
269 fPrevEvent ->SetEnabled(evNavOn);
270 fLastEvent ->SetEnabled(evNavOn);
271 fNextEvent ->SetEnabled(!autoLoad);
272 fRefresh ->SetEnabled(evNavOn);
274 fEventId->SetNumber(fM->GetEventId());
275 fEventId->SetState(evNavOn);
276 fInfoLabel->SetText(Form("/ %d", fM->GetMaxEventId()));
278 fAutoLoad->SetState(fM->GetAutoLoad() ? kButtonDown : kButtonUp);
279 fAutoLoadTime->SetValue(fM->GetAutoLoadTime());
281 // Loop over active trigger classes
283 for(Int_t iTrig = 0; iTrig < AliESDRun::kNTriggerClasses; iTrig++) {
284 TString trigName = fM->GetESD()->GetESDRun()->GetTriggerClass(iTrig);
285 if (trigName.IsNull()) {
286 if (fTrigSel->GetListBox()->GetEntry(iTrig)) {
287 if (fTrigSel->GetSelected() == iTrig) fTrigSel->Select(-1);
288 fTrigSel->RemoveEntry(iTrig);
292 if (!fTrigSel->FindEntry(trigName.Data()))
293 fTrigSel->AddEntry(trigName.Data(),iTrig);
296 fTrigSel->SetEnabled(!evNavOn);
298 fEventInfo->LoadBuffer(fM->GetEventInfoHorizontal());
303 //------------------------------------------------------------------------------
305 //------------------------------------------------------------------------------
307 //______________________________________________________________________________
308 TGTextButton* AliEveEventManagerWindow::MkTxtButton(TGCompositeFrame* p,
309 const char* txt, Int_t width,
310 Int_t lo, Int_t ro, Int_t to, Int_t bo)
312 // Create a standard button.
313 // If width is not zero, the fixed-width flag is set.
315 TGTextButton* b = new TGTextButton(p, txt);
318 b->ChangeOptions(b->GetOptions() | kFixedWidth);
320 p->AddFrame(b, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
324 //______________________________________________________________________________
325 TGLabel* AliEveEventManagerWindow::MkLabel(TGCompositeFrame* p,
326 const char* txt, Int_t width,
327 Int_t lo, Int_t ro, Int_t to, Int_t bo)
329 // Create a standard button.
330 // If width is not zero, the fixed-width flag is set.
332 TGLabel* l = new TGLabel(p, txt);
335 l->ChangeOptions(l->GetOptions() | kFixedWidth);
337 p->AddFrame(l, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));