00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <stdlib.h>
00011 #include <TGLabel.h>
00012 #include <TRootHelpDialog.h>
00013 #include <TGMsgBox.h>
00014
00015 #include "SettingsDlg.h"
00016 #include "RootShower.h"
00017 #include "constants.h"
00018 #include "RSHelpText.h"
00019
00020
00021
00022
00023
00024 typedef struct {
00025 Int_t pdg_code;
00026 const char *pdg_name;
00027 } str_choice_def;
00028
00029 str_choice_def choice_def[] = {
00030 { 22, "gamma" },
00031 { 11, "e-" },
00032 { -11, "e+" },
00033 { 13, "mu-" },
00034 { -13, "mu+" },
00035 { 15, "tau-" },
00036 { -15, "tau+" },
00037 { 111, "pi0" },
00038 { 211, "pi+" },
00039 { -211, "pi-" },
00040 { 221, "Eta" },
00041 { 321, "K+" },
00042 { -321, "K-" },
00043 { 130, "K(L)0" },
00044 { 310, "K(S)0" },
00045 { 113, "rho(770)0" },
00046 { 213, "rho(770)+" },
00047 { -213, "rho(770)-" },
00048 { 223, "omega(782)0" },
00049 { 333, "phi(1020)0" },
00050 { 443, "J/psi(1S)0" },
00051 { 511, "B0" },
00052 { 513, "B*0" },
00053 { 521, "B+" },
00054 { -521, "B-" },
00055 { 523, "B*+" },
00056 { -523, "B*-" },
00057 { 531, "B(s)0" },
00058 { 411, "D+" },
00059 { -411, "D-" },
00060 { 421, "D0" },
00061 { 431, "D(s)+" },
00062 { -431, "D(s)-" },
00063 { 433, "D(s)*+" },
00064 { -433, "D(s)*-" },
00065 { 24, "W+" },
00066 { -24, "W-" },
00067 { 23, "Z0" },
00068 { 0, 0 }
00069 };
00070
00071
00072
00073
00074
00075
00076 enum RootShowerSettingsTypes {
00077 Id1,
00078 Id2,
00079 Id3,
00080 Id4,
00081 Id5
00082 };
00083
00084
00085
00086 SettingsDialog::SettingsDialog(const TGWindow *p, const TGWindow *main, UInt_t w,
00087 UInt_t h, UInt_t options)
00088 : TGTransientFrame(p, main, w, h, options)
00089 {
00090
00091
00092
00093 Int_t i;
00094 Char_t tmp[20];
00095 UInt_t wh1 = (UInt_t)(0.6 * h);
00096 UInt_t wh2 = h - wh1;
00097
00098 fFrame1 = new TGHorizontalFrame(this, w, wh2, 0);
00099
00100 fOkButton = new TGTextButton(fFrame1, " &Ok ", 1);
00101 fOkButton->Associate(this);
00102 fCancelButton = new TGTextButton(fFrame1, " &Cancel ", 2);
00103 fCancelButton->Associate(this);
00104 fHelpButton = new TGTextButton(fFrame1, " &Help ", 3);
00105 fHelpButton->Associate(this);
00106
00107 fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
00108 2, 2, 2, 2);
00109 fL2 = new TGLayoutHints(kLHintsBottom | kLHintsRight | kLHintsExpandX, 2, 2, 5, 1);
00110
00111 fFrame1->AddFrame(fOkButton, fL1);
00112 fFrame1->AddFrame(fHelpButton, fL1);
00113 fFrame1->AddFrame(fCancelButton, fL1);
00114
00115 fFrame1->Resize(150, fOkButton->GetDefaultHeight());
00116 AddFrame(fFrame1, fL2);
00117
00118
00119 fTab = new TGTab(this, 300, 300);
00120 fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 10, 10, 10);
00121
00122 TGCompositeFrame *tf = fTab->AddTab("Physics settings");
00123 tf->SetLayoutManager(new TGHorizontalLayout(tf));
00124
00125 fF3 = new TGGroupFrame(tf, "Particle", kVerticalFrame);
00126 tf->AddFrame(fF3, fL3);
00127 fF3->SetLayoutManager(new TGMatrixLayout(fF3, 0, 1, 10));
00128
00129 fF3->AddFrame(fListBox = new TGListBox(fF3, 89));
00130
00131 for (i = 0; choice_def[i].pdg_name; i++) {
00132 fListBox->AddEntry(choice_def[i].pdg_name, i);
00133 }
00134 fFirstEntry = 0;
00135 fLastEntry = 30;
00136 fListBox->Resize(120, 110);
00137
00138 fF3->Resize(fF3->GetDefaultSize());
00139
00140 fF4 = new TGGroupFrame(tf, "E0 / B", kVerticalFrame);
00141 fF4->SetTitlePos(TGGroupFrame::kRight);
00142 tf->AddFrame(fF4, fL3);
00143 fF4->SetLayoutManager(new TGMatrixLayout(fF4, 0, 2, 10));
00144
00145 fF4->AddFrame(new TGLabel(fF4, "E0 [GeV]"));
00146 fF4->AddFrame(fTxt4 = new TGTextEntry(fF4, new TGTextBuffer(100), Id4));
00147 fF4->AddFrame(new TGLabel(fF4, "B [kGauss]"));
00148 fF4->AddFrame(fTxt5 = new TGTextEntry(fF4, new TGTextBuffer(100), Id5));
00149 fTxt4->Associate(this);
00150 fTxt5->Associate(this);
00151 fTxt4->Resize(65, fTxt4->GetDefaultHeight());
00152 fTxt5->Resize(65, fTxt5->GetDefaultHeight());
00153 sprintf(tmp,"%1.4f",gRootShower->fE0);
00154 fTxt4->SetText(tmp);
00155 sprintf(tmp,"%1.4f",gRootShower->fB);
00156 fTxt5->SetText(tmp);
00157
00158 TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
00159 kLHintsExpandY, 2, 2, 5, 1);
00160 AddFrame(fTab, fL5);
00161
00162 MapSubwindows();
00163 Resize(GetDefaultSize());
00164
00165 fF4->Resize(fF4->GetDefaultWidth(),fF3->GetDefaultHeight());
00166
00167 for (i = 0; choice_def[i].pdg_name; i++) {
00168 if (gRootShower->fFirstParticle == choice_def[i].pdg_code) {
00169 fListBox->Select(i);
00170 fListBox->GetScrollBar()->SetPosition(i-2);
00171 break;
00172 }
00173 }
00174 fListBox->MapSubwindows();
00175 fListBox->Layout();
00176
00177 Window_t wdum;
00178 Int_t ax, ay;
00179 gVirtualX->TranslateCoordinates(main->GetId(), GetParent()->GetId(),
00180 (Int_t)(((TGFrame *) main)->GetWidth() - fWidth) >> 1,
00181 (Int_t)(((TGFrame *) main)->GetHeight() - fHeight) >> 1,
00182 ax, ay, wdum);
00183 Move(ax, ay);
00184
00185 SetWindowName("Shower Settings");
00186
00187
00188 UInt_t width = GetDefaultWidth();
00189 UInt_t height = GetDefaultHeight();
00190 SetWMSize(width, height);
00191 SetWMSizeHints(width, height, width, height, 0, 0);
00192
00193 SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
00194 kMWMDecorMinimize | kMWMDecorMenu,
00195 kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
00196 kMWMFuncMinimize, kMWMInputModeless);
00197 MapWindow();
00198 fClient->WaitFor(this);
00199 }
00200
00201
00202 SettingsDialog::~SettingsDialog()
00203 {
00204
00205
00206 delete fOkButton;
00207 delete fCancelButton;
00208 delete fHelpButton;
00209 delete fFrame1;
00210 delete fListBox;
00211 delete fF3;
00212 delete fF4;
00213 delete fTxt4;
00214 delete fTxt5;
00215 delete fTab;
00216 delete fL3;
00217 delete fL2;
00218 delete fL1;
00219 }
00220
00221
00222 void SettingsDialog::CloseWindow()
00223 {
00224
00225
00226 DeleteWindow();
00227 }
00228
00229
00230 Bool_t SettingsDialog::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
00231 {
00232
00233
00234 Int_t Selection;
00235 Int_t retval;
00236 TRootHelpDialog* hd;
00237
00238 const Char_t *buf_tmp;
00239
00240 switch (GET_MSG(msg)) {
00241 case kC_COMMAND:
00242
00243 switch (GET_SUBMSG(msg)) {
00244 case kCM_BUTTON:
00245 switch (parm1) {
00246 case 1:
00247 Selection = fListBox->GetSelected();
00248 if (Selection > 37) {
00249 new TGMsgBox(fClient->GetRoot(), this, "Particle selection",
00250 "This particle is not implemented yet !",
00251 kMBIconExclamation, kMBOk, &retval);
00252 fListBox->Select(2);
00253 break;
00254 }
00255 gRootShower->fFirstParticle = choice_def[Selection].pdg_code;
00256 buf_tmp = fTxt4->GetBuffer()->GetString();
00257 gRootShower->fE0 = atof(buf_tmp);
00258 buf_tmp = fTxt5->GetBuffer()->GetString();
00259 gRootShower->fB = atof(buf_tmp);
00260 gRootShower->SettingsModified();
00261 case 2:
00262 CloseWindow();
00263 break;
00264 case 3:
00265 hd = new TRootHelpDialog(this, "Help on Settings Dialog", 560, 400);
00266 hd->SetText(gSettingsHelp);
00267 hd->Popup();
00268 fClient->WaitFor(hd);
00269 break;
00270 default:
00271 break;
00272 }
00273 break;
00274 case kCM_TAB:
00275 break;
00276 default:
00277 break;
00278 }
00279 break;
00280 case kC_TEXTENTRY:
00281 switch (GET_SUBMSG(msg)) {
00282 case kTE_ENTER:
00283 switch (parm1) {
00284 case Id4:
00285 fTxt5->SetFocus();
00286 break;
00287 case Id5:
00288 fTxt4->SetFocus();
00289 break;
00290 }
00291 break;
00292 case kTE_TAB:
00293 switch (parm1) {
00294 case Id4:
00295 fTxt5->SetFocus();
00296 break;
00297 case Id5:
00298 fTxt4->SetFocus();
00299 break;
00300 }
00301 break;
00302 default:
00303 break;
00304 }
00305 break;
00306
00307 default:
00308 break;
00309 }
00310 return kTRUE;
00311 }