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