4 // Author: I. Hrivnacova
6 // Class AliModuleConstructionMessenger
7 // ------------------------------------
8 // See the class description in the header file.
10 #include "AliModuleConstructionMessenger.h"
11 #include "AliModuleConstruction.h"
12 #include "AliGlobals.h"
13 #ifdef ALICE_VISUALIZE
14 #include "AliColourStore.h"
17 #include "TG4GeometryServices.h"
19 #include <G4UIdirectory.hh>
20 #include <G4UIcmdWithABool.hh>
21 #include <G4UIcmdWithAString.hh>
22 #include <G4UIcmdWithoutParameter.hh>
24 //_____________________________________________________________________________
25 AliModuleConstructionMessenger::AliModuleConstructionMessenger(
26 AliModuleConstruction* moduleConstruction, const G4String& moduleName)
27 : fModuleConstruction(moduleConstruction)
30 G4String dirName = "/aliDet/";
31 dirName = dirName + moduleName + "/";
32 fModuleDirectory = new G4UIdirectory(dirName);
33 G4String guidance = "AlSubDetConstruction ";
34 guidance = guidance + moduleName + " control commands.";
35 fModuleDirectory->SetGuidance(guidance);
37 G4String commandPath = dirName + "setFrame";
38 fSetFrameCmd= new G4UIcmdWithAString(commandPath, this);
39 fSetFrameCmd ->SetGuidance("Set detector frame");
40 fSetFrameCmd->SetParameterName("frameName", false);
41 fSetFrameCmd->AvailableForStates(PreInit, Idle);
43 commandPath = dirName + "list";
44 fListCmd = new G4UIcmdWithoutParameter(commandPath, this);
45 guidance = "List all logical volumes of ";
46 guidance = guidance + moduleName + " detector";
47 fListCmd->SetGuidance(guidance);
48 fListCmd->AvailableForStates(PreInit,Idle);
50 commandPath = dirName + "listLong";
51 fListLongCmd = new G4UIcmdWithoutParameter(commandPath, this);
53 ->SetGuidance("List all logical volumes and number of its physical volumes");
54 guidance = "of " + moduleName + " detector";
55 fListLongCmd->SetGuidance(guidance);
56 fListLongCmd->AvailableForStates(PreInit,Idle);
58 commandPath = dirName + "listDaughters";
59 fListDaughtersCmd = new G4UIcmdWithAString(commandPath, this);
60 fListDaughtersCmd->SetGuidance("List daughters of the given logical volumes");
61 fListDaughtersCmd->SetParameterName("lvName", false);
62 fListDaughtersCmd->AvailableForStates(PreInit,Idle);
64 commandPath = dirName + "listLongDaughters";
65 fListLongDaughtersCmd = new G4UIcmdWithAString(commandPath, this);
67 ->SetGuidance("List daughters of the given logical volumes");
68 fListLongDaughtersCmd->SetGuidance("and number of its physical volumes");
69 fListLongDaughtersCmd->SetParameterName("lvName", false);
70 fListLongDaughtersCmd->AvailableForStates(PreInit,Idle);
72 #ifdef ALICE_VISUALIZE
75 commandPath = dirName + "setVolume";
76 fSetCurrentLVCmd = new G4UIcmdWithAString(commandPath, this);
77 fSetCurrentLVCmd->SetGuidance("Set the current logical volume.");
78 fSetCurrentLVCmd->SetParameterName("curVolume", false);
79 fSetCurrentLVCmd->AvailableForStates(PreInit,Idle);
81 commandPath = dirName + "setVisibility";
82 fSetDetVisibilityCmd = new G4UIcmdWithABool(commandPath, this);
84 guidance = guidance + moduleName + " detector visible/invisible.";
85 fSetDetVisibilityCmd->SetGuidance(guidance);
86 fSetDetVisibilityCmd->SetParameterName("detVisibility", false);
87 fSetDetVisibilityCmd->AvailableForStates(PreInit,Idle);
89 commandPath = dirName + "setLVTreeVisibility";
90 fSetLVTreeVisibilityCmd = new G4UIcmdWithABool(commandPath, this);
91 fSetLVTreeVisibilityCmd
92 ->SetGuidance("Make current volume tree visible/invisible.");
93 fSetLVTreeVisibilityCmd->SetParameterName("volVisibility", false);
94 fSetLVTreeVisibilityCmd->AvailableForStates(PreInit,Idle);
96 commandPath = dirName + "setVolVisibility";
97 fSetVolVisibilityCmd = new G4UIcmdWithABool(commandPath, this);
99 ->SetGuidance("Make current volume visible/invisible.");
100 fSetVolVisibilityCmd->SetParameterName("volVisibility", false);
101 fSetVolVisibilityCmd->AvailableForStates(PreInit,Idle);
103 commandPath = dirName + "setColour";
104 fSetDetColourCmd = new G4UIcmdWithAString(commandPath, this);
105 AliColourStore* pColours = AliColourStore::Instance();
106 guidance = "Set colour for all ";
107 guidance = guidance + moduleName + " detector volumes.";
108 fSetDetColourCmd->SetGuidance(guidance);
109 fSetDetColourCmd->SetGuidance("Available colours:");
110 fSetDetColourCmd->SetGuidance(pColours->GetColoursListWithCommas());
111 fSetDetColourCmd->SetParameterName("detColour", false);
112 G4String candidatesList = pColours->GetColoursList();
113 fSetDetColourCmd->SetCandidates(candidatesList);
114 fSetDetColourCmd->AvailableForStates(PreInit,Idle);
116 commandPath = dirName + "setLVTreeColour";
117 fSetLVTreeColourCmd = new G4UIcmdWithAString(commandPath, this);
118 fSetLVTreeColourCmd->SetGuidance("Set colour for the current volume tree.");
119 fSetLVTreeColourCmd->SetGuidance("Available colours:");
120 fSetLVTreeColourCmd->SetGuidance(pColours->GetColoursListWithCommas());
121 fSetLVTreeColourCmd->SetParameterName("volColour", false);
122 candidatesList = pColours->GetColoursList();
123 fSetLVTreeColourCmd->SetCandidates(candidatesList);
124 fSetLVTreeColourCmd->AvailableForStates(PreInit,Idle);
126 commandPath = dirName + "setVolColour";
127 fSetVolColourCmd = new G4UIcmdWithAString(commandPath, this);
128 fSetVolColourCmd->SetGuidance("Set colour for the current volume.");
129 fSetVolColourCmd->SetGuidance("Available colours:");
130 fSetVolColourCmd->SetGuidance(pColours->GetColoursListWithCommas());
131 fSetVolColourCmd->SetParameterName("volColour", false);
132 candidatesList = pColours->GetColoursList();
133 fSetVolColourCmd->SetCandidates(candidatesList);
134 fSetVolColourCmd->AvailableForStates(PreInit,Idle);
135 #endif //ALICE_VISUALIZE
138 //_____________________________________________________________________________
139 AliModuleConstructionMessenger::AliModuleConstructionMessenger() {
143 //_____________________________________________________________________________
144 AliModuleConstructionMessenger::AliModuleConstructionMessenger(
145 const AliModuleConstructionMessenger& right)
148 AliGlobals::Exception(
149 "AliModuleConstructionMessenger is protected from copying.");
152 //_____________________________________________________________________________
153 AliModuleConstructionMessenger::~AliModuleConstructionMessenger()
156 delete fModuleDirectory;
160 delete fListDaughtersCmd;
161 delete fListLongDaughtersCmd;
162 #ifdef ALICE_VISUALIZE
163 delete fSetDetVisibilityCmd;
164 delete fSetDetColourCmd;
165 delete fSetCurrentLVCmd;
166 delete fSetVolVisibilityCmd;
167 delete fSetVolColourCmd;
168 delete fSetLVTreeVisibilityCmd;
169 delete fSetLVTreeColourCmd;
170 #endif //ALICE_VISUALIZE
175 //_____________________________________________________________________________
176 AliModuleConstructionMessenger&
177 AliModuleConstructionMessenger::operator=(
178 const AliModuleConstructionMessenger& right)
180 // check assignement to self
181 if (this == &right) return *this;
183 AliGlobals::Exception(
184 "AliModuleConstructionMessenger is protected from assigning.");
191 //_____________________________________________________________________________
192 void AliModuleConstructionMessenger::SetNewValue(G4UIcommand* command,
195 // Applies command to the associated object.
198 if (command == fSetFrameCmd) {
199 fModuleConstruction->SetDetFrame(newValues);
201 else if (command == fListCmd) {
202 fModuleConstruction->ListAllLVTree();
204 else if (command == fListLongCmd) {
205 fModuleConstruction->ListAllLVTreeLong();
207 else if (command == fListDaughtersCmd) {
208 fModuleConstruction->ListLVTree(newValues);
210 else if (command == fListLongDaughtersCmd) {
211 fModuleConstruction->ListLVTreeLong(newValues);
213 #ifdef ALICE_VISUALIZE
214 if (command == fSetCurrentLVCmd) {
216 = TG4GeometryServices::Instance()->FindLogicalVolume(newValues);
218 else if (command == fSetDetVisibilityCmd) {
220 ->SetDetVisibility(fSetDetVisibilityCmd->GetNewBoolValue(newValues));
222 else if (command == fSetLVTreeVisibilityCmd) {
224 ->SetLVTreeVisibility(fCurrentVolume,
225 fSetVolVisibilityCmd->GetNewBoolValue(newValues));
227 else if (command == fSetVolVisibilityCmd) {
229 ->SetVolumeVisibility(fCurrentVolume,
230 fSetVolVisibilityCmd->GetNewBoolValue(newValues));
232 else if (command == fSetDetColourCmd) {
234 ->SetDetColour(newValues);
236 else if (command == fSetLVTreeColourCmd) {
238 ->SetLVTreeColour(fCurrentVolume, newValues);
240 else if (command == fSetVolColourCmd) {
242 ->SetVolumeColour(fCurrentVolume, newValues);
244 #endif //ALICE_VISUALIZE