Geant4 11.2.2
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 ()=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, 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 (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 311 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneAddLogo()

G4VisCommandSceneAddLogo::G4VisCommandSceneAddLogo ( )

Definition at line 1541 of file G4VisCommandsSceneAdd.cc.

1541 {
1542 G4bool omitable;
1543 fpCommand = new G4UIcommand ("/vis/scene/add/logo", this);
1544 fpCommand -> SetGuidance ("Adds a G4 logo to the current scene.");
1545 fpCommand -> SetGuidance
1546 ("If \"unit\" is \"auto\", height is roughly one tenth of scene extent.");
1547 fpCommand -> SetGuidance
1548 ("\"direction\" is that of outward-facing normal to front face of logo."
1549 "\nIf \"direction\" is \"auto\", logo faces the user in the current viewer.");
1550 fpCommand -> SetGuidance
1551 ("\nIf \"placement\" is \"auto\", logo is placed at bottom right of screen"
1552 "\n when viewed from logo direction.");
1553 G4UIparameter* parameter;
1554 parameter = new G4UIparameter ("height", 'd', omitable = true);
1555 parameter->SetDefaultValue (1.);
1556 fpCommand->SetParameter (parameter);
1557 parameter = new G4UIparameter ("unit", 's', omitable = true);
1558 parameter->SetDefaultValue ("auto");
1559 fpCommand->SetParameter (parameter);
1560 parameter = new G4UIparameter ("direction", 's', omitable = true);
1561 parameter->SetGuidance ("auto|[-]x|[-]y|[-]z");
1562 parameter->SetDefaultValue ("auto");
1563 fpCommand->SetParameter (parameter);
1564 parameter = new G4UIparameter ("red", 'd', omitable = true);
1565 parameter->SetDefaultValue (0.);
1566 fpCommand->SetParameter (parameter);
1567 parameter = new G4UIparameter ("green", 'd', omitable = true);
1568 parameter->SetDefaultValue (1.);
1569 fpCommand->SetParameter (parameter);
1570 parameter = new G4UIparameter ("blue", 'd', omitable = true);
1571 parameter->SetDefaultValue (0.);
1572 fpCommand->SetParameter (parameter);
1573 parameter = new G4UIparameter ("placement", 's', omitable = true);
1574 parameter -> SetParameterCandidates("auto manual");
1575 parameter->SetDefaultValue ("auto");
1576 fpCommand->SetParameter (parameter);
1577 parameter = new G4UIparameter ("xmid", 'd', omitable = true);
1578 parameter->SetDefaultValue (0.);
1579 fpCommand->SetParameter (parameter);
1580 parameter = new G4UIparameter ("ymid", 'd', omitable = true);
1581 parameter->SetDefaultValue (0.);
1582 fpCommand->SetParameter (parameter);
1583 parameter = new G4UIparameter ("zmid", 'd', omitable = true);
1584 parameter->SetDefaultValue (0.);
1585 fpCommand->SetParameter (parameter);
1586 parameter = new G4UIparameter ("unit", 's', omitable = true);
1587 parameter->SetDefaultValue ("m");
1588 fpCommand->SetParameter (parameter);
1589}
bool G4bool
Definition G4Types.hh:86
void SetParameter(G4UIparameter *const newParameter)
void SetDefaultValue(const char *theDefaultValue)
void SetGuidance(const char *theGuidance)

◆ ~G4VisCommandSceneAddLogo()

G4VisCommandSceneAddLogo::~G4VisCommandSceneAddLogo ( )
virtual

Definition at line 1591 of file G4VisCommandsSceneAdd.cc.

1591 {
1592 delete fpCommand;
1593}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneAddLogo::GetCurrentValue ( G4UIcommand * command)
virtual

Reimplemented from G4UImessenger.

Definition at line 1595 of file G4VisCommandsSceneAdd.cc.

1595 {
1596 return "";
1597}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 1599 of file G4VisCommandsSceneAdd.cc.

1599 {
1600
1602 G4bool warn = verbosity >= G4VisManager::warnings;
1603
1605 if (!pScene) {
1606 if (verbosity >= G4VisManager::errors) {
1607 G4warn << "ERROR: No current scene. Please create one." << G4endl;
1608 }
1609 return;
1610 } else {
1611 if (pScene->GetExtent().GetExtentRadius() <= 0.) {
1612 if (verbosity >= G4VisManager::errors) {
1613 G4warn
1614 << "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
1615 << G4endl;
1616 }
1617 return;
1618 }
1619 }
1620
1622 if (!pViewer) {
1623 if (verbosity >= G4VisManager::errors) {
1624 G4warn <<
1625 "ERROR: G4VisCommandSceneAddLogo::SetNewValue: no viewer."
1626 "\n Auto direction needs a viewer."
1627 << G4endl;
1628 }
1629 return;
1630 }
1631
1632 G4double userHeight, red, green, blue, xmid, ymid, zmid;
1633 G4String userHeightUnit, direction, placement, positionUnit;
1634 std::istringstream is (newValue);
1635 is >> userHeight >> userHeightUnit >> direction
1636 >> red >> green >> blue
1637 >> placement
1638 >> xmid >> ymid >> zmid >> positionUnit;
1639
1640 G4double height = userHeight;
1641 const G4VisExtent& sceneExtent = pScene->GetExtent(); // Existing extent.
1642 if (userHeightUnit == "auto") {
1643 height *= 0.2 * sceneExtent.GetExtentRadius();
1644 } else {
1645 height *= G4UIcommand::ValueOf(userHeightUnit);
1646 }
1647
1648 G4double unit = G4UIcommand::ValueOf(positionUnit);
1649 xmid *= unit; ymid *= unit; zmid *= unit;
1650
1651 Direction logoDirection = X; // Initialise to keep some compilers happy.
1652 if (direction == "auto") {
1653 // Take cue from viewer
1654 const G4Vector3D& vp =
1656 if (vp.x() > vp.y() && vp.x() > vp.z()) logoDirection = X;
1657 else if (vp.x() < vp.y() && vp.x() < vp.z()) logoDirection = minusX;
1658 else if (vp.y() > vp.x() && vp.y() > vp.z()) logoDirection = Y;
1659 else if (vp.y() < vp.x() && vp.y() < vp.z()) logoDirection = minusY;
1660 else if (vp.z() > vp.x() && vp.z() > vp.y()) logoDirection = Z;
1661 else if (vp.z() < vp.x() && vp.z() < vp.y()) logoDirection = minusZ;
1662 }
1663 else if (direction[0] == 'x') logoDirection = X;
1664 else if (direction[0] == 'y') logoDirection = Y;
1665 else if (direction[0] == 'z') logoDirection = Z;
1666 else if (direction[0] == '-') {
1667 if (direction[1] == 'x') logoDirection = minusX;
1668 else if (direction[1] == 'y') logoDirection = minusY;
1669 else if (direction[1] == 'z') logoDirection = minusZ;
1670 } else {
1671 if (verbosity >= G4VisManager::errors) {
1672 G4warn << "ERROR: Unrecogniseed direction: \""
1673 << direction << "\"." << G4endl;
1674 return;
1675 }
1676 }
1677
1678 G4bool autoPlacing = false; if (placement == "auto") autoPlacing = true;
1679 // Parameters read and interpreted.
1680
1681 // Current scene extent
1682 const G4double xmin = sceneExtent.GetXmin();
1683 const G4double xmax = sceneExtent.GetXmax();
1684 const G4double ymin = sceneExtent.GetYmin();
1685 const G4double ymax = sceneExtent.GetYmax();
1686 const G4double zmin = sceneExtent.GetZmin();
1687 const G4double zmax = sceneExtent.GetZmax();
1688
1689 // Test existing extent and issue warnings...
1690 G4bool worried = false;
1691 if (sceneExtent.GetExtentRadius() == 0) {
1692 worried = true;
1693 if (verbosity >= G4VisManager::warnings) {
1694 G4warn <<
1695 "WARNING: Existing scene does not yet have any extent."
1696 "\n Maybe you have not yet added any geometrical object."
1697 << G4endl;
1698 }
1699 }
1700
1701 // Useful constants, etc...
1702 const G4double halfHeight(height / 2.);
1703 const G4double comfort(0.01); // 0.15 seems too big. 0.05 might be better.
1704 const G4double freeHeightFraction (1. + 2. * comfort);
1705
1706 // Test existing scene for room...
1707 G4bool room = true;
1708 switch (logoDirection) {
1709 case X:
1710 case minusX:
1711 if (freeHeightFraction * (xmax - xmin) < height) room = false;
1712 break;
1713 case Y:
1714 case minusY:
1715 if (freeHeightFraction * (ymax - ymin) < height) room = false;
1716 break;
1717 case Z:
1718 case minusZ:
1719 if (freeHeightFraction * (zmax - zmin) < height) room = false;
1720 break;
1721 }
1722 if (!room) {
1723 worried = true;
1724 if (verbosity >= G4VisManager::warnings) {
1725 G4warn <<
1726 "WARNING: Not enough room in existing scene. Maybe logo is too large."
1727 << G4endl;
1728 }
1729 }
1730 if (worried) {
1731 if (verbosity >= G4VisManager::warnings) {
1732 G4warn <<
1733 "WARNING: The logo you have asked for is bigger than the existing"
1734 "\n scene. Maybe you have added it too soon. It is recommended that"
1735 "\n you add the logo last so that it can be correctly auto-positioned"
1736 "\n so as not to be obscured by any existing object and so that the"
1737 "\n view parameters can be correctly recalculated."
1738 << G4endl;
1739 }
1740 }
1741
1742 G4double sxmid(xmid), symid(ymid), szmid(zmid);
1743 if (autoPlacing) {
1744 // Aim to place at bottom right of screen when viewed from logoDirection.
1745 // Give some comfort zone.
1746 const G4double xComfort = comfort * (xmax - xmin);
1747 const G4double yComfort = comfort * (ymax - ymin);
1748 const G4double zComfort = comfort * (zmax - zmin);
1749 switch (logoDirection) {
1750 case X: // y-axis up, z-axis to left?
1751 sxmid = xmax + halfHeight + xComfort;
1752 symid = ymin - yComfort;
1753 szmid = zmin - zComfort;
1754 break;
1755 case minusX: // y-axis up, z-axis to right?
1756 sxmid = xmin - halfHeight - xComfort;
1757 symid = ymin - yComfort;
1758 szmid = zmax + zComfort;
1759 break;
1760 case Y: // z-axis up, x-axis to left?
1761 sxmid = xmin - xComfort;
1762 symid = ymax + halfHeight + yComfort;
1763 szmid = zmin - zComfort;
1764 break;
1765 case minusY: // z-axis up, x-axis to right?
1766 sxmid = xmax + xComfort;
1767 symid = ymin - halfHeight - yComfort;
1768 szmid = zmin - zComfort;
1769 break;
1770 case Z: // y-axis up, x-axis to right?
1771 sxmid = xmax + xComfort;
1772 symid = ymin - yComfort;
1773 szmid = zmax + halfHeight + zComfort;
1774 break;
1775 case minusZ: // y-axis up, x-axis to left?
1776 sxmid = xmin - xComfort;
1777 symid = ymin - yComfort;
1778 szmid = zmin - halfHeight - zComfort;
1779 break;
1780 }
1781 }
1782
1783 G4Transform3D transform;
1784 switch (logoDirection) {
1785 case X: // y-axis up, z-axis to left?
1786 transform = G4RotateY3D(halfpi);
1787 break;
1788 case minusX: // y-axis up, z-axis to right?
1789 transform = G4RotateY3D(-halfpi);
1790 break;
1791 case Y: // z-axis up, x-axis to left?
1792 transform = G4RotateX3D(-halfpi) * G4RotateZ3D(pi);
1793 break;
1794 case minusY: // z-axis up, x-axis to right?
1795 transform = G4RotateX3D(halfpi);
1796 break;
1797 case Z: // y-axis up, x-axis to right?
1798 // No transformation required.
1799 break;
1800 case minusZ: // y-axis up, x-axis to left?
1801 transform = G4RotateY3D(pi);
1802 break;
1803 }
1804 transform = G4Translate3D(sxmid,symid,szmid) * transform;
1805
1806 G4VisAttributes visAtts(G4Colour(red, green, blue));
1807 visAtts.SetForceSolid(true); // Always solid.
1808
1809 G4Logo* logo = new G4Logo(height,visAtts,transform);
1810 G4VModel* model =
1812 model->SetType("G4Logo");
1813 model->SetGlobalTag("G4Logo");
1814 model->SetGlobalDescription("G4Logo: " + newValue);
1815 G4double& h = height;
1816 G4double h2 = h/2.;
1817 G4VisExtent extent(-h,h,-h2,h2,-h2,h2);
1818 model->SetExtent(extent.Transform(transform));
1819 // This extent gets "added" to existing scene extent in
1820 // AddRunDurationModel below.
1821 const G4String& currentSceneName = pScene -> GetName ();
1822 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1823 if (successful) {
1824 if (verbosity >= G4VisManager::confirmations) {
1825 G4cout << "G4 Logo of height " << userHeight << ' ' << userHeightUnit
1826 << ", " << direction << "-direction, added to scene \""
1827 << currentSceneName << "\"";
1828 if (verbosity >= G4VisManager::parameters) {
1829 G4cout << "\n with extent " << extent
1830 << "\n at " << transform.getRotation()
1831 << " " << transform.getTranslation();
1832 }
1833 G4cout << G4endl;
1834 }
1835 }
1836 else G4VisCommandsSceneAddUnsuccessful(verbosity);
1837
1839}
#define G4warn
Definition G4Scene.cc:41
HepGeom::RotateZ3D G4RotateZ3D
HepGeom::RotateX3D G4RotateX3D
HepGeom::RotateY3D G4RotateY3D
HepGeom::Translate3D G4Translate3D
double G4double
Definition G4Types.hh:83
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
const G4VisExtent & GetExtent() const
static G4double ValueOf(const char *unitName)
void SetType(const G4String &)
void SetGlobalDescription(const G4String &)
void SetGlobalTag(const G4String &)
void SetExtent(const G4VisExtent &)
const G4ViewParameters & GetViewParameters() const
void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity)
void CheckSceneAndNotifyHandlers(G4Scene *=nullptr)
static G4VisManager * fpVisManager
const G4Vector3D & GetViewpointDirection() const
G4double GetYmin() const
G4double GetXmax() const
G4double GetExtentRadius() const
G4double GetYmax() const
G4double GetZmax() const
G4double GetZmin() const
G4double GetXmin() const
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: