[814] | 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 | // $Id: G4ScoringMessenger.cc,v 1.36 2007/11/12 13:27:31 asaim Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-01-patch-02 $ |
---|
| 29 | // |
---|
| 30 | // --------------------------------------------------------------------- |
---|
| 31 | |
---|
| 32 | #include "G4ScoringMessenger.hh" |
---|
| 33 | #include "G4ScoringManager.hh" |
---|
| 34 | #include "G4VScoringMesh.hh" |
---|
| 35 | #include "G4ScoringBox.hh" |
---|
| 36 | |
---|
| 37 | #include "G4UIdirectory.hh" |
---|
| 38 | #include "G4UIcmdWithoutParameter.hh" |
---|
| 39 | #include "G4UIcmdWithAnInteger.hh" |
---|
| 40 | #include "G4UIcmdWithAString.hh" |
---|
| 41 | #include "G4UIcmdWithABool.hh" |
---|
| 42 | #include "G4UIcmdWithADoubleAndUnit.hh" |
---|
| 43 | #include "G4UIcmdWith3VectorAndUnit.hh" |
---|
| 44 | #include "G4UIcommand.hh" |
---|
| 45 | #include "G4Tokenizer.hh" |
---|
| 46 | #include "G4UnitsTable.hh" |
---|
| 47 | #include "G4VScoreColorMap.hh" |
---|
| 48 | |
---|
| 49 | G4ScoringMessenger::G4ScoringMessenger(G4ScoringManager* SManager) |
---|
| 50 | :fSMan(SManager) |
---|
| 51 | { |
---|
| 52 | G4UIparameter* param; |
---|
| 53 | |
---|
| 54 | scoreDir = new G4UIdirectory("/score/"); |
---|
| 55 | scoreDir->SetGuidance("Interactive scoring commands."); |
---|
| 56 | |
---|
| 57 | listCmd = new G4UIcmdWithoutParameter("/score/list",this); |
---|
| 58 | listCmd->SetGuidance("List scoring worlds."); |
---|
| 59 | |
---|
| 60 | dumpCmd = new G4UIcmdWithoutParameter("/score/dump",this); |
---|
| 61 | dumpCmd->SetGuidance("Dump results of scorers."); |
---|
| 62 | |
---|
| 63 | verboseCmd = new G4UIcmdWithAnInteger("/score/verbose",this); |
---|
| 64 | verboseCmd->SetGuidance("Verbosity."); |
---|
| 65 | verboseCmd->SetGuidance(" 0) errors or warnings,"); |
---|
| 66 | verboseCmd->SetGuidance(" 1) information with 0)"); |
---|
| 67 | |
---|
| 68 | meshDir = new G4UIdirectory("/score/mesh/"); |
---|
| 69 | meshDir->SetGuidance(" Mesh processing commands."); |
---|
| 70 | |
---|
| 71 | meshCreateDir = new G4UIdirectory("/score/create/"); |
---|
| 72 | meshCreateDir->SetGuidance(" Mesh creation commands."); |
---|
| 73 | // |
---|
| 74 | // Mesh commands |
---|
| 75 | meshBoxCreateCmd = new G4UIcmdWithAString("/score/create/boxMesh",this); |
---|
| 76 | meshBoxCreateCmd->SetGuidance("Create scoring box mesh."); |
---|
| 77 | meshBoxCreateCmd->SetParameterName("MeshName",false); |
---|
| 78 | // |
---|
| 79 | // meshTubsCreateCmd = new G4UIcmdWithAString("/score/create/tubsMesh",this); |
---|
| 80 | // meshTubsCreateCmd->SetGuidance("Create scoring mesh."); |
---|
| 81 | // meshTubsCreateCmd->SetParameterName("MeshName",false); |
---|
| 82 | // |
---|
| 83 | // meshSphereCreateCmd = new G4UIcmdWithAString("/score/create/sphereMesh",this); |
---|
| 84 | // meshSphereCreateCmd->SetGuidance("Create scoring mesh."); |
---|
| 85 | // meshSphereCreateCmd->SetParameterName("MeshName",false); |
---|
| 86 | // |
---|
| 87 | meshOpnCmd = new G4UIcmdWithAString("/score/open",this); |
---|
| 88 | meshOpnCmd->SetGuidance("Open scoring mesh."); |
---|
| 89 | meshOpnCmd->SetParameterName("MeshName",false); |
---|
| 90 | // |
---|
| 91 | meshClsCmd = new G4UIcmdWithoutParameter("/score/close",this); |
---|
| 92 | meshClsCmd->SetGuidance("Close scoring mesh."); |
---|
| 93 | // |
---|
| 94 | // meshActCmd = new G4UIcmdWithABool("/score/mesh/activate",this); |
---|
| 95 | // meshActCmd->SetGuidance("Activate scoring mesh."); |
---|
| 96 | // meshActCmd->SetParameterName("MeshName",false); |
---|
| 97 | // |
---|
| 98 | mBoxSizeCmd = new G4UIcmdWith3VectorAndUnit("/score/mesh/boxSize",this); |
---|
| 99 | mBoxSizeCmd->SetGuidance("Define size of the scoring mesh."); |
---|
| 100 | mBoxSizeCmd->SetParameterName("Di","Dj","Dk",false,false); |
---|
| 101 | mBoxSizeCmd->SetRange("Di>0. && Dj>0. && Dk>0."); |
---|
| 102 | mBoxSizeCmd->SetDefaultUnit("mm"); |
---|
| 103 | // |
---|
| 104 | // Division command |
---|
| 105 | mBinCmd = new G4UIcommand("/score/mesh/nBin",this); |
---|
| 106 | mBinCmd->SetGuidance("Define segments of the scoring mesh."); |
---|
| 107 | mBinCmd->SetGuidance("[usage] /score/mesh/nBin"); |
---|
| 108 | mBinCmd->SetGuidance(" Ni :(int) Number of bins i "); |
---|
| 109 | mBinCmd->SetGuidance(" Nj :(int) Number of bins j "); |
---|
| 110 | mBinCmd->SetGuidance(" Nk :(int) Number of bins k "); |
---|
| 111 | //mBinCmd->SetGuidance(" Axis:(int) Axis of division "); |
---|
| 112 | // mBinCmd->SetGuidance(" P1..Pn-1 :(double) \"paramter from P1 to Pn-1 for division.\""); |
---|
| 113 | param = new G4UIparameter("Ni",'i',false); |
---|
| 114 | param->SetDefaultValue("1"); |
---|
| 115 | param->SetParameterRange("Ni>0"); |
---|
| 116 | mBinCmd->SetParameter(param); |
---|
| 117 | param = new G4UIparameter("Nj",'i',false); |
---|
| 118 | param->SetDefaultValue("1"); |
---|
| 119 | param->SetParameterRange("Nj>0"); |
---|
| 120 | mBinCmd->SetParameter(param); |
---|
| 121 | param = new G4UIparameter("Nk",'i',false); |
---|
| 122 | param->SetDefaultValue("1"); |
---|
| 123 | mBinCmd->SetParameter(param); |
---|
| 124 | param->SetParameterRange("Nk>0"); |
---|
| 125 | //param = new G4UIparameter("Axis",'i',true); |
---|
| 126 | //param->SetDefaultValue("3"); |
---|
| 127 | //mBinCmd->SetParameter(param); |
---|
| 128 | // |
---|
| 129 | // Placement command |
---|
| 130 | mTransDir = new G4UIdirectory("/score/mesh/translate/"); |
---|
| 131 | mTransDir->SetGuidance("Mesh translation commands."); |
---|
| 132 | // |
---|
| 133 | mTResetCmd = new G4UIcmdWithoutParameter("/score/mesh/translate/reset",this); |
---|
| 134 | mTResetCmd->SetGuidance("Reset translated position of the scoring mesh."); |
---|
| 135 | // |
---|
| 136 | mTXyzCmd = new G4UIcmdWith3VectorAndUnit("/score/mesh/translate/xyz",this); |
---|
| 137 | mTXyzCmd->SetGuidance("Translate the scoring mesh."); |
---|
| 138 | mTXyzCmd->SetParameterName("X","Y","Z",false,false); |
---|
| 139 | mTXyzCmd->SetDefaultUnit("mm"); |
---|
| 140 | // |
---|
| 141 | mRotDir = new G4UIdirectory("/score/mesh/rotate/"); |
---|
| 142 | mRotDir->SetGuidance("Mesh rotation commands."); |
---|
| 143 | // |
---|
| 144 | mRResetCmd = new G4UIcmdWithoutParameter("/score/mesh/rotate/reset",this); |
---|
| 145 | mRResetCmd->SetGuidance("Reset rotation angles of the scoring mesh."); |
---|
| 146 | // |
---|
| 147 | mRotXCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateX",this); |
---|
| 148 | mRotXCmd->SetGuidance("Rotate the scoring mesh in X axis."); |
---|
| 149 | mRotXCmd->SetParameterName("Rx",false); |
---|
| 150 | mRotXCmd->SetDefaultUnit("deg"); |
---|
| 151 | // |
---|
| 152 | mRotYCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateY",this); |
---|
| 153 | mRotYCmd->SetGuidance("Rotate the scoring mesh in Y axis."); |
---|
| 154 | mRotYCmd->SetParameterName("Ry",false); |
---|
| 155 | mRotYCmd->SetDefaultUnit("deg"); |
---|
| 156 | // |
---|
| 157 | mRotZCmd = new G4UIcmdWithADoubleAndUnit("/score/mesh/rotate/rotateZ",this); |
---|
| 158 | mRotZCmd->SetGuidance("Rotate the scoring mesh in Z axis."); |
---|
| 159 | mRotZCmd->SetParameterName("Rz",false); |
---|
| 160 | mRotZCmd->SetDefaultUnit("deg"); |
---|
| 161 | // |
---|
| 162 | |
---|
| 163 | // Draw Scoring result |
---|
| 164 | drawCmd = new G4UIcommand("/score/drawProjection",this); |
---|
| 165 | drawCmd->SetGuidance("Draw projection(s) of scored quantities."); |
---|
| 166 | drawCmd->SetGuidance("Parameter <proj> specified which projection(s) to be drawn."); |
---|
| 167 | drawCmd->SetGuidance(" 100 : xy-plane, 010 : yz-place, 001 : zx-plane -- default 111"); |
---|
| 168 | param = new G4UIparameter("meshName",'s',false); |
---|
| 169 | drawCmd->SetParameter(param); |
---|
| 170 | param = new G4UIparameter("psName",'s',false); |
---|
| 171 | drawCmd->SetParameter(param); |
---|
| 172 | param = new G4UIparameter("colorMapName",'s',true); |
---|
| 173 | param->SetDefaultValue("defaultLinearColorMap"); |
---|
| 174 | drawCmd->SetParameter(param); |
---|
| 175 | param = new G4UIparameter("proj",'i',true); |
---|
| 176 | param->SetDefaultValue(111); |
---|
| 177 | drawCmd->SetParameter(param); |
---|
| 178 | |
---|
| 179 | // Draw column |
---|
| 180 | drawColumnCmd = new G4UIcommand("/score/drawColumn",this); |
---|
| 181 | drawColumnCmd->SetGuidance("Draw a cell column."); |
---|
| 182 | drawColumnCmd->SetGuidance(" plane = 0 : xy, 1: yz, 2: zx"); |
---|
| 183 | param = new G4UIparameter("meshName",'s',false); |
---|
| 184 | drawColumnCmd->SetParameter(param); |
---|
| 185 | param = new G4UIparameter("psName",'s',false); |
---|
| 186 | drawColumnCmd->SetParameter(param); |
---|
| 187 | param = new G4UIparameter("plane",'i',false); |
---|
| 188 | param->SetParameterRange("plane>=0 && plane<=2"); |
---|
| 189 | drawColumnCmd->SetParameter(param); |
---|
| 190 | param = new G4UIparameter("column",'i',false); |
---|
| 191 | drawColumnCmd->SetParameter(param); |
---|
| 192 | param = new G4UIparameter("colorMapName",'s',true); |
---|
| 193 | param->SetDefaultValue("defaultLinearColorMap"); |
---|
| 194 | drawColumnCmd->SetParameter(param); |
---|
| 195 | |
---|
| 196 | colorMapDir = new G4UIdirectory("/score/colorMap/"); |
---|
| 197 | colorMapDir->SetGuidance("Color map commands."); |
---|
| 198 | |
---|
| 199 | listColorMapCmd = new G4UIcmdWithoutParameter("/score/colorMap/listScoreColorMaps",this); |
---|
| 200 | listColorMapCmd->SetGuidance("List registered score color maps."); |
---|
| 201 | |
---|
| 202 | floatMinMaxCmd = new G4UIcmdWithAString("/score/colorMap/floatMinMax",this); |
---|
| 203 | floatMinMaxCmd->SetGuidance("Min/Max of the color map is calculated accorging to the actual scores."); |
---|
| 204 | floatMinMaxCmd->SetParameterName("colorMapName",true,false); |
---|
| 205 | floatMinMaxCmd->SetDefaultValue("defaultLinearColorMap"); |
---|
| 206 | |
---|
| 207 | colorMapMinMaxCmd = new G4UIcommand("/score/colorMap/setMinMax",this); |
---|
| 208 | colorMapMinMaxCmd->SetGuidance("Define min/max value of the color map."); |
---|
| 209 | param = new G4UIparameter("colorMapMame",'s',true); |
---|
| 210 | param->SetDefaultValue("defaultLinearColorMap"); |
---|
| 211 | colorMapMinMaxCmd->SetParameter(param); |
---|
| 212 | param = new G4UIparameter("minValue",'d',false); |
---|
| 213 | colorMapMinMaxCmd->SetParameter(param); |
---|
| 214 | param = new G4UIparameter("maxValue",'d',false); |
---|
| 215 | colorMapMinMaxCmd->SetParameter(param); |
---|
| 216 | |
---|
| 217 | // Dump a scored quantity |
---|
| 218 | dumpQtyToFileCmd = new G4UIcommand("/score/dumpQuantityToFile", this); |
---|
| 219 | dumpQtyToFileCmd->SetGuidance("Dump one scored quantity to file."); |
---|
| 220 | param = new G4UIparameter("meshName", 's', false); |
---|
| 221 | dumpQtyToFileCmd->SetParameter(param); |
---|
| 222 | param = new G4UIparameter("psName", 's', false); |
---|
| 223 | dumpQtyToFileCmd->SetParameter(param); |
---|
| 224 | param = new G4UIparameter("fileName", 's', false); |
---|
| 225 | dumpQtyToFileCmd->SetParameter(param); |
---|
| 226 | param = new G4UIparameter("option", 's', true); |
---|
| 227 | dumpQtyToFileCmd->SetParameter(param); |
---|
| 228 | |
---|
| 229 | // Dump all scored quantities |
---|
| 230 | dumpAllQtsToFileCmd = new G4UIcommand("/score/dumpAllQuantitiesToFile", this); |
---|
| 231 | dumpAllQtsToFileCmd->SetGuidance("Dump all quantities of the mesh to file."); |
---|
| 232 | param = new G4UIparameter("meshName", 's', false); |
---|
| 233 | dumpAllQtsToFileCmd->SetParameter(param); |
---|
| 234 | param = new G4UIparameter("fileName", 's', false); |
---|
| 235 | dumpAllQtsToFileCmd->SetParameter(param); |
---|
| 236 | param = new G4UIparameter("option", 's', true); |
---|
| 237 | dumpAllQtsToFileCmd->SetParameter(param); |
---|
| 238 | |
---|
| 239 | } |
---|
| 240 | |
---|
| 241 | G4ScoringMessenger::~G4ScoringMessenger() |
---|
| 242 | { |
---|
| 243 | delete listCmd; |
---|
| 244 | delete verboseCmd; |
---|
| 245 | // |
---|
| 246 | delete meshCreateDir; |
---|
| 247 | delete meshBoxCreateCmd; |
---|
| 248 | // delete meshTubsCreateCmd; |
---|
| 249 | // delete meshSphereCreateCmd; |
---|
| 250 | // |
---|
| 251 | delete meshOpnCmd; |
---|
| 252 | // |
---|
| 253 | delete meshClsCmd; |
---|
| 254 | // delete meshActCmd; |
---|
| 255 | delete meshDir; |
---|
| 256 | // |
---|
| 257 | delete mBoxSizeCmd; |
---|
| 258 | delete mTubsSizeCmd; |
---|
| 259 | delete mSphereSizeCmd; |
---|
| 260 | // |
---|
| 261 | delete mBinCmd; |
---|
| 262 | // |
---|
| 263 | delete mTResetCmd; |
---|
| 264 | delete mTXyzCmd; |
---|
| 265 | delete mTransDir; |
---|
| 266 | delete mRResetCmd; |
---|
| 267 | delete mRotXCmd; |
---|
| 268 | delete mRotYCmd; |
---|
| 269 | delete mRotZCmd; |
---|
| 270 | delete mRotDir; |
---|
| 271 | // |
---|
| 272 | delete dumpCmd; |
---|
| 273 | delete drawCmd; |
---|
| 274 | delete drawColumnCmd; |
---|
| 275 | delete listColorMapCmd; |
---|
| 276 | delete floatMinMaxCmd; |
---|
| 277 | delete colorMapMinMaxCmd; |
---|
| 278 | delete colorMapDir; |
---|
| 279 | delete dumpQtyToFileCmd; |
---|
| 280 | delete dumpAllQtsToFileCmd; |
---|
| 281 | // |
---|
| 282 | delete scoreDir; |
---|
| 283 | } |
---|
| 284 | |
---|
| 285 | void G4ScoringMessenger::SetNewValue(G4UIcommand * command,G4String newVal) |
---|
| 286 | { |
---|
| 287 | if(command==listCmd) { |
---|
| 288 | fSMan->List(); |
---|
| 289 | } else if(command==dumpCmd) { |
---|
| 290 | fSMan->Dump(); |
---|
| 291 | } else if(command==drawCmd) { |
---|
| 292 | G4Tokenizer next(newVal); |
---|
| 293 | G4String meshName = next(); |
---|
| 294 | G4String psName = next(); |
---|
| 295 | G4String colorMapName = next(); |
---|
| 296 | G4int axflg = StoI(next()); |
---|
| 297 | fSMan->DrawMesh(meshName,psName,colorMapName,axflg); |
---|
| 298 | } else if(command==drawColumnCmd) { |
---|
| 299 | G4Tokenizer next(newVal); |
---|
| 300 | G4String meshName = next(); |
---|
| 301 | G4String psName = next(); |
---|
| 302 | G4int iPlane = StoI(next()); |
---|
| 303 | G4int iColumn = StoI(next()); |
---|
| 304 | G4String colorMapName = next(); |
---|
| 305 | fSMan->DrawMesh(meshName,psName,iPlane,iColumn,colorMapName); |
---|
| 306 | } else if(command==dumpQtyToFileCmd) { |
---|
| 307 | G4Tokenizer next(newVal); |
---|
| 308 | G4String meshName = next(); |
---|
| 309 | G4String psName = next(); |
---|
| 310 | G4String fileName = next(); |
---|
| 311 | G4String option = next("\n"); |
---|
| 312 | fSMan->DumpQuantityToFile(meshName, psName, fileName, option); |
---|
| 313 | } else if(command==dumpAllQtsToFileCmd) { |
---|
| 314 | G4Tokenizer next(newVal); |
---|
| 315 | G4String meshName = next(); |
---|
| 316 | G4String fileName = next(); |
---|
| 317 | G4String option = next("\n"); |
---|
| 318 | fSMan->DumpAllQuantitiesToFile(meshName, fileName, option); |
---|
| 319 | } else if(command==verboseCmd) { |
---|
| 320 | fSMan->SetVerboseLevel(verboseCmd->GetNewIntValue(newVal)); |
---|
| 321 | } else if(command==meshBoxCreateCmd) { |
---|
| 322 | G4VScoringMesh* currentmesh = fSMan->GetCurrentMesh(); |
---|
| 323 | if ( currentmesh ){ |
---|
| 324 | G4cerr << "ERROR[" << meshBoxCreateCmd->GetCommandPath() |
---|
| 325 | << "] : Mesh <" << currentmesh->GetWorldName() << "> is still open. Close it first. Command ignored." << G4endl; |
---|
| 326 | } else { |
---|
| 327 | |
---|
| 328 | G4VScoringMesh* mesh = fSMan->FindMesh(newVal); |
---|
| 329 | if ( !mesh ){ |
---|
| 330 | mesh = new G4ScoringBox(newVal); |
---|
| 331 | fSMan->RegisterScoringMesh(mesh); |
---|
| 332 | }else{ |
---|
| 333 | G4cerr << "ERROR[" << meshBoxCreateCmd->GetCommandPath() |
---|
| 334 | << "] : Scoring mesh <" << newVal |
---|
| 335 | << "> already exists. Command ignored." << G4endl; |
---|
| 336 | } |
---|
| 337 | } |
---|
| 338 | } else if(command==listColorMapCmd) { |
---|
| 339 | fSMan->ListScoreColorMaps(); |
---|
| 340 | } else if(command==floatMinMaxCmd) { |
---|
| 341 | G4VScoreColorMap* colorMap = fSMan->GetScoreColorMap(newVal); |
---|
| 342 | if(colorMap) |
---|
| 343 | { colorMap->SetFloatingMinMax(true); } |
---|
| 344 | else |
---|
| 345 | { G4cerr << "ERROR[" << floatMinMaxCmd->GetCommandPath() |
---|
| 346 | << "] : color map <" << newVal << "> is not defined. Command ignored." << G4endl; } |
---|
| 347 | } else if(command==colorMapMinMaxCmd) { |
---|
| 348 | G4Tokenizer next(newVal); |
---|
| 349 | G4String mapName = next(); |
---|
| 350 | G4double minVal = StoD(next()); |
---|
| 351 | G4double maxVal = StoD(next()); |
---|
| 352 | G4VScoreColorMap* colorMap = fSMan->GetScoreColorMap(mapName); |
---|
| 353 | if(colorMap) |
---|
| 354 | { colorMap->SetFloatingMinMax(false); |
---|
| 355 | colorMap->SetMinMax(minVal,maxVal); } |
---|
| 356 | else |
---|
| 357 | { G4cerr << "ERROR[" << colorMapMinMaxCmd->GetCommandPath() |
---|
| 358 | << "] : color map <" << newVal << "> is not defined. Command ignored." << G4endl; } |
---|
| 359 | } else if(command==meshOpnCmd) { |
---|
| 360 | G4VScoringMesh* currentmesh = fSMan->GetCurrentMesh(); |
---|
| 361 | if ( currentmesh ){ |
---|
| 362 | G4cerr << "ERROR[" << meshOpnCmd->GetCommandPath() |
---|
| 363 | << "] : Mesh <" << currentmesh->GetWorldName() << "> is still open. Close it first. Command ignored." << G4endl; |
---|
| 364 | } else { |
---|
| 365 | G4VScoringMesh* mesh = fSMan->FindMesh(newVal); |
---|
| 366 | if ( !mesh ){ |
---|
| 367 | G4cerr << "ERROR[" << meshOpnCmd->GetCommandPath() |
---|
| 368 | << "] : Scoring mesh <" << newVal << "> does not exist. Command ignored." << G4endl; |
---|
| 369 | } else { |
---|
| 370 | fSMan->SetCurrentMesh(mesh); |
---|
| 371 | } |
---|
| 372 | } |
---|
| 373 | } else if(command==meshClsCmd) { |
---|
| 374 | fSMan->CloseCurrentMesh(); |
---|
| 375 | } else { |
---|
| 376 | // |
---|
| 377 | // Get Current Mesh |
---|
| 378 | // |
---|
| 379 | G4VScoringMesh* mesh = fSMan->GetCurrentMesh(); |
---|
| 380 | // |
---|
| 381 | // Commands for Current Mesh |
---|
| 382 | if ( mesh ){ |
---|
| 383 | // Tokens |
---|
| 384 | G4TokenVec token; |
---|
| 385 | FillTokenVec(newVal,token); |
---|
| 386 | // |
---|
| 387 | // Mesh Geometry |
---|
| 388 | // |
---|
| 389 | // if(command==meshActCmd) { |
---|
| 390 | // mesh->Activate(meshActCmd->GetNewBoolValue(newVal)); |
---|
| 391 | // } else |
---|
| 392 | if(command==mBoxSizeCmd) { |
---|
| 393 | MeshShape shape = mesh->GetShape(); |
---|
| 394 | if ( shape == boxMesh ){ |
---|
| 395 | G4ThreeVector size = mBoxSizeCmd->GetNew3VectorValue(newVal); |
---|
| 396 | G4double vsize[3]; |
---|
| 397 | vsize[0] = size.x(); |
---|
| 398 | vsize[1] = size.y(); |
---|
| 399 | vsize[2] = size.z(); |
---|
| 400 | mesh->SetSize(vsize); |
---|
| 401 | } else { |
---|
| 402 | G4cerr << "ERROR[" << mBoxSizeCmd->GetCommandPath() |
---|
| 403 | << "] : This mesh is not Box. Command ignored." << G4endl; |
---|
| 404 | } |
---|
| 405 | } else if(command==mBinCmd) { |
---|
| 406 | MeshBinCommand(mesh,token); |
---|
| 407 | } else if(command==mTResetCmd) { |
---|
| 408 | G4double centerPosition[3] ={ 0., 0., 0.}; |
---|
| 409 | mesh->SetCenterPosition(centerPosition); |
---|
| 410 | } else if(command==mTXyzCmd) { |
---|
| 411 | G4ThreeVector xyz = mTXyzCmd->GetNew3VectorValue(newVal); |
---|
| 412 | G4double centerPosition[3]; |
---|
| 413 | centerPosition[0] = xyz.x(); |
---|
| 414 | centerPosition[1] = xyz.y(); |
---|
| 415 | centerPosition[2] = xyz.z(); |
---|
| 416 | mesh->SetCenterPosition(centerPosition); |
---|
| 417 | } else if(command==mRResetCmd) { |
---|
| 418 | } else if(command==mRotXCmd) { |
---|
| 419 | G4double value = mRotXCmd->GetNewDoubleValue(newVal); |
---|
| 420 | mesh->RotateX(value); |
---|
| 421 | } else if(command==mRotYCmd) { |
---|
| 422 | G4double value = mRotYCmd->GetNewDoubleValue(newVal); |
---|
| 423 | mesh->RotateY(value); |
---|
| 424 | } else if(command==mRotZCmd) { |
---|
| 425 | G4double value = mRotZCmd->GetNewDoubleValue(newVal); |
---|
| 426 | mesh->RotateZ(value); |
---|
| 427 | } |
---|
| 428 | }else{ |
---|
| 429 | G4cerr << "ERROR: No mesh is currently open. Open/create a mesh first. Command ignored." << G4endl; |
---|
| 430 | } |
---|
| 431 | } |
---|
| 432 | } |
---|
| 433 | |
---|
| 434 | G4String G4ScoringMessenger::GetCurrentValue(G4UIcommand * command) |
---|
| 435 | { |
---|
| 436 | G4String val; |
---|
| 437 | if(command==verboseCmd) |
---|
| 438 | { val = verboseCmd->ConvertToString(fSMan->GetVerboseLevel()); } |
---|
| 439 | |
---|
| 440 | return val; |
---|
| 441 | } |
---|
| 442 | |
---|
| 443 | void G4ScoringMessenger::FillTokenVec(G4String newValues, G4TokenVec& token){ |
---|
| 444 | |
---|
| 445 | G4Tokenizer next(newValues); |
---|
| 446 | G4String val; |
---|
| 447 | while ( !(val = next()).isNull() ) { |
---|
| 448 | token.push_back(val); |
---|
| 449 | } |
---|
| 450 | } |
---|
| 451 | |
---|
| 452 | |
---|
| 453 | void G4ScoringMessenger::MeshBinCommand(G4VScoringMesh* mesh,G4TokenVec& token){ |
---|
| 454 | G4int Ni = StoI(token[0]); |
---|
| 455 | G4int Nj = StoI(token[1]); |
---|
| 456 | G4int Nk = StoI(token[2]); |
---|
| 457 | G4int nSegment[3]; |
---|
| 458 | nSegment[0] = Ni; |
---|
| 459 | nSegment[1] = Nj; |
---|
| 460 | nSegment[2] = Nk; |
---|
| 461 | // |
---|
| 462 | mesh->SetNumberOfSegments(nSegment); |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | |
---|