#include <G4VisCommandsSceneAdd.hh>
Inheritance diagram for G4VisCommandSceneAddLogicalVolume:
Public Member Functions | |
G4VisCommandSceneAddLogicalVolume () | |
virtual | ~G4VisCommandSceneAddLogicalVolume () |
G4String | GetCurrentValue (G4UIcommand *command) |
void | SetNewValue (G4UIcommand *command, G4String newValue) |
Definition at line 240 of file G4VisCommandsSceneAdd.hh.
G4VisCommandSceneAddLogicalVolume::G4VisCommandSceneAddLogicalVolume | ( | ) |
Definition at line 1063 of file G4VisCommandsSceneAdd.cc.
01063 { 01064 G4bool omitable; 01065 fpCommand = new G4UIcommand ("/vis/scene/add/logicalVolume", this); 01066 fpCommand -> SetGuidance ("Adds a logical volume to the current scene,"); 01067 fpCommand -> SetGuidance 01068 ("Shows boolean components (if any), voxels (if any) and readout geometry" 01069 "\n(if any). Note: voxels are not constructed until start of run -" 01070 "\n \"/run/beamOn\"."); 01071 G4UIparameter* parameter; 01072 parameter = new G4UIparameter ("logical-volume-name", 's', omitable = false); 01073 fpCommand -> SetParameter (parameter); 01074 parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true); 01075 parameter -> SetGuidance ("Depth of descent of geometry hierarchy."); 01076 parameter -> SetDefaultValue (1); 01077 fpCommand -> SetParameter (parameter); 01078 parameter = new G4UIparameter ("booleans-flag", 'b', omitable = true); 01079 parameter -> SetDefaultValue (true); 01080 fpCommand -> SetParameter (parameter); 01081 parameter = new G4UIparameter ("voxels-flag", 'b', omitable = true); 01082 parameter -> SetDefaultValue (true); 01083 fpCommand -> SetParameter (parameter); 01084 parameter = new G4UIparameter ("readout-flag", 'b', omitable = true); 01085 parameter -> SetDefaultValue (true); 01086 fpCommand -> SetParameter (parameter); 01087 }
G4VisCommandSceneAddLogicalVolume::~G4VisCommandSceneAddLogicalVolume | ( | ) | [virtual] |
G4String G4VisCommandSceneAddLogicalVolume::GetCurrentValue | ( | G4UIcommand * | command | ) | [virtual] |
void G4VisCommandSceneAddLogicalVolume::SetNewValue | ( | G4UIcommand * | command, | |
G4String | newValue | |||
) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 1097 of file G4VisCommandsSceneAdd.cc.
References G4VisManager::confirmations, G4UIcommand::ConvertToBool(), G4VisManager::errors, G4VVisCommand::fpVisManager, G4cout, G4endl, G4VisManager::GetCurrentScene(), G4LogicalVolumeStore::GetInstance(), G4VisManager::GetVerbosity(), G4VVisCommand::UpdateVisManagerScene(), and G4VisManager::warnings.
01098 { 01099 01100 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 01101 G4bool warn(verbosity >= G4VisManager::warnings); 01102 01103 G4Scene* pScene = fpVisManager->GetCurrentScene(); 01104 if (!pScene) { 01105 if (verbosity >= G4VisManager::errors) { 01106 G4cout << "ERROR: No current scene. Please create one." << G4endl; 01107 } 01108 return; 01109 } 01110 01111 G4String name; 01112 G4int requestedDepthOfDescent; 01113 G4String booleansString, voxelsString, readoutString; 01114 std::istringstream is (newValue); 01115 is >> name >> requestedDepthOfDescent 01116 >> booleansString >> voxelsString >> readoutString; 01117 G4bool booleans = G4UIcommand::ConvertToBool(booleansString); 01118 G4bool voxels = G4UIcommand::ConvertToBool(voxelsString); 01119 G4bool readout = G4UIcommand::ConvertToBool(readoutString); 01120 01121 G4LogicalVolumeStore *pLVStore = G4LogicalVolumeStore::GetInstance(); 01122 int nLV = pLVStore -> size (); 01123 int iLV; 01124 G4LogicalVolume* pLV = 0; 01125 for (iLV = 0; iLV < nLV; iLV++ ) { 01126 pLV = (*pLVStore) [iLV]; 01127 if (pLV -> GetName () == name) break; 01128 } 01129 if (iLV == nLV) { 01130 if (verbosity >= G4VisManager::errors) { 01131 G4cout << "ERROR: Logical volume " << name 01132 << " not found in logical volume store." << G4endl; 01133 } 01134 return; 01135 } 01136 01137 const std::vector<G4Scene::Model>& rdModelList = pScene -> GetRunDurationModelList(); 01138 std::vector<G4Scene::Model>::const_iterator i; 01139 for (i = rdModelList.begin(); i != rdModelList.end(); ++i) { 01140 if (i->fpModel->GetGlobalDescription().find("Volume") != std::string::npos) break; 01141 } 01142 if (i != rdModelList.end()) { 01143 if (verbosity >= G4VisManager::errors) { 01144 G4cout << "There is already a volume, \"" 01145 << i->fpModel->GetGlobalDescription() 01146 << "\",\n in the run-duration model list of scene \"" 01147 << pScene -> GetName() 01148 << "\".\n Your logical volume must be the only volume in the scene." 01149 << "\n Create a new scene and try again:" 01150 << "\n /vis/specify " << name 01151 << "\n or" 01152 << "\n /vis/scene/create" 01153 << "\n /vis/scene/add/logicalVolume " << name 01154 << "\n /vis/sceneHandler/attach" 01155 << "\n (and also, if necessary, /vis/viewer/flush)" 01156 << G4endl; 01157 } 01158 } 01159 01160 G4VModel* model = new G4LogicalVolumeModel 01161 (pLV, requestedDepthOfDescent, booleans, voxels, readout); 01162 const G4String& currentSceneName = pScene -> GetName (); 01163 G4bool successful = pScene -> AddRunDurationModel (model, warn); 01164 if (successful) { 01165 if (verbosity >= G4VisManager::confirmations) { 01166 G4cout << "Logical volume \"" << pLV -> GetName () 01167 << " with requested depth of descent " 01168 << requestedDepthOfDescent 01169 << ",\n with"; 01170 if (!booleans) G4cout << "out"; 01171 G4cout << " boolean components, with"; 01172 if (!voxels) G4cout << "out"; 01173 G4cout << " voxels and with"; 01174 if (!readout) G4cout << "out"; 01175 G4cout << " readout geometry," 01176 << "\n has been added to scene \"" << currentSceneName << "\"." 01177 << G4endl; 01178 } 01179 } 01180 else { 01181 G4VisCommandsSceneAddUnsuccessful(verbosity); 01182 return; 01183 } 01184 01185 UpdateVisManagerScene (currentSceneName); 01186 }