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