#include <G4VisCommandsSceneAdd.hh>
Inheritance diagram for G4VisCommandSceneAddDate:
Public Member Functions | |
G4VisCommandSceneAddDate () | |
virtual | ~G4VisCommandSceneAddDate () |
G4String | GetCurrentValue (G4UIcommand *command) |
void | SetNewValue (G4UIcommand *command, G4String newValue) |
Data Structures | |
struct | Date |
Definition at line 91 of file G4VisCommandsSceneAdd.hh.
G4VisCommandSceneAddDate::G4VisCommandSceneAddDate | ( | ) |
Definition at line 360 of file G4VisCommandsSceneAdd.cc.
00360 { 00361 G4bool omitable; 00362 fpCommand = new G4UIcommand ("/vis/scene/add/date", this); 00363 fpCommand -> SetGuidance ("Adds date to current scene."); 00364 G4UIparameter* parameter; 00365 parameter = new G4UIparameter ("size", 'i', omitable = true); 00366 parameter -> SetGuidance ("Screen size of text in pixels."); 00367 parameter -> SetDefaultValue (18); 00368 fpCommand -> SetParameter (parameter); 00369 parameter = new G4UIparameter ("x-position", 'd', omitable = true); 00370 parameter -> SetGuidance ("x screen position in range -1 < x < 1."); 00371 parameter -> SetDefaultValue (0.0); // Would prefer 0.95 right. 00372 fpCommand -> SetParameter (parameter); 00373 parameter = new G4UIparameter ("y-position", 'd', omitable = true); 00374 parameter -> SetGuidance ("y screen position in range -1 < y < 1."); 00375 parameter -> SetDefaultValue (0.9); 00376 fpCommand -> SetParameter (parameter); 00377 parameter = new G4UIparameter ("layout", 's', omitable = true); 00378 parameter -> SetGuidance ("Layout, i.e., adjustment: left|centre|right."); 00379 parameter -> SetDefaultValue ("left"); // Would prefer right. 00380 fpCommand -> SetParameter (parameter); 00381 parameter = new G4UIparameter ("date", 's', omitable = true); 00382 parameter -> SetGuidance 00383 ("The date you want to appear on the view of the scene (this includes the" 00384 "\nrest of the line, including spaces). The default, \'-\', writes the" 00385 "\ndate and time of the moment of drawing."); 00386 parameter -> SetDefaultValue ("-"); 00387 fpCommand -> SetParameter (parameter); 00388 }
G4VisCommandSceneAddDate::~G4VisCommandSceneAddDate | ( | ) | [virtual] |
G4String G4VisCommandSceneAddDate::GetCurrentValue | ( | G4UIcommand * | command | ) | [virtual] |
void G4VisCommandSceneAddDate::SetNewValue | ( | G4UIcommand * | command, | |
G4String | newValue | |||
) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 398 of file G4VisCommandsSceneAdd.cc.
References G4Text::centre, G4VisManager::confirmations, G4VisManager::errors, G4VVisCommand::fpVisManager, G4cout, G4endl, G4VisManager::GetCurrentScene(), G4VisManager::GetVerbosity(), G4Text::left, G4Text::right, G4VModel::SetGlobalDescription(), G4VModel::SetGlobalTag(), G4VModel::SetType(), G4VVisCommand::UpdateVisManagerScene(), and G4VisManager::warnings.
00399 { 00400 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 00401 G4bool warn(verbosity >= G4VisManager::warnings); 00402 00403 G4Scene* pScene = fpVisManager->GetCurrentScene(); 00404 if (!pScene) { 00405 if (verbosity >= G4VisManager::errors) { 00406 G4cout << "ERROR: No current scene. Please create one." << G4endl; 00407 } 00408 return; 00409 } 00410 00411 G4int size; 00412 G4double x, y; 00413 G4String layoutString, dateString; 00414 std::istringstream is(newValue); 00415 is >> size >> x >> y >> layoutString >> dateString; 00416 // Read rest of line, if any. 00417 const size_t NREMAINDER = 100; 00418 char remainder[NREMAINDER]; 00419 is.getline(remainder, NREMAINDER); 00420 dateString += remainder; 00421 G4Text::Layout layout = G4Text::right; 00422 if (layoutString(0) == 'l') layout = G4Text::left; 00423 else if (layoutString(0) == 'c') layout = G4Text::centre; 00424 else if (layoutString(0) == 'r') layout = G4Text::right; 00425 00426 Date* date = new Date(fpVisManager, size, x, y, layout, dateString); 00427 G4VModel* model = 00428 new G4CallbackModel<G4VisCommandSceneAddDate::Date>(date); 00429 model->SetType("Date"); 00430 model->SetGlobalTag("Date"); 00431 model->SetGlobalDescription("Date"); 00432 const G4String& currentSceneName = pScene -> GetName (); 00433 G4bool successful = pScene -> AddRunDurationModel (model, warn); 00434 if (successful) { 00435 if (verbosity >= G4VisManager::confirmations) { 00436 G4cout << "Date has been added to scene \"" 00437 << currentSceneName << "\"." 00438 << G4endl; 00439 } 00440 } 00441 else G4VisCommandsSceneAddUnsuccessful(verbosity); 00442 UpdateVisManagerScene (currentSceneName); 00443 }