]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveBase/AliEveEventManagerEditor.cxx
Use GRP from event-directory if:
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveEventManagerEditor.cxx
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 //______________________________________________________________________________
24 // GUI editor for AliEveEventManager.
25 //
26
27 ClassImp(AliEveEventManagerEditor)
28
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),
33   fM(0),
34   fNextEvent(0),
35   fEventInfo(0)
36 {
37   // Constructor.
38
39   MakeTitle("AliEveEventManager");
40
41   {
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));
50   }
51   {
52     TGVerticalFrame* f = new TGVerticalFrame(this);
53
54     TGLabel *eventInfoLabel = new TGLabel(f, "Event Information:");
55     f->AddFrame(eventInfoLabel, new TGLayoutHints(kLHintsNormal, 0,0,6,2));
56
57     fEventInfo = new TGTextView(f, 200, 300);
58     f->AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
59
60     AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
61   }
62 }
63
64 /******************************************************************************/
65
66 //______________________________________________________________________________
67 void AliEveEventManagerEditor::SetModel(TObject* obj)
68 {
69   // Set model object.
70
71   fM = dynamic_cast<AliEveEventManager*>(obj);
72
73   fEventInfo->LoadBuffer(fM->GetEventInfoVertical());
74 }
75
76 /******************************************************************************/
77
78 //______________________________________________________________________________
79 void AliEveEventManagerEditor::DoNextEvent()
80 {
81   // Load next event
82
83   fM->NextEvent();
84 }
85
86
87 //==============================================================================
88 // AliEveEventManagerWindow
89 //==============================================================================
90
91 //______________________________________________________________________________
92 //
93 // Horizontal GUI for AliEveEventManager, to be placed in the
94 // bottom part of ROOT browser.
95
96 ClassImp(AliEveEventManagerWindow)
97
98 AliEveEventManagerWindow::AliEveEventManagerWindow(AliEveEventManager* mgr) :
99   TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame),
100   fM            (mgr),
101   fFirstEvent   (0),
102   fPrevEvent    (0),
103   fNextEvent    (0),
104   fLastEvent    (0),
105   fRefresh      (0),
106   fEventId      (0),
107   fInfoLabel    (0),
108   fAutoLoad     (0),
109   fAutoLoadTime (0),
110   fEventInfo    (0)
111 {
112   // Constructor.
113
114   const TString cls("AliEveEventManagerWindow");
115   TGTextButton *b = 0;
116   {
117     Int_t width = 50;
118
119     TGHorizontalFrame* f = new TGHorizontalFrame(this);
120     AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
121
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()");
126
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));
133
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()");
138
139     MkLabel(f, "||", 0, 8, 8);
140
141     fRefresh = b = MkTxtButton(f, "Refresh", width + 8);
142     b->Connect("Clicked()",cls, this, "DoRefresh()");
143
144     MkLabel(f, "||", 0, 8, 8);
145
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()");
150
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()");
159
160   }
161
162   fEventInfo = new TGTextView(this, 400, 600);
163   AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
164
165   fM->Connect("NewEventLoaded()", cls, this, "Update()");
166
167   SetCleanup(kDeepCleanup);
168   Layout();
169   MapSubwindows();
170   MapWindow();
171 }
172
173 //______________________________________________________________________________
174 AliEveEventManagerWindow::~AliEveEventManagerWindow()
175 {
176   // Destructor.
177
178   fM->Disconnect("NewEventLoaded()", this);
179 }
180
181 //______________________________________________________________________________
182 void AliEveEventManagerWindow::DoFirstEvent()
183 {
184   // Load previous event
185   fM->GotoEvent(0);
186 }
187
188 //______________________________________________________________________________
189 void AliEveEventManagerWindow::DoPrevEvent()
190 {
191   // Load previous event
192   fM->PrevEvent();
193 }
194
195 //______________________________________________________________________________
196 void AliEveEventManagerWindow::DoNextEvent()
197 {
198   // Load next event
199   fM->NextEvent();
200 }
201
202 //______________________________________________________________________________
203 void AliEveEventManagerWindow::DoLastEvent()
204 {
205   // Load previous event
206   fM->GotoEvent(-1);
207 }
208
209 //______________________________________________________________________________
210 void AliEveEventManagerWindow::DoSetEvent()
211 {
212   // Set current event
213   fM->GotoEvent((Int_t) fEventId->GetNumber());
214 }
215
216 //______________________________________________________________________________
217 void AliEveEventManagerWindow::DoRefresh()
218 {
219   // Refresh event status.
220
221   Int_t ev = fM->GetEventId();
222   fM->Close();
223   fM->Open();
224   fM->GotoEvent(ev);
225 }
226
227 //______________________________________________________________________________
228 void AliEveEventManagerWindow::DoSetAutoLoad()
229 {
230   // Set the auto-load flag
231
232   fM->SetAutoLoad(fAutoLoad->IsOn());
233   Update();
234 }
235
236 //______________________________________________________________________________
237 void AliEveEventManagerWindow::DoSetAutoLoadTime()
238 {
239   // Set the auto-load time in seconds
240
241   fM->SetAutoLoadTime(fAutoLoadTime->GetValue());
242 }
243
244 //______________________________________________________________________________
245 void AliEveEventManagerWindow::Update()
246 {
247   // Update current event, number of available events, list of active triggers
248
249   Bool_t autoLoad = fM->GetAutoLoad();
250   Bool_t extCtrl  = fM->IsUnderExternalControl();
251   Bool_t evNavOn  = !autoLoad && !extCtrl;
252
253   fFirstEvent->SetEnabled(evNavOn);
254   fPrevEvent ->SetEnabled(evNavOn);
255   fLastEvent ->SetEnabled(evNavOn);
256   fNextEvent ->SetEnabled(!autoLoad);
257   fRefresh   ->SetEnabled(evNavOn);
258
259   fEventId->SetNumber(fM->GetEventId());
260   fEventId->SetState(evNavOn);
261   fInfoLabel->SetText(Form("/ %d", fM->GetMaxEventId()));
262
263   fAutoLoad->SetState(fM->GetAutoLoad() ? kButtonDown : kButtonUp);
264   fAutoLoadTime->SetValue(fM->GetAutoLoadTime());
265
266   fEventInfo->LoadBuffer(fM->GetEventInfoHorizontal());
267
268   Layout();
269 }
270
271 //------------------------------------------------------------------------------
272 // Protected methods
273 //------------------------------------------------------------------------------
274
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)
279 {
280   // Create a standard button.
281   // If width is not zero, the fixed-width flag is set.
282
283   TGTextButton* b = new TGTextButton(p, txt);
284   if (width > 0) {
285     b->SetWidth(width);
286     b->ChangeOptions(b->GetOptions() | kFixedWidth);
287   }
288   p->AddFrame(b, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
289   return b;
290 }
291
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)
296 {
297   // Create a standard button.
298   // If width is not zero, the fixed-width flag is set.
299
300   TGLabel* l = new TGLabel(p, txt);
301   if (width > 0) {
302     l->SetWidth(width);
303     l->ChangeOptions(l->GetOptions() | kFixedWidth);
304   }
305   p->AddFrame(l, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
306   return l;
307 }
308