File indexing completed on 2026-04-08 07:53:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #include "OpNoviceDetectorMessenger.hh"
0030
0031 #include "OpNoviceDetectorConstruction.hh"
0032 #include "OpNoviceGDMLDetectorConstruction.hh"
0033
0034 #include "G4UIcmdWithABool.hh"
0035 #include "G4UIcmdWithAString.hh"
0036 #include "G4UIdirectory.hh"
0037
0038
0039
0040 OpNoviceDetectorMessenger::OpNoviceDetectorMessenger(G4VUserDetectorConstruction* detcon)
0041 : G4UImessenger(), fOpNoviceDetCon(detcon)
0042 {
0043 fDetConDir = new G4UIdirectory("/OpNovice/DetectorConstruction/");
0044 fDetConDir->SetGuidance("Configuring Detector Construction");
0045
0046 fVerboseCmd = new G4UIcmdWithABool("/OpNovice/DetectorConstruction/enableVerbose", this);
0047 fVerboseCmd->SetGuidance("Set flag for enabling verbose diagnostic printout");
0048 fVerboseCmd->SetDefaultValue(false);
0049 fVerboseCmd->AvailableForStates(G4State_PreInit);
0050
0051 fDumpGdmlCmd = new G4UIcmdWithABool("/OpNovice/DetectorConstruction/dumpGdml", this);
0052 fDumpGdmlCmd->SetGuidance("Set flag for enabling dumping the detector to a gdml file");
0053 fDumpGdmlCmd->SetDefaultValue(false);
0054 fDumpGdmlCmd->AvailableForStates(G4State_PreInit);
0055
0056 fDumpGdmlFileNameCmd =
0057 new G4UIcmdWithAString("/OpNovice/DetectorConstruction/dumpGdmlFileName", this);
0058 fDumpGdmlFileNameCmd->SetGuidance("Enter file name to dump gdml file ");
0059 fDumpGdmlFileNameCmd->SetDefaultValue("OpNovice_dump.gdml");
0060 fDumpGdmlFileNameCmd->AvailableForStates(G4State_PreInit);
0061 }
0062
0063
0064
0065 OpNoviceDetectorMessenger::~OpNoviceDetectorMessenger()
0066 {
0067 delete fDetConDir;
0068 delete fVerboseCmd;
0069 delete fDumpGdmlCmd;
0070 delete fDumpGdmlFileNameCmd;
0071 }
0072
0073
0074
0075 void OpNoviceDetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
0076 {
0077 auto dc1 = dynamic_cast<OpNoviceDetectorConstruction*>(fOpNoviceDetCon);
0078 if (dc1 != nullptr) {
0079 if (command == fVerboseCmd) dc1->SetVerbose(fVerboseCmd->GetNewBoolValue(newValue));
0080 if (command == fDumpGdmlCmd) dc1->SetDumpGdml(fDumpGdmlCmd->GetNewBoolValue(newValue));
0081 if (command == fDumpGdmlFileNameCmd) dc1->SetDumpGdmlFile(newValue);
0082 }
0083 else {
0084 auto dc2 = dynamic_cast<OpNoviceGDMLDetectorConstruction*>(fOpNoviceDetCon);
0085 if (command == fVerboseCmd) dc2->SetVerbose(fVerboseCmd->GetNewBoolValue(newValue));
0086 if (command == fDumpGdmlCmd) dc2->SetDumpGdml(fDumpGdmlCmd->GetNewBoolValue(newValue));
0087 if (command == fDumpGdmlFileNameCmd) dc2->SetDumpGdmlFile(newValue);
0088 }
0089 }
0090