Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
examples/extended/hadronic/Hadr05/src/DetectorMessenger.cc
Go to the documentation of this file.
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 /// \file hadronic/Hadr00/src/DetectorMessenger.cc
27 /// \brief Implementation of the DetectorMessenger class
28 //
29 //
30 // $Id: DetectorMessenger.cc 77210 2013-11-22 01:58:38Z adotti $
31 //
32 //
33 /////////////////////////////////////////////////////////////////////////
34 //
35 // DetectorMessenger
36 //
37 // Created: 20.06.08 V.Ivanchenko
38 //
39 // Modified:
40 //
41 ////////////////////////////////////////////////////////////////////////
42 //
43 
44 #include "DetectorMessenger.hh"
45 
46 #include "DetectorConstruction.hh"
47 #include "G4UIdirectory.hh"
48 #include "G4UIcmdWithABool.hh"
49 #include "G4UIcmdWithAString.hh"
50 #include "G4UIcmdWithAnInteger.hh"
51 #include "G4UIcmdWith3Vector.hh"
54 #include "HistoManager.hh"
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
59 :G4UImessenger(), fDetector(Det)
60 {
61  ftestDir = new G4UIdirectory("/testhadr/");
62  ftestDir->SetGuidance(" Hadronic Extended Example.");
63 
64  fmatCmd = new G4UIcmdWithAString("/testhadr/TargetMat",this);
65  fmatCmd->SetGuidance("Select Material for the target");
66  fmatCmd->SetParameterName("tMaterial",false);
68  fmatCmd->SetToBeBroadcasted(false);
69 
70  fmat1Cmd = new G4UIcmdWithAString("/testhadr/WorldMat",this);
71  fmat1Cmd->SetGuidance("Select Material for world");
72  fmat1Cmd->SetParameterName("wMaterial",false);
74  fmat1Cmd->SetToBeBroadcasted(false);
75 
76  frCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetRadius",this);
77  frCmd->SetGuidance("Set radius of the target");
78  frCmd->SetParameterName("radius",false);
79  frCmd->SetUnitCategory("Length");
80  frCmd->SetRange("radius>0");
82  frCmd->SetToBeBroadcasted(false);
83 
84  flCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetLength",this);
85  flCmd->SetGuidance("Set length of the target");
86  flCmd->SetParameterName("length",false);
87  flCmd->SetUnitCategory("Length");
88  flCmd->SetRange("length>0");
90  flCmd->SetToBeBroadcasted(false);
91 
92 }
93 
94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
95 
97 {
98  delete fmatCmd;
99  delete fmat1Cmd;
100  delete frCmd;
101  delete flCmd;
102  delete ftestDir;
103 }
104 
105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106 
107 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
108 {
109  if( command == fmatCmd ) {
110  fDetector->SetTargetMaterial(newValue);
111  } else if( command == fmat1Cmd ) {
112  fDetector->SetWorldMaterial(newValue);
113  } else if( command == frCmd ) {
114  fDetector->SetTargetRadius(frCmd->GetNewDoubleValue(newValue));
115  } else if( command == flCmd ) {
116  fDetector->SetTargetLength(flCmd->GetNewDoubleValue(newValue));
117  }
118 }
119 
120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121 
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetToBeBroadcasted(G4bool val)
Definition: G4UIcommand.hh:184
void SetUnitCategory(const char *unitCategory)
static G4double GetNewDoubleValue(const char *paramString)
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:225
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)