First version of the online reco + AliEVE attached to it. (Matevz and Cvetan)
[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   fEventInfo(0)
37 {
38   // Constructor.
39
40   MakeTitle("AliEveEventManager");
41
42   // Create widgets
43   {
44     fAutoLoadTime = new TEveGValuator(this, "Autoload time:", 110, 0);
45     fAutoLoadTime->SetShowSlider(kFALSE);
46     fAutoLoadTime->SetNELength(4);
47     fAutoLoadTime->Build();
48     fAutoLoadTime->SetLimits(0, 1000);
49     fAutoLoadTime->SetToolTip("Automatic event loading time in seconds");
50     fAutoLoadTime->Connect("ValueSet(Double_t)",
51                            "AliEveEventManagerEditor", this, "DoSetAutoLoadTime()");
52
53     fAutoLoad = new TGCheckButton(fAutoLoadTime,"Autoload");
54     fAutoLoad->SetToolTipText("Automatic event loading (online)");
55     fAutoLoadTime->AddFrame(fAutoLoad, new TGLayoutHints(kLHintsLeft, 12, 0, 2, 0));
56     fAutoLoad->Connect("Toggled(Bool_t)",
57                        "AliEveEventManagerEditor", this, "DoSetAutoLoad()");
58     AddFrame(fAutoLoadTime);
59   }
60   {
61     TGHorizontalFrame* f = new TGHorizontalFrame(this);
62     fPrevEvent = new TGTextButton(f, "Previous Event");
63     f->AddFrame(fPrevEvent, new TGLayoutHints(kLHintsExpandX, 0,4,0,0));
64     fPrevEvent->Connect("Clicked()",
65                         "AliEveEventManagerEditor", this, "DoPrevEvent()");
66     fNextEvent = new TGTextButton(f, "Next Event");
67     f->AddFrame(fNextEvent, new TGLayoutHints(kLHintsExpandX, 4,0,0,0));
68     fNextEvent->Connect("Clicked()",
69                         "AliEveEventManagerEditor", this, "DoNextEvent()");
70     AddFrame(f, new TGLayoutHints(kLHintsExpandX, 8,8,8,0));
71   }
72
73   {
74     TGVerticalFrame* f = new TGVerticalFrame(this);
75
76     TGLabel *eventInfoLabel = new TGLabel(f, "Event Information:");
77     f->AddFrame(eventInfoLabel, new TGLayoutHints(kLHintsNormal, 0,0,6,2));
78
79     fEventInfo = new TGTextView(f, 200, 200);
80     f->AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
81
82     AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
83   }
84
85 }
86
87 /******************************************************************************/
88
89 //______________________________________________________________________________
90 void AliEveEventManagerEditor::SetModel(TObject* obj)
91 {
92   // Set model object.
93
94   fM = dynamic_cast<AliEveEventManager*>(obj);
95
96   // Set values of widgets
97   fAutoLoadTime->SetValue(fM->GetAutoLoadTime());
98   fAutoLoadTime->SetEnabled(fM->GetAutoLoad());
99   fAutoLoad->SetState(fM->GetAutoLoad() ? kButtonDown : kButtonUp);
100
101   fPrevEvent->SetEnabled(!fM->GetIsOnline()); 
102
103   fEventInfo->LoadBuffer(fM->GetEventInfo());
104 }
105
106 /******************************************************************************/
107
108 // Implements callback/slot methods
109
110 //______________________________________________________________________________
111 void AliEveEventManagerEditor::DoSetAutoLoad()
112 {
113   // Set the auto-load flag
114   //
115   fM->SetAutoLoad(fAutoLoad->IsOn());
116   Update();
117 }
118
119 //______________________________________________________________________________
120 void AliEveEventManagerEditor::DoSetAutoLoadTime()
121 {
122   // Set the auto-load time in seconds
123   //
124   fM->SetAutoLoadTime(fAutoLoadTime->GetValue());
125   fM->SetAutoLoad(fAutoLoad->IsOn());
126   Update();
127 }
128
129 //______________________________________________________________________________
130 void AliEveEventManagerEditor::DoPrevEvent()
131 {
132   // Load previous event
133   fM->PrevEvent();
134 }
135
136 //______________________________________________________________________________
137 void AliEveEventManagerEditor::DoNextEvent()
138 {
139   // Load next event
140   fM->NextEvent();
141 }