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 | // SprayParticleGunMessenger.cc |
---|
28 | // |
---|
29 | // Implementation of SprayParticleGun's UI interface |
---|
30 | // |
---|
31 | |
---|
32 | #include "SprayParticleGunMessenger.hh" |
---|
33 | #include "SprayParticleGun.hh" |
---|
34 | #include "G4ThreeVector.hh" |
---|
35 | #include "G4UIdirectory.hh" |
---|
36 | #include "G4UIcmdWithoutParameter.hh" |
---|
37 | #include "G4UIcmdWith3VectorAndUnit.hh" |
---|
38 | #include "G4UIcmdWithAnInteger.hh" |
---|
39 | #include "G4ios.hh" |
---|
40 | |
---|
41 | // |
---|
42 | // Constructor |
---|
43 | // |
---|
44 | SprayParticleGunMessenger::SprayParticleGunMessenger( SprayParticleGun *ourGun ) |
---|
45 | { |
---|
46 | gun = ourGun; |
---|
47 | |
---|
48 | gunDirectory = new G4UIdirectory( "/sprayGun/" ); |
---|
49 | gunDirectory->SetGuidance( "Spray Particle Gun control commands." ); |
---|
50 | |
---|
51 | positionCmd = new G4UIcmdWith3VectorAndUnit( "/sprayGun/position", this ); |
---|
52 | positionCmd->SetGuidance( "Set starting position of particle(s)." ); |
---|
53 | positionCmd->SetParameterName( "X", "Y", "Z", true, true ); |
---|
54 | positionCmd->SetDefaultUnit( "cm" ); |
---|
55 | |
---|
56 | xSprayCmd = new G4UIcmdWithAnInteger( "/sprayGun/xSpray", this ); |
---|
57 | xSprayCmd->SetGuidance( "X spray parameter" ); |
---|
58 | xSprayCmd->SetParameterName( "xSpray", true, true ); |
---|
59 | // xSprayCmd->SetRange( "N<8" ); |
---|
60 | |
---|
61 | ySprayCmd = new G4UIcmdWithAnInteger( "/sprayGun/ySpray", this ); |
---|
62 | ySprayCmd->SetGuidance( "Y spray parameter" ); |
---|
63 | ySprayCmd->SetParameterName( "ySpray", true, true ); |
---|
64 | // ySprayCmd->SetRange( "N<8" ); |
---|
65 | |
---|
66 | zSprayCmd = new G4UIcmdWithAnInteger( "/sprayGun/zSpray", this ); |
---|
67 | zSprayCmd->SetGuidance( "Z spray parameter" ); |
---|
68 | zSprayCmd->SetParameterName( "zSpray", true, true ); |
---|
69 | // zSprayCmd->SetRange( "N<8" ); |
---|
70 | } |
---|
71 | |
---|
72 | // |
---|
73 | // Destructor |
---|
74 | // |
---|
75 | SprayParticleGunMessenger::~SprayParticleGunMessenger() |
---|
76 | { |
---|
77 | // is the order important? |
---|
78 | delete positionCmd; |
---|
79 | delete xSprayCmd; |
---|
80 | delete ySprayCmd; |
---|
81 | delete zSprayCmd; |
---|
82 | delete gunDirectory; |
---|
83 | } |
---|
84 | |
---|
85 | |
---|
86 | // |
---|
87 | // SetNewValue |
---|
88 | // |
---|
89 | // Called by the UI when user requests a change |
---|
90 | // |
---|
91 | void SprayParticleGunMessenger::SetNewValue( G4UIcommand *command, G4String newValues ) |
---|
92 | { |
---|
93 | if (command == positionCmd) { |
---|
94 | gun->SetPosition( positionCmd->GetNew3VectorValue( newValues ) ); |
---|
95 | } |
---|
96 | else if (command == xSprayCmd) { |
---|
97 | gun->SetXSpray( xSprayCmd->GetNewIntValue( newValues ) ); |
---|
98 | } |
---|
99 | else if (command == ySprayCmd) { |
---|
100 | gun->SetYSpray( ySprayCmd->GetNewIntValue( newValues ) ); |
---|
101 | } |
---|
102 | else if (command == zSprayCmd) { |
---|
103 | gun->SetZSpray( zSprayCmd->GetNewIntValue( newValues ) ); |
---|
104 | } |
---|
105 | } |
---|
106 | |
---|
107 | // |
---|
108 | // GetCurrentValue |
---|
109 | // |
---|
110 | // Return current values to UI |
---|
111 | // |
---|
112 | G4String SprayParticleGunMessenger::GetCurrentValue( G4UIcommand *command ) |
---|
113 | { |
---|
114 | if (command == positionCmd) { |
---|
115 | return positionCmd->ConvertToString( gun->GetPosition(), "cm" ); |
---|
116 | } |
---|
117 | else if (command == xSprayCmd) { |
---|
118 | return xSprayCmd->ConvertToString( gun->GetXSpray() ); |
---|
119 | } |
---|
120 | else if (command == ySprayCmd) { |
---|
121 | return ySprayCmd->ConvertToString( gun->GetYSpray() ); |
---|
122 | } |
---|
123 | else if (command == zSprayCmd) { |
---|
124 | return zSprayCmd->ConvertToString( gun->GetZSpray() ); |
---|
125 | } |
---|
126 | |
---|
127 | return "baloney"; |
---|
128 | } |
---|
129 | |
---|