source: trunk/source/geometry/solids/test/fred/src/GridParticleGunMessenger.cc @ 1316

Last change on this file since 1316 was 1316, checked in by garnier, 14 years ago

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

File size: 5.0 KB
Line 
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// GridParticleGunMessenger.cc
28//
29// Implemenation of GridParticleGun's messenger
30//
31
32#include "GridParticleGunMessenger.hh"
33#include "GridParticleGun.hh"
34#include "G4ThreeVector.hh"
35#include "G4UIdirectory.hh"
36#include "G4UIcmdWith3Vector.hh"
37#include "G4UIcmdWith3VectorAndUnit.hh"
38#include "G4UIcmdWithAnInteger.hh"
39#include "G4ios.hh"
40
41//
42// Constructor
43//
44GridParticleGunMessenger::GridParticleGunMessenger( GridParticleGun *ourGun )
45{
46        gun = ourGun;
47       
48        gunDirectory = new G4UIdirectory( "/gridGun/" );
49        gunDirectory->SetGuidance( "Grid Particle Gun control commands." );
50       
51        directionCmd = new G4UIcmdWith3Vector( "/gridGun/direction", this );
52        directionCmd->SetGuidance( "Set direction of particles." );
53        directionCmd->SetParameterName( "X", "Y", "Z", true, true );
54       
55        originCmd = new G4UIcmdWith3VectorAndUnit( "/gridGun/origin", this );
56        originCmd->SetGuidance( "Set origin of grid." );
57        originCmd->SetParameterName( "X", "Y", "Z", true, true );
58        originCmd->SetDefaultUnit( "m" );       
59
60        grid1Cmd = new G4UIcmdWith3VectorAndUnit( "/gridGun/grid1", this );
61        grid1Cmd->SetGuidance( "Set first axis of grid." );
62        grid1Cmd->SetParameterName( "X", "Y", "Z", true, true );
63        grid1Cmd->SetDefaultUnit( "m" );
64
65        grid2Cmd = new G4UIcmdWith3VectorAndUnit( "/gridGun/grid2", this );
66        grid2Cmd->SetGuidance( "Set second axis of grid." );
67        grid2Cmd->SetParameterName( "X", "Y", "Z", true, true );
68        grid2Cmd->SetDefaultUnit( "m" );
69
70        n1Cmd = new G4UIcmdWithAnInteger( "/gridGun/n1", this );
71        n1Cmd->SetGuidance( "Set number of grid points along first axis." );
72        n1Cmd->SetParameterName( "n1", true, true );
73       
74        n2Cmd = new G4UIcmdWithAnInteger( "/gridGun/n2", this );
75        n2Cmd->SetGuidance( "Set number of grid points along second axis." );
76        n2Cmd->SetParameterName( "n2", true, true );
77}
78
79//
80// Destructor
81//
82GridParticleGunMessenger::~GridParticleGunMessenger()
83{
84        delete directionCmd;
85        delete originCmd;
86        delete grid1Cmd;
87        delete grid2Cmd;
88        delete n1Cmd;
89        delete n2Cmd;
90        delete gunDirectory;
91}
92
93//
94// SetNewValue
95//
96// Called by the UI when user requests a change
97//
98void GridParticleGunMessenger::SetNewValue( G4UIcommand *command, G4String newValues )
99{
100        if (command == directionCmd) {
101                gun->SetDirection( directionCmd->GetNew3VectorValue( newValues ) );
102        }
103        else if (command == originCmd) {
104                gun->SetOrigin( originCmd->GetNew3VectorValue( newValues ) );
105        }
106        else if (command == grid1Cmd) {
107                gun->SetGrid1( grid1Cmd->GetNew3VectorValue( newValues ) );
108        }
109        else if (command == grid2Cmd) {
110                gun->SetGrid2( grid2Cmd->GetNew3VectorValue( newValues ) );
111        }
112        else if (command == n1Cmd) {
113                gun->SetN1( n1Cmd->GetNewIntValue( newValues ) );
114        }
115        else if (command == n2Cmd) {
116                gun->SetN2( n2Cmd->GetNewIntValue( newValues ) );
117        }
118}
119
120//
121// GetCurrentValue
122//
123G4String GridParticleGunMessenger::GetCurrentValue( G4UIcommand *command )
124{
125        if (command == directionCmd) {
126                return directionCmd->ConvertToString( gun->GetDirection() );
127        }
128        else if (command == originCmd) {
129                return originCmd->ConvertToString( gun->GetOrigin(), "m" );
130        }
131        else if (command == grid1Cmd) {
132                return grid1Cmd->ConvertToString( gun->GetGrid1(), "m" );
133        }
134        else if (command == grid2Cmd) {
135                return grid2Cmd->ConvertToString( gun->GetGrid2(), "m" );
136        }
137        else if (command == n1Cmd) {
138                return n1Cmd->ConvertToString( gun->GetN1() );
139        }
140        else if (command == n2Cmd) {
141                return n2Cmd->ConvertToString( gun->GetN2() );
142        }
143       
144        return "baloney";
145}
146
147       
148       
149       
150       
Note: See TracBrowser for help on using the repository browser.