[807] | 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 | // |
---|
[1230] | 26 | // $Id: HadrontherapyDetectorMessenger.cc; |
---|
| 27 | // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy |
---|
| 28 | |
---|
| 29 | |
---|
[807] | 30 | #include "HadrontherapyDetectorMessenger.hh" |
---|
| 31 | #include "HadrontherapyDetectorConstruction.hh" |
---|
| 32 | #include "G4UIdirectory.hh" |
---|
| 33 | #include "G4UIcmdWithADoubleAndUnit.hh" |
---|
| 34 | #include "G4UIcmdWithAString.hh" |
---|
[1230] | 35 | #include "G4UIcmdWith3VectorAndUnit.hh" |
---|
[807] | 36 | |
---|
[1230] | 37 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 38 | HadrontherapyDetectorMessenger::HadrontherapyDetectorMessenger(HadrontherapyDetectorConstruction* detector) |
---|
[807] | 39 | :hadrontherapyDetector(detector) |
---|
[1230] | 40 | { |
---|
| 41 | // Change Phantom size |
---|
| 42 | changeThePhantomDir = new G4UIdirectory("/changePhantom/"); |
---|
| 43 | changeThePhantomDir -> SetGuidance("Command to change the Phantom Size/position"); |
---|
| 44 | changeThePhantomSizeCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/size", this); |
---|
| 45 | changeThePhantomSizeCmd -> SetGuidance("Insert sizes X Y and Z" |
---|
| 46 | "\n 0 or negative values mean <<Don't change it!>>"); |
---|
| 47 | changeThePhantomSizeCmd -> SetParameterName("PhantomSizeAlongX", |
---|
| 48 | "PhantomSizeAlongY", |
---|
| 49 | "PhantomSizeAlongZ", false); |
---|
| 50 | changeThePhantomSizeCmd -> SetDefaultUnit("mm"); |
---|
| 51 | changeThePhantomSizeCmd -> SetUnitCandidates("um mm cm"); |
---|
| 52 | changeThePhantomSizeCmd -> AvailableForStates(G4State_Idle); |
---|
[807] | 53 | |
---|
| 54 | |
---|
[1230] | 55 | // Change Phantom position |
---|
| 56 | changeThePhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/position", this); |
---|
| 57 | changeThePhantomPositionCmd -> SetGuidance("Insert X Y and Z dimensions for the position of the center of the Phantom" |
---|
| 58 | " respect to that of the \"World\""); |
---|
| 59 | changeThePhantomPositionCmd -> SetParameterName("PositionAlongX", |
---|
| 60 | "PositionAlongY", |
---|
| 61 | "PositionAlongZ", false); |
---|
| 62 | changeThePhantomPositionCmd -> SetDefaultUnit("mm"); |
---|
| 63 | changeThePhantomPositionCmd -> SetUnitCandidates("mm cm m"); |
---|
| 64 | changeThePhantomPositionCmd -> AvailableForStates(G4State_Idle); |
---|
[807] | 65 | |
---|
| 66 | |
---|
[1230] | 67 | // Change detector size |
---|
| 68 | changeTheDetectorDir = new G4UIdirectory("/changeDetector/"); |
---|
| 69 | changeTheDetectorDir -> SetGuidance("Command to change the Detector's Size/position/Voxels"); |
---|
| 70 | |
---|
| 71 | changeTheDetectorSizeCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/size",this); |
---|
| 72 | changeTheDetectorSizeCmd -> SetGuidance("Insert sizes for X Y and Z dimensions of the Detector" |
---|
| 73 | "\n 0 or negative values mean <<Don't change it>>"); |
---|
| 74 | changeTheDetectorSizeCmd -> SetParameterName("DetectorSizeAlongX", "DetectorSizeAlongY", "DetectorSizeAlongZ", false); |
---|
| 75 | changeTheDetectorSizeCmd -> SetDefaultUnit("mm"); |
---|
| 76 | changeTheDetectorSizeCmd -> SetUnitCandidates("um mm cm"); |
---|
| 77 | changeTheDetectorSizeCmd -> AvailableForStates(G4State_Idle); |
---|
[807] | 78 | |
---|
[1230] | 79 | // Change the detector to phantom displacement |
---|
| 80 | changeTheDetectorToPhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/displacement",this); |
---|
| 81 | changeTheDetectorToPhantomPositionCmd -> SetGuidance("Insert X Y and Z displacements between Detector and Phantom" |
---|
| 82 | "\nNegative values mean <<Don't change it!>>"); |
---|
| 83 | changeTheDetectorToPhantomPositionCmd -> SetParameterName("DisplacementAlongX", |
---|
| 84 | "DisplacementAlongY", |
---|
| 85 | "DisplacementAlongZ", false); |
---|
| 86 | changeTheDetectorToPhantomPositionCmd -> SetDefaultUnit("mm"); |
---|
| 87 | changeTheDetectorToPhantomPositionCmd -> SetUnitCandidates("um mm cm"); |
---|
| 88 | changeTheDetectorToPhantomPositionCmd -> AvailableForStates(G4State_Idle); |
---|
| 89 | |
---|
| 90 | // Change voxels by its size |
---|
| 91 | changeTheDetectorVoxelCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/voxelSize",this); |
---|
| 92 | changeTheDetectorVoxelCmd -> SetGuidance("Insert Voxel sizes for X Y and Z dimensions" |
---|
| 93 | "\n 0 or negative values mean <<Don't change it!>>"); |
---|
| 94 | changeTheDetectorVoxelCmd -> SetParameterName("VoxelSizeAlongX", "VoxelSizeAlongY", "VoxelSizeAlongZ", false); |
---|
| 95 | changeTheDetectorVoxelCmd -> SetDefaultUnit("mm"); |
---|
| 96 | changeTheDetectorVoxelCmd -> SetUnitCandidates("um mm cm"); |
---|
| 97 | changeTheDetectorVoxelCmd -> AvailableForStates(G4State_Idle); |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | ///////////////////////////////////////////////////////////////////////////// |
---|
[807] | 101 | HadrontherapyDetectorMessenger::~HadrontherapyDetectorMessenger() |
---|
[1230] | 102 | { |
---|
| 103 | delete changeThePhantomDir; |
---|
| 104 | delete changeThePhantomSizeCmd; |
---|
| 105 | delete changeThePhantomPositionCmd; |
---|
| 106 | delete changeTheDetectorDir; |
---|
| 107 | delete changeTheDetectorSizeCmd; |
---|
| 108 | delete changeTheDetectorToPhantomPositionCmd; |
---|
| 109 | delete changeTheDetectorVoxelCmd; |
---|
[807] | 110 | } |
---|
| 111 | |
---|
[1230] | 112 | ///////////////////////////////////////////////////////////////////////////// |
---|
[807] | 113 | void HadrontherapyDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) |
---|
[1230] | 114 | { |
---|
| 115 | |
---|
| 116 | if( command == changeThePhantomSizeCmd) |
---|
| 117 | { |
---|
| 118 | G4ThreeVector size = changeThePhantomSizeCmd -> GetNew3VectorValue(newValue); |
---|
| 119 | hadrontherapyDetector -> SetPhantomSize(size.getX(),size.getY(),size.getZ()); |
---|
| 120 | } |
---|
| 121 | else if (command == changeThePhantomPositionCmd ) |
---|
| 122 | { |
---|
| 123 | G4ThreeVector size = changeThePhantomPositionCmd -> GetNew3VectorValue(newValue); |
---|
| 124 | hadrontherapyDetector -> SetPhantomPosition(size); |
---|
| 125 | } |
---|
| 126 | else if (command == changeTheDetectorSizeCmd) |
---|
| 127 | { |
---|
| 128 | G4ThreeVector size = changeTheDetectorSizeCmd -> GetNew3VectorValue(newValue); |
---|
| 129 | hadrontherapyDetector -> SetDetectorSize(size.getX(),size.getY(),size.getZ()); |
---|
| 130 | } |
---|
| 131 | else if (command == changeTheDetectorToPhantomPositionCmd) |
---|
| 132 | { |
---|
| 133 | G4ThreeVector size = changeTheDetectorToPhantomPositionCmd-> GetNew3VectorValue(newValue); |
---|
| 134 | hadrontherapyDetector -> SetDetectorToPhantomPosition(size); |
---|
| 135 | } |
---|
| 136 | else if (command == changeTheDetectorVoxelCmd) |
---|
| 137 | { |
---|
| 138 | G4ThreeVector size = changeTheDetectorVoxelCmd -> GetNew3VectorValue(newValue); |
---|
| 139 | hadrontherapyDetector -> SetNumberOfVoxelBySize(size.getX(),size.getY(),size.getZ()); |
---|
| 140 | } |
---|
[807] | 141 | } |
---|