Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
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
32
50
51////////////////////////////////////////////////////////////////////////////////
52/// Constructor for medium editor
53
55 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
56{
57 fMedium = nullptr;
60 Pixel_t color;
61 TGLabel *label;
62
63 // TextEntry for medium name
64 MakeTitle("Name");
65 fMedName = new TGTextEntry(this, "", kMED_NAME);
66 fMedName->SetDefaultSize(135, fMedName->GetDefaultHeight());
67 fMedName->SetToolTipText("Enter the medium name");
68 fMedName->Associate(this);
70
71 TGTextEntry *nef;
72
73 // Composite frame for medium ID and sensitivity
75 f1->AddFrame(new TGLabel(f1, "ID"), new TGLayoutHints(kLHintsLeft, 4, 1, 6, 0));
76 fMedId = new TGNumberEntry(f1, 0., 1, kMED_ID);
77 nef = (TGTextEntry *)fMedId->GetNumberEntry();
78 nef->SetToolTipText("Enter the medium ID");
79 fMedId->Associate(this);
80 f1->AddFrame(fMedId, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 4, 4));
81 fMedSensitive = new TGCheckButton(f1, "&Sens", kMED_SENS);
82 fMedSensitive->Associate(this);
83 f1->AddFrame(fMedSensitive, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
84 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 3, 3, 2, 2));
85
86 // Current material
88 f1->AddFrame(label = new TGLabel(f1, "Current material"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
89 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
90 gClient->GetColorByName("#ff0000", color);
91 label->SetTextColor(color);
92 AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
93 f1 = new TGCompositeFrame(this, 155, 30, kHorizontalFrame);
94 fSelectedMaterial = nullptr;
95 fLSelMaterial = new TGLabel(f1, "Select material");
96 gClient->GetColorByName("#0000ff", color);
97 fLSelMaterial->SetTextColor(color);
100 fBSelMaterial = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kMED_MATSEL);
101 fBSelMaterial->SetToolTipText("Replace with one of the existing materials");
102 fBSelMaterial->Associate(this);
103 f1->AddFrame(fBSelMaterial, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
104 fEditMaterial = new TGTextButton(f1, "Edit");
105 f1->AddFrame(fEditMaterial, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
106 fEditMaterial->SetToolTipText("Edit selected material");
107 fEditMaterial->Associate(this);
109
110 // Combo box for magnetic field option
112 f1->AddFrame(label = new TGLabel(f1, "Mag. field option"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
113 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
114 gClient->GetColorByName("#ff0000", color);
115 label->SetTextColor(color);
116 AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
118 fMagfldOption->Resize(135, fMedName->GetDefaultHeight());
120
121 // Number entries for other settings
123 f1->AddFrame(label = new TGLabel(f1, "Medium cuts"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
124 f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
125 gClient->GetColorByName("#ff0000", color);
126 label->SetTextColor(color);
127 AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
129
130 // Number entry for fieldm
132 f1->AddFrame(new TGLabel(f1, "FIELDM"), new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
133 fMedFieldm = new TGNumberEntry(f1, 0., 5, kMED_FIELDM);
134 nef = (TGTextEntry *)fMedFieldm->GetNumberEntry();
135 nef->SetToolTipText("Maximum magnetic field [kilogauss]");
136 fMedFieldm->Associate(this);
137 fMedFieldm->Resize(90, fMedFieldm->GetDefaultHeight());
138 f1->AddFrame(fMedFieldm, new TGLayoutHints(kLHintsRight | kLHintsExpandY, 2, 2, 2, 2));
139 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 1, 1));
140
141 // Number entry for tmaxfd
142 TGCompositeFrame *f2 =
144 f2->AddFrame(new TGLabel(f2, "TMAXFD"), new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
145 fMedTmaxfd = new TGNumberEntry(f2, 0., 5, kMED_TMAX);
146 nef = (TGTextEntry *)fMedTmaxfd->GetNumberEntry();
147 nef->SetToolTipText("Maximum angle per step due to field [deg]");
148 fMedTmaxfd->Associate(this);
149 fMedTmaxfd->Resize(90, fMedTmaxfd->GetDefaultHeight());
151 compxyz->AddFrame(f2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 1, 1));
152
153 // Number entry for stemax
154 TGCompositeFrame *f3 =
156 f3->AddFrame(new TGLabel(f3, "STEMAX"), new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
157 fMedStemax = new TGNumberEntry(f3, 0., 5, kMED_STEMAX);
158 nef = (TGTextEntry *)fMedStemax->GetNumberEntry();
159 nef->SetToolTipText("Maximum step allowed [cm]");
160 fMedStemax->Associate(this);
161 fMedStemax->Resize(90, fMedStemax->GetDefaultHeight());
163 compxyz->AddFrame(f3, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 1, 1));
164
165 // Number entry for deemax
166 TGCompositeFrame *f4 =
168 f4->AddFrame(new TGLabel(f4, "DEEMAX"), new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
169 fMedDeemax = new TGNumberEntry(f4, 0., 5, kMED_DEEMAX);
170 nef = (TGTextEntry *)fMedDeemax->GetNumberEntry();
171 nef->SetToolTipText("Maximum fraction of energy lost in a step");
172 fMedDeemax->Associate(this);
173 fMedDeemax->Resize(90, fMedDeemax->GetDefaultHeight());
175 compxyz->AddFrame(f4, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 1, 1));
176
177 // Number entry for epsil
178 TGCompositeFrame *f5 =
180 f5->AddFrame(new TGLabel(f5, "EPSIL"), new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
181 fMedEpsil = new TGNumberEntry(f5, 0., 5, kMED_EPSIL);
182 nef = (TGTextEntry *)fMedEpsil->GetNumberEntry();
183 nef->SetToolTipText("Tracking precision [cm]");
184 fMedEpsil->Associate(this);
185 fMedEpsil->Resize(90, fMedEpsil->GetDefaultHeight());
187 compxyz->AddFrame(f5, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 1, 1));
188
189 // Number entry for stmin
190 TGCompositeFrame *f6 =
192 f6->AddFrame(new TGLabel(f6, "STMIN"), new TGLayoutHints(kLHintsLeft, 1, 1, 4, 0));
193 fMedStmin = new TGNumberEntry(f6, 0., 5, kMED_STMIN);
194 nef = (TGTextEntry *)fMedStmin->GetNumberEntry();
195 nef->SetToolTipText("Minimum step due to continuous processes [cm]");
196 fMedStmin->Associate(this);
197 fMedStmin->Resize(90, fMedStmin->GetDefaultHeight());
199 compxyz->AddFrame(f6, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 1, 1));
200
201 compxyz->Resize(160, 50);
202 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
203
204 // Buttons
206 fApply = new TGTextButton(f23, "&Apply");
207 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
208 fApply->Associate(this);
209 fUndo = new TGTextButton(f23, " &Undo ");
210 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4));
211 fUndo->Associate(this);
212 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
213}
214
215////////////////////////////////////////////////////////////////////////////////
216/// Destructor
217
219{
220 TGFrameElement *el;
221 TIter next(GetList());
222 while ((el = (TGFrameElement *)next())) {
223 if (el->fFrame->IsA() == TGCompositeFrame::Class() || el->fFrame->IsA() == TGHorizontalFrame::Class() ||
226 }
227 Cleanup();
228}
229
230////////////////////////////////////////////////////////////////////////////////
231/// Connect signals to slots.
232
234{
235 fApply->Connect("Clicked()", "TGeoMediumEditor", this, "DoApply()");
236 fUndo->Connect("Clicked()", "TGeoMediumEditor", this, "DoUndo()");
237 fMedName->Connect("TextChanged(const char *)", "TGeoMediumEditor", this, "DoMedName()");
238 fBSelMaterial->Connect("Clicked()", "TGeoMediumEditor", this, "DoSelectMaterial()");
239 fEditMaterial->Connect("Clicked()", "TGeoMediumEditor", this, "DoEditMaterial()");
240 fMedId->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoMediumEditor", this, "DoMedId()");
241 fMedTmaxfd->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoMediumEditor", this, "DoTmaxfd()");
242 fMedStemax->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoMediumEditor", this, "DoStemax()");
243 fMedDeemax->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoMediumEditor", this, "DoDeemax()");
244 fMedEpsil->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoMediumEditor", this, "DoEpsil()");
245 fMedStmin->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoMediumEditor", this, "DoStmin()");
246 fMedSensitive->Connect("Clicked()", "TGeoMediumEditor", this, "DoToggleSensitive()");
247 fMagfldOption->Connect("Selected(Int_t)", "TGeoMediumEditor", this, "DoMagfldSelect(Int_t)");
248 fInit = kFALSE;
249}
250
251////////////////////////////////////////////////////////////////////////////////
252/// Connect to the selected object.
253
255{
256 if (obj == nullptr || !(obj->IsA() == TGeoMedium::Class())) {
258 return;
259 }
260 fMedium = (TGeoMedium *)obj;
261 const char *sname = fMedium->GetName();
262 if (!strcmp(sname, fMedium->ClassName()))
263 fMedName->SetText("");
264 else
265 fMedName->SetText(sname);
266
267 fMedId->SetNumber(fMedium->GetId());
268 Int_t isvol = (Int_t)fMedium->GetParam(0);
269 fMedSensitive->SetState((isvol == 0) ? kButtonUp : kButtonDown);
270
271 fSelectedMaterial = fMedium->GetMaterial();
273 fLSelMaterial->SetText(fSelectedMaterial->GetName());
274
275 if (!fMagfldOption->GetNumberOfEntries()) {
276 fMagfldOption->AddEntry("No field", 0);
277 fMagfldOption->AddEntry("User decision", 1);
278 fMagfldOption->AddEntry("Runge-Kutta", 2);
279 fMagfldOption->AddEntry("Helix", 3);
280 fMagfldOption->AddEntry("Helix3", 4);
281 fMagfldOption->AddEntry("Unknown option", 5);
282 }
283 Int_t ifld = (Int_t)fMedium->GetParam(1);
284 switch (ifld) {
285 case 0: fMagfldOption->Select(0); break;
286 case -1: fMagfldOption->Select(1); break;
287 case 1: fMagfldOption->Select(2); break;
288 case 2: fMagfldOption->Select(3); break;
289 case 3: fMagfldOption->Select(4); break;
290 default: fMagfldOption->Select(5); break;
291 }
292
293 fMedFieldm->SetNumber(fMedium->GetParam(2));
294 fMedTmaxfd->SetNumber(fMedium->GetParam(3));
295 fMedStemax->SetNumber(fMedium->GetParam(4));
296 fMedDeemax->SetNumber(fMedium->GetParam(5));
297 fMedEpsil->SetNumber(fMedium->GetParam(6));
298 fMedStmin->SetNumber(fMedium->GetParam(7));
299
300 fUndo->SetEnabled(kFALSE);
302
303 if (fInit)
305 SetActive();
306}
307
308////////////////////////////////////////////////////////////////////////////////
309/// Edit selected material.
310
312{
313 fTabMgr->GetMaterialEditor(fMedium->GetMaterial());
314}
315
316////////////////////////////////////////////////////////////////////////////////
317/// Slot for medium name.
318
320{
321 const char *name = fMedName->GetText();
322 if (!name[0] || !strcmp(name, fMedium->GetName()))
323 return;
324 fMedium->SetName(name);
325}
326
327////////////////////////////////////////////////////////////////////////////////
328/// Slot for medium id.
329
331
332////////////////////////////////////////////////////////////////////////////////
333/// Select the material component.
334
345
346////////////////////////////////////////////////////////////////////////////////
347/// Slot for sensitivity.
348
353
354////////////////////////////////////////////////////////////////////////////////
355/// Slot for mag. field.
356
361
362////////////////////////////////////////////////////////////////////////////////
363/// Slot for max field.
364
369
370////////////////////////////////////////////////////////////////////////////////
371/// Slot for tmaxfd.
372
377
378////////////////////////////////////////////////////////////////////////////////
379/// Slot for the max allowed step.
380
385
386////////////////////////////////////////////////////////////////////////////////
387/// Slot for the maximum allowed dedx.
388
393
394////////////////////////////////////////////////////////////////////////////////
395/// Slot for tracking precision.
396
401
402////////////////////////////////////////////////////////////////////////////////
403/// Slot for min. step.
404
409
410////////////////////////////////////////////////////////////////////////////////
411/// Slot for applying modifications.
412
414{
415 if (!fIsModified)
416 return;
417 Double_t isvol = (fMedSensitive->IsOn()) ? 1 : 0;
418 Double_t ifield = fMagfldOption->GetSelected();
419 if (ifield > 0) {
420 ifield -= 1.;
421 if (ifield < 1.)
422 ifield -= 1.;
423 }
424 Double_t fieldm = fMedFieldm->GetNumber();
425 Double_t tmaxfd = fMedTmaxfd->GetNumber();
426 Double_t stemax = fMedStemax->GetNumber();
427 Double_t deemax = fMedDeemax->GetNumber();
428 Double_t epsil = fMedEpsil->GetNumber();
429 Double_t stmin = fMedStmin->GetNumber();
430
431 fMedium->SetParam(0, isvol);
432 fMedium->SetParam(1, ifield);
433 fMedium->SetParam(2, fieldm);
434 fMedium->SetParam(3, tmaxfd);
435 fMedium->SetParam(4, stemax);
436 fMedium->SetParam(5, deemax);
437 fMedium->SetParam(6, epsil);
438 fMedium->SetParam(7, stmin);
439 if (strcmp(fMedium->GetName(), fMedName->GetText()))
440 fMedium->SetName(fMedName->GetText());
441 if (fMedium->GetId() != fMedId->GetIntNumber())
442 fMedium->SetId(fMedId->GetIntNumber());
443}
444
445////////////////////////////////////////////////////////////////////////////////
446/// Slot for undoing last operation.
447
@ kChildFrame
Definition GuiTypes.h:380
@ kRaisedFrame
Definition GuiTypes.h:385
@ kSunkenFrame
Definition GuiTypes.h:384
@ kVerticalFrame
Definition GuiTypes.h:382
@ kDoubleBorder
Definition GuiTypes.h:386
@ kFixedWidth
Definition GuiTypes.h:388
@ kFitWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:383
@ kOwnBackground
Definition GuiTypes.h:392
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ kButtonDown
Definition TGButton.h:54
@ kButtonUp
Definition TGButton.h:53
#define gClient
Definition TGClient.h:157
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
char name[80]
Definition TGX11.cxx:148
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
Selects different options.
Definition TGButton.h:264
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
Definition TGComboBox.h:47
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
virtual TList * GetList() const
Definition TGFrame.h:312
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:959
TGCompositeFrame(const TGCompositeFrame &)=delete
static TClass * Class()
TGFrame * fFrame
Definition TGLayout.h:112
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
TClass * IsA() const override
Definition TGFrame.h:285
A horizontal 3D line is a line that typically separates a toolbar from the menubar.
Definition TG3DLine.h:18
static TClass * Class()
This class handles GUI labels.
Definition TGLabel.h:24
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition TGLabel.cxx:361
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
TGNumberEntry is a number entry input widget with up/down buttons.
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Yield an action as soon as it is clicked.
Definition TGButton.h:228
Yield an action as soon as it is clicked.
Definition TGButton.h:142
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
static TClass * Class()
ROOT GUI Window base class.
Definition TGWindow.h:23
Bool_t fInit
init flag for setting signals/slots
Definition TGedFrame.h:47
virtual void MakeTitle(const char *title)
Create attribute frame title.
Definition TGedFrame.cxx:94
TGeoGedFrame(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor.
virtual void SetActive(Bool_t active=kTRUE)
Set active GUI attribute frames related to the selected object.
TGeoTabManager * fTabMgr
Base class describing materials.
TGComboBox * fMagfldOption
void SetModel(TObject *obj) override
Connect to the selected object.
~TGeoMediumEditor() override
Destructor.
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
TGeoMediumEditor(const TGWindow *p=nullptr, 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
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:23
static TClass * Class()
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
static TObject * GetSelected()
static; return selected object
Mother of all ROOT objects.
Definition TObject.h:42
virtual TClass * IsA() const
Definition TObject.h:248
TF1 * f1
Definition legend1.C:11