Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VisCommandViewerSave Class Reference

#include <G4VisCommandsViewer.hh>

Inheritance diagram for G4VisCommandViewerSave:
Collaboration diagram for G4VisCommandViewerSave:

Public Member Functions

 G4VisCommandViewerSave ()
 
virtual ~G4VisCommandViewerSave ()
 
G4String GetCurrentValue (G4UIcommand *command)
 
void SetNewValue (G4UIcommand *command, G4String newValue)
 
- Public Member Functions inherited from G4VVisCommandViewer
 G4VVisCommandViewer ()
 
virtual ~G4VVisCommandViewer ()
 
- Public Member Functions inherited from G4VVisCommand
 G4VVisCommand ()
 
virtual ~G4VVisCommand ()
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
static void SetVisManager (G4VisManager *)
 
static const G4ColourGetCurrentColour ()
 
static G4double GetCurrentLineWidth ()
 
static const G4ColourGetCurrentTextColour ()
 
static G4Text::Layout GetCurrentTextLayout ()
 
static G4double GetCurrentTextSize ()
 
- Protected Member Functions inherited from G4VVisCommandViewer
void SetViewParameters (G4VViewer *, const G4ViewParameters &)
 
void RefreshIfRequired (G4VViewer *)
 
- Protected Member Functions inherited from G4VVisCommand
void UpdateVisManagerScene (const G4String &sceneName="")
 
- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4double StoD (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 void ConvertToDoublePair (const G4String &paramString, G4double &xval, G4double &yval)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir
 
G4String baseDirName
 
G4bool commandsShouldBeInMaster
 
- Static Protected Attributes inherited from G4VVisCommand
static G4VisManagerfpVisManager = 0
 
static G4int fErrorCode = 0
 
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
G4ModelingParameters::PVNameCopyNoPath 
fCurrentTouchablePath
 

Detailed Description

Definition at line 272 of file G4VisCommandsViewer.hh.

Constructor & Destructor Documentation

G4VisCommandViewerSave::G4VisCommandViewerSave ( )

Definition at line 1604 of file G4VisCommandsViewer.cc.

1604  {
1605  G4bool omitable;
1606  fpCommand = new G4UIcmdWithAString ("/vis/viewer/save", this);
1607  fpCommand -> SetGuidance
1608  ("Write commands that define the current view to file.");
1609  fpCommand -> SetGuidance
1610  ("Read them back into the same or any viewer with \"/control/execute\".");
1611  fpCommand -> SetGuidance
1612  ("If the filename is omitted the view is saved to a file "
1613  "\"g4_nn.g4view\", where nn is a sequential two-digit number.");
1614  fpCommand -> SetGuidance
1615  ("If the filename is \"-\", the data are written to G4cout.");
1616  fpCommand -> SetGuidance
1617  ("If you are wanting to save views for future interpolation a recommended "
1618  "procedure is: save views to \"g4_nn.g4view\", as above, then move the files "
1619  "into a sub-directory, say, \"views\", then interpolate with"
1620  "\"/vis/viewer/interpolate views/\" (note the trailing \'/\').");
1621  fpCommand -> SetParameterName ("filename", omitable = true);
1622  fpCommand -> SetDefaultValue ("");
1623 }
bool G4bool
Definition: G4Types.hh:79
G4VisCommandViewerSave::~G4VisCommandViewerSave ( )
virtual

Definition at line 1625 of file G4VisCommandsViewer.cc.

1625  {
1626  delete fpCommand;
1627 }

Member Function Documentation

G4String G4VisCommandViewerSave::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 1630 of file G4VisCommandsViewer.cc.

1630  {
1631  return "";
1632 }
void G4VisCommandViewerSave::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 1649 of file G4VisCommandsViewer.cc.

1649  {
1650 
1652 
1653  const G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
1654  if (!currentViewer) {
1655  if (verbosity >= G4VisManager::errors) {
1656  G4cerr <<
1657  "ERROR: G4VisCommandsViewerSave::SetNewValue: no current viewer."
1658  << G4endl;
1659  }
1660  return;
1661  }
1662 
1663  const G4Scene* currentScene = currentViewer->GetSceneHandler()->GetScene();
1664  if (!currentScene) {
1665  if (verbosity >= G4VisManager::errors) {
1666  G4cerr <<
1667  "ERROR: G4VisCommandsViewerSave::SetNewValue: no current scene."
1668  << G4endl;
1669  }
1670  return;
1671  }
1672 
1673  // Get view parameters and ther relevant information.
1674  G4ViewParameters vp = currentViewer->GetViewParameters();
1675  // Concatenate any private vis attributes modifiers...
1676  const std::vector<G4ModelingParameters::VisAttributesModifier>*
1677  privateVAMs = currentViewer->GetPrivateVisAttributesModifiers();
1678  if (privateVAMs) {
1679  std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator i;
1680  for (i = privateVAMs->begin(); i != privateVAMs->end(); ++i) {
1681  vp.AddVisAttributesModifier(*i);
1682  }
1683  }
1684  const G4Point3D& stp = currentScene->GetStandardTargetPoint();
1685 
1686  G4String filename = newValue;
1687  if (newValue.length() == 0) {
1688  // Null filename - generate a filename
1689  const G4int maxNoOfFiles = 100;
1690  static G4int sequenceNumber = 0;
1691  if (sequenceNumber >= maxNoOfFiles) {
1692  if (verbosity >= G4VisManager::errors) {
1693  G4cerr
1694  << "ERROR: G4VisCommandsViewerSave::SetNewValue: Maximum number, "
1695  << maxNoOfFiles
1696  << ", of files exceeded."
1697  << G4endl;
1698  }
1699  return;
1700  }
1701  std::ostringstream oss;
1702  oss << std::setw(2) << std::setfill('0') << sequenceNumber++;
1703  filename = "g4_" + oss.str() + ".g4view";
1704  }
1705 
1706  if (filename == "-") {
1707  // Write to standard output
1708  WriteCommands(G4cout,vp,stp);
1709  } else {
1710  // Write to file
1711  std::ofstream ofs(filename);
1712  if (!ofs) {
1713  if (verbosity >= G4VisManager::errors) {
1714  G4cerr <<
1715  "ERROR: G4VisCommandsViewerSave::SetNewValue: Trouble opening file \""
1716  << filename << "\"."
1717  << G4endl;
1718  }
1719  ofs.close();
1720  return;
1721  }
1722  WriteCommands(ofs,vp,stp);
1723  ofs.close();
1724  }
1725 
1726  if (verbosity >= G4VisManager::warnings) {
1727  G4cout << "Viewer \"" << currentViewer -> GetName ()
1728  << "\"" << " saved to ";
1729  if (filename == "-") {
1730  G4cout << "G4cout.";
1731  } else {
1732  G4cout << "file \'" << filename << "\"." <<
1733  "\n Read the view back into this or any viewer with"
1734  "\n \"/control/execute " << filename << "\" or use"
1735  "\n \"/vis/viewer/interpolate\" if you have several saved files -"
1736  "\n see \"help /vis/viewer/interpolate\" for guidance.";
1737  }
1738  G4cout << G4endl;
1739  }
1740 }
const G4ViewParameters & GetViewParameters() const
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
const G4Point3D & GetStandardTargetPoint() const
G4Scene * GetScene() const
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
G4VSceneHandler * GetSceneHandler() const
virtual const std::vector< G4ModelingParameters::VisAttributesModifier > * GetPrivateVisAttributesModifiers() const
static Verbosity GetVerbosity()
#define G4endl
Definition: G4ios.hh:61
G4VViewer * GetCurrentViewer() const
G4GLOB_DLL std::ostream G4cerr
static G4VisManager * fpVisManager

Here is the call graph for this function:


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