00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "G4GMocrenMessenger.hh"
00033
00034 #include "G4UIdirectory.hh"
00035 #include "G4UIcmdWithABool.hh"
00036 #include "G4UIcmdWithAString.hh"
00037 #include "G4UIcmdWithoutParameter.hh"
00038 #include "G4UIcommand.hh"
00039 #include "G4Tokenizer.hh"
00040
00041 G4GMocrenMessenger::G4GMocrenMessenger()
00042 : suffix (""), geometry(true), solids(true), invisibles(true),
00043 kgMocrenVolumeName("gMocrenVolume"),
00044 kgMocrenScoringMeshName("gMocrenScoringMesh"),
00045 kDrawVolumeGrid(false) {
00046
00047 kgMocrenDirectory = new G4UIdirectory("/vis/gMocren/");
00048 kgMocrenDirectory->SetGuidance("gMocren commands.");
00049
00050 setEventNumberSuffixCommand = new G4UIcmdWithAString("/vis/gMocren/setEventNumberSuffix", this);
00051 setEventNumberSuffixCommand->SetGuidance("Write separate event files, appended with given suffix.");
00052 setEventNumberSuffixCommand->SetGuidance("Define the suffix with a pattern such as '-0000'.");
00053 setEventNumberSuffixCommand->SetParameterName("suffix",false);
00054 setEventNumberSuffixCommand->SetDefaultValue("");
00055 setEventNumberSuffixCommand->AvailableForStates(G4State_Idle);
00056
00057 appendGeometryCommand = new G4UIcmdWithABool("/vis/gMocren/appendGeometry", this);
00058 appendGeometryCommand->SetGuidance("Appends copy of geometry to every event.");
00059 appendGeometryCommand->SetParameterName("flag",false);
00060 appendGeometryCommand->SetDefaultValue(true);
00061 appendGeometryCommand->AvailableForStates(G4State_Idle);
00062
00063 addPointAttributesCommand = new G4UIcmdWithABool("/vis/gMocren/addPointAttributes", this);
00064 addPointAttributesCommand->SetGuidance("Adds point attributes to the points of trajectories.");
00065 addPointAttributesCommand->SetParameterName("flag",false);
00066 addPointAttributesCommand->SetDefaultValue(false);
00067 addPointAttributesCommand->AvailableForStates(G4State_Idle);
00068
00069 useSolidsCommand = new G4UIcmdWithABool("/vis/gMocren/useSolids", this);
00070 useSolidsCommand->SetGuidance("Use GMocren Solids, rather than Geant4 Primitives.");
00071 useSolidsCommand->SetParameterName("flag",false);
00072 useSolidsCommand->SetDefaultValue(true);
00073 useSolidsCommand->AvailableForStates(G4State_Idle);
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 kSetgMocrenVolumeNameCommand = new G4UIcmdWithAString("/vis/gMocren/setVolumeName", this);
00084 kSetgMocrenVolumeNameCommand->SetGuidance("detector name for a volume data in gMocren data.");
00085 kSetgMocrenVolumeNameCommand->SetParameterName("kgMocrenVolumeName",false);
00086 kSetgMocrenVolumeNameCommand->SetDefaultValue("gMocrenVolume");
00087 kSetgMocrenVolumeNameCommand->AvailableForStates(G4State_Idle);
00088
00089 kAddgMocrenHitNameCommand = new G4UIcmdWithAString("/vis/gMocren/addHitName", this);
00090 kAddgMocrenHitNameCommand->SetGuidance("hit name for a dose distribution in gMocren data.");
00091 kAddgMocrenHitNameCommand->SetParameterName("kgMocrenHitName",false);
00092 kAddgMocrenHitNameCommand->AvailableForStates(G4State_Idle);
00093
00094 kResetgMocrenHitNameCommand = new G4UIcmdWithoutParameter("/vis/gMocren/resetHitNames", this);
00095 kResetgMocrenHitNameCommand->SetGuidance("reset all hit names.");
00096 kResetgMocrenHitNameCommand->AvailableForStates(G4State_Idle);
00097
00098 kSetgMocrenScoringMeshNameCommand = new G4UIcmdWithAString("/vis/gMocren/setScoringMeshName", this);
00099 kSetgMocrenScoringMeshNameCommand->SetGuidance("scoring mesh name for a dose distribution in gMocren data.");
00100 kSetgMocrenScoringMeshNameCommand->SetParameterName("kgMocrenScoringMeshName",false);
00101 kSetgMocrenScoringMeshNameCommand->SetDefaultValue("gMocrenScoringMesh");
00102 kSetgMocrenScoringMeshNameCommand->AvailableForStates(G4State_Idle);
00103
00104 kAddgMocrenHitScorerNameCommand = new G4UIcmdWithAString("/vis/gMocren/addHitScorerName", this);
00105 kAddgMocrenHitScorerNameCommand->SetGuidance("hit scorer name for a dose distribution in gMocren data.");
00106 kAddgMocrenHitScorerNameCommand->SetParameterName("kgMocrenHitScorerNames",false);
00107 kAddgMocrenHitScorerNameCommand->AvailableForStates(G4State_Idle);
00108
00109 kResetgMocrenHitScorerNameCommand = new G4UIcmdWithoutParameter("/vis/gMocren/resetHitScorerName", this);
00110 kResetgMocrenHitScorerNameCommand->SetGuidance("reset all hit scorer names.");
00111 kResetgMocrenHitScorerNameCommand->AvailableForStates(G4State_Idle);
00112
00113 kSetgMocrenNoVoxelsCommand = new G4UIcommand("/vis/gMocren/setNumberOfVoxels", this);
00114 kSetgMocrenNoVoxelsCommand->SetGuidance("set number of voxels.");
00115 kSetgMocrenNoVoxelsCommand->AvailableForStates(G4State_Idle);
00116 G4UIparameter * param = new G4UIparameter("nX", 'i', false);
00117 param->SetDefaultValue("1");
00118 param->SetParameterRange("nX>0");
00119 kSetgMocrenNoVoxelsCommand->SetParameter(param);
00120 param = new G4UIparameter("nY", 'i', false);
00121 param->SetDefaultValue("1");
00122 param->SetParameterRange("nY>0");
00123 kSetgMocrenNoVoxelsCommand->SetParameter(param);
00124 param = new G4UIparameter("nZ", 'i', false);
00125 param->SetDefaultValue("1");
00126 param->SetParameterRange("nZ>0");
00127 kSetgMocrenNoVoxelsCommand->SetParameter(param);
00128
00129 kListgMocrenCommand = new G4UIcmdWithoutParameter("/vis/gMocren/list", this);
00130 kListgMocrenCommand->SetGuidance("list gMocren command parameters.");
00131 kListgMocrenCommand->AvailableForStates(G4State_Idle);
00132
00133 kDrawVolumeGridCommand = new G4UIcmdWithABool("/vis/gMocren/drawVolumeGrid", this);
00134 kDrawVolumeGridCommand->SetGuidance("Add grid of the volume.");
00135 kDrawVolumeGridCommand->SetParameterName("kDrawVolumeGrid",false);
00136 kDrawVolumeGridCommand->SetDefaultValue(false);
00137 kDrawVolumeGridCommand->AvailableForStates(G4State_Idle);
00138
00139 }
00140
00141 G4GMocrenMessenger::~G4GMocrenMessenger() {
00142 delete setEventNumberSuffixCommand;
00143 delete appendGeometryCommand;
00144 delete addPointAttributesCommand;
00145 delete useSolidsCommand;
00146
00147 delete kSetgMocrenVolumeNameCommand;
00148 delete kAddgMocrenHitNameCommand;
00149 delete kResetgMocrenHitNameCommand;
00150
00151 delete kSetgMocrenScoringMeshNameCommand;
00152 delete kAddgMocrenHitScorerNameCommand;
00153 delete kResetgMocrenHitScorerNameCommand;
00154
00155 delete kSetgMocrenNoVoxelsCommand;
00156
00157 delete kgMocrenDirectory;
00158
00159 delete kDrawVolumeGridCommand;
00160 }
00161
00162 G4String G4GMocrenMessenger::GetCurrentValue(G4UIcommand * command) {
00163 if (command==setEventNumberSuffixCommand) {
00164 return suffix;
00165 } else if (command==appendGeometryCommand) {
00166 return appendGeometryCommand->ConvertToString(geometry);
00167 } else if (command==addPointAttributesCommand) {
00168 return addPointAttributesCommand->ConvertToString(pointAttributes);
00169 } else if (command==useSolidsCommand) {
00170 return useSolidsCommand->ConvertToString(solids);
00171
00172
00173 } else if (command == kSetgMocrenVolumeNameCommand) {
00174 return kgMocrenVolumeName;
00175 } else if (command == kAddgMocrenHitNameCommand) {
00176 G4String strval;
00177 std::vector<G4String>::iterator itr = kgMocrenHitNames.begin();
00178 for(; itr != kgMocrenHitNames.end(); itr++) {
00179 strval += *itr;
00180 strval += " ";
00181 }
00182 return strval;
00183 } else if (command == kSetgMocrenScoringMeshNameCommand) {
00184 return kgMocrenScoringMeshName;
00185 } else if (command == kAddgMocrenHitScorerNameCommand) {
00186 G4String strval;
00187 std::vector<G4String>::iterator itr = kgMocrenHitScorerNames.begin();
00188 for(; itr != kgMocrenHitScorerNames.end(); itr++) {
00189 strval += *itr;
00190 strval += " ";
00191 }
00192 return strval;
00193 } else if (command==kDrawVolumeGridCommand) {
00194 return kDrawVolumeGridCommand->ConvertToString(kDrawVolumeGrid);
00195 } else {
00196 return "";
00197 }
00198 }
00199
00200 void G4GMocrenMessenger::SetNewValue(G4UIcommand * command, G4String newValue) {
00201 if (command==setEventNumberSuffixCommand) {
00202 suffix = newValue;
00203 } else if (command==appendGeometryCommand) {
00204 geometry = appendGeometryCommand->GetNewBoolValue(newValue);
00205 } else if (command==addPointAttributesCommand) {
00206 pointAttributes = addPointAttributesCommand->GetNewBoolValue(newValue);
00207 } else if (command==useSolidsCommand) {
00208 solids = useSolidsCommand->GetNewBoolValue(newValue);
00209
00210
00211 } else if (command == kSetgMocrenVolumeNameCommand) {
00212 kgMocrenVolumeName = newValue;
00213 } else if (command == kAddgMocrenHitNameCommand) {
00214 kgMocrenHitNames.push_back(newValue);
00215 } else if (command == kResetgMocrenHitNameCommand) {
00216 kgMocrenHitNames.clear();
00217 } else if (command == kSetgMocrenScoringMeshNameCommand) {
00218 kgMocrenScoringMeshName = newValue;
00219 } else if (command == kAddgMocrenHitScorerNameCommand) {
00220 kgMocrenHitScorerNames.push_back(newValue);
00221 } else if (command == kResetgMocrenHitScorerNameCommand) {
00222 kgMocrenHitScorerNames.clear();
00223 } else if (command == kListgMocrenCommand) {
00224 list();
00225 } else if (command == kSetgMocrenNoVoxelsCommand) {
00226 G4Tokenizer next(newValue);
00227 for(int i = 0; i < 3; i++) {
00228 kgMocrenNoVoxels[i] = StoI(next());
00229 }
00230 } else if (command==kDrawVolumeGridCommand) {
00231 kDrawVolumeGrid = kDrawVolumeGridCommand->GetNewBoolValue(newValue);
00232 }
00233 }
00234
00235 G4String G4GMocrenMessenger::getEventNumberSuffix() {
00236 return suffix;
00237 }
00238
00239 G4bool G4GMocrenMessenger::appendGeometry() {
00240 return geometry;
00241 }
00242
00243 G4bool G4GMocrenMessenger::addPointAttributes() {
00244 return pointAttributes;
00245 }
00246
00247 G4bool G4GMocrenMessenger::useSolids() {
00248 return solids;
00249 }
00250
00251 G4bool G4GMocrenMessenger::writeInvisibles() {
00252 return invisibles;
00253 }
00254
00255 G4String G4GMocrenMessenger::getVolumeName() {
00256 return kgMocrenVolumeName;
00257 }
00258
00259 std::vector<G4String> G4GMocrenMessenger::getHitNames() {
00260 return kgMocrenHitNames;
00261 }
00262
00263 G4String G4GMocrenMessenger::getScoringMeshName() {
00264 return kgMocrenScoringMeshName;
00265 }
00266
00267 std::vector<G4String> G4GMocrenMessenger::getHitScorerNames() {
00268 return kgMocrenHitScorerNames;
00269 }
00270
00271 void G4GMocrenMessenger::list() {
00272 G4cout << " Current valuess of gMocren command parameters:" << G4endl;
00273
00274 G4cout << " volume name: " << kgMocrenVolumeName << G4endl;
00275
00276 G4cout << " hit names: ";
00277 if(kgMocrenHitNames.size() > 0) {
00278 std::vector<G4String>::iterator itr = kgMocrenHitNames.begin();
00279 for(; itr != kgMocrenHitNames.end(); itr++)
00280 G4cout << *itr << " " << G4endl;
00281 } else {
00282 G4cout << G4endl;
00283 }
00284
00285 G4cout << " scoring mesh name: " << kgMocrenScoringMeshName << G4endl;
00286
00287 G4cout << " scorer names: ";
00288 if(kgMocrenHitScorerNames.size() > 0) {
00289 std::vector<G4String>::iterator itr = kgMocrenHitScorerNames.begin();
00290 for(; itr != kgMocrenHitScorerNames.end(); itr++)
00291 G4cout << *itr << " " << G4endl;
00292 } else {
00293 G4cout << G4endl;
00294 }
00295 G4cout << G4endl;
00296 }
00297
00298 void G4GMocrenMessenger::getNoVoxels(G4int & nx, G4int & ny, G4int & nz) const {
00299 nx = kgMocrenNoVoxels[0];
00300 ny = kgMocrenNoVoxels[1];
00301 nz = kgMocrenNoVoxels[2];
00302 }