Geant4  10.02.p03
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
 

Private Member Functions

 G4VisCommandViewerSave (const G4VisCommandViewerSave &)
 
G4VisCommandViewerSaveoperator= (const G4VisCommandViewerSave &)
 

Private Attributes

G4UIcmdWithAStringfpCommand
 

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 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 248 of file G4VisCommandsViewer.hh.

Constructor & Destructor Documentation

◆ G4VisCommandViewerSave() [1/2]

G4VisCommandViewerSave::G4VisCommandViewerSave ( )

Definition at line 1313 of file G4VisCommandsViewer.cc.

1313  {
1314  G4bool omitable;
1315  fpCommand = new G4UIcmdWithAString ("/vis/viewer/save", this);
1316  fpCommand -> SetGuidance
1317  ("Write commands that define the current view to file.");
1318  fpCommand -> SetGuidance
1319  ("Read them back into the same or any viewer with \"/control/execute <filename>\".");
1320  fpCommand -> SetParameterName ("file-name", omitable = true);
1321  fpCommand -> SetDefaultValue ("G4cout");
1322 }
bool G4bool
Definition: G4Types.hh:79
G4UIcmdWithAString * fpCommand

◆ ~G4VisCommandViewerSave()

G4VisCommandViewerSave::~G4VisCommandViewerSave ( )
virtual

Definition at line 1324 of file G4VisCommandsViewer.cc.

1324  {
1325  delete fpCommand;
1326 }
G4UIcmdWithAString * fpCommand
Here is the call graph for this function:

◆ G4VisCommandViewerSave() [2/2]

G4VisCommandViewerSave::G4VisCommandViewerSave ( const G4VisCommandViewerSave )
private

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandViewerSave::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 1329 of file G4VisCommandsViewer.cc.

1329  {
1330  return "";
1331 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

G4VisCommandViewerSave& G4VisCommandViewerSave::operator= ( const G4VisCommandViewerSave )
private

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 1348 of file G4VisCommandsViewer.cc.

1348  {
1349 
1351 
1352  const G4VViewer* currentViewer = fpVisManager->GetCurrentViewer();
1353  if (!currentViewer) {
1354  if (verbosity >= G4VisManager::errors) {
1355  G4cerr <<
1356  "ERROR: G4VisCommandsViewerSave::SetNewValue: no current viewer."
1357  << G4endl;
1358  }
1359  return;
1360  }
1361 
1362  const G4Scene* currentScene = currentViewer->GetSceneHandler()->GetScene();
1363  if (!currentScene) {
1364  if (verbosity >= G4VisManager::errors) {
1365  G4cerr <<
1366  "ERROR: G4VisCommandsViewerSave::SetNewValue: no current scene."
1367  << G4endl;
1368  }
1369  return;
1370  }
1371 
1372  std::ofstream ofs;
1373  if (newValue != "G4cout") {
1374  // Check if file exists
1375  std::ifstream ifs(newValue);
1376  if (ifs) {
1377  if (verbosity >= G4VisManager::errors) {
1378  G4cerr <<
1379  "ERROR: G4VisCommandsViewerSave::SetNewValue: File \""
1380  << newValue << "\" already exists."
1381  << G4endl;
1382  }
1383  ifs.close();
1384  return;
1385  }
1386  ofs.open(newValue);
1387  if (!ofs) {
1388  if (verbosity >= G4VisManager::errors) {
1389  G4cerr <<
1390  "ERROR: G4VisCommandsViewerSave::SetNewValue: Trouble opening file \""
1391  << newValue << "\"."
1392  << G4endl;
1393  }
1394  ofs.close();
1395  return;
1396  }
1397  }
1398 
1399  G4ViewParameters vp = currentViewer->GetViewParameters();
1400  // Concatenate any private vis attributes modifiers...
1401  const std::vector<G4ModelingParameters::VisAttributesModifier>*
1402  privateVAMs = currentViewer->GetPrivateVisAttributesModifiers();
1403  if (privateVAMs) {
1404  std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator i;
1405  for (i = privateVAMs->begin(); i != privateVAMs->end(); ++i) {
1406  vp.AddVisAttributesModifier(*i);
1407  }
1408  }
1409  const G4Point3D& stp = currentScene->GetStandardTargetPoint();
1410 
1411  if (newValue == "G4cout") {
1412  WriteCommands(G4cout,vp,stp);
1413  } else {
1414  WriteCommands(ofs,vp,stp);
1415  ofs.close();
1416  }
1417 
1418  if (verbosity >= G4VisManager::confirmations) {
1419  G4cout << "Viewer \"" << currentViewer -> GetName ()
1420  << "\"" << " saved to ";
1421  if (newValue == "G4cout") {
1422  G4cout << "G4cout.";
1423  } else {
1424  G4cout << "file \'" << newValue << "\"." <<
1425  "\n Read view parameters back into this or any viewer with"
1426  "\n \"/control/execute " << newValue << "\"";
1427  }
1428  G4cout << G4endl;
1429  }
1430 }
G4VViewer * GetCurrentViewer() const
G4Scene * GetScene() const
G4VSceneHandler * GetSceneHandler() const
G4GLOB_DLL std::ostream G4cout
const G4Point3D & GetStandardTargetPoint() const
virtual const std::vector< G4ModelingParameters::VisAttributesModifier > * GetPrivateVisAttributesModifiers() const
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
static Verbosity GetVerbosity()
const G4ViewParameters & GetViewParameters() const
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
static G4VisManager * fpVisManager
Here is the call graph for this function:

Member Data Documentation

◆ fpCommand

G4UIcmdWithAString* G4VisCommandViewerSave::fpCommand
private

Definition at line 257 of file G4VisCommandsViewer.hh.


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