00001
00002
00003
00004
00005
00006 #include "DetectorMessenger.hh"
00007
00008 #include "DetectorConstruction.hh"
00009 #include "G4UIdirectory.hh"
00010 #include "G4UIcmdWithAString.hh"
00011 #include "G4UIcmdWithADoubleAndUnit.hh"
00012 #include "G4UIcmdWithoutParameter.hh"
00013
00014
00015
00016 DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
00017 :m_detector(Det)
00018 {
00019 m_detDir = new G4UIdirectory("/tutorial/det/");
00020 m_detDir->SetGuidance("detector construction commands");
00021
00022 m_materialCmd = new G4UIcmdWithAString ("/tutorial/det/spacecraftMaterial", this);
00023 m_materialCmd->SetGuidance("Select spacecraft material");
00024 m_materialCmd->SetParameterName("spacecraftMaterial",false);
00025
00026 m_thicknessCmd = new G4UIcmdWithADoubleAndUnit("/tutorial/det/spacecraftThickness",this);
00027 m_thicknessCmd->SetGuidance("Select spacecraft thickness");
00028 m_thicknessCmd->SetParameterName("spacecraftThickness",false);
00029 m_thicknessCmd->SetRange("spacecraftThickness>0.");
00030 m_thicknessCmd->SetUnitCategory("Length");
00031
00032 m_radiusCmd = new G4UIcmdWithADoubleAndUnit ("/tutorial/det/cabinRadius", this);
00033 m_radiusCmd->SetGuidance("Select spacecraft radius");
00034 m_radiusCmd->SetParameterName("cabinRadius",false);
00035 m_radiusCmd->SetUnitCategory("Length");
00036
00037 m_lengthCmd = new G4UIcmdWithADoubleAndUnit ("/tutorial/det/cabinLength", this);
00038 m_lengthCmd->SetGuidance("Select spacecraft length");
00039 m_lengthCmd->SetParameterName("spacecraftLength",false);
00040 m_lengthCmd->SetRange("cabinLength>0.&&cabinLength<20*m");
00041 m_lengthCmd->SetUnitCategory("Length");
00042
00043 m_updateCmd = new G4UIcmdWithoutParameter("/tutorial/det/update",this);
00044 m_updateCmd->SetGuidance("force to recompute geometry.");
00045 m_updateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
00046 m_updateCmd->SetGuidance("if you changed geometrical value(s).");
00047 m_updateCmd->AvailableForStates(G4State_Idle);
00048 }
00049
00050
00051
00052 DetectorMessenger::~DetectorMessenger()
00053 {
00054 delete m_materialCmd;
00055 delete m_thicknessCmd;
00056 delete m_radiusCmd;
00057 delete m_lengthCmd;
00058 delete m_updateCmd;
00059
00060 delete m_detDir;
00061 }
00062
00063
00064
00065 void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
00066 {
00067 if( command == m_materialCmd )
00068 { m_detector->SetSpacecraftMaterial(newValue);}
00069
00070 if( command == m_thicknessCmd )
00071 { m_detector->SetSpacecraftThickness(m_thicknessCmd->GetNewDoubleValue(newValue));}
00072
00073 if( command == m_radiusCmd )
00074 { m_detector->SetCabinRadius(m_radiusCmd->GetNewDoubleValue(newValue));}
00075
00076 if( command == m_lengthCmd )
00077 { m_detector->SetCabinLength(m_lengthCmd->GetNewDoubleValue(newValue));}
00078
00079 if( command == m_updateCmd )
00080 { m_detector->UpdateGeometry();}
00081 }
00082
00083