#include <G4VisCommandsSceneAdd.hh>
Inheritance diagram for G4VisCommandSceneAddText:
Public Member Functions | |
G4VisCommandSceneAddText () | |
virtual | ~G4VisCommandSceneAddText () |
G4String | GetCurrentValue (G4UIcommand *command) |
void | SetNewValue (G4UIcommand *command, G4String newValue) |
Definition at line 324 of file G4VisCommandsSceneAdd.hh.
G4VisCommandSceneAddText::G4VisCommandSceneAddText | ( | ) |
Definition at line 2078 of file G4VisCommandsSceneAdd.cc.
References G4UIparameter::SetDefaultValue(), G4UIparameter::SetGuidance(), and G4UIcommand::SetParameter().
02078 { 02079 G4bool omitable; 02080 fpCommand = new G4UIcommand ("/vis/scene/add/text", this); 02081 fpCommand -> SetGuidance ("Adds text to current scene."); 02082 fpCommand -> SetGuidance 02083 ("Use \"/vis/set/textColour\" to set colour."); 02084 fpCommand -> SetGuidance 02085 ("Use \"/vis/set/textLayout\" to set layout:"); 02086 G4UIparameter* parameter; 02087 parameter = new G4UIparameter ("x", 'd', omitable = true); 02088 parameter->SetDefaultValue (0); 02089 parameter->SetGuidance ("x"); 02090 fpCommand->SetParameter (parameter); 02091 parameter = new G4UIparameter ("y", 'd', omitable = true); 02092 parameter->SetDefaultValue (0); 02093 parameter->SetGuidance ("y"); 02094 fpCommand->SetParameter (parameter); 02095 parameter = new G4UIparameter ("z", 'd', omitable = true); 02096 parameter->SetDefaultValue (0); 02097 parameter->SetGuidance ("z"); 02098 fpCommand->SetParameter (parameter); 02099 parameter = new G4UIparameter ("unit", 's', omitable = true); 02100 parameter->SetDefaultValue ("m"); 02101 fpCommand->SetParameter (parameter); 02102 parameter = new G4UIparameter ("font_size", 'd', omitable = true); 02103 parameter->SetDefaultValue (12); 02104 parameter->SetGuidance ("pixels"); 02105 fpCommand->SetParameter (parameter); 02106 parameter = new G4UIparameter ("x_offset", 'd', omitable = true); 02107 parameter->SetDefaultValue (0); 02108 parameter->SetGuidance ("pixels"); 02109 fpCommand->SetParameter (parameter); 02110 parameter = new G4UIparameter ("y_offset", 'd', omitable = true); 02111 parameter->SetDefaultValue (0); 02112 parameter->SetGuidance ("pixels"); 02113 fpCommand->SetParameter (parameter); 02114 parameter = new G4UIparameter ("text", 's', omitable = true); 02115 parameter->SetGuidance ("The rest of the line is text."); 02116 parameter->SetDefaultValue ("Hello G4"); 02117 fpCommand->SetParameter (parameter); 02118 }
G4VisCommandSceneAddText::~G4VisCommandSceneAddText | ( | ) | [virtual] |
G4String G4VisCommandSceneAddText::GetCurrentValue | ( | G4UIcommand * | command | ) | [virtual] |
void G4VisCommandSceneAddText::SetNewValue | ( | G4UIcommand * | command, | |
G4String | newValue | |||
) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 2128 of file G4VisCommandsSceneAdd.cc.
References G4VisManager::confirmations, G4VisManager::errors, G4VVisCommand::fCurrentTextColour, G4VVisCommand::fCurrentTextLayout, G4VVisCommand::fpVisManager, G4cout, G4endl, G4VisManager::GetCurrentScene(), G4VisManager::GetVerbosity(), G4Text::SetLayout(), G4Text::SetOffset(), G4VMarker::SetScreenSize(), G4Visible::SetVisAttributes(), G4UImessenger::StoD(), G4VVisCommand::UpdateVisManagerScene(), G4UIcommand::ValueOf(), and G4VisManager::warnings.
02128 { 02129 02130 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 02131 G4bool warn = verbosity >= G4VisManager::warnings; 02132 02133 G4Scene* pScene = fpVisManager->GetCurrentScene(); 02134 if (!pScene) { 02135 if (verbosity >= G4VisManager::errors) { 02136 G4cout << "ERROR: No current scene. Please create one." << G4endl; 02137 } 02138 return; 02139 } 02140 02141 G4Tokenizer next(newValue); 02142 G4double x = StoD(next()); 02143 G4double y = StoD(next()); 02144 G4double z = StoD(next()); 02145 G4String unitString = next(); 02146 G4double font_size = StoD(next()); 02147 G4double x_offset = StoD(next()); 02148 G4double y_offset = StoD(next()); 02149 G4String text = next("\n"); 02150 02151 G4double unit = G4UIcommand::ValueOf(unitString); 02152 x *= unit; y *= unit; z *= unit; 02153 02154 G4Text g4text(text, G4Point3D(x,y,z)); 02155 G4VisAttributes visAtts(fCurrentTextColour); 02156 g4text.SetVisAttributes(visAtts); 02157 g4text.SetLayout(fCurrentTextLayout); 02158 g4text.SetScreenSize(font_size); 02159 g4text.SetOffset(x_offset,y_offset); 02160 G4VModel* model = new G4TextModel(g4text); 02161 const G4String& currentSceneName = pScene -> GetName (); 02162 G4bool successful = pScene -> AddRunDurationModel (model, warn); 02163 if (successful) { 02164 if (verbosity >= G4VisManager::confirmations) { 02165 G4cout << "Text \"" << text 02166 << "\" has been added to scene \"" << currentSceneName << "\"." 02167 << G4endl; 02168 } 02169 } 02170 else G4VisCommandsSceneAddUnsuccessful(verbosity); 02171 UpdateVisManagerScene (currentSceneName); 02172 }