1719 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
1725 G4String userLengthUnit, direction, auto_manual, positionUnit;
1726 std::istringstream is (newValue);
1727 is >> userLength >> userLengthUnit >> direction
1728 >> red >> green >> blue
1730 >> xmid >> ymid >> zmid >> positionUnit;
1734 if (userLengthUnit ==
"auto") {
1736 G4double intLog10Length = std::floor(std::log10(length));
1737 length = std::pow(10,intLog10Length);
1744 xmid *= unit; ymid *= unit; zmid *= unit;
1747 if (direction(0) ==
'y') scaleDirection =
G4Scale::y;
1748 if (direction(0) ==
'z') scaleDirection =
G4Scale::z;
1754 "ERROR: G4VisCommandSceneAddScale::SetNewValue: no viewer."
1755 "\n Auto direction needs a viewer."
1766 if (direction ==
"auto") {
1767 if (std::abs(vp.
x()) > std::abs(vp.
y()) &&
1768 std::abs(vp.
x()) > std::abs(vp.
z())) {
1769 if (std::abs(up.
y()) > std::abs(up.
z())) scaleDirection =
G4Scale::z;
1772 else if (std::abs(vp.
y()) > std::abs(vp.
x()) &&
1773 std::abs(vp.
y()) > std::abs(vp.
z())) {
1774 if (std::abs(up.
x()) > std::abs(up.
z())) scaleDirection =
G4Scale::z;
1777 else if (std::abs(vp.
z()) > std::abs(vp.
x()) &&
1778 std::abs(vp.
z()) > std::abs(vp.
y())) {
1779 if (std::abs(up.
y()) > std::abs(up.
x())) scaleDirection =
G4Scale::x;
1784 G4bool autoPlacing =
false;
if (auto_manual ==
"auto") autoPlacing =
true;
1788 const G4double halfLength(length / 2.);
1790 const G4double freeLengthFraction (1. + 2. * comfort);
1805 "WARNING: Existing scene does not yet have any extent."
1806 "\n Maybe you have not yet added any geometrical object."
1812 switch (scaleDirection) {
1814 if (freeLengthFraction * (xmax - xmin) < length) room =
false;
break;
1816 if (freeLengthFraction * (ymax - ymin) < length) room =
false;
break;
1818 if (freeLengthFraction * (zmax - zmin) < length) room =
false;
break;
1824 "WARNING: Not enough room in existing scene. Maybe scale is too long."
1831 "WARNING: The scale you have asked for is bigger than the existing"
1832 "\n scene. Maybe you have added it too soon. It is recommended that"
1833 "\n you add the scale last so that it can be correctly auto-positioned"
1834 "\n so as not to be obscured by any existing object and so that the"
1835 "\n view parameters can be correctly recalculated."
1842 G4Scale scale(length, annotation, scaleDirection,
1843 false, xmid, ymid, zmid);
1849 scale.SetVisAttributes(pVisAttr);
1879 G4double sxmid(xmid), symid(ymid), szmid(zmid);
1883 const G4double xComfort = comfort * (xmax - xmin);
1884 const G4double yComfort = comfort * (ymax - ymin);
1885 const G4double zComfort = comfort * (zmax - zmin);
1886 switch (scaleDirection) {
1889 sxmid = xmax + xComfort;
1890 symid = ymin - yComfort;
1891 szmid = zmin - zComfort;
1893 sxmid = xmin - xComfort;
1894 symid = ymin - yComfort;
1895 szmid = zmax + zComfort;
1900 sxmid = xmin - xComfort;
1901 symid = ymax + yComfort;
1902 szmid = zmin - zComfort;
1904 sxmid = xmax + xComfort;
1905 symid = ymin - yComfort;
1906 szmid = zmin - zComfort;
1911 sxmid = xmax + xComfort;
1912 symid = ymin - yComfort;
1913 szmid = zmax + zComfort;
1915 sxmid = xmin - xComfort;
1916 symid = ymin - yComfort;
1917 szmid = zmax + zComfort;
1973 switch (scaleDirection) {
1975 scaleExtent =
G4VisExtent(-halfLength,halfLength,0,0,0,0);
1979 scaleExtent =
G4VisExtent(0,0,-halfLength,halfLength,0,0);
1983 scaleExtent =
G4VisExtent(0,0,0,0,-halfLength,halfLength);
1997 const G4String& currentSceneName = pScene -> GetName ();
1998 G4bool successful = pScene -> AddRunDurationModel (model, warn);
2001 G4cout <<
"Scale of " << annotation
2002 <<
" added to scene \"" << currentSceneName <<
"\".";
2004 G4cout <<
"\n with extent " << scaleExtent
2011 else G4VisCommandsSceneAddUnsuccessful(verbosity);
void UpdateVisManagerScene(const G4String &sceneName="")
const G4ViewParameters & GetViewParameters() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void SetExtent(const G4VisExtent &)
void SetTransformation(const G4Transform3D &)
G4double GetExtentRadius() const
const G4Vector3D & GetViewpointDirection() const
G4GLOB_DLL std::ostream G4cout
const G4VisExtent & GetExtent() const
const XML_Char XML_Content * model
static G4double ValueOf(const char *unitName)
static Verbosity GetVerbosity()
G4VViewer * GetCurrentViewer() const
const G4Vector3D & GetUpVector() const
G4Scene * GetCurrentScene() const
static G4VisManager * fpVisManager