44 G4bool omitable, currentAsDefault;
46 fpCommand -> SetGuidance (
"Attaches scene to current scene handler.");
48 (
"If scene-name is omitted, current scene is attached. To see scenes and"
49 "\nscene handlers, use \"/vis/scene/list\" and \"/vis/sceneHandler/list\"");
50 fpCommand -> SetParameterName (
"scene-name",
52 currentAsDefault =
true);
61 return pScene ? pScene -> GetName () :
G4String(
"");
71 if (sceneName.length () == 0) {
74 "WARNING: No scene specified. Maybe there are no scenes available"
75 "\n yet. Please create one." <<
G4endl;
84 "ERROR: Current scene handler not defined. Please select or create one."
92 if (sceneList.empty ()) {
95 "ERROR: No valid scenes available yet. Please create one."
101 G4int iScene, nScenes = sceneList.size ();
102 for (iScene = 0; iScene < nScenes; iScene++) {
103 if (sceneList [iScene] -> GetName () == sceneName)
break;
105 if (iScene < nScenes) {
106 G4Scene* pScene = sceneList [iScene];
107 pSceneHandler -> SetScene (pScene);
111 G4VViewer* pViewer = pSceneHandler -> GetCurrentViewer();
112 if (pViewer && pViewer -> GetViewParameters().IsAutoRefresh()) {
113 pViewer -> SetView ();
114 pViewer -> ClearView ();
115 pViewer -> DrawView ();
118 G4cout <<
"Scene \"" << sceneName
119 <<
"\" attached to scene handler \""
120 << pSceneHandler -> GetName () <<
121 ".\n (You may have to refresh with \"/vis/viewer/flush\" if view"
122 " is not \"auto-refresh\".)"
128 G4cerr <<
"ERROR: Scene \"" << sceneName
129 <<
"\" not found. Use \"/vis/scene/list\" to see possibilities."
141 (
"Creates an scene handler for a specific graphics system.");
143 (
"Attaches current scene, if any. (You can change attached scenes with"
144 "\n\"/vis/sceneHandler/attach\".) Invents a scene handler name if not"
145 "\nsupplied. This scene handler becomes current.");
148 's', omitable =
false);
152 for (
const auto gs: gslist) {
154 candidates +=
name +
' ';
155 for (
const auto& nickname: gs -> GetNicknames ()) {
157 if (nickname !=
name) candidates += nickname +
' ';
161 parameter -> SetParameterCandidates(candidates);
164 (
"scene-handler-name",
's', omitable =
true);
165 parameter -> SetCurrentAsDefault (
true);
174 std::ostringstream oss;
175 oss <<
"scene-handler-" <<
fId;
184 if (graphicsSystem) {
185 graphicsSystemName = graphicsSystem -> GetName ();
190 if (gslist.size ()) {
191 graphicsSystemName = gslist [0] -> GetName ();
194 graphicsSystemName =
"none";
198 return graphicsSystemName +
" " +
NextName ();
207 std::istringstream is (newValue);
208 is >> graphicsSystem >> newName;
212 G4int nSystems = gsl.size ();
216 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
217 " no graphics systems available."
218 "\n Did you instantiate any in"
219 " YourVisManager::RegisterGraphicsSystems()?";
225 for (iGS = 0; iGS < nSystems; iGS++) {
226 const auto& gs = gsl[iGS];
231 const auto& nicknames = gs->GetNicknames();
232 for (
size_t i = 0; i < nicknames.size(); ++i) {
233 const auto& nickname = nicknames[i];
247 std::set<G4String> candidates;
248 for (
const auto gs:
fpVisManager -> GetAvailableGraphicsSystems()) {
250 for (
const auto& nickname: gs->GetNicknames()) {
252 candidates.insert(nickname);
258 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
259 "\n Invalid graphics system \""
262 <<
"\n Candidates are:";
263 for (
const auto& candidate: candidates) {
264 ed <<
' ' << candidate;
272 G4int loopCounter = 0;
273 while (!gsl[iGS]->IsUISessionCompatible()) {
274 G4int iGSBeingTested = iGS;
277 G4String fallbackNickname = gsl[iGS]->GetNickname() +
"_FALLBACK";
278 for (iGS = 0; iGS < nSystems; iGS++) {
279 const auto& nicknames = gsl[iGS]->GetNicknames();
280 for (
size_t i = 0; i < nicknames.size(); ++i) {
281 const auto& nickname = nicknames[i];
291 if (iGS < 0 || iGS >= nSystems || loopCounter >=3) {
293 ed <<
"\"" << gsl[iGSBeingTested]->GetNickname()
294 <<
"\" is not compatible with your chosen session,"
295 " and no fallback system found.";
307 G4cout <<
"WARNING: G4VisCommandSceneHandlerCreate::SetNewValue:"
308 "\n Using fallback graphics system: "
309 << pSystem -> GetName ()
311 << pSystem -> GetNickname ()
321 if (newName == nextName)
fId++;
325 for (iScene = 0; iScene < list.size (); iScene++) {
327 if (sceneHandler -> GetName () == newName) {
330 "ERROR: Scene handler \"" << newName
331 <<
"\" already exists.";
347 G4cout <<
"Graphics system set to "
348 << pSystem -> GetName ()
350 << pSystem -> GetNickname ()
357 if (
fpVisManager -> GetCurrentSceneHandler () -> GetName () != newName) {
360 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
361 " Curious name mismatch."
363 <<
fpVisManager -> GetCurrentSceneHandler () -> GetName ()
364 <<
"\" is not the new name \""
366 <<
"\".\n Please report to vis coordinator.";
372 G4cout <<
"New scene handler \"" << newName <<
"\" created." <<
G4endl;
378 ed <<
"sub-command \"/vis/sceneHandler/attach\" failed.";
390 fpCommand -> SetGuidance (
"Lists scene handler(s).");
392 (
"\"help /vis/verbose\" for definition of verbosity.");
394 parameter =
new G4UIparameter(
"scene-handler-name",
's', omitable =
true);
395 parameter -> SetDefaultValue (
"all");
397 parameter =
new G4UIparameter (
"verbosity",
's', omitable =
true);
398 parameter -> SetDefaultValue (
"warnings");
413 std::istringstream is (newValue);
414 is >>
name >> verbosityString;
420 if (currentSceneHandler) currentName = currentSceneHandler->
GetName();
424 for (
size_t iSH = 0; iSH < list.size (); iSH++) {
425 const G4String& iName = list [iSH] -> GetName ();
427 if (
name != iName)
continue;
430 if (iName == currentName) {
436 G4cout <<
" scene handler \"" << list [iSH] -> GetName () <<
"\""
437 <<
" (" << list [iSH] -> GetGraphicsSystem () -> GetName () <<
")";
439 G4cout <<
"\n " << *(list [iSH]);
444 G4cout <<
"No scene handlers found";
457 fpCommand -> SetGuidance (
"Selects a scene handler.");
459 (
"Makes the scene handler current. \"/vis/sceneHandler/list\" to see"
460 "\n possible scene handler names.");
461 fpCommand -> SetParameterName (
"scene-handler-name",
482 for (iSH = 0; iSH < list.size (); iSH++) {
483 if (list [iSH] -> GetName () == selectName)
break;
485 if (iSH < list.size ()) {
486 if (
fpVisManager -> GetCurrentSceneHandler () -> GetName ()
489 G4cout <<
"Scene handler \"" << selectName <<
"\""
490 <<
" already selected." <<
G4endl;
495 G4cout <<
"Scene handler \"" << selectName <<
"\""
496 <<
" being selected." <<
G4endl;
503 G4cerr <<
"ERROR: Scene handler \"" << selectName <<
"\""
504 <<
" not found - \"/vis/sceneHandler/list\" to see possibilities."
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
static G4UImanager * GetUIpointer()
const G4String & GetName() const
const G4ViewParameters & GetViewParameters() const
static G4VisManager * fpVisManager
static G4ViewParameters fVPExistingViewer
static G4bool fThereWasAViewer
G4String GetCurrentValue(G4UIcommand *command)
G4UIcmdWithAString * fpCommand
G4VisCommandSceneHandlerAttach()
~G4VisCommandSceneHandlerAttach()
void SetNewValue(G4UIcommand *command, G4String newValue)
~G4VisCommandSceneHandlerCreate()
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandSceneHandlerCreate()
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneHandlerList()
~G4VisCommandSceneHandlerList()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4UIcmdWithAString * fpCommand
G4VisCommandSceneHandlerSelect()
~G4VisCommandSceneHandlerSelect()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
G4VViewer * GetCurrentViewer() const
static Verbosity GetVerbosity()
static Verbosity GetVerbosityValue(const G4String &)
const char * name(G4int ptype)
G4int icompare(std::string_view lhs, std::string_view rhs)
Case insensitive comparison of two strings.
void strip(G4String &str, char c=' ')
Remove leading and trailing characters from string.
G4bool contains(const G4String &str, std::string_view ss)
Check if a string contains a given substring.