[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" |
---|
[1313] | 33 | #include "G4UIcmdWith3VectorAndUnit.hh" |
---|
| 34 | #include "G4UIcmdWithoutParameter.hh" |
---|
[807] | 35 | #include "G4UIcmdWithAString.hh" |
---|
| 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"); |
---|
[1313] | 51 | changeThePhantomSizeCmd -> SetUnitCandidates("nm um mm cm"); |
---|
[1230] | 52 | changeThePhantomSizeCmd -> AvailableForStates(G4State_Idle); |
---|
[807] | 53 | |
---|
| 54 | |
---|
[1313] | 55 | // Change Phantom material |
---|
| 56 | changeThePhantomMaterialCmd = new G4UIcmdWithAString("/changePhantom/material", this); |
---|
| 57 | changeThePhantomMaterialCmd -> SetGuidance("Change the Phantom and the detector material"); |
---|
| 58 | changeThePhantomMaterialCmd -> SetParameterName("PhantomMaterial", false); |
---|
| 59 | changeThePhantomMaterialCmd -> SetDefaultValue("G4_WATER"); |
---|
| 60 | changeThePhantomMaterialCmd -> AvailableForStates(G4State_Idle); |
---|
| 61 | |
---|
[1230] | 62 | // Change Phantom position |
---|
| 63 | changeThePhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changePhantom/position", this); |
---|
| 64 | changeThePhantomPositionCmd -> SetGuidance("Insert X Y and Z dimensions for the position of the center of the Phantom" |
---|
| 65 | " respect to that of the \"World\""); |
---|
| 66 | changeThePhantomPositionCmd -> SetParameterName("PositionAlongX", |
---|
| 67 | "PositionAlongY", |
---|
| 68 | "PositionAlongZ", false); |
---|
| 69 | changeThePhantomPositionCmd -> SetDefaultUnit("mm"); |
---|
[1313] | 70 | changeThePhantomPositionCmd -> SetUnitCandidates("um mm cm m"); |
---|
[1230] | 71 | changeThePhantomPositionCmd -> AvailableForStates(G4State_Idle); |
---|
[807] | 72 | |
---|
| 73 | |
---|
[1313] | 74 | updateCmd = new G4UIcmdWithoutParameter("/changePhantom/update",this); |
---|
| 75 | updateCmd->SetGuidance("Update Phantom/Detector geometry."); |
---|
| 76 | updateCmd->SetGuidance("This command MUST be applied before \"beamOn\" "); |
---|
| 77 | updateCmd->SetGuidance("if you changed geometrical value(s)."); |
---|
| 78 | updateCmd->AvailableForStates(G4State_Idle); |
---|
| 79 | |
---|
[1230] | 80 | // Change detector size |
---|
| 81 | changeTheDetectorDir = new G4UIdirectory("/changeDetector/"); |
---|
| 82 | changeTheDetectorDir -> SetGuidance("Command to change the Detector's Size/position/Voxels"); |
---|
| 83 | |
---|
| 84 | changeTheDetectorSizeCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/size",this); |
---|
| 85 | changeTheDetectorSizeCmd -> SetGuidance("Insert sizes for X Y and Z dimensions of the Detector" |
---|
| 86 | "\n 0 or negative values mean <<Don't change it>>"); |
---|
| 87 | changeTheDetectorSizeCmd -> SetParameterName("DetectorSizeAlongX", "DetectorSizeAlongY", "DetectorSizeAlongZ", false); |
---|
| 88 | changeTheDetectorSizeCmd -> SetDefaultUnit("mm"); |
---|
[1313] | 89 | changeTheDetectorSizeCmd -> SetUnitCandidates("nm um mm cm"); |
---|
[1230] | 90 | changeTheDetectorSizeCmd -> AvailableForStates(G4State_Idle); |
---|
[807] | 91 | |
---|
[1230] | 92 | // Change the detector to phantom displacement |
---|
| 93 | changeTheDetectorToPhantomPositionCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/displacement",this); |
---|
| 94 | changeTheDetectorToPhantomPositionCmd -> SetGuidance("Insert X Y and Z displacements between Detector and Phantom" |
---|
| 95 | "\nNegative values mean <<Don't change it!>>"); |
---|
| 96 | changeTheDetectorToPhantomPositionCmd -> SetParameterName("DisplacementAlongX", |
---|
| 97 | "DisplacementAlongY", |
---|
| 98 | "DisplacementAlongZ", false); |
---|
| 99 | changeTheDetectorToPhantomPositionCmd -> SetDefaultUnit("mm"); |
---|
[1313] | 100 | changeTheDetectorToPhantomPositionCmd -> SetUnitCandidates("nm um mm cm"); |
---|
[1230] | 101 | changeTheDetectorToPhantomPositionCmd -> AvailableForStates(G4State_Idle); |
---|
| 102 | |
---|
| 103 | // Change voxels by its size |
---|
| 104 | changeTheDetectorVoxelCmd = new G4UIcmdWith3VectorAndUnit("/changeDetector/voxelSize",this); |
---|
| 105 | changeTheDetectorVoxelCmd -> SetGuidance("Insert Voxel sizes for X Y and Z dimensions" |
---|
| 106 | "\n 0 or negative values mean <<Don't change it!>>"); |
---|
| 107 | changeTheDetectorVoxelCmd -> SetParameterName("VoxelSizeAlongX", "VoxelSizeAlongY", "VoxelSizeAlongZ", false); |
---|
| 108 | changeTheDetectorVoxelCmd -> SetDefaultUnit("mm"); |
---|
[1313] | 109 | changeTheDetectorVoxelCmd -> SetUnitCandidates("nm um mm cm"); |
---|
[1230] | 110 | changeTheDetectorVoxelCmd -> AvailableForStates(G4State_Idle); |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | ///////////////////////////////////////////////////////////////////////////// |
---|
[807] | 114 | HadrontherapyDetectorMessenger::~HadrontherapyDetectorMessenger() |
---|
[1230] | 115 | { |
---|
| 116 | delete changeThePhantomDir; |
---|
| 117 | delete changeThePhantomSizeCmd; |
---|
| 118 | delete changeThePhantomPositionCmd; |
---|
[1313] | 119 | delete changeThePhantomMaterialCmd; |
---|
| 120 | delete updateCmd; |
---|
[1230] | 121 | delete changeTheDetectorDir; |
---|
| 122 | delete changeTheDetectorSizeCmd; |
---|
| 123 | delete changeTheDetectorToPhantomPositionCmd; |
---|
| 124 | delete changeTheDetectorVoxelCmd; |
---|
[807] | 125 | } |
---|
| 126 | |
---|
[1230] | 127 | ///////////////////////////////////////////////////////////////////////////// |
---|
[807] | 128 | void HadrontherapyDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) |
---|
[1230] | 129 | { |
---|
| 130 | |
---|
| 131 | if( command == changeThePhantomSizeCmd) |
---|
| 132 | { |
---|
| 133 | G4ThreeVector size = changeThePhantomSizeCmd -> GetNew3VectorValue(newValue); |
---|
| 134 | hadrontherapyDetector -> SetPhantomSize(size.getX(),size.getY(),size.getZ()); |
---|
| 135 | } |
---|
| 136 | else if (command == changeThePhantomPositionCmd ) |
---|
| 137 | { |
---|
| 138 | G4ThreeVector size = changeThePhantomPositionCmd -> GetNew3VectorValue(newValue); |
---|
| 139 | hadrontherapyDetector -> SetPhantomPosition(size); |
---|
| 140 | } |
---|
[1313] | 141 | else if (command == changeThePhantomMaterialCmd) |
---|
| 142 | { |
---|
| 143 | hadrontherapyDetector -> SetPhantomMaterial(newValue); |
---|
| 144 | } |
---|
[1230] | 145 | else if (command == changeTheDetectorSizeCmd) |
---|
| 146 | { |
---|
| 147 | G4ThreeVector size = changeTheDetectorSizeCmd -> GetNew3VectorValue(newValue); |
---|
| 148 | hadrontherapyDetector -> SetDetectorSize(size.getX(),size.getY(),size.getZ()); |
---|
| 149 | } |
---|
| 150 | else if (command == changeTheDetectorToPhantomPositionCmd) |
---|
| 151 | { |
---|
| 152 | G4ThreeVector size = changeTheDetectorToPhantomPositionCmd-> GetNew3VectorValue(newValue); |
---|
| 153 | hadrontherapyDetector -> SetDetectorToPhantomPosition(size); |
---|
| 154 | } |
---|
| 155 | else if (command == changeTheDetectorVoxelCmd) |
---|
| 156 | { |
---|
| 157 | G4ThreeVector size = changeTheDetectorVoxelCmd -> GetNew3VectorValue(newValue); |
---|
[1313] | 158 | hadrontherapyDetector -> SetVoxelSize(size.getX(),size.getY(),size.getZ()); |
---|
[1230] | 159 | } |
---|
[1313] | 160 | else if (command == updateCmd) |
---|
| 161 | { |
---|
| 162 | hadrontherapyDetector -> UpdateGeometry(); |
---|
| 163 | } |
---|
[807] | 164 | } |
---|