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),
114 const TString cls("AliEveEventManagerWindow");
119 TGHorizontalFrame* f = new TGHorizontalFrame(this);
120 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
122 fFirstEvent = b = MkTxtButton(f, "First", width);
123 b->Connect("Clicked()", cls, this, "DoFirstEvent()");
124 fPrevEvent = b = MkTxtButton(f, "Prev", width);
125 b->Connect("Clicked()", cls, this, "DoPrevEvent()");
127 fEventId = new TGNumberEntry(f, 0, 5, -1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
128 TGNumberFormat::kNELLimitMinMax, 0, 10000);
129 f->AddFrame(fEventId, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
130 fEventId->Connect("ValueSet(Long_t)", cls, this, "DoSetEvent()");
131 fInfoLabel = new TGLabel(f);
132 f->AddFrame(fInfoLabel, new TGLayoutHints(kLHintsNormal, 5, 10, 4, 0));
134 fNextEvent = b = MkTxtButton(f, "Next", width);
135 b->Connect("Clicked()", cls, this, "DoNextEvent()");
136 fLastEvent = b = MkTxtButton(f, "Last", width);
137 b->Connect("Clicked()", cls, this, "DoLastEvent()");
139 MkLabel(f, "||", 0, 8, 8);
141 fRefresh = b = MkTxtButton(f, "Refresh", width + 8);
142 b->Connect("Clicked()",cls, this, "DoRefresh()");
144 MkLabel(f, "||", 0, 8, 8);
146 fAutoLoad = new TGCheckButton(f, "Autoload");
147 f->AddFrame(fAutoLoad, new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0));
148 fAutoLoad->SetToolTipText("Automatic event loading.");
149 fAutoLoad->Connect("Toggled(Bool_t)", cls, this, "DoSetAutoLoad()");
151 fAutoLoadTime = new TEveGValuator(f, "Time: ", 110, 0);
152 f->AddFrame(fAutoLoadTime);
153 fAutoLoadTime->SetShowSlider(kFALSE);
154 fAutoLoadTime->SetNELength(4);
155 fAutoLoadTime->Build();
156 fAutoLoadTime->SetLimits(0, 1000);
157 fAutoLoadTime->SetToolTip("Automatic event loading time in seconds.");
158 fAutoLoadTime->Connect("ValueSet(Double_t)", cls, this, "DoSetAutoLoadTime()");
162 fEventInfo = new TGTextView(this, 400, 600);
163 AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
165 fM->Connect("NewEventLoaded()", cls, this, "Update()");
167 SetCleanup(kDeepCleanup);
173 //______________________________________________________________________________
174 AliEveEventManagerWindow::~AliEveEventManagerWindow()
178 fM->Disconnect("NewEventLoaded()", this);
181 //______________________________________________________________________________
182 void AliEveEventManagerWindow::DoFirstEvent()
184 // Load previous event
188 //______________________________________________________________________________
189 void AliEveEventManagerWindow::DoPrevEvent()
191 // Load previous event
195 //______________________________________________________________________________
196 void AliEveEventManagerWindow::DoNextEvent()
202 //______________________________________________________________________________
203 void AliEveEventManagerWindow::DoLastEvent()
205 // Load previous event
209 //______________________________________________________________________________
210 void AliEveEventManagerWindow::DoSetEvent()
213 fM->GotoEvent((Int_t) fEventId->GetNumber());
216 //______________________________________________________________________________
217 void AliEveEventManagerWindow::DoRefresh()
219 // Refresh event status.
221 Int_t ev = fM->GetEventId();
227 //______________________________________________________________________________
228 void AliEveEventManagerWindow::DoSetAutoLoad()
230 // Set the auto-load flag
232 fM->SetAutoLoad(fAutoLoad->IsOn());
236 //______________________________________________________________________________
237 void AliEveEventManagerWindow::DoSetAutoLoadTime()
239 // Set the auto-load time in seconds
241 fM->SetAutoLoadTime(fAutoLoadTime->GetValue());
244 //______________________________________________________________________________
245 void AliEveEventManagerWindow::Update()
247 // Update current event, number of available events, list of active triggers
249 Bool_t autoLoad = fM->GetAutoLoad();
250 Bool_t extCtrl = fM->IsUnderExternalControl();
251 Bool_t evNavOn = !autoLoad && !extCtrl;
253 fFirstEvent->SetEnabled(evNavOn);
254 fPrevEvent ->SetEnabled(evNavOn);
255 fLastEvent ->SetEnabled(evNavOn);
256 fNextEvent ->SetEnabled(!autoLoad);
257 fRefresh ->SetEnabled(evNavOn);
259 fEventId->SetNumber(fM->GetEventId());
260 fEventId->SetState(evNavOn);
261 fInfoLabel->SetText(Form("/ %d", fM->GetMaxEventId()));
263 fAutoLoad->SetState(fM->GetAutoLoad() ? kButtonDown : kButtonUp);
264 fAutoLoadTime->SetValue(fM->GetAutoLoadTime());
266 fEventInfo->LoadBuffer(fM->GetEventInfoHorizontal());
271 //------------------------------------------------------------------------------
273 //------------------------------------------------------------------------------
275 //______________________________________________________________________________
276 TGTextButton* AliEveEventManagerWindow::MkTxtButton(TGCompositeFrame* p,
277 const char* txt, Int_t width,
278 Int_t lo, Int_t ro, Int_t to, Int_t bo)
280 // Create a standard button.
281 // If width is not zero, the fixed-width flag is set.
283 TGTextButton* b = new TGTextButton(p, txt);
286 b->ChangeOptions(b->GetOptions() | kFixedWidth);
288 p->AddFrame(b, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
292 //______________________________________________________________________________
293 TGLabel* AliEveEventManagerWindow::MkLabel(TGCompositeFrame* p,
294 const char* txt, Int_t width,
295 Int_t lo, Int_t ro, Int_t to, Int_t bo)
297 // Create a standard button.
298 // If width is not zero, the fixed-width flag is set.
300 TGLabel* l = new TGLabel(p, txt);
303 l->ChangeOptions(l->GetOptions() | kFixedWidth);
305 p->AddFrame(l, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));