source: trunk/examples/extended/radioactivedecay/exrdm/src/exrdmMaterialMessenger.cc @ 1279

Last change on this file since 1279 was 1230, checked in by garnier, 14 years ago

update to geant4.9.3

File size: 5.8 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26////////////////////////////////////////////////////////////////////////////////
27//
28#include "exrdmMaterialMessenger.hh"
29
30#include <sstream>
31
32#include "exrdmMaterial.hh"
33////////////////////////////////////////////////////////////////////////////////
34//
35exrdmMaterialMessenger::exrdmMaterialMessenger (exrdmMaterial * exrdmMat)
36  :materialsManager(exrdmMat)
37{ 
38  MaterialDir = new G4UIdirectory("/geometry/material/");
39  MaterialDir->SetGuidance(" Controls for defining geometry materials" );
40
41  AddCmd = new G4UIcommand("/geometry/material/add",this);
42  AddCmd->SetGuidance(
43    "  add a mateial by name, composition formula and density");
44  AddCmd->SetGuidance("  name: e.g. water ");
45  AddCmd->SetGuidance("  formula (e.g. H2-O for water");
46  AddCmd->SetGuidance("  density (in units of g/cm3) : den>0.");
47  G4UIparameter* MatName = new G4UIparameter("material",'s',false);
48  MatName->SetGuidance("material name");
49  AddCmd->SetParameter(MatName);
50  //
51  G4UIparameter* MatForm = new G4UIparameter("formula",'s',false);
52  MatForm->SetGuidance("material formula");
53  AddCmd->SetParameter(MatForm);
54  //   
55  G4UIparameter* DenPrm = new G4UIparameter("density",'d',false);
56  DenPrm->SetGuidance("density of the material");
57  DenPrm->SetParameterRange("density >0.");
58  AddCmd->SetParameter(DenPrm);
59  AddCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
60
61  G4UIparameter* StatePrm = new G4UIparameter("state",'s',true);
62  StatePrm->SetGuidance("state of the material (optional): gas | solid");
63  AddCmd->SetParameter(StatePrm);
64  AddCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
65
66  G4UIparameter* TempPrm = new G4UIparameter("temp",'d',true);
67  TempPrm->SetGuidance("temperature of the material in Kelvin (optional)");
68  AddCmd->SetParameter(TempPrm);
69  AddCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
70
71  G4UIparameter* PresPrm = new G4UIparameter("pres",'d',true);
72  PresPrm->SetGuidance("pressure of the gas material in Pascal (optional)");
73  AddCmd->SetParameter(PresPrm);
74  AddCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
75  //
76  DeleteIntCmd = new G4UIcmdWithAnInteger("/geometry/material/delete",this);
77  DeleteIntCmd->SetGuidance("Delete material by its index");
78  DeleteIntCmd->SetParameterName("matIdx",false);
79  DeleteIntCmd->SetRange("matIdx>=0 && matIdx<100");
80  DeleteIntCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
81 
82  DeleteNameCmd = new G4UIcmdWithAString("/geometry/material/deleteName",this);
83  DeleteNameCmd->SetGuidance("Delete material by its name.");
84  DeleteNameCmd->SetParameterName("DeleteName",false);
85  DeleteNameCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
86   
87  ListCmd = new G4UIcmdWithoutParameter("/geometry/material/list",this);
88  ListCmd->SetGuidance("List the materials defined");
89  ListCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
90}
91////////////////////////////////////////////////////////////////////////////////
92//
93exrdmMaterialMessenger::~exrdmMaterialMessenger ()
94{
95  delete MaterialDir;
96  delete AddCmd;
97  delete DeleteIntCmd;
98  delete DeleteNameCmd;
99  delete ListCmd;
100}
101////////////////////////////////////////////////////////////////////////////////
102//
103void exrdmMaterialMessenger::SetNewValue (G4UIcommand* command,G4String newValue)
104{   
105  if (command == DeleteIntCmd) {
106    materialsManager->DeleteMaterial(DeleteIntCmd->GetNewIntValue(newValue));
107
108  } else if (command == DeleteNameCmd) {
109    materialsManager->DeleteMaterial(newValue);
110
111  } else if (command == ListCmd) {
112    materialsManager->ListMaterial();
113
114  } else if (command == AddCmd) {
115    G4double den, tem, pres ;
116    G4String state;
117    char mat[80], form[80], stat[10];
118    stat[0] = ' ';
119    tem = pres = -1.;
120    const char* t = newValue;
121    std::istringstream is(t);
122    is >>mat >>form >>den >>stat >> tem >> pres ;
123    G4String material=mat;
124    G4String formula=form;
125    if (pres == -1.) { 
126      state = "";
127    } else {
128      state = stat;
129    }
130    //    G4cout<< "stat = " <<state<< "tem = " << tem<< " pre = " << pres << G4endl;
131    //     tick *= G4UIcommand::ValueOf(unt);
132    materialsManager->AddMaterial(material,formula,den*g/cm3,state,tem,pres);
133  }
134}
135////////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.