]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AliGeant4/AliModuleConstructionMessenger.cxx
Updated class description: added class title, author;
[u/mrichter/AliRoot.git] / AliGeant4 / AliModuleConstructionMessenger.cxx
1 // $Id$
2 // Category: geometry
3 //
4 // See the class description in the header file.
5
6 #include "AliModuleConstructionMessenger.h"
7 #include "AliModuleConstruction.h"
8 #include "AliGlobals.h"
9 #ifdef ALICE_VISUALIZE
10 #include "AliColourStore.h"
11 #endif
12
13 #include <G4UIdirectory.hh>
14 #include <G4UIcmdWithABool.hh>
15 #include <G4UIcmdWithAString.hh>
16 #include <G4UIcmdWithoutParameter.hh>
17
18 //_____________________________________________________________________________
19 AliModuleConstructionMessenger::AliModuleConstructionMessenger(
20    AliModuleConstruction* moduleConstruction, G4String moduleName)
21  : fModuleConstruction(moduleConstruction)
22 {
23 //
24   G4String dirName = "/aliDet/"; 
25   dirName = dirName + moduleName + "/"; 
26   fModuleDirectory = new G4UIdirectory(dirName);
27   G4String guidance = "AlSubDetConstruction ";
28   guidance = guidance + moduleName + " control commands.";
29   fModuleDirectory->SetGuidance(guidance);
30
31   G4String commandPath = dirName + "setFrame";
32   fSetFrameCmd= new G4UIcmdWithAString(commandPath, this);
33   fSetFrameCmd ->SetGuidance("Set detector frame");
34   fSetFrameCmd->SetParameterName("frameName", false);
35   fSetFrameCmd->AvailableForStates(PreInit, Idle);  
36  
37   commandPath = dirName + "list";
38   fListCmd = new G4UIcmdWithoutParameter(commandPath, this);
39   guidance = "List all logical volumes of ";
40   guidance = guidance + moduleName + " detector";
41   fListCmd->SetGuidance(guidance);
42   fListCmd->AvailableForStates(PreInit,Idle);  
43  
44   commandPath = dirName + "listLong";
45   fListLongCmd = new G4UIcmdWithoutParameter(commandPath, this);
46   fListLongCmd
47     ->SetGuidance("List all logical volumes and number of its physical volumes");
48   guidance = "of " + moduleName + " detector";
49   fListLongCmd->SetGuidance(guidance);
50   fListLongCmd->AvailableForStates(PreInit,Idle);  
51  
52   commandPath = dirName + "listDaughters";
53   fListDaughtersCmd = new G4UIcmdWithAString(commandPath, this);
54   fListDaughtersCmd->SetGuidance("List daughters of the given logical volumes");
55   fListDaughtersCmd->SetParameterName("lvName", false);
56   fListDaughtersCmd->AvailableForStates(PreInit,Idle);  
57  
58   commandPath = dirName + "listLongDaughters";
59   fListLongDaughtersCmd = new G4UIcmdWithAString(commandPath, this);
60   fListLongDaughtersCmd
61     ->SetGuidance("List daughters of the given logical volumes");
62   fListLongDaughtersCmd->SetGuidance("and number of its physical volumes");
63   fListLongDaughtersCmd->SetParameterName("lvName", false);
64   fListLongDaughtersCmd->AvailableForStates(PreInit,Idle);  
65  
66 #ifdef ALICE_VISUALIZE
67   fCurrentVolume = 0;
68
69   commandPath = dirName + "setVolume";
70   fSetCurrentLVCmd = new G4UIcmdWithAString(commandPath, this);
71   fSetCurrentLVCmd->SetGuidance("Set the current logical volume.");
72   fSetCurrentLVCmd->SetParameterName("curVolume", false);
73   fSetCurrentLVCmd->AvailableForStates(PreInit,Idle);  
74  
75   commandPath = dirName + "setVisibility";
76   fSetDetVisibilityCmd = new G4UIcmdWithABool(commandPath, this);
77   guidance = "Make ";
78   guidance = guidance + moduleName + " detector visible/invisible.";
79   fSetDetVisibilityCmd->SetGuidance(guidance);
80   fSetDetVisibilityCmd->SetParameterName("detVisibility", false);
81   fSetDetVisibilityCmd->AvailableForStates(PreInit,Idle);  
82  
83   commandPath = dirName + "setLVTreeVisibility";
84   fSetLVTreeVisibilityCmd = new G4UIcmdWithABool(commandPath, this);
85   fSetLVTreeVisibilityCmd 
86     ->SetGuidance("Make current volume tree visible/invisible.");
87   fSetLVTreeVisibilityCmd->SetParameterName("volVisibility", false);
88   fSetLVTreeVisibilityCmd->AvailableForStates(PreInit,Idle);  
89  
90   commandPath = dirName + "setVolVisibility";
91   fSetVolVisibilityCmd = new G4UIcmdWithABool(commandPath, this);
92   fSetVolVisibilityCmd 
93     ->SetGuidance("Make current volume visible/invisible.");
94   fSetVolVisibilityCmd->SetParameterName("volVisibility", false);
95   fSetVolVisibilityCmd->AvailableForStates(PreInit,Idle);  
96  
97   commandPath = dirName + "setColour";
98   fSetDetColourCmd = new G4UIcmdWithAString(commandPath, this);
99   AliColourStore* pColours = AliColourStore::Instance();
100   guidance = "Set colour for all ";
101   guidance = guidance + moduleName + " detector volumes.";
102   fSetDetColourCmd->SetGuidance(guidance);
103   fSetDetColourCmd->SetGuidance("Available colours:");
104   fSetDetColourCmd->SetGuidance(pColours->GetColoursListWithCommas());
105   fSetDetColourCmd->SetParameterName("detColour", false);
106   G4String candidatesList = pColours->GetColoursList();  
107   fSetDetColourCmd->SetCandidates(candidatesList);
108   fSetDetColourCmd->AvailableForStates(PreInit,Idle);  
109
110   commandPath = dirName + "setLVTreeColour";
111   fSetLVTreeColourCmd = new G4UIcmdWithAString(commandPath, this);
112   fSetLVTreeColourCmd->SetGuidance("Set colour for the current volume tree.");
113   fSetLVTreeColourCmd->SetGuidance("Available colours:");
114   fSetLVTreeColourCmd->SetGuidance(pColours->GetColoursListWithCommas());
115   fSetLVTreeColourCmd->SetParameterName("volColour", false);
116   candidatesList = pColours->GetColoursList();  
117   fSetLVTreeColourCmd->SetCandidates(candidatesList);
118   fSetLVTreeColourCmd->AvailableForStates(PreInit,Idle);  
119
120   commandPath = dirName + "setVolColour";
121   fSetVolColourCmd = new G4UIcmdWithAString(commandPath, this);
122   fSetVolColourCmd->SetGuidance("Set colour for the current volume.");
123   fSetVolColourCmd->SetGuidance("Available colours:");
124   fSetVolColourCmd->SetGuidance(pColours->GetColoursListWithCommas());
125   fSetVolColourCmd->SetParameterName("volColour", false);
126   candidatesList = pColours->GetColoursList();  
127   fSetVolColourCmd->SetCandidates(candidatesList);
128   fSetVolColourCmd->AvailableForStates(PreInit,Idle);  
129 #endif //ALICE_VISUALIZE
130 }
131
132 //_____________________________________________________________________________
133 AliModuleConstructionMessenger::AliModuleConstructionMessenger() {
134 //
135 }
136
137 //_____________________________________________________________________________
138 AliModuleConstructionMessenger::AliModuleConstructionMessenger(
139                                 const AliModuleConstructionMessenger& right)
140 {
141 //
142   AliGlobals::Exception(
143     "AliModuleConstructionMessenger is protected from copying.");
144 }
145
146 //_____________________________________________________________________________
147 AliModuleConstructionMessenger::~AliModuleConstructionMessenger()
148 {
149 //
150   delete fModuleDirectory;
151   delete fSetFrameCmd;  
152   delete fListCmd;
153   delete fListLongCmd;
154   delete fListDaughtersCmd;
155   delete fListLongDaughtersCmd;
156 #ifdef ALICE_VISUALIZE
157   delete fSetDetVisibilityCmd;
158   delete fSetDetColourCmd;
159   delete fSetCurrentLVCmd;
160   delete fSetVolVisibilityCmd;    
161   delete fSetVolColourCmd;    
162   delete fSetLVTreeVisibilityCmd;    
163   delete fSetLVTreeColourCmd;    
164 #endif //ALICE_VISUALIZE
165 }
166
167 // operators
168
169 //_____________________________________________________________________________
170 AliModuleConstructionMessenger& 
171 AliModuleConstructionMessenger::operator=(
172                                 const AliModuleConstructionMessenger& right)
173 {
174   // check assignement to self
175   if (this == &right) return *this;
176
177   AliGlobals::Exception(
178      "AliModuleConstructionMessenger is protected from assigning.");
179     
180   return *this;  
181 }    
182           
183 // public methods
184   
185 //_____________________________________________________________________________
186 void AliModuleConstructionMessenger::SetNewValue(G4UIcommand* command,
187                                                  G4String newValues)
188 {
189 // Applies command to the associated object.
190 // ---
191
192   if (command == fSetFrameCmd) {
193     fModuleConstruction->SetDetFrame(newValues);
194   }
195   else if (command == fListCmd) {
196     fModuleConstruction->ListAllLVTree();
197   }
198   else if (command == fListLongCmd) {
199     fModuleConstruction->ListAllLVTreeLong();
200   }
201   else if (command == fListDaughtersCmd) {
202     fModuleConstruction->ListLVTree(newValues);
203   }
204   else if (command == fListLongDaughtersCmd) {
205     fModuleConstruction->ListLVTreeLong(newValues);
206   }
207 #ifdef ALICE_VISUALIZE
208   if (command == fSetCurrentLVCmd) {
209     fCurrentVolume = fModuleConstruction->FindLogicalVolume(newValues);
210   }    
211   else if (command == fSetDetVisibilityCmd) {
212     fModuleConstruction
213       ->SetDetVisibility(fSetDetVisibilityCmd->GetNewBoolValue(newValues)); 
214   } 
215   else if (command == fSetLVTreeVisibilityCmd) {
216     fModuleConstruction
217       ->SetLVTreeVisibility(fCurrentVolume,
218           fSetVolVisibilityCmd->GetNewBoolValue(newValues)); 
219   } 
220   else if (command == fSetVolVisibilityCmd) {
221     fModuleConstruction
222       ->SetVolumeVisibility(fCurrentVolume,
223           fSetVolVisibilityCmd->GetNewBoolValue(newValues)); 
224   } 
225   else if (command == fSetDetColourCmd) {
226     fModuleConstruction
227       ->SetDetColour(newValues);
228   }     
229   else if (command == fSetLVTreeColourCmd) {
230     fModuleConstruction
231       ->SetLVTreeColour(fCurrentVolume, newValues);
232   }     
233   else if (command == fSetVolColourCmd) {
234     fModuleConstruction
235       ->SetVolumeColour(fCurrentVolume, newValues);
236   }     
237 #endif //ALICE_VISUALIZE
238 }
239