Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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 315 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneAddLogicalVolume()

G4VisCommandSceneAddLogicalVolume::G4VisCommandSceneAddLogicalVolume ( )

Definition at line 1433 of file G4VisCommandsSceneAdd.cc.

1433 {
1434 G4bool omitable;
1435 fpCommand = new G4UIcommand ("/vis/scene/add/logicalVolume", this);
1436 fpCommand -> SetGuidance ("Adds a logical volume to the current scene,");
1437 fpCommand -> SetGuidance
1438 ("Shows boolean components (if any), voxels (if any), readout geometry"
1439 "\n (if any), local axes and overlaps (if any), under control of the"
1440 "\n appropriate flag."
1441 "\n Note: voxels are not constructed until start of run -"
1442 "\n \"/run/beamOn\". (For voxels without a run, \"/run/beamOn 0\".)");
1443 G4UIparameter* parameter;
1444 parameter = new G4UIparameter ("logical-volume-name", 's', omitable = false);
1445 fpCommand -> SetParameter (parameter);
1446 parameter = new G4UIparameter ("depth-of-descent", 'i', omitable = true);
1447 parameter -> SetGuidance ("Depth of descent of geometry hierarchy.");
1448 parameter -> SetDefaultValue (1);
1449 fpCommand -> SetParameter (parameter);
1450 parameter = new G4UIparameter ("booleans-flag", 'b', omitable = true);
1451 parameter -> SetDefaultValue (true);
1452 fpCommand -> SetParameter (parameter);
1453 parameter = new G4UIparameter ("voxels-flag", 'b', omitable = true);
1454 parameter -> SetDefaultValue (true);
1455 fpCommand -> SetParameter (parameter);
1456 parameter = new G4UIparameter ("readout-flag", 'b', omitable = true);
1457 parameter -> SetDefaultValue (true);
1458 fpCommand -> SetParameter (parameter);
1459 parameter = new G4UIparameter ("axes-flag", 'b', omitable = true);
1460 parameter -> SetDefaultValue (true);
1461 parameter -> SetGuidance ("Set \"false\" to suppress axes.");
1462 fpCommand -> SetParameter (parameter);
1463 parameter = new G4UIparameter("check-overlap-flag", 'b', omitable = true);
1464 parameter->SetDefaultValue(true);
1465 parameter -> SetGuidance ("Set \"false\" to suppress overlap check.");
1466 fpCommand->SetParameter(parameter);
1467}
bool G4bool
Definition G4Types.hh:86
void SetDefaultValue(const char *theDefaultValue)

◆ ~G4VisCommandSceneAddLogicalVolume()

G4VisCommandSceneAddLogicalVolume::~G4VisCommandSceneAddLogicalVolume ( )
virtual

Definition at line 1469 of file G4VisCommandsSceneAdd.cc.

1469 {
1470 delete fpCommand;
1471}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneAddLogicalVolume::GetCurrentValue ( G4UIcommand * command)
virtual

Reimplemented from G4UImessenger.

Definition at line 1473 of file G4VisCommandsSceneAdd.cc.

1473 {
1474 return "";
1475}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 1477 of file G4VisCommandsSceneAdd.cc.

