Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VisCommandSceneNotifyHandlers Class Reference

#include <G4VisCommandsScene.hh>

+ Inheritance diagram for G4VisCommandSceneNotifyHandlers:

Public Member Functions

 G4VisCommandSceneNotifyHandlers ()
 
virtual ~G4VisCommandSceneNotifyHandlers ()
 
G4String GetCurrentValue (G4UIcommand *command)
 
void SetNewValue (G4UIcommand *command, G4String newValue)
 
- Public Member Functions inherited from G4VVisCommandScene
 G4VVisCommandScene ()
 
virtual ~G4VVisCommandScene ()
 
- Public Member Functions inherited from G4VVisCommand
 G4VVisCommand ()
 
virtual ~G4VVisCommand ()
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
static void SetVisManager (G4VisManager *)
 
- Protected Member Functions inherited from G4VVisCommandScene
G4String CurrentSceneName ()
 
- Protected Member Functions inherited from G4VVisCommand
void UpdateVisManagerScene (const G4String &sceneName="")
 
- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Static Protected Member Functions inherited from G4VVisCommand
static G4String ConvertToString (G4double x, G4double y, const char *unitName)
 
static void ConvertToDoublePair (const G4String &paramString, G4double &xval, G4double &yval)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir
 
G4String baseDirName
 
- Static Protected Attributes inherited from G4VVisCommand
static G4VisManagerfpVisManager = 0
 
static G4Colour fCurrentColour = G4Colour::White()
 
static G4Colour fCurrentTextColour = G4Colour::Blue()
 
static G4Text::Layout fCurrentTextLayout = G4Text::left
 
static G4double fCurrentLineWidth = 1.
 
static G4ModelingParameters::PVNameCopyNoPath fCurrentTouchablePath
 

Detailed Description

Definition at line 116 of file G4VisCommandsScene.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneNotifyHandlers()

G4VisCommandSceneNotifyHandlers::G4VisCommandSceneNotifyHandlers ( )

Definition at line 583 of file G4VisCommandsScene.cc.

583 {
584 G4bool omitable;
585 fpCommand = new G4UIcommand ("/vis/scene/notifyHandlers", this);
586 fpCommand -> SetGuidance
587 ("Notifies scene handlers and forces re-rendering.");
588 fpCommand -> SetGuidance
589 ("Notifies the handler(s) of the specified scene and forces a"
590 "\nreconstruction of any graphical databases."
591 "\nClears and refreshes all viewers of current scene."
592 "\n The default action \"refresh\" does not issue \"update\" (see"
593 "\n /vis/viewer/update)."
594 "\nIf \"flush\" is specified, it issues an \"update\" as well as"
595 "\n \"refresh\" - \"update\" and initiates post-processing"
596 "\n for graphics systems which need it.");
597 fpCommand -> SetGuidance
598 ("The default for <scene-name> is the current scene name.");
599 fpCommand -> SetGuidance
600 ("This command does not change current scene, scene handler or viewer.");
601 G4UIparameter* parameter;
602 parameter = new G4UIparameter ("scene-name", 's',
603 omitable = true);
604 parameter -> SetCurrentAsDefault(true);
605 fpCommand -> SetParameter (parameter);
606 parameter = new G4UIparameter ("refresh-flush", 's',
607 omitable = true);
608 parameter -> SetDefaultValue("refresh");
609 parameter -> SetParameterCandidates("r refresh f flush");
610 fpCommand -> SetParameter (parameter);
611}
bool G4bool
Definition: G4Types.hh:67

◆ ~G4VisCommandSceneNotifyHandlers()

G4VisCommandSceneNotifyHandlers::~G4VisCommandSceneNotifyHandlers ( )
virtual

Definition at line 613 of file G4VisCommandsScene.cc.

613 {
614 delete fpCommand;
615}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneNotifyHandlers::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 617 of file G4VisCommandsScene.cc.

617 {
618 return CurrentSceneName ();
619}

◆ SetNewValue()

void G4VisCommandSceneNotifyHandlers::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 621 of file G4VisCommandsScene.cc.

