#include <G4VisCommandsScene.hh>
Inheritance diagram for G4VisCommandSceneNotifyHandlers:
Public Member Functions | |
G4VisCommandSceneNotifyHandlers () | |
virtual | ~G4VisCommandSceneNotifyHandlers () |
G4String | GetCurrentValue (G4UIcommand *command) |
void | SetNewValue (G4UIcommand *command, G4String newValue) |
Definition at line 116 of file G4VisCommandsScene.hh.
G4VisCommandSceneNotifyHandlers::G4VisCommandSceneNotifyHandlers | ( | ) |
Definition at line 583 of file G4VisCommandsScene.cc.
00583 { 00584 G4bool omitable; 00585 fpCommand = new G4UIcommand ("/vis/scene/notifyHandlers", this); 00586 fpCommand -> SetGuidance 00587 ("Notifies scene handlers and forces re-rendering."); 00588 fpCommand -> SetGuidance 00589 ("Notifies the handler(s) of the specified scene and forces a" 00590 "\nreconstruction of any graphical databases." 00591 "\nClears and refreshes all viewers of current scene." 00592 "\n The default action \"refresh\" does not issue \"update\" (see" 00593 "\n /vis/viewer/update)." 00594 "\nIf \"flush\" is specified, it issues an \"update\" as well as" 00595 "\n \"refresh\" - \"update\" and initiates post-processing" 00596 "\n for graphics systems which need it."); 00597 fpCommand -> SetGuidance 00598 ("The default for <scene-name> is the current scene name."); 00599 fpCommand -> SetGuidance 00600 ("This command does not change current scene, scene handler or viewer."); 00601 G4UIparameter* parameter; 00602 parameter = new G4UIparameter ("scene-name", 's', 00603 omitable = true); 00604 parameter -> SetCurrentAsDefault(true); 00605 fpCommand -> SetParameter (parameter); 00606 parameter = new G4UIparameter ("refresh-flush", 's', 00607 omitable = true); 00608 parameter -> SetDefaultValue("refresh"); 00609 parameter -> SetParameterCandidates("r refresh f flush"); 00610 fpCommand -> SetParameter (parameter); 00611 }
G4VisCommandSceneNotifyHandlers::~G4VisCommandSceneNotifyHandlers | ( | ) | [virtual] |
G4String G4VisCommandSceneNotifyHandlers::GetCurrentValue | ( | G4UIcommand * | command | ) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 617 of file G4VisCommandsScene.cc.
References G4VVisCommandScene::CurrentSceneName().
00617 { 00618 return CurrentSceneName (); 00619 }
void G4VisCommandSceneNotifyHandlers::SetNewValue | ( | G4UIcommand * | command, | |
G4String | newValue | |||
) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 621 of file G4VisCommandsScene.cc.
References G4Scene::CalculateExtent(), G4VisManager::confirmations, G4VVisCommand::fpVisManager, G4cout, G4endl, G4VSceneHandler::GetScene(), G4VisManager::GetVerbosity(), and G4VisManager::warnings.
00622 { 00623 00624 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 00625 00626 G4String sceneName, refresh_flush; 00627 std::istringstream is (newValue); 00628 is >> sceneName >> refresh_flush; 00629 G4bool flush = false; 00630 if (refresh_flush(0) == 'f') flush = true; 00631 00632 const G4SceneList& sceneList = fpVisManager -> GetSceneList (); 00633 G4SceneHandlerList& sceneHandlerList = 00634 fpVisManager -> SetAvailableSceneHandlers (); 00635 00636 // Check scene name. 00637 const G4int nScenes = sceneList.size (); 00638 G4int iScene; 00639 for (iScene = 0; iScene < nScenes; iScene++) { 00640 G4Scene* scene = sceneList [iScene]; 00641 if (sceneName == scene -> GetName ()) break; 00642 } 00643 if (iScene >= nScenes ) { 00644 if (verbosity >= G4VisManager::warnings) { 00645 G4cout << "WARNING: Scene \"" << sceneName << "\" not found." 00646 "\n /vis/scene/list to see scenes." 00647 << G4endl; 00648 } 00649 return; 00650 } 00651 00652 // Store current context... 00653 G4VSceneHandler* pCurrentSceneHandler = 00654 fpVisManager -> GetCurrentSceneHandler(); 00655 if (!pCurrentSceneHandler) { 00656 if (verbosity >= G4VisManager::warnings) { 00657 G4cout << "WARNING: No current scene handler." 00658 << G4endl; 00659 } 00660 return; 00661 } 00662 G4VViewer* pCurrentViewer = fpVisManager -> GetCurrentViewer(); 00663 if (!pCurrentViewer) { 00664 if (verbosity >= G4VisManager::warnings) { 00665 G4cout << "WARNING: No current viewer." 00666 << G4endl; 00667 } 00668 return; 00669 } 00670 G4Scene* pCurrentScene = fpVisManager -> GetCurrentScene(); 00671 if (!pCurrentScene) { 00672 if (verbosity >= G4VisManager::warnings) { 00673 G4cout << "WARNING: No current scene." 00674 << G4endl; 00675 } 00676 return; 00677 } 00678 00679 G4VisManager::Verbosity currentVerbosity = fpVisManager -> GetVerbosity(); 00680 00681 // Suppress messages during this process (only print errors)... 00682 //fpVisManager -> SetVerboseLevel(G4VisManager::errors); 00683 00684 // For each scene handler, if it contains the scene, clear and 00685 // rebuild the graphical database, then for each viewer set (make 00686 // current), clear, (re)draw, and show. 00687 const G4int nSceneHandlers = sceneHandlerList.size (); 00688 for (G4int iSH = 0; iSH < nSceneHandlers; iSH++) { 00689 G4VSceneHandler* aSceneHandler = sceneHandlerList [iSH]; 00690 G4Scene* aScene = aSceneHandler -> GetScene (); 00691 if (aScene) { 00692 const G4String& aSceneName = aScene -> GetName (); 00693 if (sceneName == aSceneName) { 00694 aScene->CalculateExtent(); // Check and recalculate extent 00695 G4ViewerList& viewerList = aSceneHandler -> SetViewerList (); 00696 const G4int nViewers = viewerList.size (); 00697 for (G4int iV = 0; iV < nViewers; iV++) { 00698 G4VViewer* aViewer = viewerList [iV]; 00699 // Force rebuild of graphical database, if any. 00700 aViewer -> NeedKernelVisit(); 00701 if (aViewer->GetViewParameters().IsAutoRefresh()) { 00702 aSceneHandler -> SetCurrentViewer (aViewer); 00703 // Ensure consistency of vis manager... 00704 fpVisManager -> SetCurrentViewer(aViewer); 00705 fpVisManager -> SetCurrentSceneHandler(aSceneHandler); 00706 fpVisManager -> SetCurrentScene(aScene); 00707 aViewer -> SetView (); 00708 aViewer -> ClearView (); 00709 aViewer -> DrawView (); 00710 if (flush) aViewer -> ShowView (); 00711 if (verbosity >= G4VisManager::confirmations) { 00712 G4cout << "Viewer \"" << aViewer -> GetName () 00713 << "\" of scene handler \"" << aSceneHandler -> GetName () 00714 << "\"\n "; 00715 if (flush) G4cout << "flushed"; 00716 else G4cout << "refreshed"; 00717 G4cout << " at request of scene \"" << sceneName 00718 << "\"." << G4endl; 00719 } 00720 } else { 00721 if (verbosity >= G4VisManager::confirmations) { 00722 G4cout << "NOTE: The scene, \"" 00723 << sceneName 00724 << "\", of viewer \"" 00725 << aViewer -> GetName () 00726 << "\"\n of scene handler \"" 00727 << aSceneHandler -> GetName () 00728 << "\" has changed. To see effect," 00729 << "\n \"/vis/viewer/select " 00730 << aViewer -> GetShortName () 00731 << "\" and \"/vis/viewer/rebuild\"." 00732 << G4endl; 00733 } 00734 } 00735 } 00736 } 00737 } 00738 else { 00739 if (verbosity >= G4VisManager::warnings) { 00740 G4cout << "WARNING: G4VisCommandSceneNotifyHandlers: scene handler \"" 00741 << aSceneHandler->GetName() 00742 << "\" has a null scene." 00743 << G4endl; 00744 } 00745 } 00746 } 00747 00748 // Reclaim original context - but set viewer first, then scene 00749 // handler, because the latter might have been created very recently 00750 // and, not yet having a viewer, the current viewer will, 00751 // temporarily, refer to another scene handler. SetCurrentViewer 00752 // actually resets the scene handler, which is what we don't want, 00753 // so we set it again on the next line... 00754 fpVisManager -> SetCurrentViewer(pCurrentViewer); 00755 fpVisManager -> SetCurrentSceneHandler(pCurrentSceneHandler); 00756 fpVisManager -> SetCurrentScene(pCurrentScene); 00757 fpVisManager -> SetVerboseLevel(currentVerbosity); 00758 // Take care of special case of scene handler with no viewer yet. 00759 if (pCurrentSceneHandler) { 00760 G4ViewerList& viewerList = pCurrentSceneHandler -> SetViewerList (); 00761 const G4int nViewers = viewerList.size (); 00762 if (nViewers) { 00763 pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer); 00764 if (pCurrentViewer && pCurrentSceneHandler->GetScene()) { 00765 pCurrentViewer -> SetView (); 00766 } 00767 } 00768 } 00769 }