Geant4_10
ExG4DetectorConstruction02Messenger.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 // $Id$
27 //
30 
33 
34 #include "G4UIdirectory.hh"
35 #include "G4UIcmdWithAString.hh"
37 #include "G4UIcmdWithADouble.hh"
38 
39 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
40 
42  ExG4DetectorConstruction02* detectorConstruction)
43  : G4UImessenger(),
44  fDetectorConstruction(detectorConstruction),
45  fTopDirectory(0),
46  fDirectory(0),
47  fSetBoxMaterialCmd(0),
48  fSetWorldMaterialCmd(0),
49  fSetBoxDimensionsCmd(0),
50  fSetWorldSizeFactorCmd(0)
51 
52 {
53  fTopDirectory = new G4UIdirectory("/ExG4/");
54  fTopDirectory->SetGuidance("UI commands of common example classes");
55 
56  fDirectory = new G4UIdirectory("/ExG4/det/");
57  fDirectory->SetGuidance("Detector control");
58 
59  fSetBoxMaterialCmd
60  = new G4UIcmdWithAString("/ExG4/det/setBoxMaterial",this);
61  fSetBoxMaterialCmd->SetGuidance("Select material of the box.");
62  fSetBoxMaterialCmd->SetParameterName("BoxMaterial", false);
63  fSetBoxMaterialCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
64 
65  fSetWorldMaterialCmd
66  = new G4UIcmdWithAString("/ExG4/det/setWorldMaterial",this);
67  fSetWorldMaterialCmd->SetGuidance("Select material of the world.");
68  fSetWorldMaterialCmd->SetParameterName("WorldMaterial", false);
69  fSetWorldMaterialCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
70 
71  fSetBoxDimensionsCmd
72  = new G4UIcmdWith3VectorAndUnit("/ExG4/det/setBoxDimensions",this);
73  fSetBoxDimensionsCmd->SetGuidance("Set box dimensions (in half lentgh).");
74  fSetBoxDimensionsCmd->SetParameterName(
75  "BoxDimensionsHx", "BoxDimensionsHy","BoxDimensionsHz",
76  false);
77  //fSetBoxDimensionsCmd->SetUnitCategory("Length");
78  fSetBoxDimensionsCmd->AvailableForStates(G4State_PreInit);
79 
80  fSetWorldSizeFactorCmd
81  = new G4UIcmdWithADouble("/ExG4/det/setWorldSizeFactor",this);
82  fSetWorldSizeFactorCmd->SetGuidance(
83  "Set the multiplication factor from box dimensions to world dimensions.");
84  fSetWorldSizeFactorCmd->SetParameterName("WorldSizeFactor", false);
85  fSetWorldSizeFactorCmd->SetRange("WorldSizeFactor >= 1");
86  fSetWorldSizeFactorCmd->AvailableForStates(G4State_PreInit);
87 }
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90 
92 {
93  delete fTopDirectory;
94  delete fDirectory;
95  delete fSetBoxMaterialCmd;
96  delete fSetWorldMaterialCmd;
97  delete fSetBoxDimensionsCmd;
98  delete fSetWorldSizeFactorCmd;
99 }
100 
101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
102 
104  G4String newValue)
105 {
106  if( command == fSetBoxMaterialCmd ) {
107  fDetectorConstruction->SetBoxMaterial(newValue);
108  }
109  else if( command == fSetWorldMaterialCmd ) {
110  fDetectorConstruction->SetWorldMaterial(newValue);
111  }
112  else if( command == fSetBoxDimensionsCmd ) {
113  G4ThreeVector newDimensions
114  = fSetBoxDimensionsCmd->GetNew3VectorValue(newValue);
115  fDetectorConstruction
117  newDimensions.x(), newDimensions.y(), newDimensions.z());
118  }
119  else if ( command == fSetWorldSizeFactorCmd ) {
120  fDetectorConstruction
121  ->SetWorldSizeFactor(fSetWorldSizeFactorCmd->GetNewDoubleValue(newValue));
122  }
123 }
124 
125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
double x() const
void SetWorldMaterial(const G4String &materialName)
void SetBoxDimensions(G4double hx, G4double hy, G4double hz)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
void SetParameterName(const char *theNameX, const char *theNameY, const char *theNameZ, G4bool omittable, G4bool currentAsDefault=false)
double z() const
Definition of the ExG4DetectorConstruction02 class.
Simple detector construction with a box volume placed in a world.
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 SetBoxMaterial(const G4String &materialName)
Definition of the ExG4DetectorConstruction02Messenger class.
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:225
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
double y() const
ExG4DetectorConstruction02Messenger(ExG4DetectorConstruction02 *)