1480 {
1481
1484
1486 if (!pScene) {
1488 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
1489 }
1490 return;
1491 } else {
1495 << "ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
1497 }
1498 return;
1499 }
1500 }
1501
1503 if (!pViewer) {
1506 "ERROR: G4VisCommandSceneAddLogo::SetNewValue: no viewer."
1507 "\n Auto direction needs a viewer."
1509 }
1510 return;
1511 }
1512
1513 G4double userHeight, red, green, blue, xmid, ymid, zmid;
1514 G4String userHeightUnit, direction, auto_manual, positionUnit;
1515 std::istringstream is (newValue);
1516 is >> userHeight >> userHeightUnit >> direction
1517 >> red >> green >> blue
1518 >> auto_manual
1519 >> xmid >> ymid >> zmid >> positionUnit;
1520
1523 if (userHeightUnit == "auto") {
1525 } else {
1527 }
1528
1530 xmid *= unit; ymid *= unit; zmid *= unit;
1531
1532 Direction logoDirection = X;
1533 if (direction == "auto") {
1534
1537 if (vp.
x() > vp.
y() && vp.
x() > vp.
z()) logoDirection = X;
1538 else if (vp.
x() < vp.
y() && vp.
x() < vp.
z()) logoDirection = minusX;
1539 else if (vp.
y() > vp.
x() && vp.
y() > vp.
z()) logoDirection = Y;
1540 else if (vp.
y() < vp.
x() && vp.
y() < vp.
z()) logoDirection = minusY;
1541 else if (vp.
z() > vp.
x() && vp.
z() > vp.
y()) logoDirection = Z;
1542 else if (vp.
z() < vp.
x() && vp.
z() < vp.
y()) logoDirection = minusZ;
1543 }
1544 else if (direction(0) == 'x') logoDirection = X;
1545 else if (direction(0) == 'y') logoDirection = Y;
1546 else if (direction(0) == 'z') logoDirection = Z;
1547 else if (direction(0) == '-') {
1548 if (direction(1) == 'x') logoDirection = minusX;
1549 else if (direction(1) == 'y') logoDirection = minusY;
1550 else if (direction(1) == 'z') logoDirection = minusZ;
1551 } else {
1553 G4cerr <<
"ERROR: Unrecogniseed direction: \""
1554 << direction <<
"\"." <<
G4endl;
1555 return;
1556 }
1557 }
1558
1559 G4bool autoPlacing =
false;
if (auto_manual ==
"auto") autoPlacing =
true;
1560
1561
1562
1569
1570
1573 worried = true;
1576 "WARNING: Existing scene does not yet have any extent."
1577 "\n Maybe you have not yet added any geometrical object."
1579 }
1580 }
1581
1582
1583 const G4double halfHeight(height / 2.);
1585 const G4double freeHeightFraction (1. + 2. * comfort);
1586
1587
1589 switch (logoDirection) {
1590 case X:
1591 case minusX:
1592 if (freeHeightFraction * (xmax - xmin) < height) room = false;
1593 break;
1594 case Y:
1595 case minusY:
1596 if (freeHeightFraction * (ymax - ymin) < height) room = false;
1597 break;
1598 case Z:
1599 case minusZ:
1600 if (freeHeightFraction * (zmax - zmin) < height) room = false;
1601 break;
1602 }
1603 if (!room) {
1604 worried = true;
1607 "WARNING: Not enough room in existing scene. Maybe logo is too large."
1609 }
1610 }
1611 if (worried) {
1614 "WARNING: The logo you have asked for is bigger than the existing"
1615 "\n scene. Maybe you have added it too soon. It is recommended that"
1616 "\n you add the logo last so that it can be correctly auto-positioned"
1617 "\n so as not to be obscured by any existing object and so that the"
1618 "\n view parameters can be correctly recalculated."
1620 }
1621 }
1622
1623 G4double sxmid(xmid), symid(ymid), szmid(zmid);
1624 if (autoPlacing) {
1625
1626
1627 const G4double xComfort = comfort * (xmax - xmin);
1628 const G4double yComfort = comfort * (ymax - ymin);
1629 const G4double zComfort = comfort * (zmax - zmin);
1630 switch (logoDirection) {
1631 case X:
1632 sxmid = xmax + halfHeight + xComfort;
1633 symid = ymin - yComfort;
1634 szmid = zmin - zComfort;
1635 break;
1636 case minusX:
1637 sxmid = xmin - halfHeight - xComfort;
1638 symid = ymin - yComfort;
1639 szmid = zmax + zComfort;
1640 break;
1641 case Y:
1642 sxmid = xmin - xComfort;
1643 symid = ymax + halfHeight + yComfort;
1644 szmid = zmin - zComfort;
1645 break;
1646 case minusY:
1647 sxmid = xmax + xComfort;
1648 symid = ymin - halfHeight - yComfort;
1649 szmid = zmin - zComfort;
1650 break;
1651 case Z:
1652 sxmid = xmax + xComfort;
1653 symid = ymin - yComfort;
1654 szmid = zmax + halfHeight + zComfort;
1655 break;
1656 case minusZ:
1657 sxmid = xmin - xComfort;
1658 symid = ymin - yComfort;
1659 szmid = zmin - halfHeight - zComfort;
1660 break;
1661 }
1662 }
1663
1665 switch (logoDirection) {
1666 case X:
1668 break;
1669 case minusX:
1671 break;
1672 case Y:
1674 break;
1675 case minusY:
1677 break;
1678 case Z:
1679
1680 break;
1681 case minusZ:
1683 break;
1684 }
1686
1688 visAtts.SetForceSolid(true);
1689
1690 G4Logo* logo = new G4Logo(height,visAtts);
1697
1698
1703
1704
1705 const G4String& currentSceneName = pScene -> GetName ();
1706 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1707 if (successful) {
1709 G4cout <<
"G4 Logo of height " << userHeight <<
' ' << userHeightUnit
1710 << ", " << direction << "-direction, added to scene \""
1711 << currentSceneName << "\"";
1713 G4cout <<
"\n with extent " << extent
1716 }
1718 }
1719 }
1721
1723}
G4GLOB_DLL std::ostream G4cerr
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 &)
void SetTransformation(const G4Transform3D &)
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()