Geant4 11.1.1
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 ()=default
 
 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 G4VisManagerGetVisManager ()
 
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="")
 
void Twinkle (G4VViewer *currentViewer, const G4ViewParameters &baseVP, const std::vector< std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > > &paths)
 
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 CopyCameraParameters (G4ViewParameters &target, const G4ViewParameters &from)
 
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 (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const 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 = nullptr
 
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
 
static G4bool fThereWasAViewer = false
 
static G4ViewParameters fExistingVP
 

Detailed Description

Definition at line 115 of file G4VisCommandsScene.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneNotifyHandlers()

G4VisCommandSceneNotifyHandlers::G4VisCommandSceneNotifyHandlers ( )

Definition at line 588 of file G4VisCommandsScene.cc.

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

◆ ~G4VisCommandSceneNotifyHandlers()

G4VisCommandSceneNotifyHandlers::~G4VisCommandSceneNotifyHandlers ( )
virtual

Definition at line 618 of file G4VisCommandsScene.cc.

618 {
619 delete fpCommand;
620}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneNotifyHandlers::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 622 of file G4VisCommandsScene.cc.

622 {
623 return CurrentSceneName ();
624}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 626 of file G4VisCommandsScene.cc.

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