#include <G4VisCommandsSceneAdd.hh>
Inheritance diagram for G4VisCommandSceneAddAxes:
Public Member Functions | |
G4VisCommandSceneAddAxes () | |
virtual | ~G4VisCommandSceneAddAxes () |
G4String | GetCurrentValue (G4UIcommand *command) |
void | SetNewValue (G4UIcommand *command, G4String newValue) |
Definition at line 79 of file G4VisCommandsSceneAdd.hh.
G4VisCommandSceneAddAxes::G4VisCommandSceneAddAxes | ( | ) |
Definition at line 264 of file G4VisCommandsSceneAdd.cc.
References G4UIparameter::SetDefaultValue(), G4UIparameter::SetGuidance(), and G4UIcommand::SetParameter().
00264 { 00265 G4bool omitable; 00266 fpCommand = new G4UIcommand ("/vis/scene/add/axes", this); 00267 fpCommand -> SetGuidance ("Add axes."); 00268 fpCommand -> SetGuidance 00269 ("Draws axes at (x0, y0, z0) of given length and colour."); 00270 G4UIparameter* parameter; 00271 parameter = new G4UIparameter ("x0", 'd', omitable = true); 00272 parameter->SetDefaultValue (0.); 00273 fpCommand->SetParameter (parameter); 00274 parameter = new G4UIparameter ("y0", 'd', omitable = true); 00275 parameter->SetDefaultValue (0.); 00276 fpCommand->SetParameter (parameter); 00277 parameter = new G4UIparameter ("z0", 'd', omitable = true); 00278 parameter->SetDefaultValue (0.); 00279 fpCommand->SetParameter (parameter); 00280 parameter = new G4UIparameter ("length", 'd', omitable = true); 00281 parameter->SetDefaultValue (-1.); 00282 parameter->SetGuidance 00283 ("If negative, length automatic, about 25% of scene extent."); 00284 fpCommand->SetParameter (parameter); 00285 parameter = new G4UIparameter ("unit", 's', omitable = true); 00286 parameter->SetDefaultValue ("m"); 00287 fpCommand->SetParameter (parameter); 00288 parameter = new G4UIparameter ("unitcolour", 's', omitable = true); 00289 parameter->SetDefaultValue ("auto"); 00290 parameter->SetGuidance 00291 ("If \"auto\", x, y and z will be red, green and blue respectively."); 00292 parameter->SetGuidance 00293 ("Otherwise choose from the pre-defined text-specified colours - " 00294 "\n see information printed by the vis manager at start-up or" 00295 "\n use \"/vis/list\"."); 00296 fpCommand->SetParameter (parameter); 00297 }
G4VisCommandSceneAddAxes::~G4VisCommandSceneAddAxes | ( | ) | [virtual] |
G4String G4VisCommandSceneAddAxes::GetCurrentValue | ( | G4UIcommand * | command | ) | [virtual] |
void G4VisCommandSceneAddAxes::SetNewValue | ( | G4UIcommand * | command, | |
G4String | newValue | |||
) | [virtual] |
Reimplemented from G4UImessenger.
Definition at line 307 of file G4VisCommandsSceneAdd.cc.
References G4VisManager::confirmations, G4VisManager::errors, G4VVisCommand::fCurrentLineWidth, G4VVisCommand::fpVisManager, G4BestUnit, G4cout, G4endl, G4VisManager::GetCurrentScene(), G4Scene::GetExtent(), G4VisExtent::GetExtentRadius(), G4VisManager::GetVerbosity(), G4VVisCommand::UpdateVisManagerScene(), G4UIcommand::ValueOf(), and G4VisManager::warnings.
00307 { 00308 00309 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 00310 G4bool warn(verbosity >= G4VisManager::warnings); 00311 00312 G4Scene* pScene = fpVisManager->GetCurrentScene(); 00313 if (!pScene) { 00314 if (verbosity >= G4VisManager::errors) { 00315 G4cout << "ERROR: No current scene. Please create one." << G4endl; 00316 } 00317 return; 00318 } 00319 00320 G4String unitString, colourString; 00321 G4double x0, y0, z0, length; 00322 std::istringstream is (newValue); 00323 is >> x0 >> y0 >> z0 >> length >> unitString >> colourString; 00324 00325 G4double unit = G4UIcommand::ValueOf(unitString); 00326 x0 *= unit; y0 *= unit; z0 *= unit; 00327 const G4VisExtent& sceneExtent = pScene->GetExtent(); // Existing extent. 00328 if (length < 0.) { 00329 length = 0.5 * sceneExtent.GetExtentRadius(); 00330 G4double intLog10Length = std::floor(std::log10(length)); 00331 length = std::pow(10,intLog10Length); 00332 } else { 00333 length *= unit; 00334 } 00335 G4String annotation = G4BestUnit(length,"Length"); 00336 00337 // Consult scene for arrow width... 00338 G4double arrowWidth = 00339 0.005 * fCurrentLineWidth * sceneExtent.GetExtentRadius(); 00340 // ...but limit it to length/50. 00341 if (arrowWidth > length/50.) arrowWidth = length/50.; 00342 00343 G4VModel* model = new G4AxesModel 00344 (x0, y0, z0, length, arrowWidth, colourString, newValue); 00345 00346 G4bool successful = pScene -> AddRunDurationModel (model, warn); 00347 const G4String& currentSceneName = pScene -> GetName (); 00348 if (successful) { 00349 if (verbosity >= G4VisManager::confirmations) { 00350 G4cout << "Axes have been added to scene \"" << currentSceneName << "\"." 00351 << G4endl; 00352 } 00353 } 00354 else G4VisCommandsSceneAddUnsuccessful(verbosity); 00355 UpdateVisManagerScene (currentSceneName); 00356 }