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) :
70 fHFrame1(0), fVFrame1(0), fVFrame2(0),
71 fMenuDock(0), fMenuFile(0), fMenuBar(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) {
81 // AliAnalysisGUI Constructor
83 SetWindowName("AliEn");
85 // Create all the Frames, MenuBar and ToolBar
86 fVFrame1 = new TGVerticalFrame(this, 600, 600);
91 AddFrame(fVFrame1, new TGLayoutHints(kLHintsTop));
93 fTab = new TGTab(this, 900, 300);
94 // fTab->Connect("Selected(Int_t)", "TestDialog", this, "DoTab(Int_t)");
98 //_____________________________________//
99 //_________File Catalogue TAB__________//
100 //_____________________________________//
101 TGCompositeFrame *tf = fTab->AddTab("File Catalogue");
102 TGCompositeFrame *fF1 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
104 fHFrame1 = new TGHorizontalFrame(fF1, 500, 500);
105 fHFrame1->SetCleanup(kDeepCleanup);
107 fAliEnBrowser = new AliAlienBrowser(fHFrame1, 200, 250, this, "AliAnalysisGUI", kGridBrowse);
108 fHFrame1->AddFrame(fAliEnBrowser, new TGLayoutHints(kLHintsLeft | kLHintsExpandY));
110 fVFrame2 = new TGVerticalFrame(fHFrame1, 500, 500);
111 fVFrame2->SetCleanup(kDeepCleanup);
112 fHFrame1->AddFrame(fVFrame2, new TGLayoutHints(kLHintsRight | kLHintsExpandY));
114 fFileListFrame = new AliFileListFrame(fVFrame2, 250, 200);
116 fVFrame2->AddFrame(fFileListFrame,new TGLayoutHints(kLHintsExpandY));
118 fF1->AddFrame(fHFrame1,new TGLayoutHints(kLHintsNormal));
119 tf->AddFrame(fF1, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
122 //_____________________________________//
123 //_________Packages TAB__________//
124 //_____________________________________//
125 tf = fTab->AddTab("Packages");
127 fPackageFrame = new AliPackageFrame(tf, 250, 300, this);
128 tf->AddFrame(fPackageFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
130 //_____________________________________//
131 //______________TAG TAB________________//
132 //_____________________________________//
133 tf = fTab->AddTab("Event Tags");
135 //TGCompositeFrame *fF2 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
137 fTagAnalysisFrame = new AliTagAnalysisFrame(tf, 250, 200, this);
139 tf->AddFrame(fTagAnalysisFrame,new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
141 //_____________________________________//
142 //___________SELECTOR TAB______________//
143 //_____________________________________//
144 tf = fTab->AddTab("Analysis");
146 fSelectorFrame = new AliSelectorFrame(tf, 250, 300, this, fTagAnalysisFrame);
148 tf->AddFrame(fSelectorFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
159 //___________________________________________________________________________
160 AliAnalysisGUI::~AliAnalysisGUI() {
161 // AliAnalysisGUI Destructor
172 delete fFileListFrame;
174 delete fMenuBarLayout;
175 delete fMenuBarItemLayout;
178 //___________________________________________________________________________
179 void AliAnalysisGUI::CloseWindow() {
180 // Got close message for this MainFrame. Terminates the application.
182 gApplication->Terminate();
185 //___________________________________________________________________________
186 void AliAnalysisGUI::AddMenuBar() {
187 // Create the MenuBar
189 fMenuDock = new TGDockableFrame(this);
190 AddFrame(fMenuDock, new TGLayoutHints(kLHintsExpandX, 0, 0, 1, 0));
191 fMenuDock->SetWindowName("Menu");
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);
202 fMenuBar = new TGMenuBar(fMenuDock, 1, 1, kHorizontalFrame);
203 fMenuBar->AddPopup("&File", fMenuFile, fMenuBarItemLayout);
205 fMenuDock->AddFrame(fMenuBar, fMenuBarLayout);
207 // AddFrame(fMenuDock, fMenuBarLayout);
208 fVFrame1->AddFrame(fMenuDock, fMenuBarLayout);
212 // fMenuDock->Connect("Undocked()", "AliAnalysisGUI", this, "HandleMenu(=M_VIEW_UNDOCK)");
214 fMenuFile->Connect("Activated(Int_t)", "AliAnalysisGUI", this, "HandleMenu(Int_t)");
221 //___________________________________________________________________________
222 void AliAnalysisGUI::AddToolBar() {
223 // Create the ToolBar
225 // toolbar icon files
226 const char *xpmtoolbar[] = {
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 },
250 // toolbar button separator
254 const int knumIcons= 8;
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];
262 if (strlen(xpmtoolbar[i]) == 0) {
266 fToolBar->AddButton(this, &tbdata[i], separator);
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));
277 fVFrame1->AddFrame(fH3DLine, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
279 fToolBar->Connect("Clicked(Int_t)", "AliAnalysisGUI", this, "HandleToolBar(Int_t)");
286 //___________________________________________________________________________
287 void AliAnalysisGUI::AddStatusBar() {
289 Int_t parts[] = {40, 30, 30};
290 fStatusBar = new TGStatusBar(this, 50, 10, kHorizontalFrame);
291 fStatusBar->SetParts(parts, 3);
293 AddFrame(fStatusBar, new TGLayoutHints(kLHintsBottom|kLHintsExpandX, 0,0,0,0));
295 UserGroup_t * fUserGroup = gSystem->GetUserInfo();
298 sprintf(line,"User : %s - %s", fUserGroup->fRealName.Data(), fUserGroup->fGroup.Data());
299 fStatusBar->SetText(line, 1);
301 TGCompositeFrame *leftpart = fStatusBar->GetBarPart(2);
304 fStatusBar->SetText(" Disconnected", 2);
305 fRightIconPicture = (TGPicture *)fClient->GetPicture("proof_disconnected.xpm");
308 fStatusBar->SetText(" Connected", 2);
309 fRightIconPicture = (TGPicture *)fClient->GetPicture("monitor01.xpm");
312 fRightIcon = new TGIcon(leftpart, fRightIconPicture,fRightIconPicture->GetWidth(),fRightIconPicture->GetHeight());
313 leftpart->AddFrame(fRightIcon, new TGLayoutHints(kLHintsLeft, 2, 0, 0, 0));
316 //___________________________________________________________________________
317 Bool_t AliAnalysisGUI::LogIn(const char * server, const char *username) {
320 // fAlien = TGrid::Connect(server, username);
321 fAlien = TGrid::Connect(server);
323 fIsConnected = gGrid;
325 fAliEnBrowser->AddItem(0, "/");
326 fStatusBar->SetText(" Connected", 2);
327 ChangeRightLogo("proof_connected.xpm");
333 //___________________________________________________________________________
334 void AliAnalysisGUI::ChangeRightLogo(const char *name) {
335 // Change the right logo (used for animation).
337 fClient->FreePicture(fRightIconPicture);
338 fRightIconPicture = (TGPicture *)fClient->GetPicture(name);
339 fRightIcon->SetPicture(fRightIconPicture);
342 //___________________________________________________________________________
343 void AliAnalysisGUI::OnDoubleClick(TGListTreeItem* item, Int_t btn) {
344 // OnDoubleClick at the ListTree
346 fAliEnBrowser->OnDoubleClick(item, btn);
347 fFileListFrame->SetQueryPath(fAliEnBrowser->GetPath());
350 //___________________________________________________________________________
351 void AliAnalysisGUI::HandleMenu(Int_t id) {
352 // Handle menu items.
354 const char *gAlifiletypes[] = {
355 "ROOT files", "*.root",
356 "ROOT macros", "*.C",
357 "Text files", "*.[tT][xX][tT]",
364 fLogInFrame = new AliLoginFrame(gClient->GetRoot(), this, 400, 200);
367 static TString dir(".");
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);
381 // new TagFrame(gClient->GetRoot(), this, 400, 200, kHorizontalFrame, -1);
390 //___________________________________________________________________________
391 void AliAnalysisGUI::HandleToolBar(Int_t id) {
392 // Handle menu items.
397 LogIn("alien://", "");
401 fAliEnBrowser->GotoDir(gGrid->GetHomeDirectory());
402 fFileListFrame->SetQueryPath(fAliEnBrowser->GetPath());