622 {
623
625
626 G4String sceneName, refresh_flush;
627 std::istringstream is (newValue);
628 is >> sceneName >> refresh_flush;
629 G4bool flush = false;
630 if (refresh_flush(0) == 'f') flush = true;
631
632 const G4SceneList& sceneList = fpVisManager -> GetSceneList ();
633 G4SceneHandlerList& sceneHandlerList =
634 fpVisManager -> SetAvailableSceneHandlers ();
635
636 // Check scene name.
637 const G4int nScenes = sceneList.size ();
638 G4int iScene;
639 for (iScene = 0; iScene < nScenes; iScene++) {
640 G4Scene* scene = sceneList [iScene];
641 if (sceneName == scene -> GetName ()) break;
642 }
643 if (iScene >= nScenes ) {
644 if (verbosity >= G4VisManager::warnings) {
645 G4cout << "WARNING: Scene \"" << sceneName << "\" not found."
646 "\n /vis/scene/list to see scenes."
647 << G4endl;
648 }
649 return;
650 }
651
652 // Store current context...
653 G4VSceneHandler* pCurrentSceneHandler =
654 fpVisManager -> GetCurrentSceneHandler();
655 if (!pCurrentSceneHandler) {
656 if (verbosity >= G4VisManager::warnings) {
657 G4cout << "WARNING: No current scene handler."
658 << G4endl;
659 }
660 return;
661 }
662 G4VViewer* pCurrentViewer = fpVisManager -> GetCurrentViewer();
663 if (!pCurrentViewer) {
664 if (verbosity >= G4VisManager::warnings) {
665 G4cout << "WARNING: No current viewer."
666 << G4endl;
667 }
668 return;
669 }
670 G4Scene* pCurrentScene = fpVisManager -> GetCurrentScene();
671 if (!pCurrentScene) {
672 if (verbosity >= G4VisManager::warnings) {
673 G4cout << "WARNING: No current scene."
674 << G4endl;
675 }
676 return;
677 }
678
679 G4VisManager::Verbosity currentVerbosity = fpVisManager -> GetVerbosity();
680
681 // Suppress messages during this process (only print errors)...
682 //fpVisManager -> SetVerboseLevel(G4VisManager::errors);
683
684 // For each scene handler, if it contains the scene, clear and
685 // rebuild the graphical database, then for each viewer set (make
686 // current), clear, (re)draw, and show.
687 const G4int nSceneHandlers = sceneHandlerList.size ();
688 for (G4int iSH = 0; iSH < nSceneHandlers; iSH++) {
689 G4VSceneHandler* aSceneHandler = sceneHandlerList [iSH];
690 G4Scene* aScene = aSceneHandler -> GetScene ();
691 if (aScene) {
692 const G4String& aSceneName = aScene -> GetName ();
693 if (sceneName == aSceneName) {
694 aScene->CalculateExtent(); // Check and recalculate extent
695 G4ViewerList& viewerList = aSceneHandler -> SetViewerList ();
696 const G4int nViewers = viewerList.size ();
697 for (G4int iV = 0; iV < nViewers; iV++) {
698 G4VViewer* aViewer = viewerList [iV];
699 // Force rebuild of graphical database, if any.
700 aViewer -> NeedKernelVisit();
701 if (aViewer->GetViewParameters().IsAutoRefresh()) {
702 aSceneHandler -> SetCurrentViewer (aViewer);
703 // Ensure consistency of vis manager...
704 fpVisManager -> SetCurrentViewer(aViewer);
705 fpVisManager -> SetCurrentSceneHandler(aSceneHandler);
706 fpVisManager -> SetCurrentScene(aScene);
707 aViewer -> SetView ();
708 aViewer -> ClearView ();
709 aViewer -> DrawView ();
710 if (flush) aViewer -> ShowView ();
711 if (verbosity >= G4VisManager::confirmations) {
712 G4cout << "Viewer \"" << aViewer -> GetName ()
713 << "\" of scene handler \"" << aSceneHandler -> GetName ()
714 << "\"\n ";
715 if (flush) G4cout << "flushed";
716 else G4cout << "refreshed";
717 G4cout << " at request of scene \"" << sceneName
718 << "\"." << G4endl;
719 }
720 } else {
721 if (verbosity >= G4VisManager::confirmations) {
722 G4cout << "NOTE: The scene, \""
723 << sceneName
724 << "\", of viewer \""
725 << aViewer -> GetName ()
726 << "\"\n of scene handler \""
727 << aSceneHandler -> GetName ()
728 << "\" has changed. To see effect,"
729 << "\n \"/vis/viewer/select "
730 << aViewer -> GetShortName ()
731 << "\" and \"/vis/viewer/rebuild\"."
732 << G4endl;
733 }
734 }
735 }
736 }
737 }
738 else {
739 if (verbosity >= G4VisManager::warnings) {
740 G4cout << "WARNING: G4VisCommandSceneNotifyHandlers: scene handler \""
741 << aSceneHandler->GetName()
742 << "\" has a null scene."
743 << G4endl;
744 }
745 }
746 }
747
748 // Reclaim original context - but set viewer first, then scene
749 // handler, because the latter might have been created very recently
750 // and, not yet having a viewer, the current viewer will,
751 // temporarily, refer to another scene handler. SetCurrentViewer
752 // actually resets the scene handler, which is what we don't want,
753 // so we set it again on the next line...
754 fpVisManager -> SetCurrentViewer(pCurrentViewer);
755 fpVisManager -> SetCurrentSceneHandler(pCurrentSceneHandler);
756 fpVisManager -> SetCurrentScene(pCurrentScene);
757 fpVisManager -> SetVerboseLevel(currentVerbosity);
758 // Take care of special case of scene handler with no viewer yet.
759 if (pCurrentSceneHandler) {
760 G4ViewerList& viewerList = pCurrentSceneHandler -> SetViewerList ();
761 const G4int nViewers = viewerList.size ();
762 if (nViewers) {
763 pCurrentSceneHandler -> SetCurrentViewer (pCurrentViewer);
764 if (pCurrentViewer && pCurrentSceneHandler->GetScene()) {
765 pCurrentViewer -> SetView ();
766 }
767 }
768 }
769}
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
void CalculateExtent()
Definition: G4Scene.cc:72
G4Scene * GetScene() const
const G4String & GetName() const
const G4ViewParameters & GetViewParameters() const
static G4VisManager * fpVisManager
G4bool IsAutoRefresh() const
static Verbosity GetVerbosity()

The documentation for this class was generated from the following files: