]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AliGeant4/AliModulesCompositionMessenger.cxx
path to perl changes to /usr/bin/perl
[u/mrichter/AliRoot.git] / AliGeant4 / AliModulesCompositionMessenger.cxx
1 // $Id$
2 // Category: geometry
3 //
4 // Author: I. Hrivnacova
5 //
6 // Class AliModulesCompositionMessenger
7 // ------------------------------------
8 // See the class description in the header file.
9
10 #include "AliModulesCompositionMessenger.h"
11 #include "AliModulesComposition.h"
12 #include "AliGlobals.h"
13
14 #include <G4UIdirectory.hh>
15 #include <G4UIcmdWithoutParameter.hh>
16 #include <G4UIcmdWithABool.hh>
17 #include <G4UIcmdWithADoubleAndUnit.hh>
18
19 //_____________________________________________________________________________
20 AliModulesCompositionMessenger::AliModulesCompositionMessenger(
21                                    AliModulesComposition* modulesComposition)
22   : fModulesComposition(modulesComposition)
23 {
24 //
25   fDirectory = new G4UIdirectory("/aliDet/");
26   fDirectory->SetGuidance("Detector construction control commands.");
27
28   fFieldValueCmd = new G4UIcmdWithADoubleAndUnit("/aliDet/fieldValue", this);
29   fFieldValueCmd->SetGuidance("Define magnetic field in Z direction.");
30   fFieldValueCmd->SetParameterName("fieldValue", false, false);
31   fFieldValueCmd->SetDefaultUnit("tesla");
32   fFieldValueCmd->SetUnitCategory("Magnetic flux density");
33   fFieldValueCmd->AvailableForStates(PreInit,Idle);  
34   
35   fSetReadGeometryCmd 
36     = new G4UIcmdWithABool("/aliDet/readGeometry", this);
37   fSetReadGeometryCmd->SetGuidance("Read geometry from g3calls.dat files");
38   fSetReadGeometryCmd->SetParameterName("readGeometry", false);
39   fSetReadGeometryCmd->AvailableForStates(PreInit);  
40  
41   fSetWriteGeometryCmd 
42     = new G4UIcmdWithABool("/aliDet/writeGeometry", this);
43   fSetWriteGeometryCmd->SetGuidance("Write geometry to g3calls.dat file");
44   fSetWriteGeometryCmd->SetParameterName("writeGeometry", false);
45   fSetWriteGeometryCmd->AvailableForStates(PreInit);   
46
47   fPrintMaterialsCmd 
48     = new G4UIcmdWithoutParameter("/aliDet/printMaterials", this);
49   fPrintMaterialsCmd->SetGuidance("Prints all materials.");
50   fPrintMaterialsCmd->AvailableForStates(PreInit, Init, Idle);   
51
52   fGenerateXMLCmd 
53     = new G4UIcmdWithoutParameter("/aliDet/generateXML", this);
54   fGenerateXMLCmd->SetGuidance("Generate geometry XML file.");
55   fGenerateXMLCmd->AvailableForStates(Idle);   
56 }
57
58 //_____________________________________________________________________________
59 AliModulesCompositionMessenger::AliModulesCompositionMessenger() {
60 //
61 }
62
63 //_____________________________________________________________________________
64 AliModulesCompositionMessenger::AliModulesCompositionMessenger(
65                                 const AliModulesCompositionMessenger& right)
66 {
67 //
68   AliGlobals::Exception(
69     "AliModulesCompositionMessenger is protected from copying.");
70 }
71
72 //_____________________________________________________________________________
73 AliModulesCompositionMessenger::~AliModulesCompositionMessenger() {
74 //
75   delete fDirectory;
76   delete fFieldValueCmd;
77   delete fSetReadGeometryCmd;
78   delete fSetWriteGeometryCmd;
79   delete fPrintMaterialsCmd;
80   delete fGenerateXMLCmd;
81 }
82
83 // operators
84
85 //_____________________________________________________________________________
86 AliModulesCompositionMessenger& 
87 AliModulesCompositionMessenger::operator=(
88                                 const AliModulesCompositionMessenger& right)
89 {
90   // check assignement to self
91   if (this == &right) return *this;
92
93   AliGlobals::Exception(
94      "AliModulesCompositionMessenger is protected from assigning.");
95     
96   return *this;  
97 }    
98           
99 // public methods
100   
101 //_____________________________________________________________________________
102 void AliModulesCompositionMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
103 {
104 // Applies command to the associated object.
105 // ---
106
107   if (command == fFieldValueCmd) {  
108     fModulesComposition
109       ->SetMagField(fFieldValueCmd->GetNewDoubleValue(newValues)); 
110   }
111   else if (command == fSetReadGeometryCmd) {
112     fModulesComposition->SetReadGeometry(
113                          fSetReadGeometryCmd->GetNewBoolValue(newValues));
114   }  
115   else if (command == fSetWriteGeometryCmd) {
116     fModulesComposition->SetWriteGeometry(
117                          fSetWriteGeometryCmd->GetNewBoolValue(newValues));
118   }    
119   else if (command == fPrintMaterialsCmd) {
120     fModulesComposition->PrintMaterials();
121   }    
122   else if (command == fGenerateXMLCmd) {
123     fModulesComposition->GenerateXMLGeometry();
124   }    
125 }