Geant4 11.1.1
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 ()=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 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 168 of file G4VisCommandsViewer.hh.

Constructor & Destructor Documentation

◆ G4VisCommandViewerCreate()

G4VisCommandViewerCreate::G4VisCommandViewerCreate ( )

Definition at line 903 of file G4VisCommandsViewer.cc.

903 : fId (0) {
904 G4bool omitable;
905 fpCommand = new G4UIcommand ("/vis/viewer/create", this);
906 fpCommand -> SetGuidance
907 ("Creates a viewer. If the scene handler name is specified, then a"
908 "\nviewer of that scene handler is created. Otherwise, a viewer"
909 "\nof the current scene handler is created.");
910 fpCommand -> SetGuidance
911 ("If the viewer name is not specified a name is generated from the name"
912 "\nof the scene handler and a serial number.");
913 fpCommand -> SetGuidance("The scene handler and viewer become current.");
914 fpCommand -> SetGuidance
915 ("(Note: the system adds the graphics system name to the viewer name"
916 "\nfor identification, but for selecting, copying, etc., only characters"
917 "\nup to the first blank are used. For example, if the viewer name is"
918 "\n\"viewer-0 (G4OpenGLStoredQt)\", it may be referenced by \"viewer-0\","
919 "\nfor example in \"/vis/viewer/select viewer-0\".)");
920 fpCommand -> SetGuidance
921 ("Window size and placement hints, e.g. 600x600-100+100 (in pixels):");
922 fpCommand -> SetGuidance
923 ("- single number, e.g., \"600\": square window;");
924 fpCommand -> SetGuidance
925 ("- two numbers, e.g., \"800x600\": rectangluar window;");
926 fpCommand -> SetGuidance
927 ("- two numbers plus placement hint, e.g., \"600x600-100+100\" places window of size"
928 "\n 600x600 100 pixels left and 100 pixels down from top right corner.");
929 fpCommand -> SetGuidance
930 ("- If not specified, the default is \"600\", i.e., 600 pixels square, placed"
931 "\n at the window manager's discretion...or picked up from the previous viewer.");
932 fpCommand -> SetGuidance
933 ("- This is an X-Windows-type geometry string, see:"
934 "\n https://en.wikibooks.org/wiki/Guide_to_X11/Starting_Programs,"
935 "\n \"Specifying window geometry\".");
936 G4UIparameter* parameter;
937 parameter = new G4UIparameter ("scene-handler", 's', omitable = true);
938 parameter -> SetCurrentAsDefault (true);
939 fpCommand -> SetParameter (parameter);
940 parameter = new G4UIparameter ("viewer-name", 's', omitable = true);
941 parameter -> SetCurrentAsDefault (true);
942 fpCommand -> SetParameter (parameter);
943 parameter = new G4UIparameter ("window-size-hint", 's', omitable = true);
944 parameter -> SetDefaultValue("none");
945 fpCommand -> SetParameter (parameter);
946}
bool G4bool
Definition: G4Types.hh:86

◆ ~G4VisCommandViewerCreate()

G4VisCommandViewerCreate::~G4VisCommandViewerCreate ( )
virtual

Definition at line 948 of file G4VisCommandsViewer.cc.

948 {
949 delete fpCommand;
950}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandViewerCreate::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 966 of file G4VisCommandsViewer.cc.

966 {
967 G4String currentValue;
968 G4VSceneHandler* currentSceneHandler =
969 fpVisManager -> GetCurrentSceneHandler ();
970 if (currentSceneHandler) {
971 currentValue = currentSceneHandler -> GetName ();
972 } else {
973 currentValue = "none";
974 }
975 currentValue += ' ';
976 currentValue += '"';
977 currentValue += NextName ();
978 currentValue += '"';
979 return currentValue;
980}
static G4VisManager * fpVisManager

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 982 of file G4VisCommandsViewer.cc.

