G4VisCommandSceneAddText2D Class Reference

#include <G4VisCommandsSceneAdd.hh>

Inheritance diagram for G4VisCommandSceneAddText2D:

G4VVisCommandScene G4VVisCommand G4UImessenger

Public Member Functions

 G4VisCommandSceneAddText2D ()
virtual ~G4VisCommandSceneAddText2D ()
G4String GetCurrentValue (G4UIcommand *command)
void SetNewValue (G4UIcommand *command, G4String newValue)

Data Structures

struct  G4Text2D

Detailed Description

Definition at line 336 of file G4VisCommandsSceneAdd.hh.


Constructor & Destructor Documentation

G4VisCommandSceneAddText2D::G4VisCommandSceneAddText2D (  ) 

Definition at line 2177 of file G4VisCommandsSceneAdd.cc.

References G4UIparameter::SetDefaultValue(), G4UIparameter::SetGuidance(), and G4UIcommand::SetParameter().

02177                                                         {
02178   G4bool omitable;
02179   fpCommand = new G4UIcommand ("/vis/scene/add/text2D", this);
02180   fpCommand -> SetGuidance ("Adds 2D text to current scene.");
02181   fpCommand -> SetGuidance
02182     ("Use \"/vis/set/textColour\" to set colour.");
02183   fpCommand -> SetGuidance
02184     ("Use \"/vis/set/textLayout\" to set layout:");
02185   G4UIparameter* parameter;
02186   parameter = new G4UIparameter ("x", 'd', omitable = true);
02187   parameter->SetDefaultValue (0);
02188   parameter->SetGuidance ("x");
02189   fpCommand->SetParameter (parameter);
02190   parameter =  new G4UIparameter ("y", 'd', omitable = true);
02191   parameter->SetDefaultValue (0);
02192   parameter->SetGuidance ("y");
02193   fpCommand->SetParameter (parameter);
02194   parameter =  new G4UIparameter ("font_size", 'd', omitable = true);
02195   parameter->SetDefaultValue (12);
02196   parameter->SetGuidance ("pixels");
02197   fpCommand->SetParameter (parameter);
02198   parameter =  new G4UIparameter ("x_offset", 'd', omitable = true);
02199   parameter->SetDefaultValue (0);
02200   parameter->SetGuidance ("pixels");
02201   fpCommand->SetParameter (parameter);
02202   parameter =  new G4UIparameter ("y_offset", 'd', omitable = true);
02203   parameter->SetDefaultValue (0);
02204   parameter->SetGuidance ("pixels");
02205   fpCommand->SetParameter (parameter);
02206   parameter =  new G4UIparameter ("text", 's', omitable = true);
02207   parameter->SetGuidance ("The rest of the line is text.");
02208   parameter->SetDefaultValue ("Hello G4");
02209   fpCommand->SetParameter (parameter);
02210 }

G4VisCommandSceneAddText2D::~G4VisCommandSceneAddText2D (  )  [virtual]

Definition at line 2212 of file G4VisCommandsSceneAdd.cc.

02212                                                          {
02213   delete fpCommand;
02214 }


Member Function Documentation

G4String G4VisCommandSceneAddText2D::GetCurrentValue ( G4UIcommand command  )  [virtual]

Reimplemented from G4UImessenger.

Definition at line 2216 of file G4VisCommandsSceneAdd.cc.

02216                                                                   {
02217   return "";
02218 }

void G4VisCommandSceneAddText2D::SetNewValue ( G4UIcommand command,
G4String  newValue 
) [virtual]

Reimplemented from G4UImessenger.

Definition at line 2220 of file G4VisCommandsSceneAdd.cc.

References G4VisManager::confirmations, G4VisManager::errors, G4VVisCommand::fCurrentTextColour, G4VVisCommand::fCurrentTextLayout, G4VVisCommand::fpVisManager, G4cout, G4endl, G4VisManager::GetCurrentScene(), G4VisManager::GetVerbosity(), G4VModel::SetGlobalDescription(), G4VModel::SetGlobalTag(), G4Text::SetLayout(), G4Text::SetOffset(), G4VMarker::SetScreenSize(), G4VModel::SetType(), G4Visible::SetVisAttributes(), G4UImessenger::StoD(), G4VVisCommand::UpdateVisManagerScene(), and G4VisManager::warnings.

02220                                                                              {
02221 
02222   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
02223   G4bool warn = verbosity >= G4VisManager::warnings;
02224 
02225   G4Scene* pScene = fpVisManager->GetCurrentScene();
02226   if (!pScene) {
02227     if (verbosity >= G4VisManager::errors) {
02228       G4cout << "ERROR: No current scene.  Please create one." << G4endl;
02229     }
02230     return;
02231   }
02232 
02233   G4Tokenizer next(newValue);
02234   G4double x = StoD(next());
02235   G4double y = StoD(next());
02236   G4double font_size = StoD(next());
02237   G4double x_offset = StoD(next());
02238   G4double y_offset = StoD(next());
02239   G4String text = next("\n");
02240 
02241   G4Text g4text(text, G4Point3D(x,y,0.));
02242   G4VisAttributes visAtts(fCurrentTextColour);
02243   g4text.SetVisAttributes(visAtts);
02244   g4text.SetLayout(fCurrentTextLayout);
02245   g4text.SetScreenSize(font_size);
02246   g4text.SetOffset(x_offset,y_offset);
02247   G4Text2D* g4text2D = new G4Text2D(g4text);
02248   G4VModel* model =
02249     new G4CallbackModel<G4VisCommandSceneAddText2D::G4Text2D>(g4text2D);
02250   model->SetType("Text2D");
02251   model->SetGlobalTag("Text2D");
02252   model->SetGlobalDescription("Text2D: " + newValue);
02253   const G4String& currentSceneName = pScene -> GetName ();
02254   G4bool successful = pScene -> AddRunDurationModel (model, warn);
02255   if (successful) {
02256     if (verbosity >= G4VisManager::confirmations) {
02257       G4cout << "2D text \"" << text
02258              << "\" has been added to scene \"" << currentSceneName << "\"."
02259              << G4endl;
02260     }
02261   }
02262   else G4VisCommandsSceneAddUnsuccessful(verbosity);
02263   UpdateVisManagerScene (currentSceneName);
02264 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:45 2013 for Geant4 by  doxygen 1.4.7