// $Id$ // Category: geometry // // Author: I. Hrivnacova // // Class AliDetSwitchVectorMessenger // ------------------------------------ // See the class description in the header file. #include "AliDetSwitchVectorMessenger.h" #include "AliDetSwitchVector.h" #include "AliGlobals.h" #include #include #include //_____________________________________________________________________________ AliDetSwitchVectorMessenger::AliDetSwitchVectorMessenger( AliDetSwitchVector* switchVector) : fDetSwitchVector(switchVector) { // fSwitchOnCmd = new G4UIcmdWithAString("/aliDet/switchOn", this); fSwitchOnCmd->SetGuidance("Define the module to be built."); fSwitchOnCmd->SetGuidance("Available modules:"); G4String listAvailableDets = "NONE, ALL, "; listAvailableDets = listAvailableDets + fDetSwitchVector->GetAvailableDetsListWithCommas(); fSwitchOnCmd->SetGuidance(listAvailableDets); fSwitchOnCmd->SetParameterName("module", false); fSwitchOnCmd->AvailableForStates(PreInit);; fSwitchOffCmd = new G4UIcmdWithAString("/aliDet/switchOff", this); fSwitchOffCmd->SetGuidance("Define the module not to be built."); fSwitchOffCmd->SetGuidance("Available modules:"); G4String listDetsNames = "ALL, "; listDetsNames = listDetsNames + fDetSwitchVector->GetDetNamesListWithCommas(); fSwitchOffCmd->SetGuidance(listDetsNames); fSwitchOffCmd->SetParameterName("module", false); fSwitchOffCmd->AvailableForStates(PreInit);; fListCmd = new G4UIcmdWithoutParameter("/aliDet/list", this); fListCmd->SetGuidance("List the currently switched modules."); fListCmd ->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc); fListAvailableCmd = new G4UIcmdWithoutParameter("/aliDet/listAvailable", this); fListAvailableCmd->SetGuidance("List all available modules."); fListAvailableCmd ->AvailableForStates(PreInit, Init, Idle, GeomClosed, EventProc); // set candidates list SetCandidates(); // set default values to a detector fDetSwitchVector->SwitchDetOn("NONE"); } //_____________________________________________________________________________ AliDetSwitchVectorMessenger::AliDetSwitchVectorMessenger() { // } //_____________________________________________________________________________ AliDetSwitchVectorMessenger::AliDetSwitchVectorMessenger( const AliDetSwitchVectorMessenger& right) { // AliGlobals::Exception( "AliDetSwitchVectorMessenger is protected from copying."); } //_____________________________________________________________________________ AliDetSwitchVectorMessenger::~AliDetSwitchVectorMessenger() { // delete fSwitchOnCmd; delete fSwitchOffCmd; delete fListCmd; delete fListAvailableCmd; } // operators //_____________________________________________________________________________ AliDetSwitchVectorMessenger& AliDetSwitchVectorMessenger::operator=(const AliDetSwitchVectorMessenger& right) { // check assignement to self if (this == &right) return *this; AliGlobals::Exception( "AliDetSwitchVectorMessenger is protected from assigning."); return *this; } // public methods //_____________________________________________________________________________ void AliDetSwitchVectorMessenger::SetNewValue(G4UIcommand* command, G4String newValues) { // Applies command to the associated object. // --- if (command == fSwitchOnCmd) { fDetSwitchVector->SwitchDetOn(newValues); } else if (command == fSwitchOffCmd) { fDetSwitchVector->SwitchDetOff(newValues); } else if (command == fListCmd) { fDetSwitchVector->PrintSwitchedDets(); } else if (command == fListAvailableCmd) { fDetSwitchVector->PrintAvailableDets(); } } //_____________________________________________________________________________ void AliDetSwitchVectorMessenger::SetCandidates() { // Builds candidates list. // --- G4String candidatesList = "NONE ALL "; candidatesList += fDetSwitchVector->GetDetNamesList();; candidatesList += fDetSwitchVector->GetAvailableDetsList(); fSwitchOnCmd->SetCandidates(candidatesList); candidatesList = "ALL "; candidatesList += fDetSwitchVector->GetDetNamesList();; fSwitchOffCmd->SetCandidates(candidatesList); }