1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------
19 // AliAnalysisGUI class
20 // The class that deals with the analysis GUI
21 // Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
22 //-----------------------------------------------------------------
25 #include "TApplication.h"
29 #include "TGDockableFrame.h"
33 #include "TGToolBar.h"
34 #include "TGStatusBar.h"
36 #include "TGFileDialog.h"
49 enum EAliEnViewerCommands {
58 #include "AliAlienBrowser.h"
59 #include "AliFileListFrame.h"
60 #include "AliLoginFrame.h"
61 #include "AliPackageFrame.h"
63 #include "AliAnalysisGUI.h"
65 ClassImp(AliAnalysisGUI)
67 //___________________________________________________________________________
68 AliAnalysisGUI::AliAnalysisGUI(const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p,w,h), fIsConnected(false) {
69 // AliAnalysisGUI Constructor
71 SetWindowName("AliEn");
73 // Create all the Frames, MenuBar and ToolBar
74 fVFrame1 = new TGVerticalFrame(this, 600, 600);
79 AddFrame(fVFrame1, new TGLayoutHints(kLHintsTop));
81 fTab = new TGTab(this, 900, 300);
82 // fTab->Connect("Selected(Int_t)", "TestDialog", this, "DoTab(Int_t)");
86 //_____________________________________//
87 //_________File Catalogue TAB__________//
88 //_____________________________________//
89 TGCompositeFrame *tf = fTab->AddTab("File Catalogue");
90 TGCompositeFrame *fF1 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
92 fHFrame1 = new TGHorizontalFrame(fF1, 500, 500);
93 fHFrame1->SetCleanup(kDeepCleanup);
95 fAliEnBrowser = new AliAlienBrowser(fHFrame1, 200, 250, this, "AliAnalysisGUI", kGridBrowse);
96 fHFrame1->AddFrame(fAliEnBrowser, new TGLayoutHints(kLHintsLeft | kLHintsExpandY));
98 fVFrame2 = new TGVerticalFrame(fHFrame1, 500, 500);
99 fVFrame2->SetCleanup(kDeepCleanup);
100 fHFrame1->AddFrame(fVFrame2, new TGLayoutHints(kLHintsRight | kLHintsExpandY));
102 fFileListFrame = new AliFileListFrame(fVFrame2, 250, 200);
104 fVFrame2->AddFrame(fFileListFrame,new TGLayoutHints(kLHintsExpandY));
106 fF1->AddFrame(fHFrame1,new TGLayoutHints(kLHintsNormal));
107 tf->AddFrame(fF1, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
110 //_____________________________________//
111 //_________Packages TAB__________//
112 //_____________________________________//
113 tf = fTab->AddTab("Packages");
115 fPackageFrame = new AliPackageFrame(tf, 250, 300, this);
116 tf->AddFrame(fPackageFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
118 //_____________________________________//
119 //______________TAG TAB________________//
120 //_____________________________________//
121 tf = fTab->AddTab("Event Tags");
123 //TGCompositeFrame *fF2 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
125 fTagAnalysisFrame = new AliTagAnalysisFrame(tf, 250, 200, this);
127 tf->AddFrame(fTagAnalysisFrame,new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
129 //_____________________________________//
130 //___________SELECTOR TAB______________//
131 //_____________________________________//
132 tf = fTab->AddTab("Analysis");
134 fSelectorFrame = new AliSelectorFrame(tf, 250, 300, this, fTagAnalysisFrame);
136 tf->AddFrame(fSelectorFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
147 //___________________________________________________________________________
148 AliAnalysisGUI::~AliAnalysisGUI() {
149 // AliAnalysisGUI Destructor
160 delete fFileListFrame;
162 delete fMenuBarLayout;
163 delete fMenuBarItemLayout;
166 //___________________________________________________________________________
167 void AliAnalysisGUI::CloseWindow() {
168 // Got close message for this MainFrame. Terminates the application.
170 gApplication->Terminate();
173 //___________________________________________________________________________
174 void AliAnalysisGUI::AddMenuBar() {
175 // Create the MenuBar
177 fMenuDock = new TGDockableFrame(this);
178 AddFrame(fMenuDock, new TGLayoutHints(kLHintsExpandX, 0, 0, 1, 0));
179 fMenuDock->SetWindowName("Menu");
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);
190 fMenuBar = new TGMenuBar(fMenuDock, 1, 1, kHorizontalFrame);
191 fMenuBar->AddPopup("&File", fMenuFile, fMenuBarItemLayout);
193 fMenuDock->AddFrame(fMenuBar, fMenuBarLayout);
195 // AddFrame(fMenuDock, fMenuBarLayout);
196 fVFrame1->AddFrame(fMenuDock, fMenuBarLayout);
200 // fMenuDock->Connect("Undocked()", "AliAnalysisGUI", this, "HandleMenu(=M_VIEW_UNDOCK)");
202 fMenuFile->Connect("Activated(Int_t)", "AliAnalysisGUI", this, "HandleMenu(Int_t)");
209 //___________________________________________________________________________
210 void AliAnalysisGUI::AddToolBar() {
211 // Create the ToolBar
213 // toolbar icon files
214 const char *xpmtoolbar[] = {
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 },
238 // toolbar button separator
242 const int knumIcons= 8;
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];
250 if (strlen(xpmtoolbar[i]) == 0) {
254 fToolBar->AddButton(this, &tbdata[i], separator);
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));
265 fVFrame1->AddFrame(fH3DLine, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
267 fToolBar->Connect("Clicked(Int_t)", "AliAnalysisGUI", this, "HandleToolBar(Int_t)");
274 //___________________________________________________________________________
275 void AliAnalysisGUI::AddStatusBar() {
277 Int_t parts[] = {40, 30, 30};
278 fStatusBar = new TGStatusBar(this, 50, 10, kHorizontalFrame);
279 fStatusBar->SetParts(parts, 3);
281 AddFrame(fStatusBar, new TGLayoutHints(kLHintsBottom|kLHintsExpandX, 0,0,0,0));
283 UserGroup_t * fUserGroup = gSystem->GetUserInfo();
286 sprintf(line,"User : %s - %s", fUserGroup->fRealName.Data(), fUserGroup->fGroup.Data());
287 fStatusBar->SetText(line, 1);
289 TGCompositeFrame *leftpart = fStatusBar->GetBarPart(2);
292 fStatusBar->SetText(" Disconnected", 2);
293 fRightIconPicture = (TGPicture *)fClient->GetPicture("proof_disconnected.xpm");
296 fStatusBar->SetText(" Connected", 2);
297 fRightIconPicture = (TGPicture *)fClient->GetPicture("monitor01.xpm");
300 fRightIcon = new TGIcon(leftpart, fRightIconPicture,fRightIconPicture->GetWidth(),fRightIconPicture->GetHeight());
301 leftpart->AddFrame(fRightIcon, new TGLayoutHints(kLHintsLeft, 2, 0, 0, 0));
304 //___________________________________________________________________________
305 Bool_t AliAnalysisGUI::LogIn(const char * server, const char *username) {
308 // fAlien = TGrid::Connect(server, username);
309 fAlien = TGrid::Connect(server);
311 fIsConnected = gGrid;
313 fAliEnBrowser->AddItem(0, "/");
314 fStatusBar->SetText(" Connected", 2);
315 ChangeRightLogo("proof_connected.xpm");
321 //___________________________________________________________________________
322 void AliAnalysisGUI::ChangeRightLogo(const char *name) {
323 // Change the right logo (used for animation).
325 fClient->FreePicture(fRightIconPicture);
326 fRightIconPicture = (TGPicture *)fClient->GetPicture(name);
327 fRightIcon->SetPicture(fRightIconPicture);
330 //___________________________________________________________________________
331 void AliAnalysisGUI::OnDoubleClick(TGListTreeItem* item, Int_t btn) {
332 // OnDoubleClick at the ListTree
334 fAliEnBrowser->OnDoubleClick(item, btn);
335 fFileListFrame->SetQueryPath(fAliEnBrowser->GetPath());
338 //___________________________________________________________________________
339 void AliAnalysisGUI::HandleMenu(Int_t id) {
340 // Handle menu items.
342 const char *gAlifiletypes[] = {
343 "ROOT files", "*.root",
344 "ROOT macros", "*.C",
345 "Text files", "*.[tT][xX][tT]",
352 fLogInFrame = new AliLoginFrame(gClient->GetRoot(), this, 400, 200);
355 static TString dir(".");
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);
369 // new TagFrame(gClient->GetRoot(), this, 400, 200, kHorizontalFrame, -1);
378 //___________________________________________________________________________
379 void AliAnalysisGUI::HandleToolBar(Int_t id) {
380 // Handle menu items.
385 LogIn("alien://", "");
389 fAliEnBrowser->GotoDir(gGrid->GetHomeDirectory());
390 fFileListFrame->SetQueryPath(fAliEnBrowser->GetPath());