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);
67 fMedName->SetToolTipText("Enter the medium name");
68 fMedName->Associate(this);
70
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);
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);
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);
101 fBSelMaterial->SetToolTipText("Replace with one of the existing materials");
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");
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));
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);
135 nef->SetToolTipText("Maximum magnetic field [kilogauss]");
136 fMedFieldm->Associate(this);
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);
147 nef->SetToolTipText("Maximum angle per step due to field [deg]");
148 fMedTmaxfd->Associate(this);
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);
159 nef->SetToolTipText("Maximum step allowed [cm]");
160 fMedStemax->Associate(this);
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);
171 nef->SetToolTipText("Maximum fraction of energy lost in a step");
172 fMedDeemax->Associate(this);
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);
183 nef->SetToolTipText("Tracking precision [cm]");
184 fMedEpsil->Associate(this);
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);
195 nef->SetToolTipText("Minimum step due to continuous processes [cm]");
196 fMedStmin->Associate(this);
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{
221 TIter next(GetList());
222 while ((el = (TGFrameElement *)next())) {
223 if (el->fFrame->IsA() == TGCompositeFrame::Class() || el->fFrame->IsA() == TGHorizontalFrame::Class() ||
224 el->fFrame->IsA() == TGVerticalFrame::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
266
270
274
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 }
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
299
302
303 if (fInit)
305 SetActive();
306}
307
308////////////////////////////////////////////////////////////////////////////////
309/// Edit selected material.
310
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;
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
444
445////////////////////////////////////////////////////////////////////////////////
446/// Slot for undoing last operation.
447
@ 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
@ kFitWidth
Definition GuiTypes.h:386
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kOwnBackground
Definition GuiTypes.h:391
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ 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
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
char name[80]
Definition TGX11.cxx:110
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:439
virtual void SetEnabled(Bool_t e=kTRUE)
Set enabled or disabled state of button.
Definition TGButton.cxx:453
Selects different options.
Definition TGButton.h:264
Bool_t IsOn() const override
Definition TGButton.h:310
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set check button state.
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:288
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 Int_t GetSelected() const
Definition TGComboBox.h:114
virtual void AddEntry(TGString *s, Int_t id)
Definition TGComboBox.h:86
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...
virtual Int_t GetNumberOfEntries() const
Definition TGComboBox.h:107
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
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()
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition TGFrame.cxx:313
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
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
virtual void SetText(TGString *newText)
Set new text in label.
Definition TGLabel.cxx:179
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.
TGNumberEntryField * GetNumberEntry() const
Get the number entry field.
void Associate(const TGWindow *w) override
Make w the window that will receive the generated messages.
virtual Long_t GetIntNumber() const
virtual Double_t GetNumber() const
virtual void SetNumber(Double_t val, Bool_t emit=kTRUE)
UInt_t GetDefaultHeight() const override
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 SetDefaultSize(UInt_t w, UInt_t h)
Set the default / minimal size of the widget.
const char * GetText() const
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.
static TClass * Class()
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
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
Common base class for geombuilder editors.
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
void SetId(Int_t id)
Definition TGeoMedium.h:51
Int_t GetId() const
Definition TGeoMedium.h:45
void SetParam(Int_t i, Double_t val)
Definition TGeoMedium.h:47
static TClass * Class()
TGeoMaterial * GetMaterial() const
Definition TGeoMedium.h:49
Double_t GetParam(Int_t i) const
Definition TGeoMedium.h:46
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
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:149
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
virtual TClass * IsA() const
Definition TObject.h:246
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:865
TF1 * f1
Definition legend1.C:11