]>
Commit | Line | Data |
---|---|---|
5af6242d | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //----------------------------------------------------------------- | |
19 | // AliAnalysisGUI class | |
20 | // The class that deals with the analysis GUI | |
21 | // Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch | |
22 | //----------------------------------------------------------------- | |
23 | ||
24 | //ROOT | |
25 | #include "TApplication.h" | |
26 | #include "TSystem.h" | |
27 | ||
28 | #include "TGTab.h" | |
29 | #include "TGDockableFrame.h" | |
30 | #include "TGFrame.h" | |
31 | #include "TGMenu.h" | |
32 | #include "TG3DLine.h" | |
33 | #include "TGToolBar.h" | |
34 | #include "TGStatusBar.h" | |
35 | #include "TGIcon.h" | |
36 | #include "TGFileDialog.h" | |
37 | ||
38 | class TGButton; | |
39 | ||
40 | #include "TGrid.h" | |
41 | ||
42 | #define GUIDEBUG 1 | |
43 | ||
44 | #ifdef GUIDEBUG | |
45 | using namespace std; | |
46 | #endif | |
47 | ||
48 | ||
49 | enum EAliEnViewerCommands { | |
50 | kAliEnConnect, | |
51 | kAliEnHome, | |
52 | kOpen, | |
53 | kSave, | |
54 | kExit | |
55 | }; | |
56 | ||
57 | //GUI | |
58 | #include "AliAlienBrowser.h" | |
59 | #include "AliFileListFrame.h" | |
60 | #include "AliLoginFrame.h" | |
61 | #include "AliPackageFrame.h" | |
62 | ||
63 | #include "AliAnalysisGUI.h" | |
64 | ||
65 | ClassImp(AliAnalysisGUI) | |
66 | ||
67 | //___________________________________________________________________________ | |
68 | AliAnalysisGUI::AliAnalysisGUI(const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p,w,h), fIsConnected(false) { | |
69 | // AliAnalysisGUI Constructor | |
70 | ||
71 | SetWindowName("AliEn"); | |
72 | ||
73 | // Create all the Frames, MenuBar and ToolBar | |
74 | fVFrame1 = new TGVerticalFrame(this, 600, 600); | |
75 | ||
76 | AddMenuBar(); | |
77 | AddToolBar(); | |
78 | ||
79 | AddFrame(fVFrame1, new TGLayoutHints(kLHintsTop)); | |
80 | ||
81 | fTab = new TGTab(this, 900, 300); | |
82 | // fTab->Connect("Selected(Int_t)", "TestDialog", this, "DoTab(Int_t)"); | |
83 | ||
84 | AddFrame(fTab); | |
85 | ||
86 | //_____________________________________// | |
87 | //_________File Catalogue TAB__________// | |
88 | //_____________________________________// | |
89 | TGCompositeFrame *tf = fTab->AddTab("File Catalogue"); | |
90 | TGCompositeFrame *fF1 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame); | |
91 | ||
92 | fHFrame1 = new TGHorizontalFrame(fF1, 500, 500); | |
93 | fHFrame1->SetCleanup(kDeepCleanup); | |
94 | ||
95 | fAliEnBrowser = new AliAlienBrowser(fHFrame1, 200, 250, this, "AliAnalysisGUI", kGridBrowse); | |
96 | fHFrame1->AddFrame(fAliEnBrowser, new TGLayoutHints(kLHintsLeft | kLHintsExpandY)); | |
97 | ||
98 | fVFrame2 = new TGVerticalFrame(fHFrame1, 500, 500); | |
99 | fVFrame2->SetCleanup(kDeepCleanup); | |
100 | fHFrame1->AddFrame(fVFrame2, new TGLayoutHints(kLHintsRight | kLHintsExpandY)); | |
101 | ||
102 | fFileListFrame = new AliFileListFrame(fVFrame2, 250, 200); | |
103 | ||
104 | fVFrame2->AddFrame(fFileListFrame,new TGLayoutHints(kLHintsExpandY)); | |
105 | ||
106 | fF1->AddFrame(fHFrame1,new TGLayoutHints(kLHintsNormal)); | |
107 | tf->AddFrame(fF1, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)); | |
108 | ||
109 | ||
110 | //_____________________________________// | |
111 | //_________Packages TAB__________// | |
112 | //_____________________________________// | |
113 | tf = fTab->AddTab("Packages"); | |
114 | ||
115 | fPackageFrame = new AliPackageFrame(tf, 250, 300, this); | |
116 | tf->AddFrame(fPackageFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5)); | |
117 | ||
118 | //_____________________________________// | |
119 | //______________TAG TAB________________// | |
120 | //_____________________________________// | |
121 | tf = fTab->AddTab("Event Tags"); | |
122 | ||
123 | //TGCompositeFrame *fF2 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame); | |
124 | ||
125 | fTagAnalysisFrame = new AliTagAnalysisFrame(tf, 250, 200, this); | |
126 | ||
127 | tf->AddFrame(fTagAnalysisFrame,new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5)); | |
128 | ||
129 | //_____________________________________// | |
130 | //___________SELECTOR TAB______________// | |
131 | //_____________________________________// | |
132 | tf = fTab->AddTab("Analysis"); | |
133 | ||
134 | fSelectorFrame = new AliSelectorFrame(tf, 250, 300, this, fTagAnalysisFrame); | |
135 | ||
136 | tf->AddFrame(fSelectorFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5)); | |
137 | ||
138 | ||
139 | // Status Bar | |
140 | AddStatusBar(); | |
141 | ||
142 | MapSubwindows(); | |
143 | Resize(); | |
144 | MapWindow(); | |
145 | } | |
146 | ||
147 | //___________________________________________________________________________ | |
148 | AliAnalysisGUI::~AliAnalysisGUI() { | |
149 | // AliAnalysisGUI Destructor | |
150 | ||
151 | Cleanup(); | |
152 | ||
153 | delete fMenuDock; | |
154 | delete fMenuFile; | |
155 | delete fMenuBar; | |
156 | delete fToolBar; | |
157 | delete fH3DLine; | |
158 | delete fHFrame1; | |
159 | delete fCanvas2; | |
160 | delete fFileListFrame; | |
161 | delete fIcon; | |
162 | delete fMenuBarLayout; | |
163 | delete fMenuBarItemLayout; | |
164 | } | |
165 | ||
166 | //___________________________________________________________________________ | |
167 | void AliAnalysisGUI::CloseWindow() { | |
168 | // Got close message for this MainFrame. Terminates the application. | |
169 | ||
170 | gApplication->Terminate(); | |
171 | } | |
172 | ||
173 | //___________________________________________________________________________ | |
174 | void AliAnalysisGUI::AddMenuBar() { | |
175 | // Create the MenuBar | |
176 | ||
177 | fMenuDock = new TGDockableFrame(this); | |
178 | AddFrame(fMenuDock, new TGLayoutHints(kLHintsExpandX, 0, 0, 1, 0)); | |
179 | fMenuDock->SetWindowName("Menu"); | |
180 | ||
181 | fMenuFile = new TGPopupMenu(gClient->GetRoot()); | |
182 | fMenuFile->AddEntry("&Log In...", kMFILELOGIN); | |
183 | fMenuFile->AddEntry("&Open...", kMFILEOPEN); | |
184 | fMenuFile->AddEntry("S&ave as...", kMFILESAVEAS); | |
185 | fMenuFile->AddSeparator(); | |
186 | fMenuFile->AddEntry("Tag...", kMFILETAG); | |
187 | fMenuFile->AddSeparator(); | |
188 | fMenuFile->AddEntry("E&xit", kMFILEEXIT); | |
189 | ||
190 | fMenuBar = new TGMenuBar(fMenuDock, 1, 1, kHorizontalFrame); | |
191 | fMenuBar->AddPopup("&File", fMenuFile, fMenuBarItemLayout); | |
192 | ||
193 | fMenuDock->AddFrame(fMenuBar, fMenuBarLayout); | |
194 | ||
195 | // AddFrame(fMenuDock, fMenuBarLayout); | |
196 | fVFrame1->AddFrame(fMenuDock, fMenuBarLayout); | |
197 | ||
198 | ||
199 | ||
200 | // fMenuDock->Connect("Undocked()", "AliAnalysisGUI", this, "HandleMenu(=M_VIEW_UNDOCK)"); | |
201 | ||
202 | fMenuFile->Connect("Activated(Int_t)", "AliAnalysisGUI", this, "HandleMenu(Int_t)"); | |
203 | ||
204 | MapSubwindows(); | |
205 | Resize(); | |
206 | MapWindow(); | |
207 | } | |
208 | ||
209 | //___________________________________________________________________________ | |
210 | void AliAnalysisGUI::AddToolBar() { | |
211 | // Create the ToolBar | |
212 | ||
213 | // toolbar icon files | |
214 | const char *xpmtoolbar[] = { | |
215 | "connect.xpm", | |
216 | "", | |
217 | "home_t.xpm", | |
218 | "", | |
219 | "fileopen.xpm", | |
220 | "filesaveas.xpm", | |
221 | "", | |
222 | "ed_quit.png", | |
223 | "", | |
224 | }; | |
225 | ||
226 | ToolBarData_t tbdata[] = { | |
227 | { "", "Quick Connect", kFALSE, kAliEnConnect, 0 }, | |
228 | { "", 0, kFALSE, -1, 0 }, | |
229 | { "", "Home Directory", kFALSE, kAliEnHome, 0 }, | |
230 | { "", 0, kFALSE, -1, 0 }, | |
231 | { "", "Open", kFALSE, kOpen, 0 }, | |
232 | { "", "Save", kFALSE, kSave, 0 }, | |
233 | { "", 0, kFALSE, -1, 0 }, | |
234 | { "", "Exit", kFALSE, kExit, 0 }, | |
235 | { 0, 0, 0, 0, 0 } | |
236 | }; | |
237 | ||
238 | // toolbar button separator | |
239 | int separator = 5; | |
240 | ||
241 | // number of icons | |
242 | const int knumIcons= 8; | |
243 | ||
244 | // creation of a toolbar object as a child of main frame | |
245 | fToolBar = new TGToolBar(this, 640, 80); | |
246 | for (int i = 0; i < knumIcons; i++) { | |
247 | // filling the ToolBarData_t with information | |
248 | tbdata[i].fPixmap = xpmtoolbar[i]; | |
249 | ||
250 | if (strlen(xpmtoolbar[i]) == 0) { | |
251 | separator = 5; | |
252 | continue; | |
253 | } | |
254 | fToolBar->AddButton(this, &tbdata[i], separator); | |
255 | separator = 0; | |
256 | } | |
257 | ||
258 | // adding the tool bar to the main frame | |
259 | // AddFrame(fToolBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX)); | |
260 | fVFrame1->AddFrame(fToolBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX)); | |
261 | // adding a horizontal line as a separator | |
262 | fH3DLine = new TGHorizontal3DLine(this); | |
263 | // AddFrame(fH3DLine, new TGLayoutHints(kLHintsTop | kLHintsExpandX)); | |
264 | ||
265 | fVFrame1->AddFrame(fH3DLine, new TGLayoutHints(kLHintsTop | kLHintsExpandX)); | |
266 | ||
267 | fToolBar->Connect("Clicked(Int_t)", "AliAnalysisGUI", this, "HandleToolBar(Int_t)"); | |
268 | ||
269 | MapSubwindows(); | |
270 | Resize(); | |
271 | MapWindow(); | |
272 | } | |
273 | ||
274 | //___________________________________________________________________________ | |
275 | void AliAnalysisGUI::AddStatusBar() { | |
276 | // Status Bar | |
277 | Int_t parts[] = {40, 30, 30}; | |
278 | fStatusBar = new TGStatusBar(this, 50, 10, kHorizontalFrame); | |
279 | fStatusBar->SetParts(parts, 3); | |
280 | ||
281 | AddFrame(fStatusBar, new TGLayoutHints(kLHintsBottom|kLHintsExpandX, 0,0,0,0)); | |
282 | ||
283 | UserGroup_t * fUserGroup = gSystem->GetUserInfo(); | |
284 | char line [100]; | |
285 | ||
286 | sprintf(line,"User : %s - %s", fUserGroup->fRealName.Data(), fUserGroup->fGroup.Data()); | |
287 | fStatusBar->SetText(line, 1); | |
288 | ||
289 | TGCompositeFrame *leftpart = fStatusBar->GetBarPart(2); | |
290 | ||
291 | if(!fIsConnected){ | |
292 | fStatusBar->SetText(" Disconnected", 2); | |
293 | fRightIconPicture = (TGPicture *)fClient->GetPicture("proof_disconnected.xpm"); | |
294 | } | |
295 | else{ | |
296 | fStatusBar->SetText(" Connected", 2); | |
297 | fRightIconPicture = (TGPicture *)fClient->GetPicture("monitor01.xpm"); | |
298 | } | |
299 | ||
300 | fRightIcon = new TGIcon(leftpart, fRightIconPicture,fRightIconPicture->GetWidth(),fRightIconPicture->GetHeight()); | |
301 | leftpart->AddFrame(fRightIcon, new TGLayoutHints(kLHintsLeft, 2, 0, 0, 0)); | |
302 | } | |
303 | ||
304 | //___________________________________________________________________________ | |
305 | Bool_t AliAnalysisGUI::LogIn(const char * server, const char *username) { | |
306 | // Log in to AliEn | |
307 | ||
308 | // fAlien = TGrid::Connect(server, username); | |
309 | fAlien = TGrid::Connect(server); | |
310 | ||
311 | fIsConnected = gGrid; | |
312 | if(fIsConnected){ | |
313 | fAliEnBrowser->AddItem(0, "/"); | |
314 | fStatusBar->SetText(" Connected", 2); | |
315 | ChangeRightLogo("proof_connected.xpm"); | |
316 | } | |
317 | ||
318 | return fIsConnected; | |
319 | } | |
320 | ||
321 | //___________________________________________________________________________ | |
322 | void AliAnalysisGUI::ChangeRightLogo(const char *name) { | |
323 | // Change the right logo (used for animation). | |
324 | ||
325 | fClient->FreePicture(fRightIconPicture); | |
326 | fRightIconPicture = (TGPicture *)fClient->GetPicture(name); | |
327 | fRightIcon->SetPicture(fRightIconPicture); | |
328 | } | |
329 | ||
330 | //___________________________________________________________________________ | |
331 | void AliAnalysisGUI::OnDoubleClick(TGListTreeItem* item, Int_t btn) { | |
332 | // OnDoubleClick at the ListTree | |
333 | ||
334 | fAliEnBrowser->OnDoubleClick(item, btn); | |
335 | fFileListFrame->SetQueryPath(fAliEnBrowser->GetPath()); | |
336 | } | |
337 | ||
338 | //___________________________________________________________________________ | |
339 | void AliAnalysisGUI::HandleMenu(Int_t id) { | |
340 | // Handle menu items. | |
341 | ||
342 | const char *gAlifiletypes[] = { | |
343 | "ROOT files", "*.root", | |
344 | "ROOT macros", "*.C", | |
345 | "Text files", "*.[tT][xX][tT]", | |
346 | "All files", "*", | |
347 | 0, 0 | |
348 | }; | |
349 | ||
350 | switch (id) { | |
351 | case kMFILELOGIN: | |
352 | fLogInFrame = new AliLoginFrame(gClient->GetRoot(), this, 400, 200); | |
353 | break; | |
354 | case kMFILEOPEN: { | |
355 | static TString dir("."); | |
356 | TGFileInfo fi; | |
357 | fi.fFileTypes = gAlifiletypes; | |
358 | fi.fIniDir = StrDup(dir); | |
359 | new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi); | |
360 | printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir); | |
361 | dir = fi.fIniDir; | |
362 | } | |
363 | break; | |
364 | ||
365 | case kMFILESAVEAS: | |
366 | ||
367 | break; | |
368 | case kMFILETAG: | |
369 | // new TagFrame(gClient->GetRoot(), this, 400, 200, kHorizontalFrame, -1); | |
370 | ||
371 | break; | |
372 | case kMFILEEXIT: | |
373 | CloseWindow(); | |
374 | break; | |
375 | } | |
376 | } | |
377 | ||
378 | //___________________________________________________________________________ | |
379 | void AliAnalysisGUI::HandleToolBar(Int_t id) { | |
380 | // Handle menu items. | |
381 | ||
382 | switch (id) { | |
383 | case kAliEnConnect: | |
384 | ||
385 | LogIn("alien://", ""); | |
386 | break; | |
387 | case kAliEnHome: | |
388 | if(gGrid){ | |
389 | fAliEnBrowser->GotoDir(gGrid->GetHomeDirectory()); | |
390 | fFileListFrame->SetQueryPath(fAliEnBrowser->GetPath()); | |
391 | } | |
392 | break; | |
393 | case kExit: | |
394 | CloseWindow(); | |
395 | break; | |
396 | } | |
397 | } |