982 {
983
985
986 G4String sceneHandlerName, newName;
987 G4String windowSizeHintString;
988 std::istringstream is (newValue);
989 is >> sceneHandlerName;
990
991 // Now need to handle the possibility that the second string
992 // contains embedded blanks within quotation marks...
993 char c = ' ';
994 while (is.get(c) && c == ' '){}
995 if (c == '"') {
996 while (is.get(c) && c != '"') {newName += c;}
997 }
998 else {
999 newName += c;
1000 while (is.get(c) && c != ' ') {newName += c;}
1001 }
1002 G4StrUtil::strip(newName, ' ');
1003 G4StrUtil::strip(newName, '"');
1004
1005 // Now get window size hint...
1006 is >> windowSizeHintString;
1007
1008 const G4SceneHandlerList& sceneHandlerList =
1009 fpVisManager -> GetAvailableSceneHandlers ();
1010 std::size_t nHandlers = sceneHandlerList.size ();
1011 if (nHandlers == 0) {
1013 ed <<
1014 "ERROR: G4VisCommandViewerCreate::SetNewValue: no scene handlers."
1015 "\n Create a scene handler with \"/vis/sceneHandler/create\"";
1016 command->CommandFailed(ed);
1017 return;
1018 }
1019
1020 std::size_t iHandler;
1021 for (iHandler = 0; iHandler < nHandlers; ++iHandler) {
1022 if (sceneHandlerList [iHandler] -> GetName () == sceneHandlerName) break;
1023 }
1024
1025 if (iHandler >= nHandlers) {
1026 // Invalid command line argument or none.
1027 // This shouldn't happen!!!!!!
1029 ed <<
1030 "G4VisCommandViewerCreate::SetNewValue: invalid scene handler specified.";
1031 command->CommandFailed(ed);
1032 return;
1033 }
1034
1035 // Valid index. Set current scene handler and graphics system in
1036 // preparation for creating viewer.
1037 G4VSceneHandler* sceneHandler = sceneHandlerList [iHandler];
1038 if (sceneHandler != fpVisManager -> GetCurrentSceneHandler ()) {
1039 fpVisManager -> SetCurrentSceneHandler (sceneHandler);
1040 }
1041
1042 // Now deal with name of viewer.
1043 G4String nextName = NextName ();
1044 if (newName == "") {
1045 newName = nextName;
1046 }
1047 if (newName == nextName) fId++;
1048 G4String newShortName = fpVisManager -> ViewerShortName (newName);
1049
1050 for (std::size_t ih = 0; ih < nHandlers; ++ih) {
1051 G4VSceneHandler* sh = sceneHandlerList [ih];
1052 const G4ViewerList& viewerList = sh -> GetViewerList ();
1053 for (std::size_t iViewer = 0; iViewer < viewerList.size (); iViewer++) {
1054 if (viewerList [iViewer] -> GetShortName () == newShortName ) {
1056 ed <<
1057 "ERROR: Viewer \"" << newShortName << "\" already exists.";
1058 command->CommandFailed(ed);
1059 return;
1060 }
1061 }
1062 }
1063
1064 if (fThereWasAViewer) {
1065 // ...and if it's still current...
1066 auto existingViewer = fpVisManager->GetCurrentViewer();
1067 if (existingViewer) {
1068 // ...bring view parameters up to date...
1069 fExistingVP = existingViewer->GetViewParameters();
1070 }
1071 }
1072
1073 if (fThereWasAViewer && windowSizeHintString == "none") {
1074 // The user did not specify a window size hint - get from existing VPs
1075 windowSizeHintString = fExistingVP.GetXGeometryString();
1076 }
1077
1078 fpVisManager -> CreateViewer (newName,windowSizeHintString);
1079
1080 // Now we have a new viewer
1081 G4VViewer* newViewer = fpVisManager -> GetCurrentViewer ();
1082
1083 if (newViewer && newViewer -> GetName () == newName) {
1084 if (fThereWasAViewer) {
1085 G4ViewParameters vp = newViewer->GetViewParameters();
1086 // Copy view parameters from existing viewer, except for...
1089 // ...including window hint paramaters that have been set already above...
1091 vp = fExistingVP;
1092 newViewer->SetViewParameters(vp);
1093 }
1094 if (verbosity >= G4VisManager::confirmations) {
1095 G4cout << "New viewer \"" << newName << "\" created." << G4endl;
1096 }
1097 // Keep for next time...
1098 fThereWasAViewer = true;
1100 } else {
1102 if (newViewer) {
1103 ed << "ERROR: New viewer doesn\'t match!!! Curious!!";
1104 } else {
1105 ed << "WARNING: No viewer created.";
1106 }
1107 command->CommandFailed(ed);
1108 return;
1109 }
1110 // Refresh if appropriate...
1111 if (newViewer) {
1112 if (newViewer->GetViewParameters().IsAutoRefresh()) {
1113 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/refresh");
1114 }
1115 else {
1116 if (verbosity >= G4VisManager::warnings) {
1117 G4warn << "Issue /vis/viewer/refresh or flush to see effect."
1118 << G4endl;
1119 }
1120 }
1121 }
1122}
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
#define G4warn
Definition: G4Scene.cc:41
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
Definition: G4UIcommand.hh:179
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:495
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
const G4ViewParameters & GetViewParameters() const
void SetViewParameters(const G4ViewParameters &vp)
Definition: G4VViewer.cc:126
static G4ViewParameters fExistingVP
static G4bool fThereWasAViewer
void SetAutoRefresh(G4bool)
void SetBackgroundColour(const G4Colour &)
const G4String & GetXGeometryString() const
const G4Colour & GetBackgroundColour() const
void SetXGeometryString(const G4String &)
G4bool IsAutoRefresh() const
G4VViewer * GetCurrentViewer() const
static Verbosity GetVerbosity()
void strip(G4String &str, char ch=' ')
Remove leading and trailing characters from string.

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