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