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

Constructor & Destructor Documentation

◆ G4VisCommandViewerSave()

G4VisCommandViewerSave::G4VisCommandViewerSave ( )

Definition at line 1899 of file G4VisCommandsViewer.cc.

1899 {
1900 G4bool omitable;
1901 fpCommand = new G4UIcmdWithAString ("/vis/viewer/save", this);
1902 fpCommand -> SetGuidance
1903 ("Write commands that define the current view to file.");
1904 fpCommand -> SetGuidance
1905 ("Read them back into the same or any viewer with \"/control/execute\".");
1906 fpCommand -> SetGuidance
1907 ("If the filename is omitted the view is saved to a file "
1908 "\"g4_nn.g4view\", where nn is a sequential two-digit number.");
1909 fpCommand -> SetGuidance
1910 ("If the filename is \"-\", the data are written to G4cout.");
1911 fpCommand -> SetGuidance
1912 ("If you are wanting to save views for future interpolation a recommended "
1913 "procedure is: save views to \"g4_nn.g4view\", as above, then move the files "
1914 "into a sub-directory, say, \"views\", then interpolate with"
1915 "\"/vis/viewer/interpolate views\"");
1916 fpCommand -> SetParameterName ("filename", omitable = true);
1917 fpCommand -> SetDefaultValue ("");
1918}
bool G4bool
Definition: G4Types.hh:86

◆ ~G4VisCommandViewerSave()

G4VisCommandViewerSave::~G4VisCommandViewerSave ( )
virtual

Definition at line 1920 of file G4VisCommandsViewer.cc.

1920 {
1921 delete fpCommand;
1922}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandViewerSave::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 1924 of file G4VisCommandsViewer.cc.

1925 {
1926 return "";
1927}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 1945 of file G4VisCommandsViewer.cc.

1945 {
1946
1948
1949 const G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
1950 if (!currentViewer) {
1951 if (verbosity >= G4VisManager::errors) {
1952 G4warn <<
1953 "ERROR: G4VisCommandsViewerSave::SetNewValue: no current viewer."
1954 << G4endl;
1955 }
1956 return;
1957 }
1958
1959 const G4Scene* currentScene = currentViewer->GetSceneHandler()->GetScene();
1960 if (!currentScene) {
1961 if (verbosity >= G4VisManager::errors) {
1962 G4warn <<
1963 "ERROR: G4VisCommandsViewerSave::SetNewValue: no current scene."
1964 << G4endl;
1965 }
1966 return;
1967 }
1968
1969 // Get view parameters and ther relevant information.
1970 G4ViewParameters vp = currentViewer->GetViewParameters();
1971 // Concatenate any private vis attributes modifiers...
1972 const std::vector<G4ModelingParameters::VisAttributesModifier>*
1973 privateVAMs = currentViewer->GetPrivateVisAttributesModifiers();
1974 if (privateVAMs) {
1975 std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator i;
1976 for (i = privateVAMs->begin(); i != privateVAMs->end(); ++i) {
1978 }
1979 }
1980 const G4Point3D& stp = currentScene->GetStandardTargetPoint();
1981
1982 G4String filename = newValue;
1983
1984 if (newValue.length() == 0) {
1985 // Null filename - generate a filename
1986 const G4int maxNoOfFiles = 100;
1987 static G4int sequenceNumber = 0;
1988 if (sequenceNumber >= maxNoOfFiles) {
1989 if (verbosity >= G4VisManager::errors) {
1990 G4warn
1991 << "ERROR: G4VisCommandsViewerSave::SetNewValue: Maximum number, "
1992 << maxNoOfFiles
1993 << ", of files exceeded."
1994 << G4endl;
1995 }
1996 return;
1997 }
1998 std::ostringstream oss;
1999 oss << std::setw(2) << std::setfill('0') << sequenceNumber++;
2000 filename = "g4_" + oss.str() + ".g4view";
2001 }
2002
2003 if (filename == "-") {
2004 // Write to standard output
2005 WriteCommands(G4cout,vp,stp);
2006 } else {
2007 // Write to file - but add extension if not prescribed
2008 if (!G4StrUtil::contains(filename, '.')) {
2009 // No extension supplied - add .g4view
2010 filename += ".g4view";
2011 }
2012 std::ofstream ofs(filename);
2013 if (!ofs) {
2014 if (verbosity >= G4VisManager::errors) {
2015 G4warn <<
2016 "ERROR: G4VisCommandsViewerSave::SetNewValue: Trouble opening file \""
2017 << filename << "\"."
2018 << G4endl;
2019 }
2020 ofs.close();
2021 return;
2022 }
2023 WriteCommands(ofs,vp,stp);
2024 ofs.close();
2025 }
2026
2027 if (verbosity >= G4VisManager::warnings) {
2028 G4warn << "Viewer \"" << currentViewer -> GetName ()
2029 << "\"" << " saved to ";
2030 if (filename == "-") {
2031 G4warn << "G4cout.";
2032 } else {
2033 G4warn << "file \'" << filename << "\"." <<
2034 "\n Read the view back into this or any viewer with"
2035 "\n \"/control/execute " << filename << "\" or use"
2036 "\n \"/vis/viewer/interpolate\" if you have several saved files -"
2037 "\n see \"help /vis/viewer/interpolate\" for guidance.";
2038 }
2039 G4warn << G4endl;
2040 }
2041}
#define G4warn
Definition: G4Scene.cc:41
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
const G4Point3D & GetStandardTargetPoint() 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()
G4bool contains(const G4String &str, std::string_view ss)
Check if a string contains a given substring.

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