1961 {
1962
1964
1966 if (!currentViewer) {
1969 "ERROR: G4VisCommandsViewerSave::SetNewValue: no current viewer."
1971 }
1972 return;
1973 }
1974
1976 if (!currentScene) {
1979 "ERROR: G4VisCommandsViewerSave::SetNewValue: no current scene."
1981 }
1982 return;
1983 }
1984
1985
1987
1988 const std::vector<G4ModelingParameters::VisAttributesModifier>*
1990 if (privateVAMs) {
1991 std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator i;
1992 for (i = privateVAMs->begin(); i != privateVAMs->end(); ++i) {
1994 }
1995 }
1997
1999
2000 if (newValue.length() == 0) {
2001
2002 const G4int maxNoOfFiles = 100;
2003 static G4int sequenceNumber = 0;
2004 if (sequenceNumber >= maxNoOfFiles) {
2007 << "ERROR: G4VisCommandsViewerSave::SetNewValue: Maximum number, "
2008 << maxNoOfFiles
2009 << ", of files exceeded."
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
2021 WriteCommands(
G4cout,vp,stp);
2022 } else {
2023
2024 if (!G4StrUtil::contains(filename, '.')) {
2025
2026 filename += ".g4view";
2027 }
2028 std::ofstream ofs(filename);
2029 if (!ofs) {
2032 "ERROR: G4VisCommandsViewerSave::SetNewValue: Trouble opening file \""
2033 << filename << "\"."
2035 }
2036 ofs.close();
2037 return;
2038 }
2039 WriteCommands(ofs,vp,stp);
2040 ofs.close();
2041 }
2042
2044 G4warn <<
"Viewer \"" << currentViewer -> GetName ()
2045 << "\"" << " saved to ";
2046 if (filename == "-") {
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 }
2056 }
2057}
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()