Geant4 11.2.2
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 ()
 
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 LtoS (G4long l)
 
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
 
static G4SceneTreeItem fExistingSceneTree
 

Detailed Description

Definition at line 296 of file G4VisCommandsViewer.hh.

Constructor & Destructor Documentation

◆ G4VisCommandViewerSave()

G4VisCommandViewerSave::G4VisCommandViewerSave ( )

Definition at line 1915 of file G4VisCommandsViewer.cc.

1915 {
1916 G4bool omitable;
1917 fpCommand = new G4UIcmdWithAString ("/vis/viewer/save", this);
1918 fpCommand -> SetGuidance
1919 ("Write commands that define the current view to file.");
1920 fpCommand -> SetGuidance
1921 ("Read them back into the same or any viewer with \"/control/execute\".");
1922 fpCommand -> SetGuidance
1923 ("If the filename is omitted the view is saved to a file "
1924 "\"g4_nn.g4view\", where nn is a sequential two-digit number.");
1925 fpCommand -> SetGuidance
1926 ("If the filename is \"-\", the data are written to G4cout.");
1927 fpCommand -> SetGuidance
1928 ("If you are wanting to save views for future interpolation a recommended "
1929 "procedure is: save views to \"g4_nn.g4view\", as above, then move the files "
1930 "into a sub-directory, say, \"views\", then interpolate with"
1931 "\"/vis/viewer/interpolate views\"");
1932 fpCommand -> SetParameterName ("filename", omitable = true);
1933 fpCommand -> SetDefaultValue ("");
1934}
bool G4bool
Definition G4Types.hh:86

◆ ~G4VisCommandViewerSave()

G4VisCommandViewerSave::~G4VisCommandViewerSave ( )
virtual

Definition at line 1936 of file G4VisCommandsViewer.cc.

1936 {
1937 delete fpCommand;
1938}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandViewerSave::GetCurrentValue ( G4UIcommand * command)
virtual

Reimplemented from G4UImessenger.

Definition at line 1940 of file G4VisCommandsViewer.cc.

1941 {
1942 return "";
1943}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 1961 of file G4VisCommandsViewer.cc.

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

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