List event tab embedded in left panel of ED + other minor changes.
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveEventManagerEditor.cxx
CommitLineData
5655e9ce 1// @(#)root/eve:$Id$
2// Author: Matevz Tadel 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 "AliEveEventManagerEditor.h"
11#include "AliEveEventManager.h"
12
b3b7b8d3 13#include <AliESDEvent.h>
14
15#include <TVirtualPad.h>
5655e9ce 16#include "TColor.h"
17
319f3084 18#include <TEveGValuators.h>
19#include <TGButton.h>
20#include <TGTextView.h>
21#include <TGLabel.h>
5655e9ce 22
fa6aa785 23#include "Riostream.h"
24
5655e9ce 25//______________________________________________________________________________
26// GUI editor for AliEveEventManager.
27//
28
f65f2d99 29using std::ofstream;
30using std::ios;
5655e9ce 31ClassImp(AliEveEventManagerEditor)
32
33//______________________________________________________________________________
34AliEveEventManagerEditor::AliEveEventManagerEditor(const TGWindow *p, Int_t width, Int_t height,
80547f2d 35 UInt_t options, Pixel_t back) :
5655e9ce 36 TGedFrame(p, width, height, options | kVerticalFrame, back),
319f3084 37 fM(0),
fa6aa785 38 fDumpEventInfo(0),
319f3084 39 fEventInfo(0)
5655e9ce 40{
41 // Constructor.
42
43 MakeTitle("AliEveEventManager");
44
319f3084 45 {
46 TGHorizontalFrame* f = new TGHorizontalFrame(this);
fa6aa785 47 fDumpEventInfo = new TGTextButton(f, "Dump Event Info");
48 fDumpEventInfo->SetToolTipText("Append information about current event to event_info.txt file.");
49 fDumpEventInfo->SetWidth(120);
50 fDumpEventInfo->ChangeOptions(fDumpEventInfo->GetOptions() | kFixedWidth);
51 f->AddFrame(fDumpEventInfo, new TGLayoutHints(kLHintsNormal, 4,0,0,0));
52 fDumpEventInfo->Connect("Clicked()",
53 "AliEveEventManagerEditor", this, "DumpEventInfo()");
319f3084 54 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 8,8,8,0));
55 }
ca49b003 56 {
319f3084 57 TGVerticalFrame* f = new TGVerticalFrame(this);
58
59 TGLabel *eventInfoLabel = new TGLabel(f, "Event Information:");
60 f->AddFrame(eventInfoLabel, new TGLayoutHints(kLHintsNormal, 0,0,6,2));
61
ec835ab5 62 fEventInfo = new TGTextView(f, 200, 300);
319f3084 63 f->AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
64
65 AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
66 }
5655e9ce 67}
68
69/******************************************************************************/
70
80547f2d 71//______________________________________________________________________________
5655e9ce 72void AliEveEventManagerEditor::SetModel(TObject* obj)
73{
74 // Set model object.
75
04a6d27f 76 fM = static_cast<AliEveEventManager*>(obj);
5655e9ce 77
12365217 78 fEventInfo->LoadBuffer(fM->GetEventInfoVertical());
5655e9ce 79}
80
81/******************************************************************************/
82
319f3084 83//______________________________________________________________________________
fa6aa785 84void AliEveEventManagerEditor::DumpEventInfo()
319f3084 85{
fa6aa785 86 // Dump event-info into event_info.txt.
87 // The info is appended into the file.
88
89 ofstream f("event_info.txt", ios::out | ios::app);
90
91 f << "================================================================================\n\n";
92 f << fM->GetEventInfoHorizontal() << std::endl << std::endl;
ca49b003 93
fa6aa785 94 f.close();
ca49b003 95}
f76c9e9b 96
97
80547f2d 98//==============================================================================
f76c9e9b 99// AliEveEventManagerWindow
80547f2d 100//==============================================================================
f76c9e9b 101
102//______________________________________________________________________________
103//
104// Horizontal GUI for AliEveEventManager, to be placed in the
105// bottom part of ROOT browser.
106
107ClassImp(AliEveEventManagerWindow)
108
4d62585e 109AliEveEventManagerWindow::AliEveEventManagerWindow(AliEveEventManager* mgr) :
12365217 110 TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame),
4d62585e 111 fM (mgr),
80547f2d 112 fFirstEvent (0),
113 fPrevEvent (0),
114 fNextEvent (0),
115 fLastEvent (0),
116 fRefresh (0),
117 fEventId (0),
118 fInfoLabel (0),
119 fAutoLoad (0),
120 fAutoLoadTime (0),
969d3431 121 fTrigSel (0),
80547f2d 122 fEventInfo (0)
f76c9e9b 123{
124 // Constructor.
125
488869c1 126 const TString cls("AliEveEventManagerWindow");
80547f2d 127 TGTextButton *b = 0;
f76c9e9b 128 {
129 Int_t width = 50;
130
131 TGHorizontalFrame* f = new TGHorizontalFrame(this);
80547f2d 132 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
133
134 fFirstEvent = b = MkTxtButton(f, "First", width);
135 b->Connect("Clicked()", cls, this, "DoFirstEvent()");
136 fPrevEvent = b = MkTxtButton(f, "Prev", width);
137 b->Connect("Clicked()", cls, this, "DoPrevEvent()");
f76c9e9b 138
139 fEventId = new TGNumberEntry(f, 0, 5, -1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
140 TGNumberFormat::kNELLimitMinMax, 0, 10000);
141 f->AddFrame(fEventId, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
80547f2d 142 fEventId->Connect("ValueSet(Long_t)", cls, this, "DoSetEvent()");
f76c9e9b 143 fInfoLabel = new TGLabel(f);
144 f->AddFrame(fInfoLabel, new TGLayoutHints(kLHintsNormal, 5, 10, 4, 0));
145
80547f2d 146 fNextEvent = b = MkTxtButton(f, "Next", width);
147 b->Connect("Clicked()", cls, this, "DoNextEvent()");
148 fLastEvent = b = MkTxtButton(f, "Last", width);
149 b->Connect("Clicked()", cls, this, "DoLastEvent()");
164d3d29 150 fMarkEvent = b = MkTxtButton(f, "Mark", width);
151 b->Connect("Clicked()", cls, this, "DoMarkEvent()");
f76c9e9b 152
80547f2d 153 MkLabel(f, "||", 0, 8, 8);
154
155 fRefresh = b = MkTxtButton(f, "Refresh", width + 8);
156 b->Connect("Clicked()",cls, this, "DoRefresh()");
157
158 MkLabel(f, "||", 0, 8, 8);
159
160 fAutoLoad = new TGCheckButton(f, "Autoload");
161 f->AddFrame(fAutoLoad, new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0));
162 fAutoLoad->SetToolTipText("Automatic event loading.");
163 fAutoLoad->Connect("Toggled(Bool_t)", cls, this, "DoSetAutoLoad()");
164
165 fAutoLoadTime = new TEveGValuator(f, "Time: ", 110, 0);
ecb84424 166 f->AddFrame(fAutoLoadTime);
80547f2d 167 fAutoLoadTime->SetShowSlider(kFALSE);
168 fAutoLoadTime->SetNELength(4);
169 fAutoLoadTime->Build();
170 fAutoLoadTime->SetLimits(0, 1000);
171 fAutoLoadTime->SetToolTip("Automatic event loading time in seconds.");
172 fAutoLoadTime->Connect("ValueSet(Double_t)", cls, this, "DoSetAutoLoadTime()");
ecb84424 173
969d3431 174 fTrigSel = new TGComboBox(f);
175 fTrigSel->Resize(4*width,b->GetDefaultHeight());
176 fTrigSel->AddEntry("No trigger selection",-1);
177 fTrigSel->Select(-1,kFALSE);
178 f->AddFrame(fTrigSel, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
179 fTrigSel->Connect("Selected(char*)", cls, this, "DoSetTrigSel()");
12365217 180
0790c3e6 181 fStorageStatus = MkLabel(f,"Storage: Waiting",0,8,8);
182
183 }
184
80547f2d 185 fEventInfo = new TGTextView(this, 400, 600);
186 AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
187
4d62585e 188 fM->Connect("NewEventLoaded()", cls, this, "Update()");
0790c3e6 189 fM->Connect("StorageManagerOk()",cls,this,"StorageManagerChangedState(=1)");
190 fM->Connect("StorageManagerDown()",cls,this,"StorageManagerChangedState(=0)");
f76c9e9b 191
192 SetCleanup(kDeepCleanup);
193 Layout();
194 MapSubwindows();
195 MapWindow();
196}
197
198//______________________________________________________________________________
199AliEveEventManagerWindow::~AliEveEventManagerWindow()
200{
201 // Destructor.
202
4d62585e 203 fM->Disconnect("NewEventLoaded()", this);
f76c9e9b 204}
205
206//______________________________________________________________________________
207void AliEveEventManagerWindow::DoFirstEvent()
208{
209 // Load previous event
4d62585e 210 fM->GotoEvent(0);
f76c9e9b 211}
212
213//______________________________________________________________________________
214void AliEveEventManagerWindow::DoPrevEvent()
215{
216 // Load previous event
a410aca4 217 // fM->PrevEvent();
218 fM->GotoEvent(1);
219
f76c9e9b 220}
221
222//______________________________________________________________________________
223void AliEveEventManagerWindow::DoNextEvent()
224{
225 // Load next event
a410aca4 226 // fM->NextEvent();
227 fM->GotoEvent(2);
228
f76c9e9b 229}
230
231//______________________________________________________________________________
232void AliEveEventManagerWindow::DoLastEvent()
233{
234 // Load previous event
4d62585e 235 fM->GotoEvent(-1);
f76c9e9b 236}
237
238//______________________________________________________________________________
164d3d29 239void AliEveEventManagerWindow::DoMarkEvent()
240{
241 // Mark current event
242 fM->MarkCurrentEvent();
243}
244
245//______________________________________________________________________________
f76c9e9b 246void AliEveEventManagerWindow::DoSetEvent()
247{
248 // Set current event
4d62585e 249 fM->GotoEvent((Int_t) fEventId->GetNumber());
f76c9e9b 250}
251
252//______________________________________________________________________________
80547f2d 253void AliEveEventManagerWindow::DoRefresh()
254{
255 // Refresh event status.
256
4d62585e 257 Int_t ev = fM->GetEventId();
258 fM->Close();
259 fM->Open();
260 fM->GotoEvent(ev);
80547f2d 261}
262
263//______________________________________________________________________________
264void AliEveEventManagerWindow::DoSetAutoLoad()
265{
266 // Set the auto-load flag
267
4d62585e 268 fM->SetAutoLoad(fAutoLoad->IsOn());
80547f2d 269 Update();
270}
271
272//______________________________________________________________________________
273void AliEveEventManagerWindow::DoSetAutoLoadTime()
274{
275 // Set the auto-load time in seconds
276
4d62585e 277 fM->SetAutoLoadTime(fAutoLoadTime->GetValue());
80547f2d 278}
279
280//______________________________________________________________________________
969d3431 281void AliEveEventManagerWindow::DoSetTrigSel()
282{
283 // Set the trigger selection
284
285 fM->SetTrigSel(fTrigSel->GetSelectedEntry()->EntryId());
286}
287
288//______________________________________________________________________________
f76c9e9b 289void AliEveEventManagerWindow::Update()
290{
ecb84424 291 // Update current event, number of available events, list of active triggers
f76c9e9b 292
4d62585e 293 Bool_t autoLoad = fM->GetAutoLoad();
294 Bool_t extCtrl = fM->IsUnderExternalControl();
80547f2d 295 Bool_t evNavOn = !autoLoad && !extCtrl;
296
a410aca4 297 // fFirstEvent->SetEnabled(evNavOn);
298 // fPrevEvent ->SetEnabled(evNavOn);
299 // fLastEvent ->SetEnabled(evNavOn);
300 fFirstEvent->SetEnabled(!autoLoad);
301 fPrevEvent ->SetEnabled(!autoLoad);
302 fLastEvent ->SetEnabled(!autoLoad);
80547f2d 303 fNextEvent ->SetEnabled(!autoLoad);
304 fRefresh ->SetEnabled(evNavOn);
305
4d62585e 306 fEventId->SetNumber(fM->GetEventId());
80547f2d 307 fEventId->SetState(evNavOn);
4d62585e 308 fInfoLabel->SetText(Form("/ %d", fM->GetMaxEventId()));
12365217 309
4d62585e 310 fAutoLoad->SetState(fM->GetAutoLoad() ? kButtonDown : kButtonUp);
311 fAutoLoadTime->SetValue(fM->GetAutoLoadTime());
80547f2d 312
969d3431 313 // Loop over active trigger classes
314 if (fM->GetESD()) {
315 for(Int_t iTrig = 0; iTrig < AliESDRun::kNTriggerClasses; iTrig++) {
316 TString trigName = fM->GetESD()->GetESDRun()->GetTriggerClass(iTrig);
317 if (trigName.IsNull()) {
318 if (fTrigSel->GetListBox()->GetEntry(iTrig)) {
319 if (fTrigSel->GetSelected() == iTrig) fTrigSel->Select(-1);
320 fTrigSel->RemoveEntry(iTrig);
321 }
322 continue;
323 }
324 if (!fTrigSel->FindEntry(trigName.Data()))
325 fTrigSel->AddEntry(trigName.Data(),iTrig);
326 }
327 }
328 fTrigSel->SetEnabled(!evNavOn);
329
4d62585e 330 fEventInfo->LoadBuffer(fM->GetEventInfoHorizontal());
12365217 331
f76c9e9b 332 Layout();
333}
80547f2d 334
0790c3e6 335void AliEveEventManagerWindow::StorageManagerChangedState(int state)
336{
337 if (state == 0)
338 {
339 fStorageStatus->SetText("Storage: DOWN");
340 fMarkEvent->SetEnabled(false);
fae81379 341 fNextEvent->SetEnabled(false);
342 fLastEvent->SetEnabled(false);
343 fPrevEvent->SetEnabled(false);
344 fFirstEvent->SetEnabled(false);
0790c3e6 345 }
346 else if(state == 1)
347 {
348 fStorageStatus->SetText("Storage: OK");
349 fMarkEvent->SetEnabled(true);
fae81379 350 fNextEvent->SetEnabled(true);
351 fLastEvent->SetEnabled(true);
352 fPrevEvent->SetEnabled(true);
353 fFirstEvent->SetEnabled(true);
0790c3e6 354 }
355}
356
80547f2d 357//------------------------------------------------------------------------------
358// Protected methods
359//------------------------------------------------------------------------------
360
361//______________________________________________________________________________
362TGTextButton* AliEveEventManagerWindow::MkTxtButton(TGCompositeFrame* p,
363 const char* txt, Int_t width,
364 Int_t lo, Int_t ro, Int_t to, Int_t bo)
365{
366 // Create a standard button.
367 // If width is not zero, the fixed-width flag is set.
368
369 TGTextButton* b = new TGTextButton(p, txt);
370 if (width > 0) {
371 b->SetWidth(width);
372 b->ChangeOptions(b->GetOptions() | kFixedWidth);
373 }
374 p->AddFrame(b, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
375 return b;
376}
377
378//______________________________________________________________________________
379TGLabel* AliEveEventManagerWindow::MkLabel(TGCompositeFrame* p,
380 const char* txt, Int_t width,
381 Int_t lo, Int_t ro, Int_t to, Int_t bo)
382{
383 // Create a standard button.
384 // If width is not zero, the fixed-width flag is set.
385
386 TGLabel* l = new TGLabel(p, txt);
387 if (width > 0) {
388 l->SetWidth(width);
389 l->ChangeOptions(l->GetOptions() | kFixedWidth);
390 }
391 p->AddFrame(l, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
392 return l;
393}
ecb84424 394