Graduation-Project/src/GeneDetectorConstructionMes...

43 lines
1.7 KiB
C++

#include "GeneDetectorConstructionMessenger.hh"
#include "G4UIcmdWithADouble.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIdirectory.hh"
#include "GeneDetectorConstruction.hh"
GeneDetectorConstructionMessenger::GeneDetectorConstructionMessenger(GeneDetectorConstruction* pDets)
: pDetectorConstruction(pDets) {
DetectorDir = new G4UIdirectory("/Gene/Detector/");
DetectorDir->SetGuidance("Command to set detector offset");
ZoffsetCmd = new G4UIcmdWithADoubleAndUnit("/Gene/Detector/SetZoffset", this);
ZoffsetCmd->SetGuidance("Set detector Z offset");
ZoffsetCmd->SetParameterName("Zoffset", false);
ZoffsetCmd->SetUnitCategory("Length");
// ZoffsetCmd->SetRange("Zoffset>0");
ZoffsetCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
ZactiveshiftCmd = new G4UIcmdWithADoubleAndUnit("/Gene/Detector/SetZactiveshift", this);
ZactiveshiftCmd->SetGuidance("Set He3 active region Z shift");
ZactiveshiftCmd->SetParameterName("Zactiveshift", false);
ZactiveshiftCmd->SetUnitCategory("Length");
ZactiveshiftCmd->SetRange("Zactiveshift>-20 && Zactiveshift<20");
ZactiveshiftCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
GeneDetectorConstructionMessenger::~GeneDetectorConstructionMessenger() {
delete ZoffsetCmd;
delete ZactiveshiftCmd;
delete DetectorDir;
}
void GeneDetectorConstructionMessenger::SetNewValue(G4UIcommand* command, G4String newValue) {
if (command == ZoffsetCmd) {
pDetectorConstruction->SetZoffset(ZoffsetCmd->GetNewDoubleValue(newValue));
}
if (command == ZactiveshiftCmd) {
pDetectorConstruction->SetZactiveshift(ZactiveshiftCmd->GetNewDoubleValue(newValue));
}
}