#include <G4VisCommandsSceneHandler.hh>
Inheritance diagram for G4VisCommandSceneHandlerAttach:
Public Member Functions | |
G4VisCommandSceneHandlerAttach () | |
~G4VisCommandSceneHandlerAttach () | |
G4String | GetCurrentValue (G4UIcommand *command) |
void | SetNewValue (G4UIcommand *command, G4String newValue) |
Definition at line 39 of file G4VisCommandsSceneHandler.hh.
G4VisCommandSceneHandlerAttach::G4VisCommandSceneHandlerAttach | ( | ) |
Definition at line 44 of file G4VisCommandsSceneHandler.cc.
00044 { 00045 G4bool omitable, currentAsDefault; 00046 fpCommand = new G4UIcmdWithAString ("/vis/sceneHandler/attach", this); 00047 fpCommand -> SetGuidance ("Attaches scene to current scene handler."); 00048 fpCommand -> SetGuidance 00049 ("If scene-name is omitted, current scene is attached. To see scenes and" 00050 "\nscene handlers, use \"/vis/scene/list\" and \"/vis/sceneHandler/list\""); 00051 fpCommand -> SetParameterName ("scene-name", 00052 omitable = true, 00053 currentAsDefault = true); 00054 }
G4VisCommandSceneHandlerAttach::~G4VisCommandSceneHandlerAttach | ( | ) |
G4String G4VisCommandSceneHandlerAttach::GetCurrentValue | ( | G4UIcommand * | command | ) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 60 of file G4VisCommandsSceneHandler.cc.
References G4VVisCommand::fpVisManager.
00060 { 00061 G4Scene* pScene = fpVisManager -> GetCurrentScene (); 00062 return pScene ? pScene -> GetName () : G4String(""); 00063 }
void G4VisCommandSceneHandlerAttach::SetNewValue | ( | G4UIcommand * | command, | |
G4String | newValue | |||
) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 65 of file G4VisCommandsSceneHandler.cc.
References G4VisManager::confirmations, G4VisManager::errors, G4VVisCommand::fpVisManager, G4cout, G4endl, G4VisManager::GetVerbosity(), and G4VisManager::warnings.
00066 { 00067 00068 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 00069 00070 G4String& sceneName = newValue; 00071 00072 if (sceneName.length () == 0) { 00073 if (verbosity >= G4VisManager::warnings) { 00074 G4cout << 00075 "WARNING: No scene specified. Maybe there are no scenes available" 00076 "\n yet. Please create one." << G4endl; 00077 } 00078 return; 00079 } 00080 00081 G4VSceneHandler* pSceneHandler = fpVisManager -> GetCurrentSceneHandler (); 00082 if (!pSceneHandler) { 00083 if (verbosity >= G4VisManager::errors) { 00084 G4cout << 00085 "ERROR: Current scene handler not defined. Please select or create one." 00086 << G4endl; 00087 } 00088 return; 00089 } 00090 00091 G4SceneList& sceneList = fpVisManager -> SetSceneList (); 00092 00093 if (sceneList.empty ()) { 00094 if (verbosity >= G4VisManager::errors) { 00095 G4cout << 00096 "ERROR: No valid scenes available yet. Please create one." 00097 << G4endl; 00098 } 00099 return; 00100 } 00101 00102 G4int iScene, nScenes = sceneList.size (); 00103 for (iScene = 0; iScene < nScenes; iScene++) { 00104 if (sceneList [iScene] -> GetName () == sceneName) break; 00105 } 00106 if (iScene < nScenes) { 00107 G4Scene* pScene = sceneList [iScene]; 00108 pSceneHandler -> SetScene (pScene); 00109 // Make sure scene is current... 00110 fpVisManager -> SetCurrentScene (pScene); 00111 // Refresh viewer, if any (only if auto-refresh)... 00112 G4VViewer* pViewer = pSceneHandler -> GetCurrentViewer(); 00113 if (pViewer && pViewer -> GetViewParameters().IsAutoRefresh()) { 00114 pViewer -> SetView (); 00115 pViewer -> ClearView (); 00116 pViewer -> DrawView (); 00117 } 00118 if (verbosity >= G4VisManager::confirmations) { 00119 G4cout << "Scene \"" << sceneName 00120 << "\" attached to scene handler \"" 00121 << pSceneHandler -> GetName () << 00122 ".\n (You may have to refresh with \"/vis/viewer/flush\" if view" 00123 " is not \"auto-refresh\".)" 00124 << G4endl; 00125 } 00126 } 00127 else { 00128 if (verbosity >= G4VisManager::errors) { 00129 G4cout << "ERROR: Scene \"" << sceneName 00130 << "\" not found. Use \"/vis/scene/list\" to see possibilities." 00131 << G4endl; 00132 } 00133 } 00134 }