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

#include <G4VisCommandsSceneAdd.hh>

Inheritance diagram for G4VisCommandSceneAddLocalAxes:

Public Member Functions

 G4VisCommandSceneAddLocalAxes ()
virtual ~G4VisCommandSceneAddLocalAxes ()
G4String GetCurrentValue (G4UIcommand *command)
void SetNewValue (G4UIcommand *command, G4String newValue)
Public Member Functions inherited from G4VVisCommandScene
 G4VVisCommandScene ()
virtual ~G4VVisCommandScene ()
Public Member Functions inherited from G4VVisCommand
 G4VVisCommand ()
virtual ~G4VVisCommand ()
Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
virtual ~G4UImessenger ()
G4bool CommandsShouldBeInMaster () const

Additional Inherited Members

Static Public Member Functions inherited from G4VVisCommand
static G4VisManagerGetVisManager ()
static void SetVisManager (G4VisManager *pVisManager)
static const G4ColourGetCurrentTextColour ()
Protected Member Functions inherited from G4VVisCommandScene
G4String CurrentSceneName ()
Protected Member Functions inherited from G4VVisCommand
void SetViewParameters (G4VViewer *viewer, const G4ViewParameters &viewParams)
void RefreshIfRequired (G4VViewer *viewer)
void InterpolateViews (G4VViewer *currentViewer, const std::vector< G4ViewParameters > &viewVector, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String &exportString="")
void InterpolateToNewView (G4VViewer *currentViewer, const G4ViewParameters &oldVP, const G4ViewParameters &newVP, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String &exportString="")
void Twinkle (G4VViewer *currentViewer, const G4ViewParameters &baseVP, const std::vector< std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > > &paths)
const G4StringConvertToColourGuidance ()
void ConvertToColour (G4Colour &colour, const G4String &redOrString, G4double green, G4double blue, G4double opacity)
G4bool ProvideValueOfUnit (const G4String &where, const G4String &unit, const G4String &category, G4double &value)
void CopyCameraParameters (G4ViewParameters &target, const G4ViewParameters &from)
void CheckSceneAndNotifyHandlers (G4Scene *=nullptr)
G4bool CheckView ()
void G4VisCommandsSceneAddUnsuccessful (G4VisManager::Verbosity verbosity)
void CopyGuidanceFrom (const G4UIcommand *fromCmd, G4UIcommand *toCmd, G4int startLine=0)
void CopyParametersFrom (const G4UIcommand *fromCmd, G4UIcommand *toCmd)
void DrawExtent (const G4VisExtent &)
Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
G4String LtoS (G4long l)
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 (const 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)
Static Protected Member Functions inherited from G4VVisCommand
static G4String ConvertToString (G4double x, G4double y, const char *unitName)
static G4bool ConvertToDoublePair (const G4String &paramString, G4double &xval, G4double &yval)
Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
G4String baseDirName = ""
G4bool commandsShouldBeInMaster = false
Static Protected Attributes inherited from G4VVisCommand
static G4VisManagerfpVisManager = nullptr
static G4int fCurrentArrow3DLineSegmentsPerCircle = 6
static G4Colour fCurrentColour = G4Colour::White()
static G4double fCurrentLineWidth = 1.
static G4Colour fCurrentTextColour = G4Colour::Blue()
static G4Text::Layout fCurrentTextLayout = G4Text::left
static G4double fCurrentTextSize = 12.
static G4PhysicalVolumeModel::TouchableProperties fCurrentTouchableProperties
static G4VisExtent fCurrentExtentForField
static std::vector< G4PhysicalVolumesSearchScene::FindingsfCurrrentPVFindingsForField
static G4bool fThereWasAViewer = false
static G4ViewParameters fExistingVP
static G4SceneTreeItem fExistingSceneTree

Detailed Description

Definition at line 303 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneAddLocalAxes()

G4VisCommandSceneAddLocalAxes::G4VisCommandSceneAddLocalAxes ( )

Definition at line 1308 of file G4VisCommandsSceneAdd.cc.

1308 {
1309 G4bool omitable;
1310 fpCommand = new G4UIcommand ("/vis/scene/add/localAxes", this);
1311 fpCommand -> SetGuidance
1312 ("Adds local axes to physical volume(s).");
1313 G4UIparameter* parameter;
1314 parameter = new G4UIparameter ("physical-volume-name", 's', omitable = false);
1315 fpCommand -> SetParameter (parameter);
1316 parameter = new G4UIparameter ("copy-no", 'i', omitable = true);
1317 parameter -> SetGuidance ("If negative, matches any copy no.");
1318 parameter -> SetDefaultValue (-1);
1319 fpCommand -> SetParameter (parameter);
1320}
bool G4bool
Definition G4Types.hh:86

◆ ~G4VisCommandSceneAddLocalAxes()

G4VisCommandSceneAddLocalAxes::~G4VisCommandSceneAddLocalAxes ( )
virtual

Definition at line 1322 of file G4VisCommandsSceneAdd.cc.

