44 G4bool omitable, currentAsDefault;
46 fpCommand -> SetGuidance (
"Attaches scene to current scene handler.");
47 fpCommand -> SetGuidance
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."
139 fpCommand =
new G4UIcommand (
"/vis/sceneHandler/create",
this);
140 fpCommand -> SetGuidance
141 (
"Creates an scene handler for a specific graphics system.");
142 fpCommand -> SetGuidance
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) {
153 const G4String& name = gs -> GetName ();
154 candidates += name +
' ';
155 for (
const auto& nickname: gs -> GetNicknames ()) {
156 if (nickname != name) candidates += nickname +
' ';
159 candidates = candidates.
strip ();
160 parameter -> SetParameterCandidates(candidates);
161 fpCommand -> SetParameter (parameter);
163 (
"scene-handler-name",
's', omitable =
true);
164 parameter -> SetCurrentAsDefault (
true);
165 fpCommand -> SetParameter (parameter);
172G4String G4VisCommandSceneHandlerCreate::NextName () {
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 const auto& gs = gsl[iGS];
230 const auto& nicknames = gs->GetNicknames();
231 for (
size_t i = 0; i < nicknames.size(); ++i) {
232 const auto& nickname = nicknames[i];
248 "ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
249 "\n invalid graphics system \""
259 G4int loopCounter = 0;
260 while (!gsl[iGS]->IsUISessionCompatible()) {
261 G4int iGSBeingTested = iGS;
264 G4String fallbackNickname = gsl[iGS]->GetNickname() +
"_FALLBACK";
265 for (iGS = 0; iGS < nSystems; iGS++) {
266 const auto& nicknames = gsl[iGS]->GetNicknames();
267 for (
size_t i = 0; i < nicknames.size(); ++i) {
268 const auto& nickname = nicknames[i];
278 if (iGS < 0 || iGS >= nSystems || loopCounter >=3) {
279 std::ostringstream oss;
280 oss <<
"\"" << gsl[iGSBeingTested]->GetNickname()
281 <<
"\" is not compatible with your chosen session,"
282 " and no fallback system found.";
284 G4cerr <<
"ERROR: G4VisCommandSceneHandlerCreate::SetNewValue: "
298 G4cout <<
"WARNING: G4VisCommandSceneHandlerCreate::SetNewValue:"
299 "\n Using fallback graphics system: "
300 << pSystem -> GetName ()
302 << pSystem -> GetNickname ()
311 G4cout <<
"Graphics system set to "
312 << pSystem -> GetName ()
314 << pSystem -> GetNickname ()
324 if (newName == nextName) fId++;
328 for (iScene = 0; iScene < list.size (); iScene++) {
330 if (sceneHandler -> GetName () == newName) {
332 G4cerr <<
"ERROR: Scene handler \"" << newName
333 <<
"\" already exists." <<
G4endl;
341 if (
fpVisManager -> GetCurrentSceneHandler () -> GetName () != newName) {
343 G4cerr <<
"ERROR: G4VisCommandSceneHandlerCreate::SetNewValue:"
344 " Curious name mismatch."
346 <<
fpVisManager -> GetCurrentSceneHandler () -> GetName ()
347 <<
"\" is not the new name \""
349 <<
"\".\n Please report to vis coordinator."
356 G4cout <<
"New scene handler \"" << newName <<
"\" created." <<
G4endl;
368 fpCommand =
new G4UIcommand (
"/vis/sceneHandler/list",
this);
369 fpCommand -> SetGuidance (
"Lists scene handler(s).");
370 fpCommand -> SetGuidance
371 (
"\"help /vis/verbose\" for definition of verbosity.");
373 parameter =
new G4UIparameter(
"scene-handler-name",
's', omitable =
true);
374 parameter -> SetDefaultValue (
"all");
375 fpCommand -> SetParameter (parameter);
376 parameter =
new G4UIparameter (
"verbosity",
's', omitable =
true);
377 parameter -> SetDefaultValue (
"warnings");
378 fpCommand -> SetParameter (parameter);
392 std::istringstream is (newValue);
393 is >> name >> verbosityString;
399 if (currentSceneHandler) currentName = currentSceneHandler->
GetName();
403 for (
size_t iSH = 0; iSH < list.size (); iSH++) {
404 const G4String& iName = list [iSH] -> GetName ();
406 if (name != iName)
continue;
409 if (iName == currentName) {
415 G4cout <<
" scene handler \"" << list [iSH] -> GetName () <<
"\""
416 <<
" (" << list [iSH] -> GetGraphicsSystem () -> GetName () <<
")";
418 G4cout <<
"\n " << *(list [iSH]);
423 G4cout <<
"No scene handlers found";
425 G4cout <<
" of name \"" << name <<
"\"";
436 fpCommand -> SetGuidance (
"Selects a scene handler.");
437 fpCommand -> SetGuidance
438 (
"Makes the scene handler current. \"/vis/sceneHandler/list\" to see"
439 "\n possible scene handler names.");
440 fpCommand -> SetParameterName (
"scene-handler-name",
461 for (iSH = 0; iSH < list.size (); iSH++) {
462 if (list [iSH] -> GetName () == selectName)
break;
464 if (iSH < list.size ()) {
465 if (
fpVisManager -> GetCurrentSceneHandler () -> GetName ()
468 G4cout <<
"Scene handler \"" << selectName <<
"\""
469 <<
" already selected." <<
G4endl;
474 G4cout <<
"Scene handler \"" << selectName <<
"\""
475 <<
" being selected." <<
G4endl;
482 G4cerr <<
"ERROR: Scene handler \"" << selectName <<
"\""
483 <<
" not found - \"/vis/sceneHandler/list\" to see possibilities."
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
G4String strip(G4int strip_Type=trailing, char c=' ')
G4int compareTo(const char *, caseCompare mode=exact) const
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
static G4UImanager * GetUIpointer()
const G4String & GetName() const
static G4VisManager * fpVisManager
G4String GetCurrentValue(G4UIcommand *command)
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)
G4VisCommandSceneHandlerSelect()
~G4VisCommandSceneHandlerSelect()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
static Verbosity GetVerbosity()
static Verbosity GetVerbosityValue(const G4String &)