Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGeoMaterialEditor.cxx
Go to the documentation of this file.
1// @(#):$Id$
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 TGeoMaterialEditor
13\ingroup Geometry_builder
14
15Editors for materials.
16
17
18*/
19
20#include "TGeoMaterialEditor.h"
21#include "TGeoTabManager.h"
22#include "TGeoMaterial.h"
23#include "TGeoElement.h"
24#include "TGeoManager.h"
25#include "TVirtualGeoPainter.h"
26#include "TGTab.h"
27#include "TGComboBox.h"
28#include "TGButton.h"
29#include "TGTextEntry.h"
30#include "TGNumberEntry.h"
31#include "TGLabel.h"
32
34
49
51
53
54////////////////////////////////////////////////////////////////////////////////
55/// Constructor for material editor.
56
58 : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
59{
60 fMaterial = nullptr;
61 fAi = fZi = 0;
62 fDensityi = 0.0;
63 fNamei = "";
66
67 // TextEntry for material name
68 MakeTitle("Name");
70 fMaterialName->SetDefaultSize(135, fMaterialName->GetDefaultHeight());
71 fMaterialName->SetToolTipText("Enter the material name");
72 fMaterialName->Associate(this);
74
75 TGTextEntry *nef;
76 MakeTitle("Material properties");
78 f1->AddFrame(new TGLabel(f1, "A"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
80 nef = (TGTextEntry *)fMatA->GetNumberEntry();
81 nef->SetToolTipText("Enter the atomic mass");
82 fMatA->Associate(this);
83 f1->AddFrame(fMatA, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
84 f1->AddFrame(new TGLabel(f1, "Z"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
86 nef = (TGTextEntry *)fMatZ->GetNumberEntry();
87 nef->SetToolTipText("Enter the atomic charge");
88 fMatZ->Associate(this);
89 f1->AddFrame(fMatZ, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
90 f1->Resize(150, 30);
91 AddFrame(f1, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
92
94 // Combo box for material state
96 f1->AddFrame(new TGLabel(f1, "State"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
98 fMatState->AddEntry("Undefined", TGeoMaterial::kMatStateUndefined);
99 fMatState->AddEntry("Solid", TGeoMaterial::kMatStateSolid);
100 fMatState->AddEntry("Liquid", TGeoMaterial::kMatStateLiquid);
101 fMatState->AddEntry("Gas", TGeoMaterial::kMatStateGas);
102 fMatState->Resize(90, fMaterialName->GetDefaultHeight());
103 f1->AddFrame(fMatState, new TGLayoutHints(kLHintsRight, 2, 2, 1, 1));
104 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 1, 1));
105
106 // Number entry for density
108 f1->AddFrame(new TGLabel(f1, "Density"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
110 fMatDensity->Resize(90, fMaterialName->GetDefaultHeight());
111 nef = (TGTextEntry *)fMatDensity->GetNumberEntry();
112 nef->SetToolTipText("Enter material density in [g/cm3]");
113 fMatDensity->Associate(this);
114 f1->AddFrame(fMatDensity, new TGLayoutHints(kLHintsRight, 2, 2, 1, 1));
115 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 1, 1));
116
117 // Number entry for temperature
119 f1->AddFrame(new TGLabel(f1, "Temperature"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
121 fMatTemperature->Resize(90, fMaterialName->GetDefaultHeight());
122 nef = (TGTextEntry *)fMatTemperature->GetNumberEntry();
123 nef->SetToolTipText("Enter material temperature in [Kelvin]");
124 fMatTemperature->Associate(this);
125 f1->AddFrame(fMatTemperature, new TGLayoutHints(kLHintsRight, 2, 2, 1, 1));
126 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 1, 1));
127
128 // Number entry for pressure
130 f1->AddFrame(new TGLabel(f1, "Pressure"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
132 fMatPressure->Resize(90, fMaterialName->GetDefaultHeight());
133 nef = (TGTextEntry *)fMatPressure->GetNumberEntry();
134 nef->SetToolTipText("Enter material pressure in [bar]");
135 fMatPressure->Associate(this);
136 f1->AddFrame(fMatPressure, new TGLayoutHints(kLHintsRight, 2, 2, 1, 1));
137 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 1, 1));
138
139 // Number entry for radiation length
141 f1->AddFrame(new TGLabel(f1, "RadLen"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
143 fMatRadLen->Resize(90, fMaterialName->GetDefaultHeight());
144 nef = (TGTextEntry *)fMatRadLen->GetNumberEntry();
145 nef->SetToolTipText("Computed radiation length");
146 fMatRadLen->Associate(this);
147 f1->AddFrame(fMatRadLen, new TGLayoutHints(kLHintsRight, 2, 2, 1, 1));
148 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 1, 1));
149
150 // Number entry for absorption length
152 f1->AddFrame(new TGLabel(f1, "AbsLen"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
154 fMatAbsLen->Resize(90, fMaterialName->GetDefaultHeight());
155 nef = (TGTextEntry *)fMatAbsLen->GetNumberEntry();
156 nef->SetToolTipText("Absorption length");
157 fMatAbsLen->Associate(this);
158 f1->AddFrame(fMatAbsLen, new TGLayoutHints(kLHintsRight, 2, 2, 1, 1));
159 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 1, 1));
160
161 compxyz->Resize(150, 30);
162 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 0, 0, 2, 2));
163
164 // Buttons
166 fApply = new TGTextButton(f23, "Apply");
167 f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 1, 1));
168 fApply->Associate(this);
169 fUndo = new TGTextButton(f23, " Undo ");
170 f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight, 2, 2, 1, 1));
171 fUndo->Associate(this);
172 AddFrame(f23, new TGLayoutHints(kLHintsLeft, 0, 0, 4, 4));
173 fUndo->SetSize(fApply->GetSize());
174}
175
176////////////////////////////////////////////////////////////////////////////////
177/// Destructor
178
180{
181 TGFrameElement *el;
182 TIter next(GetList());
183 while ((el = (TGFrameElement *)next())) {
184 if (el->fFrame->IsComposite())
186 }
187 Cleanup();
188}
189
190////////////////////////////////////////////////////////////////////////////////
191/// Connect signals to slots.
192
194{
195 fApply->Connect("Clicked()", "TGeoMaterialEditor", this, "DoApply()");
196 fUndo->Connect("Clicked()", "TGeoMaterialEditor", this, "DoUndo()");
197 fMaterialName->Connect("TextChanged(const char *)", "TGeoMaterialEditor", this, "DoName()");
198 fMatA->Connect("ValueSet(Long_t)", "TGeoMaterialEditor", this, "DoA()");
199 fMatZ->Connect("ValueSet(Long_t)", "TGeoMaterialEditor", this, "DoZ()");
200 fMatState->Connect("Selected(Int_t)", "TGeoMaterialEditor", this, "DoState(Int_t)");
201 fMatDensity->Connect("ValueSet(Long_t)", "TGeoMaterialEditor", this, "DoDensity()");
202 fMatTemperature->Connect("ValueSet(Long_t)", "TGeoMaterialEditor", this, "DoTemperature()");
203 fMatPressure->Connect("ValueSet(Long_t)", "TGeoMaterialEditor", this, "DoPressure()");
204 fMatRadLen->Connect("ValueSet(Long_t)", "TGeoMaterialEditor", this, "DoRadAbs()");
205 fMatAbsLen->Connect("ValueSet(Long_t)", "TGeoMaterialEditor", this, "DoRadAbs()");
206 fInit = kFALSE;
207}
208
209////////////////////////////////////////////////////////////////////////////////
210/// Connect to the selected material.
211
213{
214 if (obj == nullptr || !(obj->InheritsFrom(TGeoMaterial::Class()))) {
216 return;
217 }
218 fMaterial = (TGeoMaterial *)obj;
219 fAi = fMaterial->GetA();
220 fZi = (Int_t)fMaterial->GetZ();
221 fStatei = (Int_t)fMaterial->GetState();
222 fDensityi = fMaterial->GetDensity();
223 fTempi = fMaterial->GetTemperature();
224 fPresi = fMaterial->GetPressure() / 6.2415e+8;
225 fNamei = fMaterial->GetName();
226 fMaterialName->SetText(fMaterial->GetName());
227 fMatA->SetNumber(fAi);
228 fMatZ->SetNumber(fZi);
229 fMatState->Select(fStatei);
230 fMatDensity->SetNumber(fDensityi);
231 fMatTemperature->SetNumber(fTempi);
232 fMatPressure->SetNumber(fPresi);
233 fMatRadLen->SetNumber(fMaterial->GetRadLen());
234 fMatAbsLen->SetNumber(fMaterial->GetIntLen());
235 fApply->SetEnabled(kFALSE);
236 fUndo->SetEnabled(kFALSE);
237
238 if (fInit)
240 SetActive();
241}
242
243////////////////////////////////////////////////////////////////////////////////
244/// Perform name change.
245
250
251////////////////////////////////////////////////////////////////////////////////
252/// Slot for atomic mass.
253
255{
256 if (fMaterial->IsMixture()) {
257 fMatA->SetNumber(fMaterial->GetA());
258 return;
259 }
260 DoModified();
261}
262
263////////////////////////////////////////////////////////////////////////////////
264/// Slot for charge.
265
267{
268 if (fMaterial->IsMixture()) {
269 fMatZ->SetNumber(fMaterial->GetZ());
270 return;
271 }
272 Int_t z = (Int_t)fMatZ->GetNumber();
273 TGeoElementTable *table = gGeoManager->GetElementTable();
274 if (z >= table->GetNelements()) {
275 z = table->GetNelements() - 1;
276 fMatZ->SetNumber(z);
277 }
278 TGeoElement *elem = table->GetElement(z);
279 if (!elem)
280 return;
281 Double_t a = elem->A();
282 fMatA->SetNumber(a);
283 DoModified();
284}
285
286////////////////////////////////////////////////////////////////////////////////
287/// Slot for material state.
288
290{
291 DoModified();
292}
293
294////////////////////////////////////////////////////////////////////////////////
295/// Slot for material temperature.
296
301
302////////////////////////////////////////////////////////////////////////////////
303/// Slot for material pressure.
304
309
310////////////////////////////////////////////////////////////////////////////////
311/// Slot for density.
312/// fMatDensity->SetNumber(fDensityi);
313
318
319////////////////////////////////////////////////////////////////////////////////
320/// Slot for radiation/absorption length.
321
323{
324 fMatRadLen->SetNumber(fMaterial->GetRadLen());
325 fMatAbsLen->SetNumber(fMaterial->GetIntLen());
326 DoModified();
327}
328
329////////////////////////////////////////////////////////////////////////////////
330/// Slot for applying modifications.
331
333{
334 const char *name = fMaterialName->GetText();
335 fMaterial->SetName(name);
336
337 fMaterial->SetA(fMatA->GetNumber());
338 fMaterial->SetZ(fMatZ->GetNumber());
339 fMaterial->SetDensity(fMatDensity->GetNumber());
340 fMaterial->SetTemperature(fMatTemperature->GetNumber());
341 fMaterial->SetPressure(6.2415e+8 * fMatPressure->GetNumber());
342 fMaterial->SetState((TGeoMaterial::EGeoMaterialState)fMatState->GetSelected());
343 fMaterial->SetRadLen(fMatRadLen->GetNumber(), fMatAbsLen->GetNumber());
344 fMatRadLen->SetNumber(fMaterial->GetRadLen());
345 fMatAbsLen->SetNumber(fMaterial->GetIntLen());
346 fUndo->SetEnabled();
347 fApply->SetEnabled(kFALSE);
348}
349
350////////////////////////////////////////////////////////////////////////////////
351/// Slot for cancelling current modifications.
352
354{
355 fMaterialName->SetText(fNamei.Data());
356 fMaterial->SetName(fNamei.Data());
357 fMatA->SetNumber(fAi);
358 fMaterial->SetA(fAi);
359 fMatZ->SetNumber(fZi);
360 fMaterial->SetZ(fZi);
361 fMatState->Select(fStatei);
363 fMatDensity->SetNumber(fDensityi);
364 fMaterial->SetDensity(fDensityi);
365 fMatTemperature->SetNumber(fTempi);
366 fMaterial->SetTemperature(fTempi);
367 fMatPressure->SetNumber(fPresi);
368 fMaterial->SetPressure(fPresi * 6.2415e+8);
369 fMatRadLen->SetNumber(fMaterial->GetRadLen());
370 fMatAbsLen->SetNumber(fMaterial->GetIntLen());
371 fApply->SetEnabled(kFALSE);
372 fUndo->SetEnabled(kFALSE);
373}
374
375////////////////////////////////////////////////////////////////////////////////
376/// Slot for signaling modifications.
377
379{
380 fApply->SetEnabled();
381}
382
383/** \class TGeoMixtureEditor
384\ingroup Geometry_builder
385
386Editors for mixtures.
387
388*/
389
391
392////////////////////////////////////////////////////////////////////////////////
393/// Constructor for mixture editor.
394
396 : TGeoMaterialEditor(p, width, height, options | kVerticalFrame, back)
397{
398 fMixture = nullptr;
399 TGCompositeFrame *compxyz = nullptr, *f1 = nullptr;
400 TGTextEntry *nef;
401 MakeTitle("Mixture settings");
402 fNelem = new TGLabel(this, "Number of elements: 0");
403 AddFrame(fNelem, new TGLayoutHints(kLHintsLeft, 6, 2, 2, 2));
404 compxyz = new TGCompositeFrame(this, 118, 30, kVerticalFrame | kRaisedFrame | kDoubleBorder);
405 // Combo box for selecting elements
408 TGeoElementTable *table = gGeoManager->GetElementTable();
409 if (table) {
410 TGeoElement *element;
411 for (Int_t i = 0; i < table->GetNelements(); i++) {
412 element = table->GetElement(i);
413 if (element)
414 fMixElem->AddEntry(element->GetTitle(), i);
415 }
416 }
417 fMixElem->Select(0);
418 fMixElem->Resize(90, fMaterialName->GetDefaultHeight());
419 f1->AddFrame(fMixElem, new TGLayoutHints(kLHintsLeft, 2, 2, 1, 1));
420 TGCompositeFrame *comp1 = new TGCompositeFrame(f1, 118, 30, kVerticalFrame);
421 fAelem = new TGLabel(comp1, "A = 0");
422 comp1->AddFrame(fAelem, new TGLayoutHints(kLHintsRight, 2, 2, 2, 0));
423 fZelem = new TGLabel(comp1, "Z = 0");
424 comp1->AddFrame(fZelem, new TGLayoutHints(kLHintsRight, 2, 2, 2, 0));
425 f1->AddFrame(comp1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 2, 2, 0, 0));
426 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 0, 0));
427
428 // Fraction by weight
430 fChkFraction = new TGCheckButton(f1, "% weight");
431 fChkFraction->SetDown(kTRUE);
432 f1->AddFrame(fChkFraction, new TGLayoutHints(kLHintsLeft, 2, 2, 6, 1));
435 fNEFraction->Resize(65, fMaterialName->GetDefaultHeight());
436 nef = (TGTextEntry *)fNEFraction->GetNumberEntry();
437 nef->SetToolTipText("Enter fraction by weight of this element");
438 fNEFraction->SetNumber(0.);
439 fNEFraction->Associate(this);
440 f1->AddFrame(fNEFraction, new TGLayoutHints(kLHintsRight, 2, 2, 1, 1));
441 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 1, 1));
442
443 // Fraction by number of atoms
445 fChkNatoms = new TGCheckButton(f1, "N. atoms");
446 fChkNatoms->SetDown(kFALSE);
447 f1->AddFrame(fChkNatoms, new TGLayoutHints(kLHintsLeft, 2, 2, 6, 1));
448 fNENatoms = new TGNumberEntry(f1, 0., 5, kMIX_NATOMS);
450 fNENatoms->Resize(65, fMaterialName->GetDefaultHeight());
451 nef = (TGTextEntry *)fNENatoms->GetNumberEntry();
452 nef->SetToolTipText("Enter number of atoms for this element");
453 fNENatoms->SetNumber(0);
454 fNENatoms->Associate(this);
455 f1->AddFrame(fNENatoms, new TGLayoutHints(kLHintsRight, 2, 2, 1, 1));
456 compxyz->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 1, 1));
457
458 // Button for adding the element
459 fBAddElem = new TGTextButton(compxyz, "Add component");
460 fBAddElem->Associate(this);
461 compxyz->AddFrame(fBAddElem, new TGLayoutHints(kLHintsRight, 2, 2, 2, 0));
462
463 compxyz->Resize(150, 30);
464 AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 0, 0, 1, 1));
465
466 // List view with all components
467 fComps = new TGCompositeFrame(this, 150, 100, kVerticalFrame | kSunkenFrame);
469
471}
472
473////////////////////////////////////////////////////////////////////////////////
474/// Connect signals to slots.
475
477{
478 fApply->Connect("Clicked()", "TGeoMixtureEditor", this, "DoApply1()");
479 fUndo->Connect("Clicked()", "TGeoMixtureEditor", this, "DoUndo1()");
480 fChkFraction->Connect("Clicked()", "TGeoMixtureEditor", this, "DoChkFraction()");
481 fChkNatoms->Connect("Clicked()", "TGeoMixtureEditor", this, "DoChkNatoms()");
482 fNEFraction->Connect("ValueSet(Long_t)", "TGeoMixtureEditor", this, "DoFraction()");
483 fNENatoms->Connect("ValueSet(Long_t)", "TGeoMixtureEditor", this, "DoNatoms()");
484 fMixElem->Connect("Selected(Int_t)", "TGeoMixtureEditor", this, "DoSelectElement(Int_t)");
485 fBAddElem->Connect("Clicked()", "TGeoMixtureEditor", this, "DoAddElem()");
486 fMaterialName->Connect("TextChanged(const char *)", "TGeoMaterialEditor", this, "DoName()");
487 fMatA->Connect("ValueSet(Long_t)", "TGeoMaterialEditor", this, "DoA()");
488 fMatZ->Connect("ValueSet(Long_t)", "TGeoMaterialEditor", this, "DoZ()");
489 fMatState->Connect("Selected(Int_t)", "TGeoMaterialEditor", this, "DoState(Int_t)");
490 fMatDensity->Connect("ValueSet(Long_t)", "TGeoMaterialEditor", this, "DoDensity()");
491 fMatTemperature->Connect("ValueSet(Long_t)", "TGeoMaterialEditor", this, "DoTemperature()");
492 fMatPressure->Connect("ValueSet(Long_t)", "TGeoMaterialEditor", this, "DoPressure()");
493 fMatRadLen->Connect("ValueSet(Long_t)", "TGeoMaterialEditor", this, "DoRadAbs()");
494 fMatAbsLen->Connect("ValueSet(Long_t)", "TGeoMaterialEditor", this, "DoRadAbs()");
495 fInit = kFALSE;
496}
497
498////////////////////////////////////////////////////////////////////////////////
499/// Connect to the selected mixture.
500
502{
503 if (obj == nullptr || !(obj->InheritsFrom(TGeoMixture::Class()))) {
505 return;
506 }
510}
511
512////////////////////////////////////////////////////////////////////////////////
513/// Check button state changed for fraction.
514
516{
517 if (fMixture->GetNelements() && fMixture->GetNmixt()) {
518 fChkFraction->SetDown(kFALSE);
519 fChkNatoms->SetDown(kTRUE);
520 return;
521 }
522 Bool_t isDown = fChkFraction->IsDown();
523 fChkNatoms->SetDown(!isDown);
524}
525
526////////////////////////////////////////////////////////////////////////////////
527/// Check button state changed for natoms.
528
530{
531 if (fMixture->GetNelements() && !fMixture->GetNmixt()) {
532 fChkFraction->SetDown(kTRUE);
533 fChkNatoms->SetDown(kFALSE);
534 return;
535 }
536 Bool_t isDown = fChkNatoms->IsDown();
537 fChkFraction->SetDown(!isDown);
538}
539
540////////////////////////////////////////////////////////////////////////////////
541/// Fraction changed.
542
544{
545 if (fMixture->GetNelements() && fMixture->GetNmixt())
546 return;
547 fChkFraction->SetDown(kTRUE);
548 fChkNatoms->SetDown(kFALSE);
549}
550
551////////////////////////////////////////////////////////////////////////////////
552/// Natoms changed.
553
555{
556 if (fMixture->GetNelements() && !fMixture->GetNmixt())
557 return;
558 fChkFraction->SetDown(kFALSE);
559 fChkNatoms->SetDown(kTRUE);
560}
561
562////////////////////////////////////////////////////////////////////////////////
563/// Slot for selecting an element.
564
566{
567 TGeoElement *el = gGeoManager->GetElementTable()->GetElement(ielem);
568 if (!el) {
569 Error("DoSelectElement", "No element at index %d", ielem);
570 return;
571 }
572 TString z = TString::Format("Z=%d", el->Z());
573 TString a = TString::Format("A=%d", (Int_t)el->A());
574 fAelem->SetText(a.Data());
575 fZelem->SetText(z.Data());
576}
577
578////////////////////////////////////////////////////////////////////////////////
579/// Slot for adding an element. No undo.
580
582{
583 Bool_t byfraction = fChkFraction->IsDown();
584 Int_t natoms = (Int_t)fNENatoms->GetNumber();
585 if (!byfraction && natoms <= 0)
586 return;
587 Double_t frac = fNEFraction->GetNumber();
588 if (byfraction && frac <= 0)
589 return;
590 TGeoElement *el = gGeoManager->GetElementTable()->GetElement(fMixElem->GetSelected());
591 if (!el)
592 return;
593 if (byfraction)
594 fMixture->AddElement(el, frac);
595 else
596 fMixture->AddElement(el, natoms);
597 fTabMgr->GetMaterialEditor(fMixture);
598}
599
600////////////////////////////////////////////////////////////////////////////////
601/// Slot for applying modifications.
602
604{
605 const char *name = fMaterialName->GetText();
606 fMaterial->SetName(name);
607
608 fMaterial->SetDensity(fMatDensity->GetNumber());
609 fMaterial->SetTemperature(fMatTemperature->GetNumber());
610 fMaterial->SetPressure(6.2415e+8 * fMatPressure->GetNumber());
611 fMaterial->SetState((TGeoMaterial::EGeoMaterialState)fMatState->GetSelected());
612 // fMaterial->SetRadLen(fMatRadLen->GetNumber(), fMatAbsLen->GetNumber());
613 fMatRadLen->SetNumber(fMaterial->GetRadLen());
614 fMatAbsLen->SetNumber(fMaterial->GetIntLen());
615 fUndo->SetEnabled();
616 fApply->SetEnabled(kFALSE);
617}
618
619////////////////////////////////////////////////////////////////////////////////
620/// Slot for undoing all changes.
621
623{
624 fMaterialName->SetText(fNamei.Data());
625 fMaterial->SetName(fNamei.Data());
626 fMatState->Select(fStatei);
628 fMatDensity->SetNumber(fDensityi);
629 fMaterial->SetDensity(fDensityi);
630 fMatTemperature->SetNumber(fTempi);
631 fMaterial->SetTemperature(fTempi);
632 fMatPressure->SetNumber(fPresi);
633 fMaterial->SetPressure(fPresi * 6.2415e+8);
634 fMatRadLen->SetNumber(fMaterial->GetRadLen());
635 fMatAbsLen->SetNumber(fMaterial->GetIntLen());
636 fApply->SetEnabled(kFALSE);
637 fUndo->SetEnabled(kFALSE);
638}
639
640////////////////////////////////////////////////////////////////////////////////
641/// Update the list of elements in the TGCanvas.
642
644{
645 fComps->RemoveAll();
646 Int_t nelem = fMixture->GetNelements();
647 for (Int_t i = 0; i < nelem; i++) {
648 TString s;
649 Bool_t byfrac = (fMixture->GetNmixt()) ? kFALSE : kTRUE;
650 if (byfrac)
651 s.TString::Format("%d-%s-%d: Wmass = %g %%", (Int_t)fMixture->GetZmixt()[i],
652 fMixture->GetElement(i)->GetName(), (Int_t)fMixture->GetAmixt()[i], fMixture->GetWmixt()[i]);
653 else
654 s.TString::Format("%d-%s-%d: Natoms = %d", (Int_t)fMixture->GetZmixt()[i], fMixture->GetElement(i)->GetName(),
655 (Int_t)fMixture->GetAmixt()[i], fMixture->GetNmixt()[i]);
656
657 TGLabel *label = new TGLabel(fComps, s);
659 fComps->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 1, 1, 0, 0));
660 }
661 fComps->MapSubwindows();
662}
@ 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
#define a(i)
Definition RSha256.hxx:99
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:377
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsExpandX
Definition TGLayout.h:30
@ kTextLeft
Definition TGWidget.h:23
@ kTextCenterY
Definition TGWidget.h:28
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
@ kMATERIAL_NAME
R__EXTERN TGeoManager * gGeoManager
@ kMATERIAL_TEMP
@ kMATERIAL_A
@ kMATERIAL_STATE
@ kMATERIAL_ABS
@ kMATERIAL_APPLY
@ kMATERIAL_RHO
@ kMATERIAL_Z
@ kMATERIAL_PRES
@ kMATERIAL_CANCEL
@ kMATERIAL_UNDO
@ kMATERIAL_RAD
ETGeoMaterialStates
@ kMAT_UNDEFINED
@ kMAT_LIQUID
@ kMIX_NATOMS
@ kMIX_ADDELEM
Int_t i
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
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual TList * GetList() const
Definition TGFrame.h:310
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:967
TGCompositeFrame(const TGCompositeFrame &)=delete
TGFrame * fFrame
Definition TGLayout.h:112
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
virtual Bool_t IsComposite() const
Definition TGFrame.h:212
This class handles GUI labels.
Definition TGLabel.h:24
void SetTextJustify(Int_t tmode)
Set text justification.
Definition TGLabel.cxx:396
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.
@ kNEANonNegative
Non-negative number.
@ kNESRealThree
Fixed fraction real, three digit.
@ kNESInteger
Style of number entry field.
@ kNESRealTwo
Fixed fraction real, two digit.
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
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.
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:95
Table of elements.
TGeoElement * GetElement(Int_t z)
Int_t GetNelements() const
Base class for chemical elements.
Definition TGeoElement.h:36
Double_t A() const
Definition TGeoElement.h:71
Int_t Z() const
Definition TGeoElement.h:68
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
Editors for materials.
void DoState(Int_t state)
Slot for material state.
TGTextEntry * fMaterialName
void DoTemperature()
Slot for material temperature.
TGeoMaterialEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for material editor.
void DoRadAbs()
Slot for radiation/absorption length.
void DoPressure()
Slot for material pressure.
TGeoMaterial * fMaterial
void DoZ()
Slot for charge.
TGNumberEntry * fMatDensity
~TGeoMaterialEditor() override
Destructor.
TGNumberEntry * fMatAbsLen
TGNumberEntry * fMatTemperature
TGNumberEntry * fMatZ
virtual void ConnectSignals2Slots()
Connect signals to slots.
void DoModified()
Slot for signaling modifications.
TGCompositeFrame * f23
TGNumberEntry * fMatPressure
void DoA()
Slot for atomic mass.
void DoName()
Perform name change.
TGNumberEntry * fMatA
TGNumberEntry * fMatRadLen
void DoUndo()
Slot for cancelling current modifications.
void SetModel(TObject *obj) override
Connect to the selected material.
void DoDensity()
Slot for density.
void DoApply()
Slot for applying modifications.
Base class describing materials.
static TClass * Class()
Editors for mixtures.
void DoAddElem()
Slot for adding an element. No undo.
TGNumberEntry * fNENatoms
void DoNatoms()
Natoms changed.
TGTextButton * fBAddElem
void ConnectSignals2Slots() override
Connect signals to slots.
void UpdateElements()
Update the list of elements in the TGCanvas.
TGCheckButton * fChkNatoms
void DoUndo1()
Slot for undoing all changes.
TGeoMixtureEditor(const TGWindow *p=nullptr, Int_t width=140, Int_t height=30, UInt_t options=kChildFrame, Pixel_t back=GetDefaultFrameBackground())
Constructor for mixture editor.
void DoChkNatoms()
Check button state changed for natoms.
TGCompositeFrame * fComps
void DoApply1()
Slot for applying modifications.
TGNumberEntry * fNEFraction
TGCheckButton * fChkFraction
void DoChkFraction()
Check button state changed for fraction.
void DoFraction()
Fraction changed.
void DoSelectElement(Int_t iel)
Slot for selecting an element.
void SetModel(TObject *obj) override
Connect to the selected mixture.
Mixtures of elements.
static TClass * Class()
static void MoveFrame(TGCompositeFrame *fr, TGCompositeFrame *p)
Move frame fr at the end of the list of parent p.
static void Cleanup(TGCompositeFrame *frame)
Static method to cleanup hierarchically all daughters of a composite frame.
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
Mother of all ROOT objects.
Definition TObject.h:41
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:525
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
TF1 * f1
Definition legend1.C:11