1599 {
1600
1603
1605 if (!pScene) {
1607 G4warn <<
"ERROR: No current scene. Please create one." <<
G4endl;
1608 }
1609 return;
1610 } else {
1614 << "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
1616 }
1617 return;
1618 }
1619 }
1620
1622 if (!pViewer) {
1625 "ERROR: G4VisCommandSceneAddLogo::SetNewValue: no viewer."
1626 "\n Auto direction needs a viewer."
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
1642 if (userHeightUnit == "auto") {
1644 } else {
1646 }
1647
1649 xmid *= unit; ymid *= unit; zmid *= unit;
1650
1651 Direction logoDirection = X;
1652 if (direction == "auto") {
1653
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 {
1672 G4warn <<
"ERROR: Unrecogniseed direction: \""
1673 << direction <<
"\"." <<
G4endl;
1674 return;
1675 }
1676 }
1677
1678 G4bool autoPlacing =
false;
if (placement ==
"auto") autoPlacing =
true;
1679
1680
1681
1688
1689
1692 worried = true;
1695 "WARNING: Existing scene does not yet have any extent."
1696 "\n Maybe you have not yet added any geometrical object."
1698 }
1699 }
1700
1701
1702 const G4double halfHeight(height / 2.);
1704 const G4double freeHeightFraction (1. + 2. * comfort);
1705
1706
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;
1726 "WARNING: Not enough room in existing scene. Maybe logo is too large."
1728 }
1729 }
1730 if (worried) {
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."
1739 }
1740 }
1741
1742 G4double sxmid(xmid), symid(ymid), szmid(zmid);
1743 if (autoPlacing) {
1744
1745
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:
1751 sxmid = xmax + halfHeight + xComfort;
1752 symid = ymin - yComfort;
1753 szmid = zmin - zComfort;
1754 break;
1755 case minusX:
1756 sxmid = xmin - halfHeight - xComfort;
1757 symid = ymin - yComfort;
1758 szmid = zmax + zComfort;
1759 break;
1760 case Y:
1761 sxmid = xmin - xComfort;
1762 symid = ymax + halfHeight + yComfort;
1763 szmid = zmin - zComfort;
1764 break;
1765 case minusY:
1766 sxmid = xmax + xComfort;
1767 symid = ymin - halfHeight - yComfort;
1768 szmid = zmin - zComfort;
1769 break;
1770 case Z:
1771 sxmid = xmax + xComfort;
1772 symid = ymin - yComfort;
1773 szmid = zmax + halfHeight + zComfort;
1774 break;
1775 case minusZ:
1776 sxmid = xmin - xComfort;
1777 symid = ymin - yComfort;
1778 szmid = zmin - halfHeight - zComfort;
1779 break;
1780 }
1781 }
1782
1784 switch (logoDirection) {
1785 case X:
1787 break;
1788 case minusX:
1790 break;
1791 case Y:
1793 break;
1794 case minusY:
1796 break;
1797 case Z:
1798
1799 break;
1800 case minusZ:
1802 break;
1803 }
1805
1807 visAtts.SetForceSolid(true);
1808
1809 G4Logo* logo = new G4Logo(height,visAtts,transform);
1818 model->
SetExtent(extent.Transform(transform));
1819
1820
1821 const G4String& currentSceneName = pScene -> GetName ();
1822 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1823 if (successful) {
1825 G4cout <<
"G4 Logo of height " << userHeight <<
' ' << userHeightUnit
1826 << ", " << direction << "-direction, added to scene \""
1827 << currentSceneName << "\"";
1829 G4cout <<
"\n with extent " << extent
1832 }
1834 }
1835 }
1837
1839}
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()