]>
Commit | Line | Data |
---|---|---|
7bb7ac14 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2003, 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 | ///////////////////////////////////////////////////////////////////////// | |
17 | // ALICE MENU CLASS // | |
18 | // Author: Mayeul ROUSSELET // | |
19 | // e-mail: Mayeul.Rousselet@cern.ch // | |
20 | // Last update:26/08/2003 // | |
21 | ///////////////////////////////////////////////////////////////////////// | |
22 | ||
23 | #include <TGMenu.h> | |
24 | #include <TGLayout.h> | |
25 | #include <TGButton.h> | |
26 | #include <TGFileDialog.h> | |
27 | #include <TRootHelpDialog.h> | |
28 | #include <TApplication.h> | |
29 | ||
30 | #include <AliMenu.h> | |
31 | #include <AliSettingFrame.h> | |
32 | #include <AliDisplay2.h> | |
33 | ||
34 | ||
35 | //extern filetypes; | |
36 | const char *gAliFileTypes[] = {"ROOT files","*.root","All files","*",0,0}; | |
37 | const char *gAliImgTypes[] = {"GIF files","*.gif",0,0}; | |
38 | ||
39 | // Help text | |
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"; | |
41 | ||
42 | ||
43 | ClassImp(AliMenu); | |
44 | ||
45 | //_____________________________________________________________ | |
46 | AliMenu::AliMenu(TGCompositeFrame *p, UInt_t w, UInt_t h, UInt_t options) | |
47 | { | |
48 | // Constructor | |
49 | fMenuBar = new TGMenuBar(p,w,h,options); | |
50 | fToolBar = new TGToolBar(p,60,20,options); | |
51 | ||
52 | fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsLeft ,0,0,0,0); | |
53 | fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft,0,4,0,0); | |
54 | ||
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)"); | |
68 | ||
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)"); | |
75 | ||
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)"); | |
82 | ||
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)"); | |
90 | ||
91 | p->AddFrame(fMenuBar,fMenuBarLayout); | |
92 | fTBD = new ToolBarData_t; | |
93 | ||
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); | |
106 | } | |
107 | ||
108 | //_____________________________________________________________ | |
109 | AliMenu::~AliMenu() | |
110 | { | |
111 | // Destructor | |
112 | delete fMenuBarLayout; | |
113 | delete fMenuBarItemLayout; | |
114 | delete fMenuFile; | |
115 | delete fMenuOptions; | |
116 | delete fMenuView; | |
117 | delete fMenuHelp; | |
118 | delete fToolBarLayout; | |
119 | delete fToolBar; | |
120 | delete fMenuBar; | |
121 | delete fTBD; | |
122 | } | |
123 | ||
124 | //_____________________________________________________________ | |
125 | void AliMenu::DoMenu(Int_t id) | |
126 | { | |
127 | switch(id){ | |
128 | case kIdmOPEN:{ | |
129 | TGFileInfo fi; | |
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; | |
135 | } | |
136 | break; | |
137 | case kIdmEXIT:{ | |
138 | gApplication->Terminate(0); | |
139 | } | |
140 | break; | |
141 | case kIdmSAVEAS:{ | |
142 | TGFileInfo fi; | |
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); | |
149 | } | |
150 | break; | |
151 | case kIdmSETTINGS:{ | |
152 | new AliSettingFrame((TGWindow *)gClient->GetRoot(),(TGWindow *)gAliDisplay2->GetMainFrame(),200,150); | |
153 | } | |
154 | break; | |
155 | case kIdmHELP:{ | |
156 | TRootHelpDialog *hd=new TRootHelpDialog((TGWindow *)gClient->GetRoot(),"Help",300,300); | |
157 | hd->SetText(helpTxt); | |
158 | hd->Popup(); | |
159 | } | |
160 | break; | |
161 | ||
162 | case kIdmSAVESETTINGS:{ | |
163 | gAliDisplay2->DoSaveSettings(); | |
164 | } | |
165 | break; | |
166 | case kIdmVIEWX3D:{ | |
167 | gAliDisplay2->DrawX3d(); | |
168 | } | |
169 | break; | |
170 | case kIdmVIEWGL:{ | |
171 | gAliDisplay2->DrawGL(); | |
172 | } | |
173 | break; | |
174 | case kIdbZoomIN:{ | |
175 | gAliDisplay2->SetZoomFactor(gAliDisplay2->GetZoomFactor()*gAliDisplay2->GetZoomStep()); | |
176 | gAliDisplay2->Draw(); | |
177 | } | |
178 | break; | |
179 | case kIdbZoomZONE:{ | |
180 | gAliDisplay2->SetZoomMode(kTRUE); | |
181 | gAliDisplay2->SetEditable(kFALSE); | |
182 | } | |
183 | break; | |
184 | case kIdbZoomOUT:{ | |
185 | gAliDisplay2->SetZoomFactor(gAliDisplay2->GetZoomFactor()/gAliDisplay2->GetZoomStep()); | |
186 | gAliDisplay2->Draw(); | |
187 | } | |
188 | break; | |
189 | default:break; | |
190 | } | |
191 | } | |
192 | ||
193 | //_____________________________________________________________ | |
194 | void AliMenu::DoToolBar(Int_t /*id*/) | |
195 | { | |
196 | TGFrame *frame = (TGFrame *) gTQSender; | |
197 | TGButton *bu = (TGButton *) frame; | |
198 | DoMenu(bu->WidgetId()); | |
199 | } | |
200 | ||
201 | //_____________________________________________________________ | |
202 | void AliMenu::AddPictureButton( const char *fname, const char *tiptext,UInt_t id, UInt_t spacing) | |
203 | { | |
204 | TString filename = StrDup(gAliDisplay2->GetIconsPath()); | |
205 | filename.Append(fname); | |
206 | ||
207 | fTBD->fPixmap=filename.Data(); | |
208 | fTBD->fTipText = tiptext; | |
209 | fTBD->fId = id; | |
210 | fTBD->fStayDown = kFALSE; | |
211 | ||
212 | fToolBar->AddButton(fToolBar,fTBD,spacing); | |
213 | if(fTBD->fButton) | |
214 | fTBD->fButton->Connect("Clicked()","AliMenu",this,"DoToolBar(Int_t)"); | |
215 | } |