1952 {
1953
1955
1956 const G4VViewer* currentViewer =
fpVisManager->GetCurrentViewer();
1957 if (!currentViewer) {
1960 "ERROR: G4VisCommandsViewerSave::SetNewValue: no current viewer."
1962 }
1963 return;
1964 }
1965
1967 if (!currentScene) {
1970 "ERROR: G4VisCommandsViewerSave::SetNewValue: no current scene."
1972 }
1973 return;
1974 }
1975
1976
1978
1979 const std::vector<G4ModelingParameters::VisAttributesModifier>*
1981 if (privateVAMs) {
1982 std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator i;
1983 for (i = privateVAMs->begin(); i != privateVAMs->end(); ++i) {
1985 }
1986 }
1988
1989 G4String filename = newValue;
1990
1991 if (newValue.length() == 0) {
1992
1993 const G4int maxNoOfFiles = 100;
1994 static G4int sequenceNumber = 0;
1995 if (sequenceNumber >= maxNoOfFiles) {
1998 << "ERROR: G4VisCommandsViewerSave::SetNewValue: Maximum number, "
1999 << maxNoOfFiles
2000 << ", of files exceeded."
2002 }
2003 return;
2004 }
2005 std::ostringstream oss;
2006 oss << std::setw(2) << std::setfill('0') << sequenceNumber++;
2007 filename = "g4_" + oss.str() + ".g4view";
2008 }
2009
2010 if (filename == "-") {
2011
2012 WriteCommands(
G4cout,vp,stp);
2013 } else {
2014
2015 if (!G4StrUtil::contains(filename, '.')) {
2016
2017 filename += ".g4view";
2018 }
2019 std::ofstream ofs(filename);
2020 if (!ofs) {
2023 "ERROR: G4VisCommandsViewerSave::SetNewValue: Trouble opening file \""
2024 << filename << "\"."
2026 }
2027 ofs.close();
2028 return;
2029 }
2030 WriteCommands(ofs,vp,stp);
2031 ofs.close();
2032 }
2033
2035 G4warn <<
"Viewer \"" << currentViewer -> GetName ()
2036 << "\"" << " saved to ";
2037 if (filename == "-") {
2039 } else {
2040 G4warn <<
"file \'" << filename <<
"\"." <<
2041 "\n Read the view back into this or any viewer with"
2042 "\n \"/control/execute " << filename << "\" or use"
2043 "\n \"/vis/viewer/interpolate\" if you have several saved files -"
2044 "\n see \"help /vis/viewer/interpolate\" for guidance.";
2045 }
2047 }
2048}
HepGeom::Point3D< G4double > G4Point3D
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 &)