Geant4 11.3.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4VisCommandSceneAddLogicalVolume Class Reference

#include <G4VisCommandsSceneAdd.hh>

+ Inheritance diagram for G4VisCommandSceneAddLogicalVolume:

Public Member Functions

 G4VisCommandSceneAddLogicalVolume ()
 
virtual ~G4VisCommandSceneAddLogicalVolume ()
 
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 298 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneAddLogicalVolume()

G4VisCommandSceneAddLogicalVolume::G4VisCommandSceneAddLogicalVolume ( )

Definition at line 1374 of file G4VisCommandsSceneAdd.cc.

1374 {
1375 G4bool omitable;
1376 fpCommand = new G4UIcommand ("/vis/scene/add/logicalVolume", this);
1377 fpCommand -> SetGuidance ("Adds a logical volume to the current scene,");
1378 fpCommand -> SetGuidance
1379 ("Shows boolean components (if any), voxels (if any), readout geometry"
1380 "\n (if any), local axes and overlaps (if any), under control of the"
1381 "\n appropriate flag."
1382 "\n Note: voxels are not constructed until start of run -"
1383 "\n \"/run/beamOn\". (For voxels without a run, \"/run/beamOn 0\".)");
1384 G4UIparameter* parameter;
1385 parameter = new G4UIparameter ("logical-volume-name", 's', omitable = false);
1386 fpCommand -> SetParameter (parameter);
1387 parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
1388 parameter -> SetGuidance ("Depth of descent of geometry hierarchy.");
1389 parameter -> SetDefaultValue (1);
1390 fpCommand -> SetParameter (parameter);
1391 parameter = new G4UIparameter ("booleans-flag", 'b', omitable = true);
1392 parameter -> SetDefaultValue (true);
1393 fpCommand -> SetParameter (parameter);
1394 parameter = new G4UIparameter ("voxels-flag", 'b', omitable = true);
1395 parameter -> SetDefaultValue (true);
1396 fpCommand -> SetParameter (parameter);
1397 parameter = new G4UIparameter ("readout-flag", 'b', omitable = true);
1398 parameter -> SetDefaultValue (true);
1399 fpCommand -> SetParameter (parameter);
1400 parameter = new G4UIparameter ("axes-flag", 'b', omitable = true);
1401 parameter -> SetDefaultValue (true);
1402 parameter -> SetGuidance ("Set \"false\" to suppress axes.");
1403 fpCommand -> SetParameter (parameter);
1404 parameter = new G4UIparameter("check-overlap-flag", 'b', omitable = true);
1405 parameter->SetDefaultValue(true);
1406 parameter -> SetGuidance ("Set \"false\" to suppress overlap check.");
1407 fpCommand->SetParameter(parameter);
1408}
bool G4bool
Definition G4Types.hh:86
void SetDefaultValue(const char *theDefaultValue)

◆ ~G4VisCommandSceneAddLogicalVolume()

G4VisCommandSceneAddLogicalVolume::~G4VisCommandSceneAddLogicalVolume ( )
virtual

Definition at line 1410 of file G4VisCommandsSceneAdd.cc.

1410 {
1411 delete fpCommand;
1412}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneAddLogicalVolume::GetCurrentValue ( G4UIcommand * command)
virtual

Reimplemented from G4UImessenger.

Definition at line 1414 of file G4VisCommandsSceneAdd.cc.

1414 {
1415 return "";
1416}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 1418 of file G4VisCommandsSceneAdd.cc.