1322 {
1323 delete fpCommand;
1324}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneAddLocalAxes::GetCurrentValue ( G4UIcommand * command)
virtual

Reimplemented from G4UImessenger.

Definition at line 1326 of file G4VisCommandsSceneAdd.cc.

1326 {
1327 return "world 0 -1";
1328}

◆ SetNewValue()

void G4VisCommandSceneAddLocalAxes::SetNewValue ( G4UIcommand * command,
G4String newValue )
virtual

Reimplemented from G4UImessenger.

Definition at line 1330 of file G4VisCommandsSceneAdd.cc.

1331 {
1332
1333 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1334 G4bool warn = verbosity >= G4VisManager::warnings;
1335
1336 G4Scene* pScene = fpVisManager->GetCurrentScene();
1337 if (!pScene) {
1338 if (verbosity >= G4VisManager::errors) {
1339 G4warn << "ERROR: No current scene. Please create one." << G4endl;
1340 }
1341 return;
1342 }
1343
1344 G4String name;
1345 G4int copyNo;
1346 std::istringstream is (newValue);
1347 is >> name >> copyNo;
1348
1349 std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
1350
1351 // Search all worlds...
1352 G4TransportationManager* transportationManager =
1354 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
1355 transportationManager->GetWorldsIterator();
1356 size_t nWorlds = transportationManager->GetNoWorlds();
1357 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
1358 G4ModelingParameters mp; // Default - no culling.
1359 G4PhysicalVolumeModel searchModel
1360 (*iterWorld,
1362 G4Transform3D(),
1363 &mp,
1364 true); // Use full extent (avoids initial descent of geometry tree)
1365 G4PhysicalVolumesSearchScene searchScene
1366 (&searchModel, name, copyNo);
1367 searchModel.DescribeYourselfTo (searchScene); // Initiate search.
1368 for (const auto& findings: searchScene.GetFindings()) {
1369 findingsVector.push_back(findings);
1370 }
1371 }
1372
1373 G4int id = 0; // To distinguish axes models by their global description
1374 for (const auto& findings: findingsVector) {
1375
1376 // Create axes model based on size and transformation of found volume(s).
1377 const auto& extent = findings.fpFoundPV->GetLogicalVolume()->GetSolid()->GetExtent();
1378 const auto& transform = findings.fFoundObjectTransformation;
1379
1380 const G4double lengthMax = extent.GetExtentRadius()/2.;
1381 const G4double intLog10LengthMax = std::floor(std::log10(lengthMax));
1382 G4double length = std::pow(10,intLog10LengthMax);
1383 if (5.*length < lengthMax) length *= 5.;
1384 else if (2.*length < lengthMax) length *= 2.;
1385
1386 const auto& axesModel = new G4AxesModel(0.,0.,0.,length,transform);
1387 axesModel->SetGlobalTag("LocalAxesModel");
1388 std::ostringstream oss; oss
1389 << "Local Axes for " << findings.fpFoundPV->GetName()
1390 << ':' << findings.fFoundPVCopyNo << ':' << id++;
1391 axesModel->SetGlobalDescription(oss.str());
1392 // ...so add it to the scene.
1393 G4bool successful = pScene->AddRunDurationModel(axesModel,warn);
1394 if (successful) {
1395 if (verbosity >= G4VisManager::confirmations) {
1396 G4cout << "\"" << findings.fpFoundPV->GetName()
1397 << "\", copy no. " << findings.fFoundPVCopyNo
1398 << ",\n found in searched volume \""
1399 << findings.fpSearchPV->GetName()
1400 << "\" at depth " << findings.fFoundDepth
1401 << ",\n base path: \"" << findings.fFoundBasePVPath
1402 << "\".\n Local axes have been added to scene \""
1403 << pScene->GetName() << "\".";
1404 if (verbosity >= G4VisManager::parameters) {
1405 G4cout << " With extent " << extent
1406 << "\n at " << transform.getRotation()
1407 << " " << transform.getTranslation();
1408 }
1409 G4cout << G4endl;
1410 }
1411 } else {
1413 }
1414 }
1415
1416 if (findingsVector.empty()) {
1417 if (verbosity >= G4VisManager::errors) {
1418 G4warn << "ERROR: Volume \"" << name << "\"";
1419 if (copyNo >= 0) {
1420 G4warn << ", copy no. " << copyNo << ",";
1421 }
1422 G4warn << " not found." << G4endl;
1423 }
1425 return;
1426 }
1427
1429}
#define G4warn
Definition G4Scene.cc:41
HepGeom::Transform3D G4Transform3D
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4bool AddRunDurationModel(G4VModel *, G4bool warn=false)
Definition G4Scene.cc:160
const G4String & GetName() const
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
std::size_t GetNoWorlds() const
void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity)
void CheckSceneAndNotifyHandlers(G4Scene *=nullptr)
static G4VisManager * fpVisManager
const char * name(G4int ptype)

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