AliEveEventManager
[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 "TVirtualPad.h"
14 #include "TColor.h"
15
16 #include <TEveGValuators.h>
17 #include <TGButton.h>
18 #include <TGTextView.h>
19 #include <TGLabel.h>
20
21 //______________________________________________________________________________
22 // GUI editor for AliEveEventManager.
23 //
24
25 ClassImp(AliEveEventManagerEditor)
26
27 //______________________________________________________________________________
28 AliEveEventManagerEditor::AliEveEventManagerEditor(const TGWindow *p, Int_t width, Int_t height,
29              UInt_t options, Pixel_t back) :
30   TGedFrame(p, width, height, options | kVerticalFrame, back),
31   fM(0),
32   fAutoLoad(0),
33   fAutoLoadTime(0),
34   fNextEvent(0),
35   fPrevEvent(0),
36   fLastEvent(0),
37   fRefresh(0),
38   fEventInfo(0)
39 {
40   // Constructor.
41
42   MakeTitle("AliEveEventManager");
43
44   // Create widgets
45   {
46     fAutoLoadTime = new TEveGValuator(this, "Autoload time:", 110, 0);
47     fAutoLoadTime->SetShowSlider(kFALSE);
48     fAutoLoadTime->SetNELength(4);
49     fAutoLoadTime->Build();
50     fAutoLoadTime->SetLimits(0, 1000);
51     fAutoLoadTime->SetToolTip("Automatic event loading time in seconds");
52     fAutoLoadTime->Connect("ValueSet(Double_t)",
53                            "AliEveEventManagerEditor", this, "DoSetAutoLoadTime()");
54
55     fAutoLoad = new TGCheckButton(fAutoLoadTime,"Autoload");
56     fAutoLoad->SetToolTipText("Automatic event loading (online)");
57     fAutoLoadTime->AddFrame(fAutoLoad, new TGLayoutHints(kLHintsLeft, 12, 0, 2, 0));
58     fAutoLoad->Connect("Toggled(Bool_t)",
59                        "AliEveEventManagerEditor", this, "DoSetAutoLoad()");
60     AddFrame(fAutoLoadTime);
61   }
62   {
63     TGHorizontalFrame* f = new TGHorizontalFrame(this);
64     fPrevEvent = new TGTextButton(f, "Previous Event");
65     fPrevEvent->SetWidth(100);
66     fPrevEvent->ChangeOptions(fPrevEvent->GetOptions() | kFixedWidth);
67     f->AddFrame(fPrevEvent, new TGLayoutHints(kLHintsNormal, 0,4,0,0));
68     fPrevEvent->Connect("Clicked()",
69                         "AliEveEventManagerEditor", this, "DoPrevEvent()");
70     fNextEvent = new TGTextButton(f, "Next Event");
71     fNextEvent->SetWidth(100);
72     fNextEvent->ChangeOptions(fNextEvent->GetOptions() | kFixedWidth);
73     f->AddFrame(fNextEvent, new TGLayoutHints(kLHintsNormal, 4,0,0,0));
74     fNextEvent->Connect("Clicked()",
75                         "AliEveEventManagerEditor", this, "DoNextEvent()");
76     AddFrame(f, new TGLayoutHints(kLHintsExpandX, 8,8,8,0));
77   }
78   {
79     TGHorizontalFrame* f = new TGHorizontalFrame(this);
80     fLastEvent = new TGTextButton(f, "Last Event");
81     fLastEvent->SetWidth(100);
82     fLastEvent->ChangeOptions(fLastEvent->GetOptions() | kFixedWidth);
83     f->AddFrame(fLastEvent, new TGLayoutHints(kLHintsNormal, 0,4,0,0));
84     fLastEvent->Connect("Clicked()",
85                         "AliEveEventManagerEditor", this, "DoLastEvent()");
86     fRefresh = new TGTextButton(f, "Refresh");
87     fRefresh->SetWidth(100);
88     fRefresh->ChangeOptions(fRefresh->GetOptions() | kFixedWidth);
89     f->AddFrame(fRefresh, new TGLayoutHints(kLHintsNormal, 4,0,0,0));
90     fRefresh->Connect("Clicked()",
91                         "AliEveEventManagerEditor", this, "DoRefresh()");
92     AddFrame(f, new TGLayoutHints(kLHintsExpandX, 8,8,8,0));
93   }
94
95   {
96     TGVerticalFrame* f = new TGVerticalFrame(this);
97
98     TGLabel *eventInfoLabel = new TGLabel(f, "Event Information:");
99     f->AddFrame(eventInfoLabel, new TGLayoutHints(kLHintsNormal, 0,0,6,2));
100
101     fEventInfo = new TGTextView(f, 200, 300);
102     f->AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
103
104     AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
105   }
106
107 }
108
109 /******************************************************************************/
110
111 //______________________________________________________________________________
112 void AliEveEventManagerEditor::SetModel(TObject* obj)
113 {
114   // Set model object.
115
116   fM = dynamic_cast<AliEveEventManager*>(obj);
117
118   // Set values of widgets
119   fAutoLoadTime->SetValue(fM->GetAutoLoadTime());
120   fAutoLoadTime->SetEnabled(fM->GetAutoLoad());
121   fAutoLoad->SetState(fM->GetAutoLoad() ? kButtonDown : kButtonUp);
122
123   fPrevEvent->SetEnabled(!fM->GetIsOnline()); 
124
125   fEventInfo->LoadBuffer(fM->GetEventInfo());
126 }
127
128 /******************************************************************************/
129
130 // Implements callback/slot methods
131
132 //______________________________________________________________________________
133 void AliEveEventManagerEditor::DoSetAutoLoad()
134 {
135   // Set the auto-load flag
136   //
137   fM->SetAutoLoad(fAutoLoad->IsOn());
138   Update();
139 }
140
141 //______________________________________________________________________________
142 void AliEveEventManagerEditor::DoSetAutoLoadTime()
143 {
144   // Set the auto-load time in seconds
145   //
146   fM->SetAutoLoadTime(fAutoLoadTime->GetValue());
147   fM->SetAutoLoad(fAutoLoad->IsOn());
148   Update();
149 }
150
151 //______________________________________________________________________________
152 void AliEveEventManagerEditor::DoPrevEvent()
153 {
154   // Load previous event
155   fM->PrevEvent();
156 }
157
158 //______________________________________________________________________________
159 void AliEveEventManagerEditor::DoNextEvent()
160 {
161   // Load next event
162   fM->NextEvent();
163 }
164
165 //______________________________________________________________________________
166 void AliEveEventManagerEditor::DoLastEvent()
167 {
168   // Load last event
169   fM->GotoEvent(-1);
170 }
171
172 //______________________________________________________________________________
173 void AliEveEventManagerEditor::DoRefresh()
174 {
175   // Refresh / reopen data-files
176   Int_t ev = fM->GetEventId();
177   fM->Close();
178   fM->Open();
179   fM->GotoEvent(ev);
180 }