1253 {
1254
1257
1259 if (!pScene) {
1261 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
1262 }
1263 return;
1264 }
1265
1267 if (!pViewer) {
1270 "ERROR: G4VisCommandSceneAddLogo::SetNewValue: no viewer."
1271 "\n Auto direction needs a viewer."
1273 }
1274 return;
1275 }
1276
1277 G4double userHeight, red, green, blue, xmid, ymid, zmid;
1278 G4String userHeightUnit, direction, auto_manual, positionUnit;
1279 std::istringstream is (newValue);
1280 is >> userHeight >> userHeightUnit >> direction
1281 >> red >> green >> blue
1282 >> auto_manual
1283 >> xmid >> ymid >> zmid >> positionUnit;
1284
1287 if (userHeightUnit == "auto") {
1289 } else {
1291 }
1292
1294 xmid *= unit; ymid *= unit; zmid *= unit;
1295
1296 Direction logoDirection = X;
1297 if (direction == "auto") {
1298
1301 if (vp.
x() > vp.
y() && vp.
x() > vp.
z()) logoDirection = X;
1302 else if (vp.
x() < vp.
y() && vp.
x() < vp.
z()) logoDirection = minusX;
1303 else if (vp.
y() > vp.
x() && vp.
y() > vp.
z()) logoDirection = Y;
1304 else if (vp.
y() < vp.
x() && vp.
y() < vp.
z()) logoDirection = minusY;
1305 else if (vp.
z() > vp.
x() && vp.
z() > vp.
y()) logoDirection = Z;
1306 else if (vp.
z() < vp.
x() && vp.
z() < vp.
y()) logoDirection = minusZ;
1307 }
1308 else if (direction(0) == 'x') logoDirection = X;
1309 else if (direction(0) == 'y') logoDirection = Y;
1310 else if (direction(0) == 'z') logoDirection = Z;
1311 else if (direction(0) == '-') {
1312 if (direction(1) == 'x') logoDirection = minusX;
1313 else if (direction(1) == 'y') logoDirection = minusY;
1314 else if (direction(1) == 'z') logoDirection = minusZ;
1315 } else {
1317 G4cout <<
"ERROR: Unrecogniseed direction: \""
1318 << direction <<
"\"." <<
G4endl;
1319 return;
1320 }
1321 }
1322
1323 G4bool autoPlacing =
false;
if (auto_manual ==
"auto") autoPlacing =
true;
1324
1325
1326
1333
1334
1337 worried = true;
1340 "WARNING: Existing scene does not yet have any extent."
1341 "\n Maybe you have not yet added any geometrical object."
1343 }
1344 }
1345
1346
1347 const G4double halfHeight(height / 2.);
1349 const G4double freeHeightFraction (1. + 2. * comfort);
1350
1351
1353 switch (logoDirection) {
1354 case X:
1355 case minusX:
1356 if (freeHeightFraction * (xmax - xmin) < height) room = false; break;
1357 case Y:
1358 case minusY:
1359 if (freeHeightFraction * (ymax - ymin) < height) room = false; break;
1360 case Z:
1361 case minusZ:
1362 if (freeHeightFraction * (zmax - zmin) < height) room = false; break;
1363 }
1364 if (!room) {
1365 worried = true;
1368 "WARNING: Not enough room in existing scene. Maybe logo is too large."
1370 }
1371 }
1372 if (worried) {
1375 "WARNING: The logo you have asked for is bigger than the existing"
1376 "\n scene. Maybe you have added it too soon. It is recommended that"
1377 "\n you add the logo last so that it can be correctly auto-positioned"
1378 "\n so as not to be obscured by any existing object and so that the"
1379 "\n view parameters can be correctly recalculated."
1381 }
1382 }
1383
1384 G4double sxmid(xmid), symid(ymid), szmid(zmid);
1385 if (autoPlacing) {
1386
1387
1388 const G4double xComfort = comfort * (xmax - xmin);
1389 const G4double yComfort = comfort * (ymax - ymin);
1390 const G4double zComfort = comfort * (zmax - zmin);
1391 switch (logoDirection) {
1392 case X:
1393 sxmid = xmax + halfHeight + xComfort;
1394 symid = ymin - yComfort;
1395 szmid = zmin - zComfort;
1396 break;
1397 case minusX:
1398 sxmid = xmin - halfHeight - xComfort;
1399 symid = ymin - yComfort;
1400 szmid = zmax + zComfort;
1401 break;
1402 case Y:
1403 sxmid = xmin - xComfort;
1404 symid = ymax + halfHeight + yComfort;
1405 szmid = zmin - zComfort;
1406 break;
1407 case minusY:
1408 sxmid = xmax + xComfort;
1409 symid = ymin - halfHeight - yComfort;
1410 szmid = zmin - zComfort;
1411 break;
1412 case Z:
1413 sxmid = xmax + xComfort;
1414 symid = ymin - yComfort;
1415 szmid = zmax + halfHeight + zComfort;
1416 break;
1417 case minusZ:
1418 sxmid = xmin - xComfort;
1419 symid = ymin - yComfort;
1420 szmid = zmin - halfHeight - zComfort;
1421 break;
1422 }
1423 }
1424
1426 switch (logoDirection) {
1427 case X:
1429 break;
1430 case minusX:
1432 break;
1433 case Y:
1435 break;
1436 case minusY:
1438 break;
1439 case Z:
1440
1441 break;
1442 case minusZ:
1444 break;
1445 }
1447
1449 visAtts.SetForceSolid(true);
1450
1451 G4Logo* logo = new G4Logo(height,visAtts);
1458
1459
1464
1465
1466 const G4String& currentSceneName = pScene -> GetName ();
1467 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1468 if (successful) {
1470 G4cout <<
"G4 Logo of height " << userHeight <<
' ' << userHeightUnit
1471 << ", " << direction << "-direction, added to scene \""
1472 << currentSceneName << "\"";
1474 G4cout <<
"\n with extent " << extent
1477 }
1479 }
1480 }
1481 else G4VisCommandsSceneAddUnsuccessful(verbosity);
1483}
G4DLLIMPORT 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
static G4VisManager * fpVisManager
void UpdateVisManagerScene(const G4String &sceneName="")
const G4Vector3D & GetViewpointDirection() const
G4double GetExtentRadius() const
G4Scene * GetCurrentScene() const
G4VViewer * GetCurrentViewer() const
static Verbosity GetVerbosity()