648 {
649
651
652 G4String sceneName, refresh_flush;
653 std::istringstream is (newValue);
654 is >> sceneName >> refresh_flush;
656 if (refresh_flush[0] == 'f') flush = true;
657
658 const G4SceneList& sceneList =
fpVisManager -> GetSceneList ();
659 G4SceneHandlerList& sceneHandlerList =
661
662
663 const std::size_t nScenes = sceneList.size ();
664 std::size_t iScene;
665 for (iScene = 0; iScene < nScenes; ++iScene) {
666 G4Scene* scene = sceneList [iScene];
667 if (sceneName == scene -> GetName ()) break;
668 }
669 if (iScene >= nScenes ) {
671 G4warn <<
"WARNING: Scene \"" << sceneName <<
"\" not found."
672 "\n /vis/scene/list to see scenes."
674 }
675 return;
676 }
677
678
679 G4VSceneHandler* pCurrentSceneHandler =
681 if (!pCurrentSceneHandler) {
683 G4warn <<
"WARNING: No current scene handler."
685 }
686 return;
687 }
688 G4VViewer* pCurrentViewer =
fpVisManager -> GetCurrentViewer();
689 if (!pCurrentViewer) {
691 G4warn <<
"WARNING: No current viewer."
693 }
694 return;
695 }
696 G4Scene* pCurrentScene =
fpVisManager -> GetCurrentScene();
697 if (!pCurrentScene) {
699 G4warn <<
"WARNING: No current scene."
701 }
702 return;
703 }
704
706
707
708
709
710
711
712
713 const std::size_t nSceneHandlers = sceneHandlerList.size ();
714 for (std::size_t iSH = 0; iSH < nSceneHandlers; ++iSH) {
715 G4VSceneHandler* aSceneHandler = sceneHandlerList [iSH];
716 G4Scene* aScene = aSceneHandler -> GetScene ();
717 if (aScene) {
718 const G4String& aSceneName = aScene -> GetName ();
719 if (sceneName == aSceneName) {
721 G4ViewerList& viewerList = aSceneHandler -> SetViewerList ();
722 const std::size_t nViewers = viewerList.size ();
723 for (std::size_t iV = 0; iV < nViewers; ++iV) {
724 G4VViewer* aViewer = viewerList [iV];
725
726 aViewer -> NeedKernelVisit();
728 aSceneHandler -> SetCurrentViewer (aViewer);
729
733 aViewer -> SetView ();
734 aViewer -> ClearView ();
735 aViewer -> DrawView ();
736 if (flush) aViewer -> ShowView ();
738 G4cout <<
"Viewer \"" << aViewer -> GetName ()
739 << "\" of scene handler \"" << aSceneHandler -> GetName ()
740 << "\"\n ";
741 if (flush)
G4cout <<
"flushed";
742 else G4cout <<
"refreshed";
743 G4cout <<
" at request of scene \"" << sceneName
745 }
746 } else {
748 G4cout <<
"NOTE: The scene, \""
749 << sceneName
750 << "\", of viewer \""
751 << aViewer -> GetName ()
752 << "\"\n of scene handler \""
753 << aSceneHandler -> GetName ()
754 << "\" has changed. To see effect,"
755 << "\n \"/vis/viewer/select "
756 << aViewer -> GetShortName ()
757 << "\" and \"/vis/viewer/rebuild\"."
759 }
760 }
761 }
762 }
763 }
764 else {
766 G4warn <<
"WARNING: G4VisCommandSceneNotifyHandlers: scene handler \""
768 << "\" has a null scene."
770 }
771 }
772 }
773
774
775
776
777
778
779
781 fpVisManager -> SetCurrentSceneHandler(pCurrentSceneHandler);
784
785 if (pCurrentSceneHandler) {
786 G4ViewerList& viewerList = pCurrentSceneHandler -> SetViewerList ();
787 const std::size_t nViewers = viewerList.size ();
788 if (nViewers) {
789 pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
790
791
792
793
794 }
795 }
796}
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
const G4ViewParameters & GetViewParameters() const
static G4VisManager * fpVisManager
G4bool IsAutoRefresh() const