Geant4 11.4.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 ()=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, const 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 (const 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 1905 of file G4VisCommandsViewer.cc.

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

◆ ~G4VisCommandViewerSave()

G4VisCommandViewerSave::~G4VisCommandViewerSave ( )
virtual

Definition at line 1926 of file G4VisCommandsViewer.cc.

1926 {
1927 delete fpCommand;
1928}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandViewerSave::GetCurrentValue ( G4UIcommand * command)
virtual

Reimplemented from G4UImessenger.

Definition at line 1930 of file G4VisCommandsViewer.cc.

1931 {
1932 return "";
1933}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 1951 of file G4VisCommandsViewer.cc.

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