Geant4 11.4.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 ()=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 328 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneAddLogo()

G4VisCommandSceneAddLogo::G4VisCommandSceneAddLogo ( )

Definition at line 1599 of file G4VisCommandsSceneAdd.cc.

1599 {
1600 G4bool omitable;
1601 fpCommand = new G4UIcommand ("/vis/scene/add/logo", this);
1602 fpCommand -> SetGuidance ("Adds a G4 logo to the current scene.");
1603 fpCommand -> SetGuidance
1604 ("If \"unit\" is \"auto\", height is roughly one tenth of scene extent.");
1605 fpCommand -> SetGuidance
1606 ("\"direction\" is that of outward-facing normal to front face of logo."
1607 "\nIf \"direction\" is \"auto\", logo faces the user in the current viewer.");
1608 fpCommand -> SetGuidance
1609 ("\nIf \"placement\" is \"auto\", logo is placed at bottom right of screen"
1610 "\n when viewed from logo direction.");
1611 G4UIparameter* parameter;
1612 parameter = new G4UIparameter ("height", 'd', omitable = true);
1613 parameter->SetDefaultValue (1.);
1614 fpCommand->SetParameter (parameter);
1615 parameter = new G4UIparameter ("unit", 's', omitable = true);
1616 parameter->SetDefaultValue ("auto");
1617 fpCommand->SetParameter (parameter);
1618 parameter = new G4UIparameter ("direction", 's', omitable = true);
1619 parameter->SetGuidance ("auto|[-]x|[-]y|[-]z");
1620 parameter->SetDefaultValue ("auto");
1621 fpCommand->SetParameter (parameter);
1622 parameter = new G4UIparameter ("red", 'd', omitable = true);
1623 parameter->SetDefaultValue (0.);
1624 fpCommand->SetParameter (parameter);
1625 parameter = new G4UIparameter ("green", 'd', omitable = true);
1626 parameter->SetDefaultValue (1.);
1627 fpCommand->SetParameter (parameter);
1628 parameter = new G4UIparameter ("blue", 'd', omitable = true);
1629 parameter->SetDefaultValue (0.);
1630 fpCommand->SetParameter (parameter);
1631 parameter = new G4UIparameter ("placement", 's', omitable = true);
1632 parameter -> SetParameterCandidates("auto manual");
1633 parameter->SetDefaultValue ("auto");
1634 fpCommand->SetParameter (parameter);
1635 parameter = new G4UIparameter ("xmid", 'd', omitable = true);
1636 parameter->SetDefaultValue (0.);
1637 fpCommand->SetParameter (parameter);
1638 parameter = new G4UIparameter ("ymid", 'd', omitable = true);
1639 parameter->SetDefaultValue (0.);
1640 fpCommand->SetParameter (parameter);
1641 parameter = new G4UIparameter ("zmid", 'd', omitable = true);
1642 parameter->SetDefaultValue (0.);
1643 fpCommand->SetParameter (parameter);
1644 parameter = new G4UIparameter ("unit", 's', omitable = true);
1645 parameter->SetDefaultValue ("m");
1646 fpCommand->SetParameter (parameter);
1647}
bool G4bool
Definition G4Types.hh:86
void SetDefaultValue(const char *theDefaultValue)
void SetGuidance(const char *theGuidance)

◆ ~G4VisCommandSceneAddLogo()

G4VisCommandSceneAddLogo::~G4VisCommandSceneAddLogo ( )
virtual

Definition at line 1649 of file G4VisCommandsSceneAdd.cc.

1649 {
1650 delete fpCommand;
1651}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneAddLogo::GetCurrentValue ( G4UIcommand * command)
virtual

Reimplemented from G4UImessenger.

Definition at line 1653 of file G4VisCommandsSceneAdd.cc.

1653 {
1654 return "";
1655}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 1657 of file G4VisCommandsSceneAdd.cc.

