1597 {
1598
1601
1603 if (!pScene) {
1605 G4warn <<
"ERROR: No current scene. Please create one." <<
G4endl;
1606 }
1607 return;
1608 } else {
1612 << "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
1614 }
1615 return;
1616 }
1617 }
1618
1620 if (!pViewer) {
1623 "ERROR: G4VisCommandSceneAddLogo::SetNewValue: no viewer."
1624 "\n Auto direction needs a viewer."
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
1640 if (userHeightUnit == "auto") {
1642 } else {
1644 }
1645
1647 xmid *= unit; ymid *= unit; zmid *= unit;
1648
1649 Direction logoDirection = X;
1650 if (direction == "auto") {
1651
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 {
1670 G4warn <<
"ERROR: Unrecogniseed direction: \""
1671 << direction <<
"\"." <<
G4endl;
1672 return;
1673 }
1674 }
1675
1676 G4bool autoPlacing =
false;
if (placement ==
"auto") autoPlacing =
true;
1677
1678
1679
1686
1687
1690 worried = true;
1693 "WARNING: Existing scene does not yet have any extent."
1694 "\n Maybe you have not yet added any geometrical object."
1696 }
1697 }
1698
1699
1700 const G4double halfHeight(height / 2.);
1702 const G4double freeHeightFraction (1. + 2. * comfort);
1703
1704
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;
1724 "WARNING: Not enough room in existing scene. Maybe logo is too large."
1726 }
1727 }
1728 if (worried) {
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."
1737 }
1738 }
1739
1740 G4double sxmid(xmid), symid(ymid), szmid(zmid);
1741 if (autoPlacing) {
1742
1743
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:
1749 sxmid = xmax + halfHeight + xComfort;
1750 symid = ymin - yComfort;
1751 szmid = zmin - zComfort;
1752 break;
1753 case minusX:
1754 sxmid = xmin - halfHeight - xComfort;
1755 symid = ymin - yComfort;
1756 szmid = zmax + zComfort;
1757 break;
1758 case Y:
1759 sxmid = xmin - xComfort;
1760 symid = ymax + halfHeight + yComfort;
1761 szmid = zmin - zComfort;
1762 break;
1763 case minusY:
1764 sxmid = xmax + xComfort;
1765 symid = ymin - halfHeight - yComfort;
1766 szmid = zmin - zComfort;
1767 break;
1768 case Z:
1769 sxmid = xmax + xComfort;
1770 symid = ymin - yComfort;
1771 szmid = zmax + halfHeight + zComfort;
1772 break;
1773 case minusZ:
1774 sxmid = xmin - xComfort;
1775 symid = ymin - yComfort;
1776 szmid = zmin - halfHeight - zComfort;
1777 break;
1778 }
1779 }
1780
1782 switch (logoDirection) {
1783 case X:
1785 break;
1786 case minusX:
1788 break;
1789 case Y:
1791 break;
1792 case minusY:
1794 break;
1795 case Z:
1796
1797 break;
1798 case minusZ:
1800 break;
1801 }
1803
1805 visAtts.SetForceSolid(true);
1806
1807 G4Logo* logo = new G4Logo(height,visAtts,transform);
1816 model->
SetExtent(extent.Transform(transform));
1817
1818
1819 const G4String& currentSceneName = pScene -> GetName ();
1820 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1821 if (successful) {
1823 G4cout <<
"G4 Logo of height " << userHeight <<
' ' << userHeightUnit
1824 << ", " << direction << "-direction, added to scene \""
1825 << currentSceneName << "\"";
1827 G4cout <<
"\n with extent " << extent
1830 }
1832 }
1833 }
1835
1837}
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 GetExtentRadius() const
G4Scene * GetCurrentScene() const
G4VViewer * GetCurrentViewer() const
static Verbosity GetVerbosity()