#include <G4VisCommandsScene.hh>
Inheritance diagram for G4VisCommandSceneActivateModel:
Public Member Functions | |
G4VisCommandSceneActivateModel () | |
virtual | ~G4VisCommandSceneActivateModel () |
G4String | GetCurrentValue (G4UIcommand *command) |
void | SetNewValue (G4UIcommand *command, G4String newValue) |
Definition at line 51 of file G4VisCommandsScene.hh.
G4VisCommandSceneActivateModel::G4VisCommandSceneActivateModel | ( | ) |
Definition at line 58 of file G4VisCommandsScene.cc.
00058 { 00059 G4bool omitable; 00060 fpCommand = new G4UIcommand ("/vis/scene/activateModel", this); 00061 fpCommand -> SetGuidance 00062 ("Activate or de-activate model."); 00063 fpCommand -> SetGuidance 00064 ("Attempts to match search string to name of model - use unique sub-string."); 00065 fpCommand -> SetGuidance 00066 ("Use \"/vis/scene/list\" to see model names."); 00067 fpCommand -> SetGuidance 00068 ("If name == \"all\" (default), all models are activated."); 00069 G4UIparameter* parameter; 00070 parameter = new G4UIparameter ("search-string", 's', omitable = true); 00071 parameter -> SetDefaultValue ("all"); 00072 fpCommand -> SetParameter (parameter); 00073 parameter = new G4UIparameter ("activate", 'b', omitable = true); 00074 parameter -> SetDefaultValue (true); 00075 fpCommand -> SetParameter (parameter); 00076 }
G4VisCommandSceneActivateModel::~G4VisCommandSceneActivateModel | ( | ) | [virtual] |
G4String G4VisCommandSceneActivateModel::GetCurrentValue | ( | G4UIcommand * | command | ) | [virtual] |
void G4VisCommandSceneActivateModel::SetNewValue | ( | G4UIcommand * | command, | |
G4String | newValue | |||
) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 86 of file G4VisCommandsScene.cc.
References G4UIcommand::ConvertToBool(), G4VisManager::errors, G4VVisCommand::fpVisManager, G4cout, G4endl, G4VisManager::GetCurrentScene(), G4VisManager::GetCurrentSceneHandler(), G4VisManager::GetVerbosity(), G4Scene::SetEndOfEventModelList(), G4Scene::SetEndOfRunModelList(), G4Scene::SetRunDurationModelList(), G4VVisCommand::UpdateVisManagerScene(), and G4VisManager::warnings.
00087 { 00088 00089 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 00090 00091 G4String searchString, activateString; 00092 std::istringstream is (newValue); 00093 is >> searchString >> activateString; 00094 G4bool activate = G4UIcommand::ConvertToBool(activateString); 00095 00096 G4Scene* pScene = fpVisManager->GetCurrentScene(); 00097 if (!pScene) { 00098 if (verbosity >= G4VisManager::errors) { 00099 G4cout << "ERROR: No current scene. Please create one." << G4endl; 00100 } 00101 return; 00102 } 00103 00104 G4VSceneHandler* pSceneHandler = fpVisManager->GetCurrentSceneHandler(); 00105 if (!pSceneHandler) { 00106 if (verbosity >= G4VisManager::errors) { 00107 G4cout << "ERROR: No current sceneHandler. Please create one." << G4endl; 00108 } 00109 return; 00110 } 00111 00112 if (searchString == "all" && !activate) { 00113 if (verbosity >= G4VisManager::warnings) { 00114 G4cout << 00115 "WARNING: You are not allowed to de-activate all models." 00116 "\n Command ignored." 00117 << G4endl; 00118 } 00119 return; 00120 } 00121 00122 G4bool any = false; 00123 00124 std::vector<G4Scene::Model>& runDurationModelList = 00125 pScene->SetRunDurationModelList(); 00126 for (size_t i = 0; i < runDurationModelList.size(); i++) { 00127 const G4String& modelName = 00128 runDurationModelList[i].fpModel->GetGlobalDescription(); 00129 if (searchString == "all" || modelName.find(searchString) 00130 != std::string::npos) { 00131 any = true; 00132 runDurationModelList[i].fActive = activate; 00133 if (verbosity >= G4VisManager::warnings) { 00134 G4cout << "Model \"" << modelName; 00135 if (activate) G4cout << "\" activated."; 00136 else G4cout << "\" de-activated."; 00137 G4cout << G4endl; 00138 } 00139 } 00140 } 00141 00142 std::vector<G4Scene::Model>& endOfEventModelList = 00143 pScene->SetEndOfEventModelList(); 00144 for (size_t i = 0; i < endOfEventModelList.size(); i++) { 00145 const G4String& modelName = 00146 endOfEventModelList[i].fpModel->GetGlobalDescription(); 00147 if (searchString == "all" || modelName.find(searchString) 00148 != std::string::npos) { 00149 any = true; 00150 endOfEventModelList[i].fActive = activate; 00151 if (verbosity >= G4VisManager::warnings) { 00152 G4cout << "Model \"" << modelName; 00153 if (activate) G4cout << "\" activated."; 00154 else G4cout << "\" de-activated."; 00155 G4cout << G4endl; 00156 } 00157 } 00158 } 00159 00160 std::vector<G4Scene::Model>& endOfRunModelList = 00161 pScene->SetEndOfRunModelList(); 00162 for (size_t i = 0; i < endOfRunModelList.size(); i++) { 00163 const G4String& modelName = 00164 endOfRunModelList[i].fpModel->GetGlobalDescription(); 00165 if (searchString == "all" || modelName.find(searchString) 00166 != std::string::npos) { 00167 any = true; 00168 endOfRunModelList[i].fActive = activate; 00169 if (verbosity >= G4VisManager::warnings) { 00170 G4cout << "Model \"" << modelName; 00171 if (activate) G4cout << "\" activated."; 00172 else G4cout << "\" de-activated."; 00173 G4cout << G4endl; 00174 } 00175 } 00176 } 00177 00178 if (!any) { 00179 if (verbosity >= G4VisManager::warnings) { 00180 G4cout << "WARNING: No match found." << G4endl; 00181 } 00182 return; 00183 } 00184 00185 const G4String& currentSceneName = pScene -> GetName (); 00186 UpdateVisManagerScene (currentSceneName); 00187 }