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

#include <G4VisCommandsViewer.hh>

+ Inheritance diagram for G4VisCommandViewerCreate:

Public Member Functions

 G4VisCommandViewerCreate ()
 
virtual ~G4VisCommandViewerCreate ()
 
G4String GetCurrentValue (G4UIcommand *command)
 
void SetNewValue (G4UIcommand *command, G4String newValue)
 
- 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 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 168 of file G4VisCommandsViewer.hh.

Constructor & Destructor Documentation

◆ G4VisCommandViewerCreate()

G4VisCommandViewerCreate::G4VisCommandViewerCreate ( )

Definition at line 900 of file G4VisCommandsViewer.cc.

900 : fId (0) {
901 G4bool omitable;
902 fpCommand = new G4UIcommand ("/vis/viewer/create", this);
903 fpCommand -> SetGuidance
904 ("Creates a viewer for the specified scene handler.");
905 fpCommand -> SetGuidance
906 ("Default scene handler is the current scene handler. Invents a name"
907 "\nif not supplied. (Note: the system adds information to the name"
908 "\nfor identification - only the characters up to the first blank are"
909 "\nused for removing, selecting, etc.) This scene handler and viewer"
910 "\nbecome current.");
911 G4UIparameter* parameter;
912 parameter = new G4UIparameter ("scene-handler", 's', omitable = true);
913 parameter -> SetCurrentAsDefault (true);
914 fpCommand -> SetParameter (parameter);
915 parameter = new G4UIparameter ("viewer-name", 's', omitable = true);
916 parameter -> SetCurrentAsDefault (true);
917 fpCommand -> SetParameter (parameter);
918 parameter = new G4UIparameter ("window-size-hint", 's', omitable = true);
919 parameter->SetGuidance
920 ("integer (pixels) for square window placed by window manager or"
921 " X-Windows-type geometry string, e.g. 600x600-100+100");
922 parameter->SetDefaultValue("600");
923 fpCommand -> SetParameter (parameter);
924}
bool G4bool
Definition: G4Types.hh:86
void SetDefaultValue(const char *theDefaultValue)
void SetGuidance(const char *theGuidance)

◆ ~G4VisCommandViewerCreate()

G4VisCommandViewerCreate::~G4VisCommandViewerCreate ( )
virtual

Definition at line 926 of file G4VisCommandsViewer.cc.

926 {
927 delete fpCommand;
928}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandViewerCreate::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 944 of file G4VisCommandsViewer.cc.

944 {
945 G4String currentValue;
946 G4VSceneHandler* currentSceneHandler =
947 fpVisManager -> GetCurrentSceneHandler ();
948 if (currentSceneHandler) {
949 currentValue = currentSceneHandler -> GetName ();
950 }
951 else {
952 currentValue = "none";
953 }
954 currentValue += ' ';
955 currentValue += '"';
956 currentValue += NextName ();
957 currentValue += '"';
958
959 currentValue += " 600"; // Default number of pixels for window size hint.
960
961 return currentValue;
962}
static G4VisManager * fpVisManager

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 964 of file G4VisCommandsViewer.cc.

