]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/EveBase/AliEveMacroExecutorWindow.cxx
add Kalman fit function for TRD. To be used in visualization,
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveMacroExecutorWindow.cxx
CommitLineData
f6afd0e1 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 "AliEveMacroExecutorWindow.h"
11#include "AliEveMacroExecutor.h"
12#include "AliEveMacro.h"
13#include "AliEveEventManager.h"
14
15#include <TGedEditor.h>
16#include <TGListBox.h>
17#include <Buttons.h>
18
19namespace
20{
21class FooEntry : public TGTextLBEntry
22{
23public:
24 static void SetFont() { fgDefaultFont = gClient->GetFontPool()->GetFont("-*-lucidatypewriter-*-*-*-*-12-*-*-*-*-*-iso8859-1"); }
25};
26
27class FooEditor : public TGedEditor
28{
29protected:
30 AliEveMacroExecutorWindow* fMEW;
31
32public:
33 FooEditor(AliEveMacroExecutorWindow* w) : TGedEditor(0), fMEW(w) {}
34 virtual ~FooEditor() {}
35 virtual void Update(TGedFrame* gframe=0)
36 {
37 TGedEditor::Update(gframe);
38 fMEW->PopulateMacros();
39 }
40};
41}
42
43//______________________________________________________________________________
44// Full description of AliEveMacroExecutorWindow
45//
46
47ClassImp(AliEveMacroExecutorWindow)
48
49//______________________________________________________________________________
50AliEveMacroExecutorWindow::AliEveMacroExecutorWindow(AliEveMacroExecutor* master) :
51 TGMainFrame(gClient->GetRoot()), fM(master),
52 fMainFrame(0), fCtrlFrame(0), fListBox(0), fEditor(0)
53{
54 // Constructor.
55
56 fMainFrame = new TGVerticalFrame(this);
57 AddFrame(fMainFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
58
59 {
60 fCtrlFrame = new TGHorizontalFrame(fMainFrame);
61 fMainFrame->AddFrame(fCtrlFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
62 fCtrlFrame->Resize(400, 120);
63
64 TGButton* b = new TGTextButton(fCtrlFrame, "Reload event");
65 fCtrlFrame->AddFrame(b);
66 b->Connect("Clicked()", "AliEveMacroExecutorWindow", this,
67 "DoReloadEvent()");
68 }
69
70 fListBox = new TGListBox(fMainFrame);
71 fMainFrame->AddFrame(fListBox, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
72 fListBox->Resize(400, 400);
73 fListBox->Connect("Selected(Int_t)", "AliEveMacroExecutorWindow", this,
74 "DoMacroSelected(Int_t)");
75
76 fMainFrame->SetEditDisabled(kEditEnable);
77 fMainFrame->SetEditable();
78 fEditor = new FooEditor(this);
79 fEditor->SetGlobal(kFALSE);
80 fMainFrame->SetEditable(kEditDisable);
81 fMainFrame->SetEditable(kFALSE);
82 {
83 TGFrameElement *el = 0;
84 TIter next(fMainFrame->GetList());
85 while ((el = (TGFrameElement *) next())) {
86 if (el->fFrame == fEditor)
87 if (el->fLayout) {
88 el->fLayout->SetLayoutHints(kLHintsExpandX);
89 el->fLayout->SetPadLeft(1); el->fLayout->SetPadRight(1);
90 el->fLayout->SetPadTop(2); el->fLayout->SetPadBottom(2);
91 break;
92 }
93 }
94 }
95 fEditor->Resize(400, 160);
96 fEditor->ChangeOptions(fEditor->GetOptions() | kFixedHeight);
97
98 Resize(400, 700);
99
100 SetCleanup(kDeepCleanup);
101 Layout();
102 MapSubwindows();
103 MapWindow();
104
105 gAliEveEvent->Connect("NewEventLoaded()", "AliEveMacroExecutorWindow", this,
106 "NewEventLoaded()");
107}
108
109AliEveMacroExecutorWindow::~AliEveMacroExecutorWindow()
110{
111 // Destructor.
112
113 gAliEveEvent->Disconnect("NewEventLoaded()", this);
114}
115
116/******************************************************************************/
117
118void AliEveMacroExecutorWindow::PopulateMacros(Bool_t keep_selected)
119{
120 // Populate list-box (or whatever will replace it) with all macros.
121 // prototype: no selection, sorting
122
123 // printf("AliEveMacroExecutorWindow::PopulateMacros()\n");
124
125 AliEveMacro* ex_sel = 0;
126 if (keep_selected && fListBox->GetSelected() != -1)
127 ex_sel = fBoxContents[fListBox->GetSelected()];
128
129 fListBox->RemoveAll();
130 fBoxContents.clear();
131
132 FooEntry::SetFont();
133
134 TIter next(fM->fMacros);
135 AliEveMacro *mac;
136 Int_t id = 0;
137 Int_t sel_id = -1;
138 while ((mac = (AliEveMacro*) next()))
139 {
140 if (mac == ex_sel)
141 sel_id = id;
142 fListBox->AddEntry(mac->FormForDisplay(), id++);
143 fBoxContents.push_back(mac);
144 }
145
146 if (sel_id != -1)
147 fListBox->Select(sel_id);
148
149 fListBox->MapSubwindows();
150 fListBox->Layout();
151}
152
153/******************************************************************************/
154
155void AliEveMacroExecutorWindow::NewEventLoaded()
156{
157 // Slot called after a new event has been loaded
158
159 // !!! Once we have exit status from the macro, can update GUI showing this.
160}
161
162void AliEveMacroExecutorWindow::DoReloadEvent()
163{
164 // Slot for reload-event.
165
166 gAliEveEvent->GotoEvent(gAliEveEvent->GetEventId());
167}
168
169void AliEveMacroExecutorWindow::DoMacroSelected(Int_t mid)
170{
171 // Slot for macro-selected.
172
173 fEditor->SetModel(0, fBoxContents[mid], kButton1Down);
174}