1478 {
1479
1480 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1481 G4bool warn(verbosity >= G4VisManager::warnings);
1482
1483 G4Scene* pScene = fpVisManager->GetCurrentScene();
1484 if (!pScene) {
1485 if (verbosity >= G4VisManager::errors) {
1486 G4warn << "ERROR: No current scene. Please create one." << G4endl;
1487 }
1488 return;
1489 }
1490
1491 G4String name;
1492 G4int requestedDepthOfDescent;
1493 G4String booleansString, voxelsString, readoutString, axesString;
1494 G4String overlapString;
1495 std::istringstream is (newValue);
1496 is >> name >> requestedDepthOfDescent
1497 >> booleansString >> voxelsString >> readoutString >> axesString
1498 >> overlapString;
1499 G4bool booleans = G4UIcommand::ConvertToBool(booleansString);
1500 G4bool voxels = G4UIcommand::ConvertToBool(voxelsString);
1501 G4bool readout = G4UIcommand::ConvertToBool(readoutString);
1503 G4bool checkOverlaps = G4UIcommand::ConvertToBool(overlapString);
1504
1505 G4LogicalVolumeStore *pLVStore = G4LogicalVolumeStore::GetInstance();
1506 G4LogicalVolume* pLV = nullptr;
1507 pLV = pLVStore->GetVolume(name);
1508 if (pLV == nullptr) return; // Volume not found; warning message thrown
1509
1510 const std::vector<G4Scene::Model>& rdModelList =
1511 pScene -> GetRunDurationModelList();
1512 std::vector<G4Scene::Model>::const_iterator i;
1513 for (i = rdModelList.begin(); i != rdModelList.end(); ++i) {
1514 if (i->fpModel->GetGlobalDescription().find("Volume") != std::string::npos) break;
1515 }
1516 if (i != rdModelList.end()) {
1517 if (verbosity >= G4VisManager::errors) {
1518 G4warn << "There is already a volume, \""
1519 << i->fpModel->GetGlobalDescription()
1520 << "\",\n in the run-duration model list of scene \""
1521 << pScene -> GetName()
1522 << "\".\n Your logical volume must be the only volume in the scene."
1523 << "\n Create a new scene and try again:"
1524 << "\n /vis/specify " << name
1525 << "\n or"
1526 << "\n /vis/scene/create"
1527 << "\n /vis/scene/add/logicalVolume " << name
1528 << "\n /vis/sceneHandler/attach"
1529 << "\n (and also, if necessary, /vis/viewer/flush)"
1530 << G4endl;
1531 }
1532 return;
1533 }
1534
1535 G4LogicalVolumeModel* model = new G4LogicalVolumeModel
1536 (pLV, requestedDepthOfDescent, booleans, voxels, readout, checkOverlaps);
1537 const G4String& currentSceneName = pScene -> GetName ();
1538 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1539
1540 if (successful) {
1541
1542 G4bool axesSuccessful = false;
1543 if (axes) {
1544 const G4double radius = model->GetExtent().GetExtentRadius();
1545 const G4double axisLengthMax = radius / 2.;
1546 const G4double intLog10Length = std::floor(std::log10(axisLengthMax));
1547 G4double axisLength = std::pow(10,intLog10Length);
1548 if (5.*axisLength < axisLengthMax) axisLength *= 5.;
1549 else if (2.*axisLength < axisLengthMax) axisLength *= 2.;
1550 const G4double axisWidth = axisLength / 20.;
1551 G4VModel* axesModel = new G4AxesModel(0.,0.,0.,axisLength,axisWidth);
1552 axesSuccessful = pScene -> AddRunDurationModel (axesModel, warn);
1553 }
1554
1555// if (verbosity >= G4VisManager::warnings) {
1556// const std::map<G4String,G4AttDef>* attDefs = model->GetAttDefs();
1557// std::vector<G4AttValue>* attValues = model->CreateCurrentAttValues();
1558// G4warn << G4AttCheck(attValues, attDefs);
1559// delete attValues;
1560// }
1561
1562 if (verbosity >= G4VisManager::confirmations) {
1563 G4cout << "Logical volume \"" << pLV -> GetName ()
1564 << "\" with requested depth of descent "
1565 << requestedDepthOfDescent
1566 << ",\n with";
1567 if (!booleans) G4cout << "out";
1568 G4cout << " boolean components, with";
1569 if (!voxels) G4cout << "out";
1570 G4cout << " voxels,\n with";
1571 if (!readout) G4cout << "out";
1572 G4cout << " readout geometry and with";
1573 if (!checkOverlaps) G4cout << "out";
1574 G4cout << " overlap checking"
1575 << "\n has been added to scene \"" << currentSceneName << "\".";
1576 if (axes) {
1577 if (axesSuccessful) {
1578 G4cout <<
1579 "\n Axes have also been added at the origin of local cooordinates.";
1580 } else {
1581 G4cout <<
1582 "\n Axes have not been added for some reason possibly stated above.";
1583 }
1584 }
1585 G4cout << G4endl;
1586 }
1587 }
1588 else {
1590 return;
1591 }
1592
1594}
#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: