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

#include <G4VisCommandsSceneAdd.hh>

+ Inheritance diagram for G4VisCommandSceneAddLogo:

Public Member Functions

 G4VisCommandSceneAddLogo ()
 
virtual ~G4VisCommandSceneAddLogo ()
 
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 ()
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
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, 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="")
 
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 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 DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (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 = 0
 
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
 

Detailed Description

Definition at line 299 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneAddLogo()

G4VisCommandSceneAddLogo::G4VisCommandSceneAddLogo ( )

Definition at line 1422 of file G4VisCommandsSceneAdd.cc.

1422 {
1423 G4bool omitable;
1424 fpCommand = new G4UIcommand ("/vis/scene/add/logo", this);
1425 fpCommand -> SetGuidance ("Adds a G4 logo to the current scene.");
1426 fpCommand -> SetGuidance
1427 ("If \"unit\" is \"auto\", height is roughly one tenth of scene extent.");
1428 fpCommand -> SetGuidance
1429 ("\"direction\" is that of outward-facing normal to front face of logo."
1430 "\nIf \"direction\" is \"auto\", logo faces the user in the current viewer.");
1431 fpCommand -> SetGuidance
1432 ("\nIf \"placement\" is \"auto\", logo is placed at bottom right of screen"
1433 "\n when viewed from logo direction.");
1434 G4UIparameter* parameter;
1435 parameter = new G4UIparameter ("height", 'd', omitable = true);
1436 parameter->SetDefaultValue (1.);
1437 fpCommand->SetParameter (parameter);
1438 parameter = new G4UIparameter ("unit", 's', omitable = true);
1439 parameter->SetDefaultValue ("auto");
1440 fpCommand->SetParameter (parameter);
1441 parameter = new G4UIparameter ("direction", 's', omitable = true);
1442 parameter->SetGuidance ("auto|[-]x|[-]y|[-]z");
1443 parameter->SetDefaultValue ("auto");
1444 fpCommand->SetParameter (parameter);
1445 parameter = new G4UIparameter ("red", 'd', omitable = true);
1446 parameter->SetDefaultValue (0.);
1447 fpCommand->SetParameter (parameter);
1448 parameter = new G4UIparameter ("green", 'd', omitable = true);
1449 parameter->SetDefaultValue (1.);
1450 fpCommand->SetParameter (parameter);
1451 parameter = new G4UIparameter ("blue", 'd', omitable = true);
1452 parameter->SetDefaultValue (0.);
1453 fpCommand->SetParameter (parameter);
1454 parameter = new G4UIparameter ("placement", 's', omitable = true);
1455 parameter -> SetParameterCandidates("auto manual");
1456 parameter->SetDefaultValue ("auto");
1457 fpCommand->SetParameter (parameter);
1458 parameter = new G4UIparameter ("xmid", 'd', omitable = true);
1459 parameter->SetDefaultValue (0.);
1460 fpCommand->SetParameter (parameter);
1461 parameter = new G4UIparameter ("ymid", 'd', omitable = true);
1462 parameter->SetDefaultValue (0.);
1463 fpCommand->SetParameter (parameter);
1464 parameter = new G4UIparameter ("zmid", 'd', omitable = true);
1465 parameter->SetDefaultValue (0.);
1466 fpCommand->SetParameter (parameter);
1467 parameter = new G4UIparameter ("unit", 's', omitable = true);
1468 parameter->SetDefaultValue ("m");
1469 fpCommand->SetParameter (parameter);
1470}
bool G4bool
Definition: G4Types.hh:86
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:146
void SetDefaultValue(const char *theDefaultValue)
void SetGuidance(const char *theGuidance)

◆ ~G4VisCommandSceneAddLogo()

G4VisCommandSceneAddLogo::~G4VisCommandSceneAddLogo ( )
virtual

Definition at line 1472 of file G4VisCommandsSceneAdd.cc.

1472 {
1473 delete fpCommand;
1474}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneAddLogo::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 1476 of file G4VisCommandsSceneAdd.cc.

1476 {
1477 return "";
1478}

◆ SetNewValue()

void G4VisCommandSceneAddLogo::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 1480 of file G4VisCommandsSceneAdd.cc.

1480 {
1481
1483 G4bool warn = verbosity >= G4VisManager::warnings;
1484
1486 if (!pScene) {
1487 if (verbosity >= G4VisManager::errors) {
1488 G4cerr << "ERROR: No current scene. Please create one." << G4endl;
1489 }
1490 return;
1491 } else {
1492 if (pScene->GetExtent().GetExtentRadius() <= 0.) {
1493 if (verbosity >= G4VisManager::errors) {
1494 G4cerr
1495 << "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
1496 << G4endl;
1497 }
1498 return;
1499 }
1500 }
1501
1503 if (!pViewer) {
1504 if (verbosity >= G4VisManager::errors) {
1505 G4cerr <<
1506 "ERROR: G4VisCommandSceneAddLogo::SetNewValue: no viewer."
1507 "\n Auto direction needs a viewer."
1508 << G4endl;
1509 }
1510 return;
1511 }
1512
1513 G4double userHeight, red, green, blue, xmid, ymid, zmid;
1514 G4String userHeightUnit, direction, auto_manual, positionUnit;
1515 std::istringstream is (newValue);
1516 is >> userHeight >> userHeightUnit >> direction
1517 >> red >> green >> blue
1518 >> auto_manual
1519 >> xmid >> ymid >> zmid >> positionUnit;
1520
1521 G4double height = userHeight;
1522 const G4VisExtent& sceneExtent = pScene->GetExtent(); // Existing extent.
1523 if (userHeightUnit == "auto") {
1524 height *= 0.2 * sceneExtent.GetExtentRadius();
1525 } else {
1526 height *= G4UIcommand::ValueOf(userHeightUnit);
1527 }
1528
1529 G4double unit = G4UIcommand::ValueOf(positionUnit);
1530 xmid *= unit; ymid *= unit; zmid *= unit;
1531
1532 Direction logoDirection = X; // Initialise to keep some compilers happy.
1533 if (direction == "auto") {
1534 // Take cue from viewer
1535 const G4Vector3D& vp =
1537 if (vp.x() > vp.y() && vp.x() > vp.z()) logoDirection = X;
1538 else if (vp.x() < vp.y() && vp.x() < vp.z()) logoDirection = minusX;
1539 else if (vp.y() > vp.x() && vp.y() > vp.z()) logoDirection = Y;
1540 else if (vp.y() < vp.x() && vp.y() < vp.z()) logoDirection = minusY;
1541 else if (vp.z() > vp.x() && vp.z() > vp.y()) logoDirection = Z;
1542 else if (vp.z() < vp.x() && vp.z() < vp.y()) logoDirection = minusZ;
1543 }
1544 else if (direction(0) == 'x') logoDirection = X;
1545 else if (direction(0) == 'y') logoDirection = Y;
1546 else if (direction(0) == 'z') logoDirection = Z;
1547 else if (direction(0) == '-') {
1548 if (direction(1) == 'x') logoDirection = minusX;
1549 else if (direction(1) == 'y') logoDirection = minusY;
1550 else if (direction(1) == 'z') logoDirection = minusZ;
1551 } else {
1552 if (verbosity >= G4VisManager::errors) {
1553 G4cerr << "ERROR: Unrecogniseed direction: \""
1554 << direction << "\"." << G4endl;
1555 return;
1556 }
1557 }
1558
1559 G4bool autoPlacing = false; if (auto_manual == "auto") autoPlacing = true;
1560 // Parameters read and interpreted.
1561
1562 // Current scene extent
1563 const G4double xmin = sceneExtent.GetXmin();
1564 const G4double xmax = sceneExtent.GetXmax();
1565 const G4double ymin = sceneExtent.GetYmin();
1566 const G4double ymax = sceneExtent.GetYmax();
1567 const G4double zmin = sceneExtent.GetZmin();
1568 const G4double zmax = sceneExtent.GetZmax();
1569
1570 // Test existing extent and issue warnings...
1571 G4bool worried = false;
1572 if (sceneExtent.GetExtentRadius() == 0) {
1573 worried = true;
1574 if (verbosity >= G4VisManager::warnings) {
1575 G4cout <<
1576 "WARNING: Existing scene does not yet have any extent."
1577 "\n Maybe you have not yet added any geometrical object."
1578 << G4endl;
1579 }
1580 }
1581
1582 // Useful constants, etc...
1583 const G4double halfHeight(height / 2.);
1584 const G4double comfort(0.01); // 0.15 seems too big. 0.05 might be better.
1585 const G4double freeHeightFraction (1. + 2. * comfort);
1586
1587 // Test existing scene for room...
1588 G4bool room = true;
1589 switch (logoDirection) {
1590 case X:
1591 case minusX:
1592 if (freeHeightFraction * (xmax - xmin) < height) room = false;
1593 break;
1594 case Y:
1595 case minusY:
1596 if (freeHeightFraction * (ymax - ymin) < height) room = false;
1597 break;
1598 case Z:
1599 case minusZ:
1600 if (freeHeightFraction * (zmax - zmin) < height) room = false;
1601 break;
1602 }
1603 if (!room) {
1604 worried = true;
1605 if (verbosity >= G4VisManager::warnings) {
1606 G4cout <<
1607 "WARNING: Not enough room in existing scene. Maybe logo is too large."
1608 << G4endl;
1609 }
1610 }
1611 if (worried) {
1612 if (verbosity >= G4VisManager::warnings) {
1613 G4cout <<
1614 "WARNING: The logo you have asked for is bigger than the existing"
1615 "\n scene. Maybe you have added it too soon. It is recommended that"
1616 "\n you add the logo last so that it can be correctly auto-positioned"
1617 "\n so as not to be obscured by any existing object and so that the"
1618 "\n view parameters can be correctly recalculated."
1619 << G4endl;
1620 }
1621 }
1622
1623 G4double sxmid(xmid), symid(ymid), szmid(zmid);
1624 if (autoPlacing) {
1625 // Aim to place at bottom right of screen when viewed from logoDirection.
1626 // Give some comfort zone.
1627 const G4double xComfort = comfort * (xmax - xmin);
1628 const G4double yComfort = comfort * (ymax - ymin);
1629 const G4double zComfort = comfort * (zmax - zmin);
1630 switch (logoDirection) {
1631 case X: // y-axis up, z-axis to left?
1632 sxmid = xmax + halfHeight + xComfort;
1633 symid = ymin - yComfort;
1634 szmid = zmin - zComfort;
1635 break;
1636 case minusX: // y-axis up, z-axis to right?
1637 sxmid = xmin - halfHeight - xComfort;
1638 symid = ymin - yComfort;
1639 szmid = zmax + zComfort;
1640 break;
1641 case Y: // z-axis up, x-axis to left?
1642 sxmid = xmin - xComfort;
1643 symid = ymax + halfHeight + yComfort;
1644 szmid = zmin - zComfort;
1645 break;
1646 case minusY: // z-axis up, x-axis to right?
1647 sxmid = xmax + xComfort;
1648 symid = ymin - halfHeight - yComfort;
1649 szmid = zmin - zComfort;
1650 break;
1651 case Z: // y-axis up, x-axis to right?
1652 sxmid = xmax + xComfort;
1653 symid = ymin - yComfort;
1654 szmid = zmax + halfHeight + zComfort;
1655 break;
1656 case minusZ: // y-axis up, x-axis to left?
1657 sxmid = xmin - xComfort;
1658 symid = ymin - yComfort;
1659 szmid = zmin - halfHeight - zComfort;
1660 break;
1661 }
1662 }
1663
1664 G4Transform3D transform;
1665 switch (logoDirection) {
1666 case X: // y-axis up, z-axis to left?
1667 transform = G4RotateY3D(halfpi);
1668 break;
1669 case minusX: // y-axis up, z-axis to right?
1670 transform = G4RotateY3D(-halfpi);
1671 break;
1672 case Y: // z-axis up, x-axis to left?
1673 transform = G4RotateX3D(-halfpi) * G4RotateZ3D(pi);
1674 break;
1675 case minusY: // z-axis up, x-axis to right?
1676 transform = G4RotateX3D(halfpi);
1677 break;
1678 case Z: // y-axis up, x-axis to right?
1679 // No transformation required.
1680 break;
1681 case minusZ: // y-axis up, x-axis to left?
1682 transform = G4RotateY3D(pi);
1683 break;
1684 }
1685 transform = G4Translate3D(sxmid,symid,szmid) * transform;
1686
1687 G4VisAttributes visAtts(G4Colour(red, green, blue));
1688 visAtts.SetForceSolid(true); // Always solid.
1689
1690 G4Logo* logo = new G4Logo(height,visAtts);
1691 G4VModel* model =
1693 model->SetType("G4Logo");
1694 model->SetGlobalTag("G4Logo");
1695 model->SetGlobalDescription("G4Logo: " + newValue);
1696 model->SetTransformation(transform);
1697 // Note: it is the responsibility of the model to act upon this, but
1698 // the extent is in local coordinates...
1699 G4double& h = height;
1700 G4double h2 = h/2.;
1701 G4VisExtent extent(-h,h,-h2,h2,-h2,h2);
1702 model->SetExtent(extent);
1703 // This extent gets "added" to existing scene extent in
1704 // AddRunDurationModel below.
1705 const G4String& currentSceneName = pScene -> GetName ();
1706 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1707 if (successful) {
1708 if (verbosity >= G4VisManager::confirmations) {
1709 G4cout << "G4 Logo of height " << userHeight << ' ' << userHeightUnit
1710 << ", " << direction << "-direction, added to scene \""
1711 << currentSceneName << "\"";
1712 if (verbosity >= G4VisManager::parameters) {
1713 G4cout << "\n with extent " << extent
1714 << "\n at " << transform.getRotation()
1715 << transform.getTranslation();
1716 }
1717 G4cout << G4endl;
1718 }
1719 }
1720 else G4VisCommandsSceneAddUnsuccessful(verbosity);
1721
1723}
HepGeom::RotateZ3D G4RotateZ3D
HepGeom::Translate3D G4Translate3D
HepGeom::RotateX3D G4RotateX3D
HepGeom::RotateY3D G4RotateY3D
double G4double
Definition: G4Types.hh:83
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
const G4VisExtent & GetExtent() const
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:348
void SetType(const G4String &)
void SetGlobalDescription(const G4String &)
void SetGlobalTag(const G4String &)
void SetExtent(const G4VisExtent &)
void SetTransformation(const G4Transform3D &)
const G4ViewParameters & GetViewParameters() const
void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity)
void CheckSceneAndNotifyHandlers(G4Scene *=nullptr)
static G4VisManager * fpVisManager
const G4Vector3D & GetViewpointDirection() const
G4double GetYmin() const
Definition: G4VisExtent.hh:101
G4double GetXmax() const
Definition: G4VisExtent.hh:100
G4double GetExtentRadius() const
Definition: G4VisExtent.cc:75
G4double GetYmax() const
Definition: G4VisExtent.hh:102
G4double GetZmax() const
Definition: G4VisExtent.hh:104
G4double GetZmin() const
Definition: G4VisExtent.hh:103
G4double GetXmin() const
Definition: G4VisExtent.hh:99
G4Scene * GetCurrentScene() const
G4VViewer * GetCurrentViewer() const
static Verbosity GetVerbosity()
CLHEP::HepRotation getRotation() const
CLHEP::Hep3Vector getTranslation() const

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