Logo ROOT  
Reference Guide
TGeoMediumEditor.cxx
Go to the documentation of this file.
1// @(#):$Id: c816a00a89512fcc6cd4a75fb1343c76ebaa3c24 $
2// Author: M.Gheata
3
4/*************************************************************************
5 * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TGeoMediumEditor
13\ingroup Geometry_builder
14
15Editor class for TGeo tracking media.
16
17*/
18
19#include "TGeoMediumEditor.h"
20#include "TGeoTabManager.h"
21#include "TGeoManager.h"
22#include "TGeoMedium.h"
23#include "TGeoMaterial.h"
24#include "TGTab.h"
25#include "TGComboBox.h"
26#include "TGButton.h"
27#include "TGTextEntry.h"
28#include "TGNumberEntry.h"
29#include "TGLabel.h"
30#include "TG3DLine.h"
31
33
40};
41
42////////////////////////////////////////////////////////////////////////////////
43/// Constructor for medium editor
44
46 Int_t height, UInt_t options, Pixel_t back)
47 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
48{
49 fMedium = 0;
52 Pixel_t color;
53 TGLabel *label;
54
55 // TextEntry for medium name
56 MakeTitle("Name");
57 fMedName = new TGTextEntry(this, "", kMED_NAME);
59 fMedName->SetToolTipText("Enter the medium name");
60 fMedName->Associate(this);
62
63 TGTextEntry *nef;
64
65// Composite frame for medium ID and sensitivity
67 f1->AddFrame(new TGLabel(f1, "ID"), new TGLayoutHints(kLHintsLeft, 4, 1, 6, 0));
68 fMedId = new TGNumberEntry(f1, 0., 1, kMED_ID);
70 nef->SetToolTipText("Enter the medium ID");
71 fMedId->Associate(this);
72 f1->AddFrame(fMedId, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
73 fMedSensitive = new TGCheckButton(f1, "&Sens", kMED_SENS);
75 f1->AddFrame(fMedSensitive, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
76 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 3, 3, 2, 2));
77
78 // Current material
80 f1->AddFrame(label = new TGLabel(f1, "Current material"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
81 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
82 gClient->GetColorByName("#ff0000", color);
83 label->SetTextColor(color);
84 AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
85 f1 = new TGCompositeFrame(this, 155, 30, kHorizontalFrame);
87 fLSelMaterial = new TGLabel(f1, "Select material");
88 gClient->GetColorByName("#0000ff", color);
93 fBSelMaterial->SetToolTipText("Replace with one of the existing materials");
95 f1->AddFrame(fBSelMaterial, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
96 fEditMaterial = new TGTextButton(f1, "Edit");
97 f1->AddFrame(fEditMaterial, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
98 fEditMaterial->SetToolTipText("Edit selected material");
101
102// Combo box for magnetic field option
104 f1->AddFrame(label = new TGLabel(f1, "Mag. field option"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
105 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
106 gClient->GetColorByName("#ff0000", color);
107 label->SetTextColor(color);
108 AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
112
113
114// Number entries for other settings
116 f1->AddFrame(label = new TGLabel(f1, "Medium cuts"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
117 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
118 gClient->GetColorByName("#ff0000", color);
119 label->SetTextColor(color);
120 AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
122
123 // Number entry for fieldm
124 f1 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
126 f1->AddFrame(new TGLabel(f1, "FIELDM"), new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
127 fMedFieldm = new TGNumberEntry(f1, 0., 5, kMED_FIELDM);
129 nef->SetToolTipText("Maximum magnetic field [kilogauss]");
130 fMedFieldm->Associate(this);
132 f1->AddFrame(fMedFieldm, new TGLayoutHints(kLHintsRight | kFixedWidth , 2, 2, 2, 2));
133 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 1, 1));
134
135 // Number entry for tmaxfd
136 TGCompositeFrame *f2 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
138 f2->AddFrame(new TGLabel(f2, "TMAXFD"), new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
139 fMedTmaxfd = new TGNumberEntry(f2, 0., 5, kMED_TMAX);
141 nef->SetToolTipText("Maximum angle per step due to field [deg]");
142 fMedTmaxfd->Associate(this);
144 f2->AddFrame(fMedTmaxfd, new TGLayoutHints(kLHintsRight | kFixedWidth , 2, 2, 2, 2));
145 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 1, 1));
146
147 // Number entry for stemax
148 TGCompositeFrame *f3 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
150 f3->AddFrame(new TGLabel(f3, "STEMAX"), new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
151 fMedStemax = new TGNumberEntry(f3, 0., 5, kMED_STEMAX);
153 nef->SetToolTipText("Maximum step allowed [cm]");
154 fMedStemax->Associate(this);
156 f3->AddFrame(fMedStemax, new TGLayoutHints(kLHintsRight | kFixedWidth , 2, 2, 2, 2));
157 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 1, 1));
158
159 // Number entry for deemax
160 TGCompositeFrame *f4 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
162 f4->AddFrame(new TGLabel(f4, "DEEMAX"), new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
163 fMedDeemax = new TGNumberEntry(f4, 0., 5, kMED_DEEMAX);
165 nef->SetToolTipText("Maximum fraction of energy lost in a step");
166 fMedDeemax->Associate(this);
168 f4->AddFrame(fMedDeemax, new TGLayoutHints(kLHintsRight | kFixedWidth , 2, 2, 2, 2));
169 compxyz->AddFrame(f4, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 1, 1));
170
171 // Number entry for epsil
172 TGCompositeFrame *f5 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
174 f5->AddFrame(new TGLabel(f5, "EPSIL"), new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
175 fMedEpsil = new TGNumberEntry(f5, 0., 5, kMED_EPSIL);
177 nef->SetToolTipText("Tracking precision [cm]");
178 fMedEpsil->Associate(this);
180 f5->AddFrame(fMedEpsil, new TGLayoutHints(kLHintsRight | kFixedWidth , 2, 2, 2, 2));
181 compxyz->AddFrame(f5, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 1, 1));
182
183 // Number entry for stmin
184 TGCompositeFrame *f6 = new TGCompositeFrame(compxyz, 118, 10, kHorizontalFrame |
186 f6->AddFrame(new TGLabel(f6, "STMIN"), new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
187 fMedStmin = new TGNumberEntry(f6, 0., 5, kMED_STMIN);
189 nef->SetToolTipText("Minimum step due to continuous processes [cm]");
190 fMedStmin->Associate(this);
192 f6->AddFrame(fMedStmin, new TGLayoutHints(kLHintsRight | kFixedWidth , 2, 2, 2, 2));
193 compxyz->AddFrame(f6, new TGLayoutHints(kLHintsLeft | kLHintsExpandX , 2, 2, 1, 1));
194
195 compxyz->Resize(160,50);
196 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
197
198 // Buttons
200 fApply = new TGTextButton(f23, "&Apply");
201 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
202 fApply->Associate(this);
203 fUndo = new TGTextButton(f23, " &Undo ");
204 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4));
205 fUndo->Associate(this);
206 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
207}
208
209////////////////////////////////////////////////////////////////////////////////
210/// Destructor
211
213{
214 TGFrameElement *el;
215 TIter next(GetList());
216 while ((el = (TGFrameElement *)next())) {
217 if (el->fFrame->IsA() == TGCompositeFrame::Class() ||
218 el->fFrame->IsA() == TGHorizontalFrame::Class() ||
219 el->fFrame->IsA() == TGVerticalFrame::Class())
221 }
222 Cleanup();
223}
224
225////////////////////////////////////////////////////////////////////////////////
226/// Connect signals to slots.
227
229{
230 fApply->Connect("Clicked()", "TGeoMediumEditor", this, "DoApply()");
231 fUndo->Connect("Clicked()", "TGeoMediumEditor", this, "DoUndo()");
232 fMedName->Connect("TextChanged(const char *)", "TGeoMediumEditor", this, "DoMedName()");
233 fBSelMaterial->Connect("Clicked()", "TGeoMediumEditor", this, "DoSelectMaterial()");
234 fEditMaterial->Connect("Clicked()", "TGeoMediumEditor", this, "DoEditMaterial()");
235 fMedId->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoMediumEditor", this, "DoMedId()");
236 fMedTmaxfd->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoMediumEditor", this, "DoTmaxfd()");
237 fMedStemax->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoMediumEditor", this, "DoStemax()");
238 fMedDeemax->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoMediumEditor", this, "DoDeemax()");
239 fMedEpsil->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoMediumEditor", this, "DoEpsil()");
240 fMedStmin->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoMediumEditor", this, "DoStmin()");
241 fMedSensitive->Connect("Clicked()", "TGeoMediumEditor", this, "DoToggleSensitive()");
242 fMagfldOption->Connect("Selected(Int_t)", "TGeoMediumEditor", this, "DoMagfldSelect(Int_t)");
243 fInit = kFALSE;
244}
245
246
247////////////////////////////////////////////////////////////////////////////////
248/// Connect to the selected object.
249
251{
252 if (obj == 0 || !(obj->IsA()==TGeoMedium::Class())) {
254 return;
255 }
256 fMedium = (TGeoMedium*)obj;
257 const char *sname = fMedium->GetName();
258 if (!strcmp(sname, fMedium->ClassName())) fMedName->SetText("");
259 else fMedName->SetText(sname);
260
262 Int_t isvol = (Int_t)fMedium->GetParam(0);
264
267
269 fMagfldOption->AddEntry("No field", 0);
270 fMagfldOption->AddEntry("User decision", 1);
271 fMagfldOption->AddEntry("Runge-Kutta", 2);
272 fMagfldOption->AddEntry("Helix", 3);
273 fMagfldOption->AddEntry("Helix3", 4);
274 fMagfldOption->AddEntry("Unknown option", 5);
275 }
276 Int_t ifld = (Int_t)fMedium->GetParam(1);
277 switch (ifld) {
278 case 0:
280 break;
281 case -1:
283 break;
284 case 1:
286 break;
287 case 2:
289 break;
290 case 3:
292 break;
293 default:
295 break;
296 }
297
304
307
308
310 SetActive();
311}
312
313////////////////////////////////////////////////////////////////////////////////
314/// Edit selected material.
315
317{
319}
320
321////////////////////////////////////////////////////////////////////////////////
322/// Slot for medium name.
323
325{
326 const char *name = fMedName->GetText();
327 if (!name[0] || !strcmp(name, fMedium->GetName())) return;
329}
330
331////////////////////////////////////////////////////////////////////////////////
332/// Slot for medium id.
333
335{
336}
337
338////////////////////////////////////////////////////////////////////////////////
339/// Select the material component.
340
342{
344 new TGeoMaterialDialog(fBSelMaterial, gClient->GetRoot(), 200,300);
347 else fSelectedMaterial = material;
348}
349
350////////////////////////////////////////////////////////////////////////////////
351/// Slot for sensitivity.
352
354{
356}
357
358////////////////////////////////////////////////////////////////////////////////
359/// Slot for mag. field.
360
362{
364}
365
366////////////////////////////////////////////////////////////////////////////////
367/// Slot for max field.
368
370{
372}
373
374////////////////////////////////////////////////////////////////////////////////
375/// Slot for tmaxfd.
376
378{
380}
381
382////////////////////////////////////////////////////////////////////////////////
383/// Slot for the max allowed step.
384
386{
388}
389
390////////////////////////////////////////////////////////////////////////////////
391/// Slot for the maximum allowed dedx.
392
394{
396}
397
398////////////////////////////////////////////////////////////////////////////////
399/// Slot for tracking precision.
400
402{
404}
405
406////////////////////////////////////////////////////////////////////////////////
407/// Slot for min. step.
408
410{
412}
413
414////////////////////////////////////////////////////////////////////////////////
415/// Slot for applying modifications.
416
418{
419 if (!fIsModified) return;
420 Double_t isvol = (fMedSensitive->IsOn())?1:0;
422 if (ifield>0) {
423 ifield -= 1.;
424 if (ifield < 1.) ifield -= 1.;
425 }
426 Double_t fieldm = fMedFieldm->GetNumber();
427 Double_t tmaxfd = fMedTmaxfd->GetNumber();
428 Double_t stemax = fMedStemax->GetNumber();
429 Double_t deemax = fMedDeemax->GetNumber();
430 Double_t epsil = fMedEpsil->GetNumber();
431 Double_t stmin = fMedStmin->GetNumber();
432
433 fMedium->SetParam(0,isvol);
434 fMedium->SetParam(1,ifield);
435 fMedium->SetParam(2,fieldm);
436 fMedium->SetParam(3,tmaxfd);
437 fMedium->SetParam(4,stemax);
438 fMedium->SetParam(5,deemax);
439 fMedium->SetParam(6,epsil);
440 fMedium->SetParam(7,stmin);
443}
444
445////////////////////////////////////////////////////////////////////////////////
446/// Slot for undoing last operation.
447
449{
450}
451
void Class()
Definition: Class.C:29
@ kChildFrame
Definition: GuiTypes.h:379
@ kRaisedFrame
Definition: GuiTypes.h:384
@ kSunkenFrame
Definition: GuiTypes.h:383
@ kVerticalFrame
Definition: GuiTypes.h:381
@ kDoubleBorder
Definition: GuiTypes.h:385
@ kFixedWidth
Definition: GuiTypes.h:387
@ kHorizontalFrame
Definition: GuiTypes.h:382
@ kOwnBackground
Definition: GuiTypes.h:391
ULong_t Pixel_t
Definition: GuiTypes.h:39
int Int_t
Definition: RtypesCore.h:43
const Bool_t kFALSE
Definition: RtypesCore.h:90
double Double_t
Definition: RtypesCore.h:57
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassImp(name)
Definition: Rtypes.h:361
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kButtonDown
Definition: TGButton.h:54
@ kButtonUp
Definition: TGButton.h:53
#define gClient
Definition: TGClient.h:166
@ kLHintsRight
Definition: TGLayout.h:33
@ kLHintsExpandY
Definition: TGLayout.h:38
@ kLHintsLeft
Definition: TGLayout.h:31
@ kLHintsTop
Definition: TGLayout.h:34
@ kLHintsExpandX
Definition: TGLayout.h:37
char name[80]
Definition: TGX11.cxx:109
ETGeoMediumWid
@ kMED_SENS
@ kMED_MATSEL
@ kMED_TMAX
@ kMED_UNDO
@ kMED_STMIN
@ kMED_APPLY
@ kMED_CANCEL
@ kMED_STEMAX
@ kMED_ID
@ kMED_FLDOPT
@ kMED_EPSIL
@ kMED_FIELDM
@ kMED_EDIT_MAT
@ kMED_NAME
@ kMED_DEEMAX
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:397
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition: TGButton.cxx:411
virtual Bool_t IsOn() const
Definition: TGButton.h:311
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1202
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:289
virtual Int_t GetSelected() const
Definition: TGComboBox.h:134
virtual void AddEntry(TGString *s, Int_t id)
Definition: TGComboBox.h:106
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
Definition: TGComboBox.cxx:451
virtual Int_t GetNumberOfEntries() const
Definition: TGComboBox.h:127
virtual TList * GetList() const
Definition: TGFrame.h:347
TGCompositeFrame(const TGCompositeFrame &)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1101
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:951
TGFrame * fFrame
Definition: TGLayout.h:119
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition: TGFrame.cxx:305
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:216
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:589
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGLabel.cxx:360
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:178
virtual void SetNumber(Double_t val)
UInt_t GetDefaultHeight() const
TGNumberEntryField * GetNumberEntry() const
virtual void Associate(const TGWindow *w)
Make w the window that will receive the generated messages.
virtual Long_t GetIntNumber() const
virtual Double_t GetNumber() const
TGClient * fClient
Definition: TGObject.h:37
virtual void SetDefaultSize(UInt_t w, UInt_t h)
Set the default / minimal size of the widget.
const char * GetText() const
Definition: TGTextEntry.h:134
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line.
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
Bool_t fInit
Definition: TGedFrame.h:53
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition: TGedFrame.cxx:96
Common base class for geombuilder editors.
Definition: TGeoGedFrame.h:13
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
TGeoTabManager * fTabMgr
Definition: TGeoGedFrame.h:17
Base class describing materials.
Definition: TGeoMaterial.h:31
Editor class for TGeo tracking media.
TGComboBox * fMagfldOption
TGNumberEntry * fMedFieldm
void DoMedName()
Slot for medium name.
void DoUndo()
Slot for undoing last operation.
void DoEditMaterial()
Edit selected material.
TGTextButton * fUndo
TGNumberEntry * fMedStemax
void DoStmin()
Slot for min. step.
void DoMedId()
Slot for medium id.
TGTextButton * fApply
TGLabel * fLSelMaterial
virtual void SetModel(TObject *obj)
Connect to the selected object.
TGeoMediumEditor(const TGWindow *p=0, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for medium editor.
void DoEpsil()
Slot for tracking precision.
void DoMagfldSelect(Int_t ientry)
Slot for mag. field.
void DoToggleSensitive()
Slot for sensitivity.
void DoApply()
Slot for applying modifications.
TGPictureButton * fBSelMaterial
TGeoMedium * fMedium
virtual ~TGeoMediumEditor()
Destructor.
TGNumberEntry * fMedDeemax
void DoSelectMaterial()
Select the material component.
void DoTmaxfd()
Slot for tmaxfd.
TGNumberEntry * fMedStmin
void DoStemax()
Slot for the max allowed step.
void DoDeemax()
Slot for the maximum allowed dedx.
void DoFieldm()
Slot for max field.
TGNumberEntry * fMedId
TGNumberEntry * fMedTmaxfd
TGeoMaterial * fSelectedMaterial
TGNumberEntry * fMedEpsil
virtual void ConnectSignals2Slots()
Connect signals to slots.
TGTextButton * fEditMaterial
TGTextEntry * fMedName
TGCheckButton * fMedSensitive
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition: TGeoMedium.h:24
void SetId(Int_t id)
Definition: TGeoMedium.h:54
Int_t GetId() const
Definition: TGeoMedium.h:48
void SetParam(Int_t i, Double_t val)
Definition: TGeoMedium.h:50
TGeoMaterial * GetMaterial() const
Definition: TGeoMedium.h:52
Double_t GetParam(Int_t i) const
Definition: TGeoMedium.h:49
void GetMaterialEditor(TGeoMaterial *material)
Get editor for a material.
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
static TObject * GetSelected()
static; return selected object
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition: TQObject.cxx:866
TF1 * f1
Definition: legend1.C:11