Geant4 11.1.1
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 ()
 
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 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 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
 

Detailed Description

Definition at line 311 of file G4VisCommandsSceneAdd.hh.

Constructor & Destructor Documentation

◆ G4VisCommandSceneAddLogo()

G4VisCommandSceneAddLogo::G4VisCommandSceneAddLogo ( )

Definition at line 1539 of file G4VisCommandsSceneAdd.cc.

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

◆ ~G4VisCommandSceneAddLogo()

G4VisCommandSceneAddLogo::~G4VisCommandSceneAddLogo ( )
virtual

Definition at line 1589 of file G4VisCommandsSceneAdd.cc.

1589 {
1590 delete fpCommand;
1591}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandSceneAddLogo::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 1593 of file G4VisCommandsSceneAdd.cc.

1593 {
1594 return "";
1595}

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 1597 of file G4VisCommandsSceneAdd.cc.

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