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