#include "PhantomMessenger.hh" #include "Phantom.hh" PhantomMessenger::PhantomMessenger(Phantom* p) :phantom(p) { phantomDir = new G4UIdirectory("/Phantom/"); phantomDir->SetGuidance("Commands to modify the Phantom"); phantomNameCmd = new G4UIcmdWithAString("/Phantom/Name", this); phantomNameCmd->SetGuidance("Command to select which phantom to build"); phantomNameCmd->SetGuidance("Current options are \"Sphere\", \"Pacman\""); phantomNameCmd->SetParameterName("PhantomName", false); phantomNameCmd->AvailableForStates(G4State_PreInit,G4State_Idle); phantomMaterialCmd = new G4UIcmdWithAString("/Phantom/SetMaterial", this); phantomMaterialCmd->SetGuidance("Command to select the phantom material"); phantomMaterialCmd->SetParameterName("PhantomMaterial", false); phantomMaterialCmd->AvailableForStates(G4State_PreInit,G4State_Idle); phantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/Phantom/SetPosition", this); phantomPositionCmd->SetGuidance("Set the centre position of the Phantom"); phantomPositionCmd->SetParameterName("PhantomPosX", "PhantomPosY", "PhantomPosZ", false); phantomPositionCmd->SetUnitCategory("Length"); phantomPositionCmd->AvailableForStates(G4State_PreInit,G4State_Idle); phantomRotXCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/SetRotationX", this); phantomRotXCmd->SetGuidance("Set the X rotation of the phantom"); phantomRotXCmd->SetParameterName("RotX", false); phantomRotXCmd->AvailableForStates(G4State_PreInit,G4State_Idle); phantomRotYCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/SetRotationY", this); phantomRotYCmd->SetGuidance("Set the Y rotation of the phantom"); phantomRotYCmd->SetParameterName("RotY", false); phantomRotYCmd->AvailableForStates(G4State_PreInit,G4State_Idle); phantomRotZCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/SetRotationZ", this); phantomRotZCmd->SetGuidance("Set the Z rotation of the phantom"); phantomRotZCmd->SetParameterName("RotZ", false); phantomRotZCmd->AvailableForStates(G4State_PreInit,G4State_Idle); phantomConstructCmd = new G4UIcmdWithABool("/Phantom/Construct", this); phantomConstructCmd->SetGuidance("Set to true of false to signify whether to build the phantom or not"); phantomConstructCmd->SetParameterName("Construct", false); phantomConstructCmd->AvailableForStates(G4State_PreInit,G4State_Idle); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// compensatorConstructCmd = new G4UIcmdWithABool("/Phantom/Compensator/Construct", this); compensatorConstructCmd->SetGuidance("Set to true of false to signify whether to build the compensator or not"); compensatorConstructCmd->SetParameterName("ConstructCompensator", false); compensatorConstructCmd->AvailableForStates(G4State_PreInit,G4State_Idle); compensatorPositionCmd = new G4UIcmdWith3VectorAndUnit("/Phantom/Compensator/SetPosition", this); compensatorPositionCmd->SetGuidance("Set the centre position of the Phantom Compensator"); compensatorPositionCmd->SetParameterName("CompensatorPosX", "CompensatorPosY", "CompensatorPosZ", false); compensatorPositionCmd->SetUnitCategory("Length"); compensatorPositionCmd->AvailableForStates(G4State_PreInit,G4State_Idle); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// phantomSphereRadiusCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/Sphere/SetRadius", this); phantomSphereRadiusCmd->SetGuidance("Command to set the radius of the Spherical Phantom"); phantomSphereRadiusCmd->SetParameterName("SphericalPhantomRadius", false); phantomSphereRadiusCmd->SetUnitCategory("Length"); phantomSphereRadiusCmd->AvailableForStates(G4State_PreInit, G4State_Idle); phantomSphereInsert1RCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/Sphere/Insert1/SetRadius", this); phantomSphereInsert1RCmd->SetGuidance("Command to set the radius of the first insert in the spherical phantom"); phantomSphereInsert1RCmd->SetParameterName("SphericalPhantomInsert1Radius", false); phantomSphereInsert1RCmd->SetUnitCategory("Length"); phantomSphereInsert1RCmd->AvailableForStates(G4State_PreInit, G4State_Idle); phantomSphereInsert1LengthCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/Sphere/Insert1/SetLength", this); phantomSphereInsert1LengthCmd->SetGuidance("Command to set the length of the first insert in the spherical phantom"); phantomSphereInsert1LengthCmd->SetParameterName("SphericalPhantomInsert1Length", false); phantomSphereInsert1LengthCmd->SetUnitCategory("Length"); phantomSphereInsert1LengthCmd->AvailableForStates(G4State_PreInit, G4State_Idle); phantomSphereInsert1MaterialCmd = new G4UIcmdWithAString("/Phantom/Sphere/Insert1/SetMaterial", this); phantomSphereInsert1MaterialCmd->SetGuidance("Command to select the material of the first insert in the spherical phantom"); phantomSphereInsert1MaterialCmd->SetParameterName("SphericalPhantomInsert1Material", false); phantomSphereInsert1MaterialCmd->AvailableForStates(G4State_PreInit,G4State_Idle); phantomSphereInsert2RCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/Sphere/Insert2/SetRadius", this); phantomSphereInsert2RCmd->SetGuidance("Command to set the radius of the second insert in the spherical phantom"); phantomSphereInsert2RCmd->SetParameterName("SphericalPhantomInsert2Radius", false); phantomSphereInsert2RCmd->SetUnitCategory("Length"); phantomSphereInsert2RCmd->AvailableForStates(G4State_PreInit, G4State_Idle); phantomSphereInsert2LengthCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/Sphere/Insert2/SetLength", this); phantomSphereInsert2LengthCmd->SetGuidance("Command to set the length of the second insert in the spherical phantom"); phantomSphereInsert2LengthCmd->SetParameterName("SphericalPhantomInsert2Length", false); phantomSphereInsert2LengthCmd->SetUnitCategory("Length"); phantomSphereInsert2LengthCmd->AvailableForStates(G4State_PreInit, G4State_Idle); phantomSphereInsert2MaterialCmd = new G4UIcmdWithAString("/Phantom/Sphere/Insert2/SetMaterial", this); phantomSphereInsert2MaterialCmd->SetGuidance("Command to select the material of the second insert in the spherical phantom"); phantomSphereInsert2MaterialCmd->SetParameterName("SphericalPhantomInsert2Material", false); phantomSphereInsert2MaterialCmd->AvailableForStates(G4State_PreInit,G4State_Idle); phantomSphereInsert3RCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/Sphere/Insert3/SetRadius", this); phantomSphereInsert3RCmd->SetGuidance("Command to set the radius of the third insert in the spherical phantom"); phantomSphereInsert3RCmd->SetParameterName("SphericalPhantomInsert3Radius", false); phantomSphereInsert3RCmd->SetUnitCategory("Length"); phantomSphereInsert3RCmd->AvailableForStates(G4State_PreInit, G4State_Idle); phantomSphereInsert3LengthCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/Sphere/Insert3/SetLength", this); phantomSphereInsert3LengthCmd->SetGuidance("Command to set the length of the third insert in the spherical phantom"); phantomSphereInsert3LengthCmd->SetParameterName("SphericalPhantomInsert3Length", false); phantomSphereInsert3LengthCmd->SetUnitCategory("Length"); phantomSphereInsert3LengthCmd->AvailableForStates(G4State_PreInit, G4State_Idle); phantomSphereInsert3MaterialCmd = new G4UIcmdWithAString("/Phantom/Sphere/Insert3/SetMaterial", this); phantomSphereInsert3MaterialCmd->SetGuidance("Command to select the material of the third insert in the spherical phantom"); phantomSphereInsert3MaterialCmd->SetParameterName("SphericalPhantomInsert3Material", false); phantomSphereInsert3MaterialCmd->AvailableForStates(G4State_PreInit,G4State_Idle); /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// phantomEllipsoidSemiXCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/Ellipsoid/SetSemiX", this); phantomEllipsoidSemiXCmd->SetGuidance("Command to set the semi X of the ellipsoid Phantom"); phantomEllipsoidSemiXCmd->SetParameterName("EllipsoidSemiX", false); phantomEllipsoidSemiXCmd->SetUnitCategory("Length"); phantomEllipsoidSemiXCmd->AvailableForStates(G4State_PreInit, G4State_Idle); phantomEllipsoidSemiYCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/Ellipsoid/SetSemiY", this); phantomEllipsoidSemiYCmd->SetGuidance("Command to set the semi Y of the ellipsoid Phantom"); phantomEllipsoidSemiYCmd->SetParameterName("EllipsoidSemiY", false); phantomEllipsoidSemiYCmd->SetUnitCategory("Length"); phantomEllipsoidSemiYCmd->AvailableForStates(G4State_PreInit, G4State_Idle); phantomEllipsoidSemiZCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/Ellipsoid/SetSemiZ", this); phantomEllipsoidSemiZCmd->SetGuidance("Command to set the semi Z of the ellipsoid Phantom"); phantomEllipsoidSemiZCmd->SetParameterName("EllipsoidSemiZ", false); phantomEllipsoidSemiZCmd->SetUnitCategory("Length"); phantomEllipsoidSemiZCmd->AvailableForStates(G4State_PreInit, G4State_Idle); phantomPacmanRadiusCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/Pacman/SetRadius", this); phantomPacmanRadiusCmd->SetGuidance("Command to set the radius of the Pacman Phantom"); phantomPacmanRadiusCmd->SetParameterName("SphericalPacmanRadius", false); phantomPacmanRadiusCmd->SetUnitCategory("Length"); phantomPacmanRadiusCmd->AvailableForStates(G4State_PreInit, G4State_Idle); phantomPacmanHalfZCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/Pacman/SetHalfZ", this); phantomPacmanHalfZCmd->SetGuidance("Command to set the half Z thickness of the Pacman Phantom"); phantomPacmanHalfZCmd->SetParameterName("SphericalPacmanHalfZ", false); phantomPacmanHalfZCmd->SetUnitCategory("Length"); phantomPacmanHalfZCmd->AvailableForStates(G4State_PreInit, G4State_Idle); phantomPacmanSpanningAngleCmd = new G4UIcmdWithADoubleAndUnit("/Phantom/Pacman/SetSpanningAngle", this); phantomPacmanSpanningAngleCmd->SetGuidance("Command to set the spanning angle of the Pacman Phantom"); phantomPacmanSpanningAngleCmd->SetParameterName("SphericalPacmanSpanningAngle", false); phantomPacmanSpanningAngleCmd->AvailableForStates(G4State_PreInit, G4State_Idle); phantomRectangleSizeCmd = new G4UIcmdWith3VectorAndUnit("/Phantom/Rectangle/SetSize",this); phantomRectangleSizeCmd->SetGuidance("Command to set the size of the simple block phantom"); phantomRectangleSizeCmd->SetParameterName("RectangularSizeX", "RectangularSizeY","RectangularSizeZ",false, false); phantomRectangleSizeCmd->AvailableForStates(G4State_PreInit, G4State_Idle); } PhantomMessenger::~PhantomMessenger() { delete phantomDir; delete phantomNameCmd; delete phantomMaterialCmd; delete phantomRotXCmd; delete phantomRotXCmd; delete phantomRotXCmd; delete phantomConstructCmd; delete compensatorPositionCmd; delete compensatorConstructCmd; delete phantomSphereRadiusCmd; delete phantomSphereInsert1RCmd; delete phantomSphereInsert1LengthCmd; delete phantomSphereInsert1MaterialCmd; delete phantomSphereInsert2RCmd; delete phantomSphereInsert1LengthCmd; delete phantomSphereInsert2MaterialCmd; delete phantomSphereInsert3MaterialCmd; delete phantomEllipsoidSemiXCmd; delete phantomEllipsoidSemiYCmd; delete phantomEllipsoidSemiZCmd; delete phantomPacmanRadiusCmd; delete phantomPacmanHalfZCmd; delete phantomPacmanSpanningAngleCmd; } void PhantomMessenger::SetNewValue(G4UIcommand* command, G4String newValue) { if(command == phantomNameCmd) phantom->SetPhantomName(newValue); if(command == phantomMaterialCmd) phantom->SetPhantomMaterial(newValue); if(command == phantomPositionCmd) phantom->SetPhantomPosition(phantomPositionCmd->GetNew3VectorValue(newValue)); if(command == phantomRotXCmd){ G4RotationMatrix* rot = phantom->GetPhantomRotation(); rot->rotateX(phantomRotXCmd->GetNewDoubleValue(newValue)); phantom->SetPhantomRotation(rot); } if(command == phantomRotYCmd){ G4RotationMatrix* rot = phantom->GetPhantomRotation(); rot->rotateY(phantomRotYCmd->GetNewDoubleValue(newValue)); phantom->SetPhantomRotation(rot); } if(command == phantomRotZCmd){ G4RotationMatrix* rot = phantom->GetPhantomRotation(); rot->rotateZ(phantomRotYCmd->GetNewDoubleValue(newValue)); phantom->SetPhantomRotation(rot); } if(command == phantomConstructCmd) phantom->SetConstructPhantom(phantomConstructCmd->GetNewBoolValue(newValue)); /////////////////////////////////////////////////////////////////////////////////////// if(command == compensatorConstructCmd) phantom->SetConstructCompensator(compensatorConstructCmd->GetNewBoolValue(newValue)); if(command == compensatorPositionCmd) phantom->SetCompensatorPosition(compensatorPositionCmd->GetNew3VectorValue(newValue)); /////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////// if(command == phantomSphereRadiusCmd) phantom->SetSphericalPhantomRadius(phantomSphereRadiusCmd->GetNewDoubleValue(newValue)); if(command == phantomSphereInsert1RCmd) phantom->SetSphericalPhantomInsert1Radius(phantomSphereInsert1RCmd->GetNewDoubleValue(newValue)); if(command == phantomSphereInsert1LengthCmd) phantom->SetSphericalPhantomInsert1Length(phantomSphereInsert1LengthCmd->GetNewDoubleValue(newValue)); if(command == phantomSphereInsert1MaterialCmd) phantom->SetSphericalPhantomInsert1Material(newValue); if(command == phantomSphereInsert2RCmd) phantom->SetSphericalPhantomInsert2Radius(phantomSphereInsert2RCmd->GetNewDoubleValue(newValue)); if(command == phantomSphereInsert2LengthCmd) phantom->SetSphericalPhantomInsert2Length(phantomSphereInsert2LengthCmd->GetNewDoubleValue(newValue)); if(command == phantomSphereInsert2MaterialCmd) phantom->SetSphericalPhantomInsert2Material(newValue); if(command == phantomSphereInsert3RCmd) phantom->SetSphericalPhantomInsert3Radius(phantomSphereInsert3RCmd->GetNewDoubleValue(newValue)); if(command == phantomSphereInsert3LengthCmd) phantom->SetSphericalPhantomInsert3Length(phantomSphereInsert3LengthCmd->GetNewDoubleValue(newValue)); if(command == phantomSphereInsert3MaterialCmd) phantom->SetSphericalPhantomInsert3Material(newValue); ///////////////////////////////////////////////////////////////////////////////////////// if(command == phantomEllipsoidSemiXCmd) phantom->SetEllopsoidalPhantomSemiX(phantomEllipsoidSemiXCmd->GetNewDoubleValue(newValue)); if(command == phantomEllipsoidSemiYCmd) phantom->SetEllopsoidalPhantomSemiY(phantomEllipsoidSemiYCmd->GetNewDoubleValue(newValue)); if(command == phantomEllipsoidSemiZCmd) phantom->SetEllopsoidalPhantomSemiZ(phantomEllipsoidSemiZCmd->GetNewDoubleValue(newValue)); if(command == phantomPacmanRadiusCmd) phantom->SetPacmanPhantomRadius(phantomPacmanRadiusCmd->GetNewDoubleValue(newValue)); if(command == phantomPacmanHalfZCmd) phantom->SetPacmanPhantomHalfZ(phantomPacmanHalfZCmd->GetNewDoubleValue(newValue)); if(command == phantomPacmanSpanningAngleCmd) phantom->SetPacmanPhantomSpanningAngle(phantomPacmanSpanningAngleCmd->GetNewDoubleValue(newValue)); if(command == phantomRectangleSizeCmd) phantom->SetRectangularPhantomSize(phantomRectangleSizeCmd->GetNew3VectorValue(newValue)); }