Geant4 10.7.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, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
static void SetVisManager (G4VisManager *pVisManager)
 
static const G4ColourGetCurrentTextColour ()
 
- Protected Member Functions inherited from G4VVisCommandScene
G4String CurrentSceneName ()
 
- Protected Member Functions inherited from G4VVisCommand
void SetViewParameters (G4VViewer *viewer, const G4ViewParameters &viewParams)
 
void RefreshIfRequired (G4VViewer *viewer)
 
void InterpolateViews (G4VViewer *currentViewer, std::vector< G4ViewParameters > viewVector, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String exportString="")
 
void InterpolateToNewView (G4VViewer *currentViewer, const G4ViewParameters &oldVP, const G4ViewParameters &newVP, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String exportString="")
 
const G4StringConvertToColourGuidance ()
 
void ConvertToColour (G4Colour &colour, const G4String &redOrString, G4double green, G4double blue, G4double opacity)
 
G4bool ProvideValueOfUnit (const G4String &where, const G4String &unit, const G4String &category, G4double &value)
 
void CheckSceneAndNotifyHandlers (G4Scene *=nullptr)
 
G4bool CheckView ()
 
void G4VisCommandsSceneAddUnsuccessful (G4VisManager::Verbosity verbosity)
 
void CopyGuidanceFrom (const G4UIcommand *fromCmd, G4UIcommand *toCmd, G4int startLine=0)
 
void CopyParametersFrom (const G4UIcommand *fromCmd, G4UIcommand *toCmd)
 
void DrawExtent (const G4VisExtent &)
 
- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
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 G4bool ConvertToDoublePair (const G4String &paramString, G4double &xval, G4double &yval)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 
- Static Protected Attributes inherited from G4VVisCommand
static G4VisManagerfpVisManager = 0
 
static G4int fCurrentArrow3DLineSegmentsPerCircle = 6
 
static G4Colour fCurrentColour = G4Colour::White()
 
static G4double fCurrentLineWidth = 1.
 
static G4Colour fCurrentTextColour = G4Colour::Blue()
 
static G4Text::Layout fCurrentTextLayout = G4Text::left
 
static G4double fCurrentTextSize = 12.
 
static G4PhysicalVolumeModel::TouchableProperties fCurrentTouchableProperties
 
static G4VisExtent fCurrentExtentForField
 
static std::vector< G4PhysicalVolumesSearchScene::FindingsfCurrrentPVFindingsForField
 

Detailed Description

Definition at line 115 of file G4VisCommandsScene.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneNotifyHandlers()

G4VisCommandSceneNotifyHandlers::G4VisCommandSceneNotifyHandlers ( )

Definition at line 586 of file G4VisCommandsScene.cc.

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

◆ ~G4VisCommandSceneNotifyHandlers()

G4VisCommandSceneNotifyHandlers::~G4VisCommandSceneNotifyHandlers ( )
virtual

Definition at line 616 of file G4VisCommandsScene.cc.

616 {
617 delete fpCommand;
618}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneNotifyHandlers::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 620 of file G4VisCommandsScene.cc.

620 {
621 return CurrentSceneName ();
622}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 624 of file G4VisCommandsScene.cc.

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