Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VtkMessenger Class Reference

#include <G4VtkMessenger.hh>

+ Inheritance diagram for G4VtkMessenger:

Public Member Functions

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

Static Public Member Functions

static G4VtkMessengerGetInstance ()
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
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 (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)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Detailed Description

Definition at line 38 of file G4VtkMessenger.hh.

Constructor & Destructor Documentation

◆ ~G4VtkMessenger()

G4VtkMessenger::~G4VtkMessenger ( )
virtual

Definition at line 73 of file G4VtkMessenger.cc.

74{
75 delete fpDirectory;
76 delete fpCommandExport;
77 delete fpCommandWarnings;
78}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VtkMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 79 of file G4VtkMessenger.cc.

79 {
80 return G4String();
81}

◆ GetInstance()

G4VtkMessenger * G4VtkMessenger::GetInstance ( )
static

Definition at line 42 of file G4VtkMessenger.cc.

43{
44 if (!fpInstance) fpInstance = new G4VtkMessenger;
45 return fpInstance;
46}

Referenced by G4Vtk::G4Vtk().

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 83 of file G4VtkMessenger.cc.

84{
85
87
88 G4VViewer* pViewer = pVisManager->GetCurrentViewer();
89 if (!pViewer) {
90 G4cout << "G4VtkMessenger::SetNewValue: No current viewer.\n"
91 << "\"/vis/open\", or similar, to get one."
92 << G4endl;
93 return;
94 }
95
96 auto* pVtkViewer = dynamic_cast<G4VtkViewer*>(pViewer);
97 if (!pVtkViewer) {
98 G4cout << "G4VtkMessenger::SetNewValue: Current viewer is not of type VTK. \n"
99 << "(It is \""
100 << pViewer->GetName()
101 << "\".)\n"
102 << "Use \"/vis/viewer/select\" or \"/vis/open\"."
103 << G4endl;
104 return;
105 }
106
107 if (command == fpCommandExport)
108 {
109 G4String format, name;
110
111 std::istringstream iss(newValue);
112 iss >> format >> name;
113
114 if(format == "jpg" || format == "tiff" ||
115 format == "png" || format == "bmp" ||
116 format == "pnm" || format == "ps")
117 pVtkViewer->ExportScreenShot(name, format);
118 else if(format == "obj")
119 pVtkViewer->ExportOBJScene(name);
120 else if(format == "vrml")
121 pVtkViewer->ExportVRMLScene(name);
122 else if(format == "vtp")
123 pVtkViewer->ExportVTPScene(name);
124 else
125 G4cout << "Unknown /vis/vtk/export file format" << G4endl;
126 }
127 else if (command == fpCommandWarnings)
128 {
129 vtkObject::GlobalWarningDisplayOff();
130 }
131}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
G4VViewer * GetCurrentViewer() const
static G4VisManager * GetInstance()
const char * name(G4int ptype)

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