33 ClassImp(TGeoMediumEditor);
36 kMED_NAME, kMED_ID, kMED_MATSEL,
37 kMED_SENS, kMED_FLDOPT, kMED_EDIT_MAT,
38 kMED_FIELDM, kMED_TMAX, kMED_STEMAX,
39 kMED_DEEMAX, kMED_EPSIL, kMED_STMIN,
40 kMED_APPLY, kMED_CANCEL, kMED_UNDO
46 TGeoMediumEditor::TGeoMediumEditor(
const TGWindow *p, Int_t width,
47 Int_t height, UInt_t options, Pixel_t back)
48 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
58 fMedName =
new TGTextEntry(
this,
"", kMED_NAME);
59 fMedName->SetDefaultSize(135, fMedName->GetDefaultHeight());
60 fMedName->SetToolTipText(
"Enter the medium name");
61 fMedName->Associate(
this);
62 AddFrame(fMedName,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 3, 1, 2, 2));
67 TGCompositeFrame *f1 =
new TGCompositeFrame(
this, 120, 30, kHorizontalFrame | kRaisedFrame);
68 f1->AddFrame(
new TGLabel(f1,
"ID"),
new TGLayoutHints(kLHintsLeft, 4, 1, 6, 0));
69 fMedId =
new TGNumberEntry(f1, 0., 1, kMED_ID);
70 nef = (TGTextEntry*)fMedId->GetNumberEntry();
71 nef->SetToolTipText(
"Enter the medium ID");
72 fMedId->Associate(
this);
73 f1->AddFrame(fMedId,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
74 fMedSensitive =
new TGCheckButton(f1,
"&Sens", kMED_SENS);
75 fMedSensitive->Associate(
this);
76 f1->AddFrame(fMedSensitive,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
77 AddFrame(f1,
new TGLayoutHints(kLHintsLeft, 3, 3, 2, 2));
80 f1 =
new TGCompositeFrame(
this, 145, 10, kHorizontalFrame | kFixedWidth | kOwnBackground);
81 f1->AddFrame(label =
new TGLabel(f1,
"Current material"),
new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
82 f1->AddFrame(
new TGHorizontal3DLine(f1),
new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
83 gClient->GetColorByName(
"#ff0000", color);
84 label->SetTextColor(color);
85 AddFrame(f1,
new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
86 f1 =
new TGCompositeFrame(
this, 155, 30, kHorizontalFrame);
87 fSelectedMaterial = 0;
88 fLSelMaterial =
new TGLabel(f1,
"Select material");
89 gClient->GetColorByName(
"#0000ff", color);
90 fLSelMaterial->SetTextColor(color);
91 fLSelMaterial->ChangeOptions(kChildFrame | kSunkenFrame | kDoubleBorder);
92 f1->AddFrame(fLSelMaterial,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
93 fBSelMaterial =
new TGPictureButton(f1, fClient->GetPicture(
"rootdb_t.xpm"), kMED_MATSEL);
94 fBSelMaterial->SetToolTipText(
"Replace with one of the existing materials");
95 fBSelMaterial->Associate(
this);
96 f1->AddFrame(fBSelMaterial,
new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
97 fEditMaterial =
new TGTextButton(f1,
"Edit");
98 f1->AddFrame(fEditMaterial,
new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
99 fEditMaterial->SetToolTipText(
"Edit selected material");
100 fEditMaterial->Associate(
this);
101 AddFrame(f1,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 0, 0));
104 f1 =
new TGCompositeFrame(
this, 145, 10, kHorizontalFrame | kLHintsExpandX | kFixedWidth | kOwnBackground);
105 f1->AddFrame(label =
new TGLabel(f1,
"Mag. field option"),
new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
106 f1->AddFrame(
new TGHorizontal3DLine(f1),
new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
107 gClient->GetColorByName(
"#ff0000", color);
108 label->SetTextColor(color);
109 AddFrame(f1,
new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
110 fMagfldOption =
new TGComboBox(
this, kMED_FLDOPT);
111 fMagfldOption->Resize(135, fMedName->GetDefaultHeight());
112 AddFrame(fMagfldOption,
new TGLayoutHints(kLHintsLeft, 3, 1, 2, 2));
116 f1 =
new TGCompositeFrame(
this, 145, 10, kHorizontalFrame | kFixedWidth | kOwnBackground);
117 f1->AddFrame(label =
new TGLabel(f1,
"Medium cuts"),
new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
118 f1->AddFrame(
new TGHorizontal3DLine(f1),
new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
119 gClient->GetColorByName(
"#ff0000", color);
120 label->SetTextColor(color);
121 AddFrame(f1,
new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
122 TGCompositeFrame *compxyz =
new TGCompositeFrame(
this, 130, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
125 f1 =
new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
126 kLHintsExpandX | kFixedWidth | kOwnBackground);
127 f1->AddFrame(
new TGLabel(f1,
"FIELDM"),
new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
128 fMedFieldm =
new TGNumberEntry(f1, 0., 5, kMED_FIELDM);
129 nef = (TGTextEntry*)fMedFieldm->GetNumberEntry();
130 nef->SetToolTipText(
"Maximum magnetic field [kilogauss]");
131 fMedFieldm->Associate(
this);
132 fMedFieldm->Resize(90, fMedFieldm->GetDefaultHeight());
133 f1->AddFrame(fMedFieldm,
new TGLayoutHints(kLHintsRight | kFixedWidth , 2, 2, 2, 2));
134 compxyz->AddFrame(f1,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 1, 1));
137 TGCompositeFrame *f2 =
new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
138 kLHintsExpandX | kFixedWidth | kOwnBackground);
139 f2->AddFrame(
new TGLabel(f2,
"TMAXFD"),
new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
140 fMedTmaxfd =
new TGNumberEntry(f2, 0., 5, kMED_TMAX);
141 nef = (TGTextEntry*)fMedTmaxfd->GetNumberEntry();
142 nef->SetToolTipText(
"Maximum angle per step due to field [deg]");
143 fMedTmaxfd->Associate(
this);
144 fMedTmaxfd->Resize(90, fMedTmaxfd->GetDefaultHeight());
145 f2->AddFrame(fMedTmaxfd,
new TGLayoutHints(kLHintsRight | kFixedWidth , 2, 2, 2, 2));
146 compxyz->AddFrame(f2,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 1, 1));
149 TGCompositeFrame *f3 =
new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
150 kLHintsExpandX | kFixedWidth | kOwnBackground);
151 f3->AddFrame(
new TGLabel(f3,
"STEMAX"),
new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
152 fMedStemax =
new TGNumberEntry(f3, 0., 5, kMED_STEMAX);
153 nef = (TGTextEntry*)fMedStemax->GetNumberEntry();
154 nef->SetToolTipText(
"Maximum step allowed [cm]");
155 fMedStemax->Associate(
this);
156 fMedStemax->Resize(90, fMedStemax->GetDefaultHeight());
157 f3->AddFrame(fMedStemax,
new TGLayoutHints(kLHintsRight | kFixedWidth , 2, 2, 2, 2));
158 compxyz->AddFrame(f3,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 1, 1));
161 TGCompositeFrame *f4 =
new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
162 kLHintsExpandX | kFixedWidth | kOwnBackground);
163 f4->AddFrame(
new TGLabel(f4,
"DEEMAX"),
new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
164 fMedDeemax =
new TGNumberEntry(f4, 0., 5, kMED_DEEMAX);
165 nef = (TGTextEntry*)fMedDeemax->GetNumberEntry();
166 nef->SetToolTipText(
"Maximum fraction of energy lost in a step");
167 fMedDeemax->Associate(
this);
168 fMedDeemax->Resize(90, fMedDeemax->GetDefaultHeight());
169 f4->AddFrame(fMedDeemax,
new TGLayoutHints(kLHintsRight | kFixedWidth , 2, 2, 2, 2));
170 compxyz->AddFrame(f4,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 1, 1));
173 TGCompositeFrame *f5 =
new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
174 kLHintsExpandX | kFixedWidth | kOwnBackground);
175 f5->AddFrame(
new TGLabel(f5,
"EPSIL"),
new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
176 fMedEpsil =
new TGNumberEntry(f5, 0., 5, kMED_EPSIL);
177 nef = (TGTextEntry*)fMedEpsil->GetNumberEntry();
178 nef->SetToolTipText(
"Tracking precision [cm]");
179 fMedEpsil->Associate(
this);
180 fMedEpsil->Resize(90, fMedEpsil->GetDefaultHeight());
181 f5->AddFrame(fMedEpsil,
new TGLayoutHints(kLHintsRight | kFixedWidth , 2, 2, 2, 2));
182 compxyz->AddFrame(f5,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 1, 1));
185 TGCompositeFrame *f6 =
new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
186 kLHintsExpandX | kFixedWidth | kOwnBackground);
187 f6->AddFrame(
new TGLabel(f6,
"STMIN"),
new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
188 fMedStmin =
new TGNumberEntry(f6, 0., 5, kMED_STMIN);
189 nef = (TGTextEntry*)fMedStmin->GetNumberEntry();
190 nef->SetToolTipText(
"Minimum step due to continuous processes [cm]");
191 fMedStmin->Associate(
this);
192 fMedStmin->Resize(90, fMedStmin->GetDefaultHeight());
193 f6->AddFrame(fMedStmin,
new TGLayoutHints(kLHintsRight | kFixedWidth , 2, 2, 2, 2));
194 compxyz->AddFrame(f6,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 1, 1));
196 compxyz->Resize(160,50);
197 AddFrame(compxyz,
new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
200 TGCompositeFrame *f23 =
new TGCompositeFrame(
this, 118, 20, kHorizontalFrame | kSunkenFrame | kDoubleBorder);
201 fApply =
new TGTextButton(f23,
"&Apply");
202 f23->AddFrame(fApply,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
203 fApply->Associate(
this);
204 fUndo =
new TGTextButton(f23,
" &Undo ");
205 f23->AddFrame(fUndo,
new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
206 fUndo->Associate(
this);
207 AddFrame(f23,
new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
213 TGeoMediumEditor::~TGeoMediumEditor()
216 TIter next(GetList());
217 while ((el = (TGFrameElement *)next())) {
218 if (el->fFrame->IsA() == TGCompositeFrame::Class() ||
219 el->fFrame->IsA() == TGHorizontalFrame::Class() ||
220 el->fFrame->IsA() == TGVerticalFrame::Class())
221 TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame);
229 void TGeoMediumEditor::ConnectSignals2Slots()
231 fApply->Connect(
"Clicked()",
"TGeoMediumEditor",
this,
"DoApply()");
232 fUndo->Connect(
"Clicked()",
"TGeoMediumEditor",
this,
"DoUndo()");
233 fMedName->Connect(
"TextChanged(const char *)",
"TGeoMediumEditor",
this,
"DoMedName()");
234 fBSelMaterial->Connect(
"Clicked()",
"TGeoMediumEditor",
this,
"DoSelectMaterial()");
235 fEditMaterial->Connect(
"Clicked()",
"TGeoMediumEditor",
this,
"DoEditMaterial()");
236 fMedId->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoMediumEditor",
this,
"DoMedId()");
237 fMedTmaxfd->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoMediumEditor",
this,
"DoTmaxfd()");
238 fMedStemax->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoMediumEditor",
this,
"DoStemax()");
239 fMedDeemax->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoMediumEditor",
this,
"DoDeemax()");
240 fMedEpsil->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoMediumEditor",
this,
"DoEpsil()");
241 fMedStmin->GetNumberEntry()->Connect(
"TextChanged(const char *)",
"TGeoMediumEditor",
this,
"DoStmin()");
242 fMedSensitive->Connect(
"Clicked()",
"TGeoMediumEditor",
this,
"DoToggleSensitive()");
243 fMagfldOption->Connect(
"Selected(Int_t)",
"TGeoMediumEditor",
this,
"DoMagfldSelect(Int_t)");
251 void TGeoMediumEditor::SetModel(TObject* obj)
253 if (obj == 0 || !(obj->IsA()==TGeoMedium::Class())) {
257 fMedium = (TGeoMedium*)obj;
258 const char *sname = fMedium->GetName();
259 if (!strcmp(sname, fMedium->ClassName())) fMedName->SetText(
"");
260 else fMedName->SetText(sname);
262 fMedId->SetNumber(fMedium->GetId());
263 Int_t isvol = (Int_t)fMedium->GetParam(0);
264 fMedSensitive->SetState((isvol==0)?kButtonUp:kButtonDown);
266 fSelectedMaterial = fMedium->GetMaterial();
267 if (fSelectedMaterial) fLSelMaterial->SetText(fSelectedMaterial->GetName());
269 if (!fMagfldOption->GetNumberOfEntries()) {
270 fMagfldOption->AddEntry(
"No field", 0);
271 fMagfldOption->AddEntry(
"User decision", 1);
272 fMagfldOption->AddEntry(
"Runge-Kutta", 2);
273 fMagfldOption->AddEntry(
"Helix", 3);
274 fMagfldOption->AddEntry(
"Helix3", 4);
275 fMagfldOption->AddEntry(
"Unknown option", 5);
277 Int_t ifld = (Int_t)fMedium->GetParam(1);
280 fMagfldOption->Select(0);
283 fMagfldOption->Select(1);
286 fMagfldOption->Select(2);
289 fMagfldOption->Select(3);
292 fMagfldOption->Select(4);
295 fMagfldOption->Select(5);
299 fMedFieldm->SetNumber(fMedium->GetParam(2));
300 fMedTmaxfd->SetNumber(fMedium->GetParam(3));
301 fMedStemax->SetNumber(fMedium->GetParam(4));
302 fMedDeemax->SetNumber(fMedium->GetParam(5));
303 fMedEpsil->SetNumber(fMedium->GetParam(6));
304 fMedStmin->SetNumber(fMedium->GetParam(7));
306 fUndo->SetEnabled(kFALSE);
307 fIsModified = kFALSE;
310 if (fInit) ConnectSignals2Slots();
317 void TGeoMediumEditor::DoEditMaterial()
319 fTabMgr->GetMaterialEditor(fMedium->GetMaterial());
325 void TGeoMediumEditor::DoMedName()
327 const char *name = fMedName->GetText();
328 if (!name[0] || !strcmp(name, fMedium->GetName()))
return;
329 fMedium->SetName(name);
335 void TGeoMediumEditor::DoMedId()
342 void TGeoMediumEditor::DoSelectMaterial()
344 TGeoMaterial *material = fSelectedMaterial;
345 new TGeoMaterialDialog(fBSelMaterial, gClient->GetRoot(), 200,300);
346 fSelectedMaterial = (TGeoMaterial*)TGeoMaterialDialog::GetSelected();
347 if (fSelectedMaterial) fLSelMaterial->SetText(fSelectedMaterial->GetName());
348 else fSelectedMaterial = material;
354 void TGeoMediumEditor::DoToggleSensitive()
362 void TGeoMediumEditor::DoMagfldSelect(Int_t)
370 void TGeoMediumEditor::DoFieldm()
378 void TGeoMediumEditor::DoTmaxfd()
386 void TGeoMediumEditor::DoStemax()
394 void TGeoMediumEditor::DoDeemax()
402 void TGeoMediumEditor::DoEpsil()
410 void TGeoMediumEditor::DoStmin()
418 void TGeoMediumEditor::DoApply()
420 if (!fIsModified)
return;
421 Double_t isvol = (fMedSensitive->IsOn())?1:0;
422 Double_t ifield = fMagfldOption->GetSelected();
425 if (ifield < 1.) ifield -= 1.;
427 Double_t fieldm = fMedFieldm->GetNumber();
428 Double_t tmaxfd = fMedTmaxfd->GetNumber();
429 Double_t stemax = fMedStemax->GetNumber();
430 Double_t deemax = fMedDeemax->GetNumber();
431 Double_t epsil = fMedEpsil->GetNumber();
432 Double_t stmin = fMedStmin->GetNumber();
434 fMedium->SetParam(0,isvol);
435 fMedium->SetParam(1,ifield);
436 fMedium->SetParam(2,fieldm);
437 fMedium->SetParam(3,tmaxfd);
438 fMedium->SetParam(4,stemax);
439 fMedium->SetParam(5,deemax);
440 fMedium->SetParam(6,epsil);
441 fMedium->SetParam(7,stmin);
442 if (strcmp(fMedium->GetName(), fMedName->GetText())) fMedium->SetName(fMedName->GetText());
443 if (fMedium->GetId() != fMedId->GetIntNumber()) fMedium->SetId(fMedId->GetIntNumber());
449 void TGeoMediumEditor::DoUndo()