#include <G4VisCommandsSceneHandler.hh>
Inheritance diagram for G4VisCommandSceneHandlerCreate:
Public Member Functions | |
G4VisCommandSceneHandlerCreate () | |
~G4VisCommandSceneHandlerCreate () | |
G4String | GetCurrentValue (G4UIcommand *command) |
void | SetNewValue (G4UIcommand *command, G4String newValue) |
Definition at line 50 of file G4VisCommandsSceneHandler.hh.
G4VisCommandSceneHandlerCreate::G4VisCommandSceneHandlerCreate | ( | ) |
Definition at line 138 of file G4VisCommandsSceneHandler.cc.
References G4VVisCommand::fpVisManager, G4String::isNull(), and G4String::strip().
00138 : fId (0) { 00139 G4bool omitable; 00140 fpCommand = new G4UIcommand ("/vis/sceneHandler/create", this); 00141 fpCommand -> SetGuidance 00142 ("Creates an scene handler for a specific graphics system."); 00143 fpCommand -> SetGuidance 00144 ("Attaches current scene, if any. (You can change attached scenes with" 00145 "\n\"/vis/sceneHandler/attach\".) Invents a scene handler name if not" 00146 "\nsupplied. This scene handler becomes current."); 00147 G4UIparameter* parameter; 00148 parameter = new G4UIparameter ("graphics-system-name", 00149 's', omitable = false); 00150 const G4GraphicsSystemList& gslist = 00151 fpVisManager -> GetAvailableGraphicsSystems (); 00152 G4String candidates; 00153 for (size_t igslist = 0; igslist < gslist.size (); igslist++) { 00154 const G4String& name = gslist [igslist] -> GetName (); 00155 const G4String& nickname = gslist [igslist] -> GetNickname (); 00156 if (nickname.isNull ()) { 00157 candidates += name; 00158 } 00159 else { 00160 candidates += nickname; 00161 } 00162 candidates += " "; 00163 } 00164 candidates = candidates.strip (); 00165 parameter -> SetParameterCandidates(candidates); 00166 fpCommand -> SetParameter (parameter); 00167 parameter = new G4UIparameter 00168 ("scene-handler-name", 's', omitable = true); 00169 parameter -> SetCurrentAsDefault (true); 00170 fpCommand -> SetParameter (parameter); 00171 }
G4VisCommandSceneHandlerCreate::~G4VisCommandSceneHandlerCreate | ( | ) |
G4String G4VisCommandSceneHandlerCreate::GetCurrentValue | ( | G4UIcommand * | command | ) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 183 of file G4VisCommandsSceneHandler.cc.
References G4VVisCommand::fpVisManager.
00183 { 00184 00185 G4String graphicsSystemName; 00186 const G4VGraphicsSystem* graphicsSystem = 00187 fpVisManager -> GetCurrentGraphicsSystem (); 00188 if (graphicsSystem) { 00189 graphicsSystemName = graphicsSystem -> GetName (); 00190 } 00191 else { 00192 const G4GraphicsSystemList& gslist = 00193 fpVisManager -> GetAvailableGraphicsSystems (); 00194 if (gslist.size ()) { 00195 graphicsSystemName = gslist [0] -> GetName (); 00196 } 00197 else { 00198 graphicsSystemName = "none"; 00199 } 00200 } 00201 00202 return graphicsSystemName + " " + NextName (); 00203 }
void G4VisCommandSceneHandlerCreate::SetNewValue | ( | G4UIcommand * | command, | |
G4String | newValue | |||
) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 205 of file G4VisCommandsSceneHandler.cc.
References G4String::compareTo(), G4VisManager::confirmations, G4VisManager::errors, G4VVisCommand::fpVisManager, G4cout, G4endl, G4UImanager::GetUIpointer(), G4VisManager::GetVerbosity(), G4String::ignoreCase, and G4VisManager::warnings.
00206 { 00207 00208 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 00209 00210 G4String graphicsSystem, newName; 00211 std::istringstream is (newValue); 00212 is >> graphicsSystem >> newName; 00213 00214 const G4GraphicsSystemList& gsl = 00215 fpVisManager -> GetAvailableGraphicsSystems (); 00216 int nSystems = gsl.size (); 00217 if (nSystems <= 0) { 00218 if (verbosity >= G4VisManager::errors) { 00219 G4cout << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:" 00220 " no graphics systems available." 00221 "\n Did you instantiate any in" 00222 " YourVisManager::RegisterGraphicsSystems()?" 00223 << G4endl; 00224 } 00225 return; 00226 } 00227 int iGS; // Selector index. 00228 for (iGS = 0; iGS < nSystems; iGS++) { 00229 if (graphicsSystem.compareTo (gsl [iGS] -> GetName (), 00230 G4String::ignoreCase) == 0 || 00231 graphicsSystem.compareTo (gsl [iGS] -> GetNickname (), 00232 G4String::ignoreCase) == 0) { 00233 break; // Match found. 00234 } 00235 } 00236 if (iGS < 0 || iGS >= nSystems) { 00237 // Invalid command line argument or non. 00238 // This shouldn't happen!!!!!! 00239 if (verbosity >= G4VisManager::errors) { 00240 G4cout << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:" 00241 " invalid graphics system specified." 00242 << G4endl; 00243 } 00244 return; 00245 } 00246 00247 // Check UI session compatibility. 00248 if (!gsl[iGS]->IsUISessionCompatible()) { 00249 G4String fallbackNickname = gsl[iGS]->GetNickname() + "_FALLBACK"; 00250 for (iGS = 0; iGS < nSystems; iGS++) { 00251 if (fallbackNickname.compareTo (gsl [iGS] -> GetNickname (), 00252 G4String::ignoreCase) == 0) { 00253 break; // Match found. 00254 } 00255 } 00256 if (iGS < 0 || iGS >= nSystems) { 00257 if (verbosity >= G4VisManager::errors) { 00258 G4cout << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:" 00259 " could not find fallback graphics system." 00260 << G4endl; 00261 } 00262 return; 00263 } 00264 if (verbosity >= G4VisManager::warnings) { 00265 G4cout << "WARNING: G4VisCommandSceneHandlerCreate::SetNewValue:" 00266 " using fallback graphics system." 00267 << G4endl; 00268 } 00269 } 00270 00271 // Set current graphics system in preparation for 00272 // creating scene handler. 00273 G4VGraphicsSystem* pSystem = gsl [iGS]; 00274 fpVisManager -> SetCurrentGraphicsSystem (pSystem); 00275 if (verbosity >= G4VisManager::confirmations) { 00276 G4cout << "Graphics system set to " << pSystem -> GetName () << G4endl; 00277 } 00278 00279 // Now deal with name of scene handler. 00280 G4String nextName = NextName (); 00281 if (newName == "") { 00282 newName = nextName; 00283 } 00284 if (newName == nextName) fId++; 00285 00286 const G4SceneHandlerList& list = fpVisManager -> GetAvailableSceneHandlers (); 00287 size_t iScene; 00288 for (iScene = 0; iScene < list.size (); iScene++) { 00289 G4VSceneHandler* sceneHandler = list [iScene]; 00290 if (sceneHandler -> GetName () == newName) { 00291 if (verbosity >= G4VisManager::errors) { 00292 G4cout << "ERROR: Scene handler \"" << newName 00293 << "\" already exists." << G4endl; 00294 } 00295 return; 00296 } 00297 } 00298 00299 //Create scene handler. 00300 fpVisManager -> CreateSceneHandler (newName); 00301 if (fpVisManager -> GetCurrentSceneHandler () -> GetName () != newName) { 00302 if (verbosity >= G4VisManager::errors) { 00303 G4cout << "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:" 00304 " Curious name mismatch." 00305 "\n Current name \"" 00306 << fpVisManager -> GetCurrentSceneHandler () -> GetName () 00307 << "\" is not the new name \"" 00308 << newName 00309 << "\".\n Please report to vis coordinator." 00310 << G4endl; 00311 } 00312 return; 00313 } 00314 00315 if (verbosity >= G4VisManager::confirmations) { 00316 G4cout << "New scene handler \"" << newName << "\" created." << G4endl; 00317 } 00318 00319 // Attach scene. 00320 if (fpVisManager -> GetCurrentScene ()) 00321 G4UImanager::GetUIpointer () -> ApplyCommand ("/vis/sceneHandler/attach"); 00322 }