1419 {
1420
1421 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1422 G4bool warn(verbosity >= G4VisManager::warnings);
1423
1424 G4Scene* pScene = fpVisManager->GetCurrentScene();
1425 if (!pScene) {
1426 if (verbosity >= G4VisManager::errors) {
1427 G4warn << "ERROR: No current scene. Please create one." << G4endl;
1428 }
1429 return;
1430 }
1431
1432 G4String name;
1433 G4int requestedDepthOfDescent;
1434 G4String booleansString, voxelsString, readoutString, axesString;
1435 G4String overlapString;
1436 std::istringstream is (newValue);
1437 is >> name >> requestedDepthOfDescent
1438 >> booleansString >> voxelsString >> readoutString >> axesString
1439 >> overlapString;
1440 G4bool booleans = G4UIcommand::ConvertToBool(booleansString);
1441 G4bool voxels = G4UIcommand::ConvertToBool(voxelsString);
1442 G4bool readout = G4UIcommand::ConvertToBool(readoutString);
1443 G4bool axes = G4UIcommand::ConvertToBool(axesString);
1444 G4bool checkOverlaps = G4UIcommand::ConvertToBool(overlapString);
1445
1446 G4LogicalVolumeStore *pLVStore = G4LogicalVolumeStore::GetInstance();
1447 G4LogicalVolume* pLV = nullptr;
1448 pLV = pLVStore->GetVolume(name);
1449 if (pLV == nullptr) return; // Volume not found; warning message thrown
1450
1451 const std::vector<G4Scene::Model>& rdModelList =
1452 pScene -> GetRunDurationModelList();
1453 std::vector<G4Scene::Model>::const_iterator i;
1454 for (i = rdModelList.begin(); i != rdModelList.end(); ++i) {
1455 if (i->fpModel->GetGlobalDescription().find("Volume") != std::string::npos) break;
1456 }
1457 if (i != rdModelList.end()) {
1458 if (verbosity >= G4VisManager::errors) {
1459 G4warn << "There is already a volume, \""
1460 << i->fpModel->GetGlobalDescription()
1461 << "\",\n in the run-duration model list of scene \""
1462 << pScene -> GetName()
1463 << "\".\n Your logical volume must be the only volume in the scene."
1464 << "\n Create a new scene and try again:"
1465 << "\n /vis/specify " << name
1466 << "\n or"
1467 << "\n /vis/scene/create"
1468 << "\n /vis/scene/add/logicalVolume " << name
1469 << "\n /vis/sceneHandler/attach"
1470 << "\n (and also, if necessary, /vis/viewer/flush)"
1471 << G4endl;
1472 }
1473 return;
1474 }
1475
1476 G4LogicalVolumeModel* model = new G4LogicalVolumeModel
1477 (pLV, requestedDepthOfDescent, booleans, voxels, readout, checkOverlaps);
1478 const G4String& currentSceneName = pScene -> GetName ();
1479 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1480
1481 if (successful) {
1482
1483 G4bool axesSuccessful = false;
1484 if (axes) {
1485 const G4double radius = model->GetExtent().GetExtentRadius();
1486 const G4double axisLengthMax = radius / 2.;
1487 const G4double intLog10Length = std::floor(std::log10(axisLengthMax));
1488 G4double axisLength = std::pow(10,intLog10Length);
1489 if (5.*axisLength < axisLengthMax) axisLength *= 5.;
1490 else if (2.*axisLength < axisLengthMax) axisLength *= 2.;
1491 const G4double axisWidth = axisLength / 20.;
1492 G4VModel* axesModel = new G4AxesModel(0.,0.,0.,axisLength,axisWidth);
1493 axesSuccessful = pScene -> AddRunDurationModel (axesModel, warn);
1494 }
1495
1496// if (verbosity >= G4VisManager::warnings) {
1497// const std::map<G4String,G4AttDef>* attDefs = model->GetAttDefs();
1498// std::vector<G4AttValue>* attValues = model->CreateCurrentAttValues();
1499// G4warn << G4AttCheck(attValues, attDefs);
1500// delete attValues;
1501// }
1502
1503 if (verbosity >= G4VisManager::confirmations) {
1504 G4cout << "Logical volume \"" << pLV -> GetName ()
1505 << "\" with requested depth of descent "
1506 << requestedDepthOfDescent
1507 << ",\n with";
1508 if (!booleans) G4cout << "out";
1509 G4cout << " boolean components, with";
1510 if (!voxels) G4cout << "out";
1511 G4cout << " voxels,\n with";
1512 if (!readout) G4cout << "out";
1513 G4cout << " readout geometry and with";
1514 if (!checkOverlaps) G4cout << "out";
1515 G4cout << " overlap checking"
1516 << "\n has been added to scene \"" << currentSceneName << "\".";
1517 if (axes) {
1518 if (axesSuccessful) {
1519 G4cout <<
1520 "\n Axes have also been added at the origin of local cooordinates.";
1521 } else {
1522 G4cout <<
1523 "\n Axes have not been added for some reason possibly stated above.";
1524 }
1525 }
1526 G4cout << G4endl;
1527 }
1528 }
1529 else {
1531 return;
1532 }
1533
1535}
#define G4warn
Definition G4Scene.cc:41
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4LogicalVolume * GetVolume(const G4String &name, G4bool verbose=true, G4bool reverseSearch=false) const
static G4LogicalVolumeStore * GetInstance()
static G4bool ConvertToBool(const char *st)
const G4VisExtent & GetExtent() const
void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity)
void CheckSceneAndNotifyHandlers(G4Scene *=nullptr)
static G4VisManager * fpVisManager
G4double GetExtentRadius() const
const char * name(G4int ptype)

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