45 G4bool omitable, currentAsDefault;
47 fpCommand -> SetGuidance (
"Attaches scene to current scene handler.");
49 (
"If scene-name is omitted, current scene is attached. To see scenes and"
50 "\nscene handlers, use \"/vis/scene/list\" and \"/vis/sceneHandler/list\"");
51 fpCommand -> SetParameterName (
"scene-name",
53 currentAsDefault =
true);
62 return pScene ? pScene -> GetName () :
G4String(
"");
72 if (sceneName.length () == 0) {
75 "WARNING: No scene specified. Maybe there are no scenes available"
76 "\n yet. Please create one." <<
G4endl;
85 "ERROR: Current scene handler not defined. Please select or create one."
93 if (sceneList.empty ()) {
96 "ERROR: No valid scenes available yet. Please create one."
102 G4int iScene, nScenes = sceneList.size ();
103 for (iScene = 0; iScene < nScenes; iScene++) {
104 if (sceneList [iScene] -> GetName () == sceneName)
break;
106 if (iScene < nScenes) {
107 G4Scene* pScene = sceneList [iScene];
108 pSceneHandler -> SetScene (pScene);
112 G4VViewer* pViewer = pSceneHandler -> GetCurrentViewer();
113 if (pViewer && pViewer -> GetViewParameters().IsAutoRefresh()) {
114 pViewer -> SetView ();
115 pViewer -> ClearView ();
116 pViewer -> DrawView ();
119 G4cout <<
"Scene \"" << sceneName
120 <<
"\" attached to scene handler \""
121 << pSceneHandler -> GetName () <<
122 ".\n (You may have to refresh with \"/vis/viewer/flush\" if view"
123 " is not \"auto-refresh\".)"
129 G4cerr <<
"ERROR: Scene \"" << sceneName
130 <<
"\" not found. Use \"/vis/scene/list\" to see possibilities."
142 (
"Creates an scene handler for a specific graphics system.");
144 (
"Attaches current scene, if any. (You can change attached scenes with"
145 "\n\"/vis/sceneHandler/attach\".) Invents a scene handler name if not"
146 "\nsupplied. This scene handler becomes current.");
149 's', omitable =
false);
153 for (
auto&& gs: gslist) {
155 candidates += name +
' ';
156 for (
auto&& nickname: gs -> GetNicknames ())
157 candidates += nickname +
' ';
159 candidates = candidates.
strip ();
160 parameter -> SetParameterCandidates(candidates);
163 (
"scene-handler-name",
's', omitable =
true);
164 parameter -> SetCurrentAsDefault (
true);
173 std::ostringstream oss;
174 oss <<
"scene-handler-" <<
fId;
183 if (graphicsSystem) {
184 graphicsSystemName = graphicsSystem -> GetName ();
189 if (gslist.size ()) {
190 graphicsSystemName = gslist [0] -> GetName ();
193 graphicsSystemName =
"none";
197 return graphicsSystemName +
" " +
NextName ();
206 std::istringstream is (newValue);
207 is >> graphicsSystem >> newName;
211 G4int nSystems = gsl.size ();
214 G4cerr <<
"ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
215 " no graphics systems available."
216 "\n Did you instantiate any in"
217 " YourVisManager::RegisterGraphicsSystems()?"
224 for (iGS = 0; iGS < nSystems; iGS++) {
225 auto&& gs = gsl[iGS];
230 auto&& nicknames = gs->GetNicknames();
231 for (
size_t i = 0; i < nicknames.size(); ++i) {
232 auto&& nickname = nicknames[i];
248 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
249 "\n invalid graphics system \""
259 while (!gsl[iGS]->IsUISessionCompatible()) {
262 G4String fallbackNickname = gsl[iGS]->GetNickname() +
"_FALLBACK";
263 for (iGS = 0; iGS < nSystems; iGS++) {
264 auto&& nicknames = gsl[iGS]->GetNicknames();
265 for (
size_t i = 0; i < nicknames.size(); ++i) {
266 auto&& nickname = nicknames[i];
276 if (iGS < 0 || iGS >= nSystems) {
279 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
280 " could not find fallback graphics system for \""
294 G4cout <<
"WARNING: G4VisCommandSceneHandlerCreate::SetNewValue:"
295 "\n Using fallback graphics system: "
296 << pSystem -> GetName ()
298 << pSystem -> GetNickname ()
307 G4cout <<
"Graphics system set to "
308 << pSystem -> GetName ()
310 << pSystem -> GetNickname ()
320 if (newName == nextName)
fId++;
324 for (iScene = 0; iScene < list.size (); iScene++) {
326 if (sceneHandler -> GetName () == newName) {
328 G4cerr <<
"ERROR: Scene handler \"" << newName
329 <<
"\" already exists." <<
G4endl;
337 if (
fpVisManager -> GetCurrentSceneHandler () -> GetName () != newName) {
339 G4cerr <<
"ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
340 " Curious name mismatch."
342 <<
fpVisManager -> GetCurrentSceneHandler () -> GetName ()
343 <<
"\" is not the new name \""
345 <<
"\".\n Please report to vis coordinator."
352 G4cout <<
"New scene handler \"" << newName <<
"\" created." <<
G4endl;
365 fpCommand -> SetGuidance (
"Lists scene handler(s).");
367 (
"\"help /vis/verbose\" for definition of verbosity.");
369 parameter =
new G4UIparameter(
"scene-handler-name",
's', omitable =
true);
370 parameter -> SetDefaultValue (
"all");
372 parameter =
new G4UIparameter (
"verbosity",
's', omitable =
true);
373 parameter -> SetDefaultValue (
"warnings");
388 std::istringstream is (newValue);
389 is >> name >> verbosityString;
395 if (currentSceneHandler) currentName = currentSceneHandler->
GetName();
399 for (
size_t iSH = 0; iSH < list.size (); iSH++) {
400 const G4String& iName = list [iSH] -> GetName ();
402 if (name != iName)
continue;
405 if (iName == currentName) {
411 G4cout <<
" scene handler \"" << list [iSH] -> GetName () <<
"\""
412 <<
" (" << list [iSH] -> GetGraphicsSystem () -> GetName () <<
")";
414 G4cout <<
"\n " << *(list [iSH]);
419 G4cout <<
"No scene handlers found";
421 G4cout <<
" of name \"" << name <<
"\"";
432 fpCommand -> SetGuidance (
"Selects a scene handler.");
434 (
"Makes the scene handler current. \"/vis/sceneHandler/list\" to see"
435 "\n possible scene handler names.");
436 fpCommand -> SetParameterName (
"scene-handler-name",
457 for (iSH = 0; iSH < list.size (); iSH++) {
458 if (list [iSH] -> GetName () == selectName)
break;
460 if (iSH < list.size ()) {
461 if (
fpVisManager -> GetCurrentSceneHandler () -> GetName ()
464 G4cout <<
"Scene handler \"" << selectName <<
"\""
465 <<
" already selected." <<
G4endl;
470 G4cout <<
"Scene handler \"" << selectName <<
"\""
471 <<
" being selected." <<
G4endl;
478 G4cerr <<
"ERROR: Scene handler \"" << selectName <<
"\""
479 <<
" not found - \"/vis/sceneHandler/list\" to see possibilities."
~G4VisCommandSceneHandlerAttach()
G4String strip(G4int strip_Type=trailing, char c=' ')
const G4String & GetName() const
static Verbosity GetVerbosityValue(const G4String &)
G4UIcmdWithAString * fpCommand
static G4UImanager * GetUIpointer()
G4String GetCurrentValue(G4UIcommand *command)
~G4VisCommandSceneHandlerCreate()
~G4VisCommandSceneHandlerSelect()
G4GLOB_DLL std::ostream G4cout
G4UIcmdWithAString * fpCommand
G4VisCommandSceneHandlerCreate()
G4VisCommandSceneHandlerList()
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneHandlerAttach()
G4VisCommandSceneHandlerSelect()
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
static Verbosity GetVerbosity()
G4int compareTo(const char *, caseCompare mode=exact) const
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
~G4VisCommandSceneHandlerList()
G4GLOB_DLL std::ostream G4cerr
void SetNewValue(G4UIcommand *command, G4String newValue)
static G4VisManager * fpVisManager