]>
Commit | Line | Data |
---|---|---|
676fb573 | 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 | #include <G4LogicalVolume.hh> | |
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 | AliModuleConstructionMessenger::AliModuleConstructionMessenger() { | |
133 | // | |
134 | } | |
135 | ||
136 | AliModuleConstructionMessenger::AliModuleConstructionMessenger( | |
137 | const AliModuleConstructionMessenger& right) | |
138 | { | |
139 | // | |
140 | AliGlobals::Exception( | |
141 | "AliModuleConstructionMessenger is protected from copying."); | |
142 | } | |
143 | ||
144 | AliModuleConstructionMessenger::~AliModuleConstructionMessenger() | |
145 | { | |
146 | // | |
147 | delete fModuleDirectory; | |
148 | delete fSetFrameCmd; | |
149 | delete fListCmd; | |
150 | delete fListLongCmd; | |
151 | delete fListDaughtersCmd; | |
152 | delete fListLongDaughtersCmd; | |
153 | #ifdef ALICE_VISUALIZE | |
154 | delete fSetDetVisibilityCmd; | |
155 | delete fSetDetColourCmd; | |
156 | delete fSetCurrentLVCmd; | |
157 | delete fSetVolVisibilityCmd; | |
158 | delete fSetVolColourCmd; | |
159 | delete fSetLVTreeVisibilityCmd; | |
160 | delete fSetLVTreeColourCmd; | |
161 | #endif //ALICE_VISUALIZE | |
162 | } | |
163 | ||
164 | // operators | |
165 | ||
166 | AliModuleConstructionMessenger& | |
167 | AliModuleConstructionMessenger::operator=( | |
168 | const AliModuleConstructionMessenger& right) | |
169 | { | |
170 | // check assignement to self | |
171 | if (this == &right) return *this; | |
172 | ||
173 | AliGlobals::Exception( | |
174 | "AliModuleConstructionMessenger is protected from assigning."); | |
175 | ||
176 | return *this; | |
177 | } | |
178 | ||
179 | // public methods | |
180 | ||
181 | void AliModuleConstructionMessenger::SetNewValue(G4UIcommand* command, | |
182 | G4String newValues) | |
183 | { | |
184 | // Applies command to the associated object. | |
185 | // --- | |
186 | ||
187 | if (command == fSetFrameCmd) { | |
188 | fModuleConstruction->SetDetFrame(newValues); | |
189 | } | |
190 | else if (command == fListCmd) { | |
191 | fModuleConstruction->ListAllLVTree(); | |
192 | } | |
193 | else if (command == fListLongCmd) { | |
194 | fModuleConstruction->ListAllLVTreeLong(); | |
195 | } | |
196 | else if (command == fListDaughtersCmd) { | |
197 | fModuleConstruction->ListLVTree(newValues); | |
198 | } | |
199 | else if (command == fListLongDaughtersCmd) { | |
200 | fModuleConstruction->ListLVTreeLong(newValues); | |
201 | } | |
202 | #ifdef ALICE_VISUALIZE | |
203 | if (command == fSetCurrentLVCmd) { | |
204 | fCurrentVolume = fModuleConstruction->FindLogicalVolume(newValues); | |
205 | } | |
206 | else if (command == fSetDetVisibilityCmd) { | |
207 | fModuleConstruction | |
208 | ->SetDetVisibility(fSetDetVisibilityCmd->GetNewBoolValue(newValues)); | |
209 | } | |
210 | else if (command == fSetLVTreeVisibilityCmd) { | |
211 | fModuleConstruction | |
212 | ->SetLVTreeVisibility(fCurrentVolume, | |
213 | fSetVolVisibilityCmd->GetNewBoolValue(newValues)); | |
214 | } | |
215 | else if (command == fSetVolVisibilityCmd) { | |
216 | fModuleConstruction | |
217 | ->SetVolumeVisibility(fCurrentVolume, | |
218 | fSetVolVisibilityCmd->GetNewBoolValue(newValues)); | |
219 | } | |
220 | else if (command == fSetDetColourCmd) { | |
221 | fModuleConstruction | |
222 | ->SetDetColour(newValues); | |
223 | } | |
224 | else if (command == fSetLVTreeColourCmd) { | |
225 | fModuleConstruction | |
226 | ->SetLVTreeColour(fCurrentVolume, newValues); | |
227 | } | |
228 | else if (command == fSetVolColourCmd) { | |
229 | fModuleConstruction | |
230 | ->SetVolumeColour(fCurrentVolume, newValues); | |
231 | } | |
232 | #endif //ALICE_VISUALIZE | |
233 | } | |
234 |