1657 {
1658
1659 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
1660 G4bool warn = verbosity >= G4VisManager::warnings;
1661
1662 G4Scene* pScene = fpVisManager->GetCurrentScene();
1663 if (!pScene) {
1664 if (verbosity >= G4VisManager::errors) {
1665 G4warn << "ERROR: No current scene. Please create one." << G4endl;
1666 }
1667 return;
1668 } else {
1669 if (pScene->GetExtent().GetExtentRadius() <= 0.) {
1670 if (verbosity >= G4VisManager::errors) {
1671 G4warn
1672 << "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
1673 << G4endl;
1674 }
1675 return;
1676 }
1677 }
1678
1679 G4VViewer* pViewer = fpVisManager->GetCurrentViewer();
1680 if (!pViewer) {
1681 if (verbosity >= G4VisManager::errors) {
1682 G4warn <<
1683 "ERROR: G4VisCommandSceneAddLogo::SetNewValue: no viewer."
1684 "\n Auto direction needs a viewer."
1685 << G4endl;
1686 }
1687 return;
1688 }
1689
1690 G4double userHeight, red, green, blue, xmid, ymid, zmid;
1691 G4String userHeightUnit, direction, placement, positionUnit;
1692 std::istringstream is (newValue);
1693 is >> userHeight >> userHeightUnit >> direction
1694 >> red >> green >> blue
1695 >> placement
1696 >> xmid >> ymid >> zmid >> positionUnit;
1697
1698 G4double height = userHeight;
1699 const G4VisExtent& sceneExtent = pScene->GetExtent(); // Existing extent.
1700 if (userHeightUnit == "auto") {
1701 height *= 0.2 * sceneExtent.GetExtentRadius();
1702 } else {
1703 height *= G4UIcommand::ValueOf(userHeightUnit);
1704 }
1705
1706 G4double unit = G4UIcommand::ValueOf(positionUnit);
1707 xmid *= unit; ymid *= unit; zmid *= unit;
1708
1709 Direction logoDirection = X; // Initialise to keep some compilers happy.
1710 if (direction == "auto") {
1711 // Take cue from viewer
1712 const G4Vector3D& vp =
1714 if (vp.x() > vp.y() && vp.x() > vp.z()) logoDirection = X;
1715 else if (vp.x() < vp.y() && vp.x() < vp.z()) logoDirection = minusX;
1716 else if (vp.y() > vp.x() && vp.y() > vp.z()) logoDirection = Y;
1717 else if (vp.y() < vp.x() && vp.y() < vp.z()) logoDirection = minusY;
1718 else if (vp.z() > vp.x() && vp.z() > vp.y()) logoDirection = Z;
1719 else if (vp.z() < vp.x() && vp.z() < vp.y()) logoDirection = minusZ;
1720 }
1721 else if (direction[0] == 'x') logoDirection = X;
1722 else if (direction[0] == 'y') logoDirection = Y;
1723 else if (direction[0] == 'z') logoDirection = Z;
1724 else if (direction[0] == '-') {
1725 if (direction[1] == 'x') logoDirection = minusX;
1726 else if (direction[1] == 'y') logoDirection = minusY;
1727 else if (direction[1] == 'z') logoDirection = minusZ;
1728 } else {
1729 if (verbosity >= G4VisManager::errors) {
1730 G4warn << "ERROR: Unrecogniseed direction: \""
1731 << direction << "\"." << G4endl;
1732 return;
1733 }
1734 }
1735
1736 G4bool autoPlacing = false; if (placement == "auto") autoPlacing = true;
1737 // Parameters read and interpreted.
1738
1739 // Current scene extent
1740 const G4double xmin = sceneExtent.GetXmin();
1741 const G4double xmax = sceneExtent.GetXmax();
1742 const G4double ymin = sceneExtent.GetYmin();
1743 const G4double ymax = sceneExtent.GetYmax();
1744 const G4double zmin = sceneExtent.GetZmin();
1745 const G4double zmax = sceneExtent.GetZmax();
1746
1747 // Test existing extent and issue warnings...
1748 G4bool worried = false;
1749 if (sceneExtent.GetExtentRadius() == 0) {
1750 worried = true;
1751 if (verbosity >= G4VisManager::warnings) {
1752 G4warn <<
1753 "WARNING: Existing scene does not yet have any extent."
1754 "\n Maybe you have not yet added any geometrical object."
1755 << G4endl;
1756 }
1757 }
1758
1759 // Useful constants, etc...
1760 const G4double halfHeight(height / 2.);
1761 const G4double comfort(0.01); // 0.15 seems too big. 0.05 might be better.
1762 const G4double freeHeightFraction (1. + 2. * comfort);
1763
1764 // Test existing scene for room...
1765 G4bool room = true;
1766 switch (logoDirection) {
1767 case X:
1768 case minusX:
1769 if (freeHeightFraction * (xmax - xmin) < height) room = false;
1770 break;
1771 case Y:
1772 case minusY:
1773 if (freeHeightFraction * (ymax - ymin) < height) room = false;
1774 break;
1775 case Z:
1776 case minusZ:
1777 if (freeHeightFraction * (zmax - zmin) < height) room = false;
1778 break;
1779 }
1780 if (!room) {
1781 worried = true;
1782 if (verbosity >= G4VisManager::warnings) {
1783 G4warn <<
1784 "WARNING: Not enough room in existing scene. Maybe logo is too large."
1785 << G4endl;
1786 }
1787 }
1788 if (worried) {
1789 if (verbosity >= G4VisManager::warnings) {
1790 G4warn <<
1791 "WARNING: The logo you have asked for is bigger than the existing"
1792 "\n scene. Maybe you have added it too soon. It is recommended that"
1793 "\n you add the logo last so that it can be correctly auto-positioned"
1794 "\n so as not to be obscured by any existing object and so that the"
1795 "\n view parameters can be correctly recalculated."
1796 << G4endl;
1797 }
1798 }
1799
1800 G4double sxmid(xmid), symid(ymid), szmid(zmid);
1801 if (autoPlacing) {
1802 // Aim to place at bottom right of screen when viewed from logoDirection.
1803 // Give some comfort zone.
1804 const G4double xComfort = comfort * (xmax - xmin);
1805 const G4double yComfort = comfort * (ymax - ymin);
1806 const G4double zComfort = comfort * (zmax - zmin);
1807 switch (logoDirection) {
1808 case X: // y-axis up, z-axis to left?
1809 sxmid = xmax + halfHeight + xComfort;
1810 symid = ymin - yComfort;
1811 szmid = zmin - zComfort;
1812 break;
1813 case minusX: // y-axis up, z-axis to right?
1814 sxmid = xmin - halfHeight - xComfort;
1815 symid = ymin - yComfort;
1816 szmid = zmax + zComfort;
1817 break;
1818 case Y: // z-axis up, x-axis to left?
1819 sxmid = xmin - xComfort;
1820 symid = ymax + halfHeight + yComfort;
1821 szmid = zmin - zComfort;
1822 break;
1823 case minusY: // z-axis up, x-axis to right?
1824 sxmid = xmax + xComfort;
1825 symid = ymin - halfHeight - yComfort;
1826 szmid = zmin - zComfort;
1827 break;
1828 case Z: // y-axis up, x-axis to right?
1829 sxmid = xmax + xComfort;
1830 symid = ymin - yComfort;
1831 szmid = zmax + halfHeight + zComfort;
1832 break;
1833 case minusZ: // y-axis up, x-axis to left?
1834 sxmid = xmin - xComfort;
1835 symid = ymin - yComfort;
1836 szmid = zmin - halfHeight - zComfort;
1837 break;
1838 }
1839 }
1840
1841 G4Transform3D transform;
1842 switch (logoDirection) {
1843 case X: // y-axis up, z-axis to left?
1844 transform = G4RotateY3D(halfpi);
1845 break;
1846 case minusX: // y-axis up, z-axis to right?
1847 transform = G4RotateY3D(-halfpi);
1848 break;
1849 case Y: // z-axis up, x-axis to left?
1850 transform = G4RotateX3D(-halfpi) * G4RotateZ3D(pi);
1851 break;
1852 case minusY: // z-axis up, x-axis to right?
1853 transform = G4RotateX3D(halfpi);
1854 break;
1855 case Z: // y-axis up, x-axis to right?
1856 // No transformation required.
1857 break;
1858 case minusZ: // y-axis up, x-axis to left?
1859 transform = G4RotateY3D(pi);
1860 break;
1861 }
1862 transform = G4Translate3D(sxmid,symid,szmid) * transform;
1863
1864 G4VisAttributes visAtts(G4Colour(red, green, blue));
1865 visAtts.SetForceSolid(true); // Always solid.
1866
1867 G4Logo* logo = new G4Logo(height,visAtts,transform);
1868 G4VModel* model =
1869 new G4CallbackModel<G4VisCommandSceneAddLogo::G4Logo>(logo);
1870 model->SetType("G4Logo");
1871 model->SetGlobalTag("G4Logo");
1872 model->SetGlobalDescription("G4Logo: " + newValue);
1873 G4double& h = height;
1874 G4double h2 = h/2.;
1875 G4VisExtent extent(-h,h,-h2,h2,-h2,h2);
1876 model->SetExtent(extent.Transform(transform));
1877 // This extent gets "added" to existing scene extent in
1878 // AddRunDurationModel below.
1879 const G4String& currentSceneName = pScene -> GetName ();
1880 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1881 if (successful) {
1882 if (verbosity >= G4VisManager::confirmations) {
1883 G4cout << "G4 Logo of height " << userHeight << ' ' << userHeightUnit
1884 << ", " << direction << "-direction, added to scene \""
1885 << currentSceneName << "\"";
1886 if (verbosity >= G4VisManager::parameters) {
1887 G4cout << "\n with extent " << extent
1888 << "\n at " << transform.getRotation()
1889 << " " << transform.getTranslation();
1890 }
1891 G4cout << G4endl;
1892 }
1893 }
1894 else G4VisCommandsSceneAddUnsuccessful(verbosity);
1895
1897}
#define G4warn
Definition G4Scene.cc:41
HepGeom::Transform3D G4Transform3D
HepGeom::RotateZ3D G4RotateZ3D
HepGeom::RotateX3D G4RotateX3D
HepGeom::RotateY3D G4RotateY3D
HepGeom::Translate3D G4Translate3D
double G4double
Definition G4Types.hh:83
HepGeom::Vector3D< G4double > G4Vector3D
Definition G4Vector3D.hh:34
#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
CLHEP::HepRotation getRotation() const
CLHEP::Hep3Vector getTranslation() const

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