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

#include <G4VisCommandsViewer.hh>

+ Inheritance diagram for G4VisCommandViewerSave:

Public Member Functions

 G4VisCommandViewerSave ()
 
virtual ~G4VisCommandViewerSave ()
 
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 284 of file G4VisCommandsViewer.hh.

Constructor & Destructor Documentation

◆ G4VisCommandViewerSave()

G4VisCommandViewerSave::G4VisCommandViewerSave ( )

Definition at line 1856 of file G4VisCommandsViewer.cc.

1856 {
1857 G4bool omitable;
1858 fpCommand = new G4UIcmdWithAString ("/vis/viewer/save", this);
1859 fpCommand -> SetGuidance
1860 ("Write commands that define the current view to file.");
1861 fpCommand -> SetGuidance
1862 ("Read them back into the same or any viewer with \"/control/execute\".");
1863 fpCommand -> SetGuidance
1864 ("If the filename is omitted the view is saved to a file "
1865 "\"g4_nn.g4view\", where nn is a sequential two-digit number.");
1866 fpCommand -> SetGuidance
1867 ("If the filename is \"-\", the data are written to G4cout.");
1868 fpCommand -> SetGuidance
1869 ("If you are wanting to save views for future interpolation a recommended "
1870 "procedure is: save views to \"g4_nn.g4view\", as above, then move the files "
1871 "into a sub-directory, say, \"views\", then interpolate with"
1872 "\"/vis/viewer/interpolate views/\" (note the trailing \'/\').");
1873 fpCommand -> SetParameterName ("filename", omitable = true);
1874 fpCommand -> SetDefaultValue ("");
1875}
bool G4bool
Definition: G4Types.hh:86

◆ ~G4VisCommandViewerSave()

G4VisCommandViewerSave::~G4VisCommandViewerSave ( )
virtual

Definition at line 1877 of file G4VisCommandsViewer.cc.

1877 {
1878 delete fpCommand;
1879}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandViewerSave::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 1881 of file G4VisCommandsViewer.cc.

1882 {
1883 return "";
1884}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 1902 of file G4VisCommandsViewer.cc.

1902 {
1903
1905
1906 const G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
1907 if (!currentViewer) {
1908 if (verbosity >= G4VisManager::errors) {
1909 G4cerr <<
1910 "ERROR: G4VisCommandsViewerSave::SetNewValue: no current viewer."
1911 << G4endl;
1912 }
1913 return;
1914 }
1915
1916 const G4Scene* currentScene = currentViewer->GetSceneHandler()->GetScene();
1917 if (!currentScene) {
1918 if (verbosity >= G4VisManager::errors) {
1919 G4cerr <<
1920 "ERROR: G4VisCommandsViewerSave::SetNewValue: no current scene."
1921 << G4endl;
1922 }
1923 return;
1924 }
1925
1926 // Get view parameters and ther relevant information.
1927 G4ViewParameters vp = currentViewer->GetViewParameters();
1928 // Concatenate any private vis attributes modifiers...
1929 const std::vector<G4ModelingParameters::VisAttributesModifier>*
1930 privateVAMs = currentViewer->GetPrivateVisAttributesModifiers();
1931 if (privateVAMs) {
1932 std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator i;
1933 for (i = privateVAMs->begin(); i != privateVAMs->end(); ++i) {
1935 }
1936 }
1937 const G4Point3D& stp = currentScene->GetStandardTargetPoint();
1938
1939 G4String filename = newValue;
1940
1941 if (newValue.length() == 0) {
1942 // Null filename - generate a filename
1943 const G4int maxNoOfFiles = 100;
1944 static G4int sequenceNumber = 0;
1945 if (sequenceNumber >= maxNoOfFiles) {
1946 if (verbosity >= G4VisManager::errors) {
1947 G4cerr
1948 << "ERROR: G4VisCommandsViewerSave::SetNewValue: Maximum number, "
1949 << maxNoOfFiles
1950 << ", of files exceeded."
1951 << G4endl;
1952 }
1953 return;
1954 }
1955 std::ostringstream oss;
1956 oss << std::setw(2) << std::setfill('0') << sequenceNumber++;
1957 filename = "g4_" + oss.str() + ".g4view";
1958 }
1959
1960 if (filename == "-") {
1961 // Write to standard output
1962 WriteCommands(G4cout,vp,stp);
1963 } else {
1964 // Write to file - but add extension if not prescribed
1965 if (!filename.contains('.')) {
1966 // No extension supplied - add .g4view
1967 filename += ".g4view";
1968 }
1969 std::ofstream ofs(filename);
1970 if (!ofs) {
1971 if (verbosity >= G4VisManager::errors) {
1972 G4cerr <<
1973 "ERROR: G4VisCommandsViewerSave::SetNewValue: Trouble opening file \""
1974 << filename << "\"."
1975 << G4endl;
1976 }
1977 ofs.close();
1978 return;
1979 }
1980 WriteCommands(ofs,vp,stp);
1981 ofs.close();
1982 }
1983
1984 if (verbosity >= G4VisManager::warnings) {
1985 G4cout << "Viewer \"" << currentViewer -> GetName ()
1986 << "\"" << " saved to ";
1987 if (filename == "-") {
1988 G4cout << "G4cout.";
1989 } else {
1990 G4cout << "file \'" << filename << "\"." <<
1991 "\n Read the view back into this or any viewer with"
1992 "\n \"/control/execute " << filename << "\" or use"
1993 "\n \"/vis/viewer/interpolate\" if you have several saved files -"
1994 "\n see \"help /vis/viewer/interpolate\" for guidance.";
1995 }
1996 G4cout << G4endl;
1997 }
1998}
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
const G4Point3D & GetStandardTargetPoint() const
G4bool contains(const std::string &) const
G4Scene * GetScene() const
const G4ViewParameters & GetViewParameters() const
virtual const std::vector< G4ModelingParameters::VisAttributesModifier > * GetPrivateVisAttributesModifiers() const
G4VSceneHandler * GetSceneHandler() const
static G4VisManager * fpVisManager
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
G4VViewer * GetCurrentViewer() const
static Verbosity GetVerbosity()

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