964 {
965
967
968 G4String sceneHandlerName, newName;
969 G4String windowSizeHintString;
970 std::istringstream is (newValue);
971 is >> sceneHandlerName;
972
973 // Now need to handle the possibility that the second string
974 // contains embedded blanks within quotation marks...
975 char c = ' ';
976 while (is.get(c) && c == ' '){}
977 if (c == '"') {
978 while (is.get(c) && c != '"') {newName += c;}
979 }
980 else {
981 newName += c;
982 while (is.get(c) && c != ' ') {newName += c;}
983 }
984 newName = newName.strip (G4String::both, ' ');
985 newName = newName.strip (G4String::both, '"');
986
987 // Now get window size hint...
988 is >> windowSizeHintString;
989
990 const G4SceneHandlerList& sceneHandlerList =
991 fpVisManager -> GetAvailableSceneHandlers ();
992 G4int nHandlers = sceneHandlerList.size ();
993 if (nHandlers <= 0) {
994 if (verbosity >= G4VisManager::errors) {
995 G4cerr <<
996 "ERROR: G4VisCommandViewerCreate::SetNewValue: no scene handlers."
997 "\n Create a scene handler with \"/vis/sceneHandler/create\""
998 << G4endl;
999 }
1000 return;
1001 }
1002
1003 G4int iHandler;
1004 for (iHandler = 0; iHandler < nHandlers; iHandler++) {
1005 if (sceneHandlerList [iHandler] -> GetName () == sceneHandlerName) break;
1006 }
1007
1008 if (iHandler < 0 || iHandler >= nHandlers) {
1009 // Invalid command line argument or none.
1010 // This shouldn't happen!!!!!!
1011 if (verbosity >= G4VisManager::errors) {
1012 G4cout << "G4VisCommandViewerCreate::SetNewValue:"
1013 " invalid scene handler specified."
1014 << G4endl;
1015 }
1016 return;
1017 }
1018
1019 // Valid index. Set current scene handler and graphics system in
1020 // preparation for creating viewer.
1021 G4VSceneHandler* sceneHandler = sceneHandlerList [iHandler];
1022 if (sceneHandler != fpVisManager -> GetCurrentSceneHandler ()) {
1023 fpVisManager -> SetCurrentSceneHandler (sceneHandler);
1024 }
1025
1026 // Now deal with name of viewer.
1027 G4String nextName = NextName ();
1028 if (newName == "") {
1029 newName = nextName;
1030 }
1031 if (newName == nextName) fId++;
1032 G4String newShortName = fpVisManager -> ViewerShortName (newName);
1033
1034 for (G4int ih = 0; ih < nHandlers; ih++) {
1035 G4VSceneHandler* sh = sceneHandlerList [ih];
1036 const G4ViewerList& viewerList = sh -> GetViewerList ();
1037 for (size_t iViewer = 0; iViewer < viewerList.size (); iViewer++) {
1038 if (viewerList [iViewer] -> GetShortName () == newShortName ) {
1039 if (verbosity >= G4VisManager::errors) {
1040 G4cerr << "ERROR: Viewer \"" << newShortName << "\" already exists."
1041 << G4endl;
1042 }
1043 return;
1044 }
1045 }
1046 }
1047
1048 // WindowSizeHint and XGeometryString are picked up from the vis
1049 // manager in the G4VViewer constructor. In G4VisManager, after Viewer
1050 // creation, we will store theses parameters in G4ViewParameters.
1051
1052 fpVisManager -> CreateViewer (newName,windowSizeHintString);
1053
1054 G4VViewer* newViewer = fpVisManager -> GetCurrentViewer ();
1055 if (newViewer && newViewer -> GetName () == newName) {
1056 if (verbosity >= G4VisManager::confirmations) {
1057 G4cout << "New viewer \"" << newName << "\" created." << G4endl;
1058 }
1059 }
1060 else {
1061 if (verbosity >= G4VisManager::errors) {
1062 if (newViewer) {
1063 G4cerr << "ERROR: New viewer doesn\'t match!!! Curious!!" << G4endl;
1064 } else {
1065 G4cout << "WARNING: No viewer created." << G4endl;
1066 }
1067 }
1068 }
1069 // Refresh if appropriate...
1070 if (newViewer) {
1071 if (newViewer->GetViewParameters().IsAutoRefresh()) {
1072 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
1073 }
1074 else {
1075 if (verbosity >= G4VisManager::warnings) {
1076 G4cout << "Issue /vis/viewer/refresh or flush to see effect."
1077 << G4endl;
1078 }
1079 }
1080 }
1081}
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4String strip(G4int strip_Type=trailing, char c=' ')
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
const G4ViewParameters & GetViewParameters() const
G4bool IsAutoRefresh() const
static Verbosity GetVerbosity()

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