]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TGeant4/TG4MaterialsFrames.cxx
not used typedef removed
[u/mrichter/AliRoot.git] / TGeant4 / TG4MaterialsFrames.cxx
CommitLineData
4b1d6659 1// $Id$
2// Category: interfaces
3//
4// Author: D. Adamova
5//
6//========================================================
7//
8//------------TG4MaterialsFrames.cxx--------------------------------//
9//--------- Frames for the the display of materials properties---//
10//
11//=========================================================
12
13#include "TG4MaterialsFrames.h"
14#include "TG4Globals.h"
15
16#include <TGTextBuffer.h>
17#include <TGTextEntry.h>
18#include <TGComboBox.h>
19#include <TGLabel.h>
f9ea40e1 20#include <TGTab.h>
4b1d6659 21
22#include <G4Material.hh>
23#include <G4Element.hh>
24
25
26
27 ClassImp(TG4MaterialsFrames)
28
f9ea40e1 29TG4MaterialsFrames::TG4MaterialsFrames( TGTab* Tab, TGMainFrame* ActionFrame )
4b1d6659 30{
31//---> creates the materials properties display frame
32//---> and plunges it into the main frame
2ced62e8 33 TGCompositeFrame* parent = Tab->AddTab("Materials Properties");
34 fCapFrame = new TGCompositeFrame(parent, 60, 20, kHorizontalFrame);
20380626 35 ULong_t back= TGFrame::GetBlackPixel();
36 fCapFrame->ChangeBackground(back);
4b1d6659 37 fMatSubframe1 = new TGCompositeFrame(fCapFrame, 60, 20, kVerticalFrame);
38 fMatFrameLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
39
40 // ComboBox for materials
41 fMaterialsCombo = new TGComboBox(fMatSubframe1, 200);
42 TGLayoutHints* lLayoutHints3 =
43 new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
44 2, 2, 2, 2);
45 Text_t* lComboLabelText = " Pick up a material here ";
46 fComboLabel = new TGLabel( fMatSubframe1, lComboLabelText);
47 fMatSubframe1->AddFrame(fComboLabel, lLayoutHints3);
48 fMatSubframe1->AddFrame(fMaterialsCombo, fMatFrameLayout);
49
50
51 fMaterialsCombo->Resize(200, 20);
52 fMaterialsCombo->Associate(ActionFrame);
53
54
55
56// text labels with material properties
57 Text_t* labelText[8] =
58 {"Index ",
59 "Number of elements",
60 "Elements list ",
61 "Atomic mass ",
62 "Density ",
63 "State ",
64 "Radiation Length ",
65 "Abs. Length " };
66
67// Entries for material properties
68 TGLayoutHints* lLayoutHints4 =
69 new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5);
70 TGLayoutHints* lLayoutHints5 =
71 new TGLayoutHints(kLHintsLeft | kLHintsExpandX );
72 fMatSubframe2 = new TGCompositeFrame(fCapFrame, 60, 20, kVerticalFrame);
73
74 { // local scope for i
75 for (Int_t i=0; i<8; i++) {
76 Int_t idT=i+1;
77 fHframe[i] = new TGHorizontalFrame(fMatSubframe2, 500, 100, kFixedWidth);
78 fMatTextBuff[i] = new TGTextBuffer(200);
79 fMatTextEntry[i] = new TGTextEntry(fHframe[i], fMatTextBuff[i], 300);
80 fLabel[i] = new TGLabel(fHframe[i], labelText[i]);
81 fHframe[i]->AddFrame(fLabel[i], lLayoutHints5);
82 fHframe[i]->AddFrame(fMatTextEntry[i], lLayoutHints5);
83 fMatSubframe2->AddFrame(fHframe[i], lLayoutHints4);
84 fMatTextEntry[i]->Associate(ActionFrame);
85 }
86 }
87
88// making up Materials frame
89 fCapFrame->AddFrame(fMatSubframe1,fMatFrameLayout);
90 fCapFrame->AddFrame(fMatSubframe2,fMatFrameLayout);
91
92// going to the main frame
2ced62e8 93 parent->AddFrame(fCapFrame, fMatFrameLayout);
4b1d6659 94
95}
96
97TG4MaterialsFrames::TG4MaterialsFrames(const TG4MaterialsFrames& mf)
98{
99// Dummy copy constructor
100 TG4Globals::Exception(
101 "Attempt to use TG4MaterialsFrames copy constructor.");
102}
103
104TG4MaterialsFrames& TG4MaterialsFrames::operator=(const TG4MaterialsFrames& mf)
105{
106 // check assignement to self
107 if (this == &mf) return *this;
108
109 TG4Globals::Exception(
110 "Attempt to assign TG4MaterialsFrames singleton.");
111
112 return *this;
113}
114
115TG4MaterialsFrames::~TG4MaterialsFrames()
116{
117 //---> liquidator
118
119 G4cout << "\n Now in TG4MaterialsFrames destructor \n"<< G4endl;
120 delete fMatSubframe1;
121 delete fMatFrameLayout;
122 delete fMaterialsCombo;
123 delete fComboLabel;
124 delete fMatSubframe2;
125 delete fCapFrame;
126
127 Int_t i;
128 for (i=0; i<8; i++) {
129 delete fHframe[i];
130 delete fMatTextBuff[i];
131 delete fMatTextEntry[i];
132 delete fLabel[i];
133 }
134
135}
136
137void TG4MaterialsFrames::SetMaterialsComboEntries()
138{
139//---> puts names of materials into the combo box entries
140
141 const G4MaterialTable* lComboEntries = G4Material::GetMaterialTable();
142
143 G4int ig = lComboEntries->entries();
144 G4String name;
145
146 for (int ii=0; ii < ig; ii++)
147 { name = ((*lComboEntries )[ii])->GetName() ;
148 AddMaterialName( name, ii+1);
149 };
150
151 name = " " ;
152 AddMaterialName( name, ig+1);
153
154}
155
156void TG4MaterialsFrames::AddMaterialName( const char* name, Int_t index) const
157{
158
159//-----> adds a material name to the combo box
160
161 fMaterialsCombo->AddEntry( name, index);
162 fMaterialsCombo->Select(index);
163 fMaterialsCombo->Resize(200, 20);
164}
165
166void TG4MaterialsFrames::DisplayMaterialCharacteristics()
167{
168
169//-----> shows informations about materials listed in G4MaterialTable
170
171 const G4MaterialTable* lComboEntries = G4Material::GetMaterialTable();
172 G4int ientr = lComboEntries->entries();
173 G4int index = fMaterialsCombo->GetSelected();
174
175 G4cout << "\nThe clicked-on material has the index: " << index << G4endl;
176
177 if( index < ientr+1 ) {
178
179 G4int ii = index-1;
180 G4Material* lvMaterial = (*lComboEntries )[ii];
181 const G4ElementVector* allElements = lvMaterial->GetElementVector();
182
183 G4cout << lvMaterial->GetName() << " "
184 << lvMaterial->GetNumberOfElements() << " "
185 << (*allElements )[0]->GetName() << "... "
20380626 186 << lvMaterial->GetDensity()/(g/cm3) << " "
4b1d6659 187 << lvMaterial->GetState() << " "
20380626 188 << lvMaterial->GetRadlen()/(cm) << " "
4b1d6659 189 << G4endl;
190
191 char buff[200];
192
193 sprintf(buff, "%10i",index );
194 fMatTextBuff[0]->Clear();
195 fMatTextBuff[0]->AddText(0, buff);
196 gClient->NeedRedraw(fMatTextEntry[0]);
197
198 G4int noe = lvMaterial->GetNumberOfElements();
199 sprintf(buff, "%10i", noe);
200 fMatTextBuff[1]->Clear();
201 fMatTextBuff[1]->AddText(0, buff);
202 gClient->NeedRedraw(fMatTextEntry[1]);
203
204 G4String stringOfElements = " ";
205 for (G4int ie=0; ie < noe; ie++) {
206 stringOfElements += (*allElements )[ie]->GetName();
207 stringOfElements += " ";
208 };
209 sprintf(buff, stringOfElements);
210 fMatTextBuff[2]->Clear();
211 fMatTextBuff[2]->AddText(0, buff);
212 gClient->NeedRedraw(fMatTextEntry[2]);
213
214 sprintf(buff, " Multi element material" );
215 if( noe < 2 )
20380626 216 sprintf(buff, "%10.2e", lvMaterial->GetA()/(g) );
4b1d6659 217 fMatTextBuff[3]->Clear();
218 fMatTextBuff[3]->AddText(0, buff);
219 gClient->NeedRedraw(fMatTextEntry[3]);
220
20380626 221 sprintf(buff, "%10.2e", lvMaterial->GetDensity()/(g/cm3) );
4b1d6659 222 fMatTextBuff[4]->Clear();
223 fMatTextBuff[4]->AddText(0, buff);
224 gClient->NeedRedraw(fMatTextEntry[4]);
225
226 sprintf(buff,"%10i", lvMaterial->GetState());
227 fMatTextBuff[5]->Clear();
228 fMatTextBuff[5]->AddText(0, buff);
229 gClient->NeedRedraw(fMatTextEntry[5]);
230
20380626 231 sprintf(buff,"%10.2e", lvMaterial->GetRadlen()/(cm));
4b1d6659 232 fMatTextBuff[6]->Clear();
233 fMatTextBuff[6]->AddText(0, buff);
234 gClient->NeedRedraw(fMatTextEntry[6]);
235
236 sprintf(buff, " " );
237 fMatTextBuff[7]->Clear();
238 fMatTextBuff[7]->AddText(0, buff);
239 gClient->NeedRedraw(fMatTextEntry[7]);
240
241 };
242
243 if( index == ientr+1 ) {
244
245 for ( G4int ii=0; ii<8; ii++) {
246 fMatTextBuff[ii]->Clear();
247 gClient->NeedRedraw(fMatTextEntry[ii]);
248 };
249 };
250
251}
252