1 /**************************************************************************
2 * Copyright(c) 1998-2003, 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 **************************************************************************/
16 /////////////////////////////////////////////////////////////////////////
17 // ALICE MENU CLASS //
18 // Author: Mayeul ROUSSELET //
19 // e-mail: Mayeul.Rousselet@cern.ch //
20 // Last update:26/08/2003 //
21 /////////////////////////////////////////////////////////////////////////
26 #include <TGFileDialog.h>
27 #include <TRootHelpDialog.h>
28 #include <TApplication.h>
31 #include <AliSettingFrame.h>
32 #include <AliDisplay2.h>
36 const char *gAliFileTypes[] = {"ROOT files","*.root","All files","*",0,0};
37 const char *gAliImgTypes[] = {"GIF files","*.gif",0,0};
40 const char helpTxt[] = "\tAliDisplay v2.0\n\t\tHelp\n\n\nWelcome in the AliDisplay help.\nHere is a list of useful subjects which discribes\nthe main functionnalities of the software\n \nEvent:Use the arrows to get the next or previous event\nView:Each button corresponds to a different view\nDetectors:Select the module you want to see\nOptions:Select the view mode\nSliders:Use the rapidity (or eta) slider to cut the set of hits\n\tAnd the momentum slider to cut with respect to the momentum\n";
45 //_____________________________________________________________
46 AliMenu::AliMenu(TGCompositeFrame *p, UInt_t w, UInt_t h, UInt_t options)
49 fMenuBar = new TGMenuBar(p,w,h,options);
50 fToolBar = new TGToolBar(p,60,20,options);
52 fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsLeft ,0,0,0,0);
53 fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft,0,4,0,0);
55 fMenuFile = new TGPopupMenu(gClient->GetRoot());
56 fMenuFile->AddEntry("Open",kIdmOPEN);
57 fMenuFile->AddEntry("Save as",kIdmSAVEAS);
58 fMenuFile->AddEntry("Close",kIdmCLOSE);
59 fMenuFile->AddSeparator();
60 fMenuFile->AddEntry("Print",kIdmPRINT);
61 fMenuFile->AddEntry("Print setup",kIdmPRINTSETUP);
62 fMenuFile->AddSeparator();
63 fMenuFile->AddEntry("Exit",kIdmEXIT);
64 fMenuFile->DisableEntry(kIdmSAVEAS);
65 fMenuFile->Associate(p);
66 fMenuBar->AddPopup("File",fMenuFile,fMenuBarItemLayout);
67 fMenuFile->Connect("Activated(Int_t)","AliMenu",this,"DoMenu(Int_t)");
69 fMenuOptions = new TGPopupMenu(gClient->GetRoot());
70 fMenuOptions->AddEntry("Settings",kIdmSETTINGS);
71 fMenuOptions->AddEntry("Save settings",kIdmSAVESETTINGS);
72 fMenuOptions->Associate(p);
73 fMenuBar->AddPopup("Options",fMenuOptions,fMenuBarItemLayout);
74 fMenuOptions->Connect("Activated(Int_t)","AliMenu",this,"DoMenu(Int_t)");
76 fMenuView = new TGPopupMenu(gClient->GetRoot());
77 fMenuView->AddEntry("X3d ",kIdmVIEWX3D);
78 fMenuView->AddEntry("OpenGL",kIdmVIEWGL);
79 fMenuView->Associate(p);
80 fMenuBar->AddPopup("View",fMenuView,fMenuBarItemLayout);
81 fMenuView->Connect("Activated(Int_t)","AliMenu",this,"DoMenu(Int_t)");
83 fMenuHelp = new TGPopupMenu(gClient->GetRoot());
84 fMenuHelp->AddEntry("Help",kIdmHELP);
85 fMenuHelp->AddSeparator();
86 fMenuHelp->AddEntry("About",kIdmABOUT);
87 fMenuHelp->Associate(p);
88 fMenuBar->AddPopup("Help",fMenuHelp,fMenuBarItemLayout);
89 fMenuHelp->Connect("Activated(Int_t)","AliMenu",this,"DoMenu(Int_t)");
91 p->AddFrame(fMenuBar,fMenuBarLayout);
92 fTBD = new ToolBarData_t;
94 fToolBarLayout = new TGLayoutHints(kLHintsTop | kLHintsExpandX,0,0,0,0);
95 AddPictureButton("open.xpm","Open file",kIdmOPEN,5);
96 AddPictureButton("save.xpm","Save current pad as gif file",kIdmSAVEAS,0);
97 AddPictureButton("settings.xpm","Settings",kIdmSETTINGS,5);
98 AddPictureButton("help.xpm","Help",kIdmHELP,5);
99 AddPictureButton("quit.xpm","Exit AliDisplay",kIdmEXIT,5);
100 AddPictureButton("opengl.xpm","Open GL view",kIdmVIEWGL,5);
101 AddPictureButton("x3d.xpm","x3d view",kIdmVIEWX3D,0);
102 AddPictureButton("zoomplus16.xpm","Zoom in",kIdbZoomIN,5);
103 AddPictureButton("zoommoins16.xpm","Zoom out",kIdbZoomOUT,0);
104 AddPictureButton("zoomzone.xpm","Zoom on zone",kIdbZoomZONE,0);
105 p->AddFrame(fToolBar,fToolBarLayout);
108 //_____________________________________________________________
112 delete fMenuBarLayout;
113 delete fMenuBarItemLayout;
118 delete fToolBarLayout;
124 //_____________________________________________________________
125 void AliMenu::DoMenu(Int_t id)
130 static TString dir(".");
131 fi.fFileTypes = gAliFileTypes;
132 fi.fIniDir = StrDup(dir.Data());
133 new TGFileDialog(gClient->GetRoot(),gAliDisplay2->GetMainFrame(),kFDOpen,&fi);
134 if(!fi.fFilename) return;
138 gApplication->Terminate(0);
143 static TString dir(".");
144 fi.fFileTypes = gAliImgTypes;
145 fi.fIniDir = StrDup(dir.Data());
146 new TGFileDialog(gClient->GetRoot(),gAliDisplay2->GetMainFrame(),kFDSave,&fi);
147 if(!fi.fFilename) return;
148 gAliDisplay2->SavePadGIF(fi.fFilename);
152 new AliSettingFrame((TGWindow *)gClient->GetRoot(),(TGWindow *)gAliDisplay2->GetMainFrame(),200,150);
156 TRootHelpDialog *hd=new TRootHelpDialog((TGWindow *)gClient->GetRoot(),"Help",300,300);
157 hd->SetText(helpTxt);
162 case kIdmSAVESETTINGS:{
163 gAliDisplay2->DoSaveSettings();
167 gAliDisplay2->DrawX3d();
171 gAliDisplay2->DrawGL();
175 gAliDisplay2->SetZoomFactor(gAliDisplay2->GetZoomFactor()*gAliDisplay2->GetZoomStep());
176 gAliDisplay2->Draw();
180 gAliDisplay2->SetZoomMode(kTRUE);
181 gAliDisplay2->SetEditable(kFALSE);
185 gAliDisplay2->SetZoomFactor(gAliDisplay2->GetZoomFactor()/gAliDisplay2->GetZoomStep());
186 gAliDisplay2->Draw();
193 //_____________________________________________________________
194 void AliMenu::DoToolBar(Int_t /*id*/)
196 TGFrame *frame = (TGFrame *) gTQSender;
197 TGButton *bu = (TGButton *) frame;
198 DoMenu(bu->WidgetId());
201 //_____________________________________________________________
202 void AliMenu::AddPictureButton( const char *fname, const char *tiptext,UInt_t id, UInt_t spacing)
204 TString filename = StrDup(gAliDisplay2->GetIconsPath());
205 filename.Append(fname);
207 fTBD->fPixmap=filename.Data();
208 fTBD->fTipText = tiptext;
210 fTBD->fStayDown = kFALSE;
212 fToolBar->AddButton(fToolBar,fTBD,spacing);
214 fTBD->fButton->Connect("Clicked()","AliMenu",this,"DoToolBar(Int_t)");