89 fpCommand -> SetGuidance (
"Adds arrow to current scene.");
104 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
125 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
132 std::istringstream is(newValue);
133 is >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> unitString;
135 x1 *= unit; y1 *= unit; z1 *= unit;
136 x2 *= unit; y2 *= unit; z2 *= unit;
144 (x1, y1, z1, x2, y2, z2,
148 const G4String& currentSceneName = pScene -> GetName ();
149 G4bool successful = pScene -> AddRunDurationModel (model, warn);
152 G4cout <<
"Arrow has been added to scene \""
153 << currentSceneName <<
"\"."
166 fpCommand -> SetGuidance (
"Adds 2D arrow to current scene.");
195 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
201 std::istringstream is(newValue);
202 is >> x1 >> y1 >> x2 >> y2;
211 const G4String& currentSceneName = pScene -> GetName ();
212 G4bool successful = pScene -> AddRunDurationModel (model, warn);
215 G4cout <<
"A 2D arrow has been added to scene \""
216 << currentSceneName <<
"\"."
229 fWidth(width), fColour(colour)
234 G4Vector3D arrowPointLeftDirection(arrowDirection);
236 G4Vector3D arrowPointRightDirection(arrowDirection);
248void G4VisCommandSceneAddArrow2D::Arrow2D::operator()
251 sceneHandler.BeginPrimitives2D();
252 sceneHandler.AddPrimitive(fShaftPolyline);
253 sceneHandler.AddPrimitive(fHeadPolyline);
254 sceneHandler.EndPrimitives2D();
264 (
"Draws axes at (x0, y0, z0) of given length and colour.");
266 (
"If \"colour-string\" is \"auto\", x, y and z will be red, green and blue"
267 "\n respectively. Otherwise it can be one of the pre-defined text-specified"
268 "\n colours - see information printed by the vis manager at start-up or"
269 "\n use \"/vis/list\".");
271 (
"If \"length\" is negative, it is set to about 25% of scene extent.");
273 (
"If \"showtext\" is false, annotations are suppressed.");
284 parameter =
new G4UIparameter (
"length",
'd', omitable =
true);
287 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
290 parameter =
new G4UIparameter (
"colour-string",
's', omitable =
true);
293 parameter =
new G4UIparameter (
"showtext",
'b', omitable =
true);
314 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
321 <<
"ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
328 G4String unitString, colourString, showTextString;
330 std::istringstream is (newValue);
331 is >> x0 >> y0 >>
z0 >> length >> unitString
332 >> colourString >> showTextString;
337 x0 *= unit; y0 *= unit;
z0 *= unit;
341 const G4double intLog10Length = std::floor(std::log10(lengthMax));
342 length = std::pow(10,intLog10Length);
343 if (5.*length < lengthMax) length *= 5.;
344 else if (2.*length < lengthMax) length *= 2.;
353 if (arrowWidth > length/50.) arrowWidth = length/50.;
356 (x0, y0,
z0, length, arrowWidth, colourString, newValue,
359 G4bool successful = pScene -> AddRunDurationModel (model, warn);
360 const G4String& currentSceneName = pScene -> GetName ();
364 <<
"have been added to scene \"" << currentSceneName <<
"\"."
378 fpCommand -> SetGuidance (
"Adds date to current scene.");
380 (
"If \"date\"is omitted, the current date and time is drawn."
381 "\nOtherwise, the string, including the rest of the line, is drawn.");
383 parameter =
new G4UIparameter (
"size",
'i', omitable =
true);
384 parameter -> SetGuidance (
"Screen size of text in pixels.");
385 parameter -> SetDefaultValue (18);
387 parameter =
new G4UIparameter (
"x-position",
'd', omitable =
true);
388 parameter -> SetGuidance (
"x screen position in range -1 < x < 1.");
389 parameter -> SetDefaultValue (0.95);
391 parameter =
new G4UIparameter (
"y-position",
'd', omitable =
true);
392 parameter -> SetGuidance (
"y screen position in range -1 < y < 1.");
393 parameter -> SetDefaultValue (0.9);
395 parameter =
new G4UIparameter (
"layout",
's', omitable =
true);
396 parameter -> SetGuidance (
"Layout, i.e., adjustment: left|centre|right.");
397 parameter -> SetDefaultValue (
"right");
399 parameter =
new G4UIparameter (
"date",
's', omitable =
true);
400 parameter -> SetDefaultValue (
"-");
420 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
428 std::istringstream is(newValue);
429 is >> size >> x >> y >> layoutString >> dateString;
431 const size_t NREMAINDER = 100;
432 char remainder[NREMAINDER];
434 is.getline(remainder, NREMAINDER);
435 dateString += remainder;
447 const G4String& currentSceneName = pScene -> GetName ();
448 G4bool successful = pScene -> AddRunDurationModel (model, warn);
451 G4cout <<
"Date has been added to scene \""
452 << currentSceneName <<
"\"."
461void G4VisCommandSceneAddDate::Date::operator()
466 time = fTimer.GetClockTime();
471 std::string::size_type i = time.rfind(
'\n');
472 if (i != std::string::npos) time.erase(i);
478 sceneHandler.BeginPrimitives2D();
479 sceneHandler.AddPrimitive(text);
480 sceneHandler.EndPrimitives2D();
487 fpCommand -> SetGuidance (
"Adds digis to current scene.");
489 (
"Digis are drawn at end of event when the scene in which"
490 "\nthey are added is current.");
509 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
515 const G4String& currentSceneName = pScene -> GetName ();
516 G4bool successful = pScene -> AddEndOfEventModel (model, warn);
519 G4cout <<
"Digis, if any, will be drawn at end of run in scene \""
520 << currentSceneName <<
"\"."
535 (
"Adds electric field representation to current scene.");
537 (
"The first parameter is no. of data points per half extent. So, possibly, at"
538 "\nmaximum, the number of data points sampled is (2*n+1)^3, which can grow"
539 "\nlarge--be warned!"
540 "\nThe default value is 10, i.e., a 21x21x21 array, i.e., 9,261 sampling points."
541 "\nThat may swamp your view, but usually, a field is limited to a small part of"
542 "\nthe extent, so it's not a problem. But if it is, here are some of the things"
544 "\n- reduce the number of data points per half extent (first parameter);"
545 "\n- specify \"lightArrow\" (second parameter);"
546 "\n- restrict the region sampled with \"/vis/set/extentForField\";"
547 "\n- restrict the drawing to a specific volume with"
548 "\n \"/vis/set/volumeForField\" or \"/vis/touchable/volumeForField\"."
549 "\nNote: you might have to deactivate existing field models with"
550 "\n \"/vis/scene/activateModel Field false\" and re-issue"
551 "\n \"/vis/scene/add/...Field\" command again.");
553 (
"In the arrow representation, the length of the arrow is proportional"
554 "\nto the magnitude of the field and the colour is mapped onto the range"
555 "\nas a fraction of the maximum magnitude: 0->0.5->1 is red->green->blue.");
557 parameter =
new G4UIparameter (
"nDataPointsPerHalfExtent",
'i', omitable =
true);
558 parameter -> SetDefaultValue (10);
560 parameter =
new G4UIparameter (
"representation",
's', omitable =
true);
561 parameter -> SetParameterCandidates(
"fullArrow lightArrow");
562 parameter -> SetDefaultValue (
"fullArrow");
583 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
588 G4int nDataPointsPerHalfExtent;
590 std::istringstream iss(newValue);
591 iss >> nDataPointsPerHalfExtent >> representation;
594 if (representation ==
"lightArrow") {
599 (nDataPointsPerHalfExtent,modelRepresentation,
603 const G4String& currentSceneName = pScene -> GetName ();
604 G4bool successful = pScene -> AddRunDurationModel (model, warn);
608 <<
"Electric field, if any, will be drawn in scene \""
611 << nDataPointsPerHalfExtent
612 <<
" data points per half extent and with representation \""
628 fpCommand -> SetGuidance (
"Adds eventID to current scene.");
630 (
"Run and event numbers are drawn at end of event or run when"
631 "\n the scene in which they are added is current.");
633 parameter =
new G4UIparameter (
"size",
'i', omitable =
true);
634 parameter -> SetGuidance (
"Screen size of text in pixels.");
635 parameter -> SetDefaultValue (18);
637 parameter =
new G4UIparameter (
"x-position",
'd', omitable =
true);
638 parameter -> SetGuidance (
"x screen position in range -1 < x < 1.");
639 parameter -> SetDefaultValue (-0.95);
641 parameter =
new G4UIparameter (
"y-position",
'd', omitable =
true);
642 parameter -> SetGuidance (
"y screen position in range -1 < y < 1.");
643 parameter -> SetDefaultValue (0.9);
645 parameter =
new G4UIparameter (
"layout",
's', omitable =
true);
646 parameter -> SetGuidance (
"Layout, i.e., adjustment: left|centre|right.");
647 parameter -> SetDefaultValue (
"left");
667 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
675 std::istringstream is(newValue);
676 is >> size >> x >> y >> layoutString;
688 eoeModel->
SetType(
"EoEEventID");
691 G4bool successfulEoE = pScene -> AddEndOfEventModel (eoeModel, warn);
698 eorModel->
SetType(
"EoREventID");
701 G4bool successfulEoR = pScene -> AddEndOfRunModel (eorModel, warn);
703 if (successfulEoE && successfulEoR) {
705 const G4String& currentSceneName = pScene -> GetName ();
706 G4cout <<
"EventID has been added to scene \""
707 << currentSceneName <<
"\"."
716void G4VisCommandSceneAddEventID::EventID::operator()
724 if (!currentRun)
return;
728 std::ostringstream oss;
734 const G4Event* currentEvent = mp->GetEvent();
735 if (!currentEvent)
return;
737 oss <<
"Run " << currentRunID <<
" Event " << eventID;
746 size_t nKeptEvents = events? events->size(): 0;
747 oss <<
"Run " << currentRunID <<
" (" << nEvents <<
" event";
748 if (nEvents != 1) oss <<
's';
749 oss <<
", " << nKeptEvents <<
" kept)";
761 sceneHandler.BeginPrimitives2D();
762 sceneHandler.AddPrimitive(text);
763 sceneHandler.EndPrimitives2D();
771 (
"Adds a dummy model with given extent to the current scene."
772 "\nRequires the limits: xmin, xmax, ymin, ymax, zmin, zmax unit."
773 "\nThis can be used to provide an extent to the scene even if"
774 "\nno other models with extent are available. For example,"
775 "\neven if there is no geometry. In that case, for example:"
777 "\n /vis/scene/create"
778 "\n /vis/scene/add/extent -300 300 -300 300 -300 300 cm"
779 "\n /vis/sceneHandler/attach");
782 parameter =
new G4UIparameter (
"xmin",
'd', omitable =
true);
783 parameter -> SetDefaultValue (0.);
785 parameter =
new G4UIparameter (
"xmax",
'd', omitable =
true);
786 parameter -> SetDefaultValue (0.);
788 parameter =
new G4UIparameter (
"ymin",
'd', omitable =
true);
789 parameter -> SetDefaultValue (0.);
791 parameter =
new G4UIparameter (
"ymax",
'd', omitable =
true);
792 parameter -> SetDefaultValue (0.);
794 parameter =
new G4UIparameter (
"zmin",
'd', omitable =
true);
795 parameter -> SetDefaultValue (0.);
797 parameter =
new G4UIparameter (
"zmax",
'd', omitable =
true);
798 parameter -> SetDefaultValue (0.);
800 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
801 parameter -> SetDefaultValue (
"m");
821 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
826 G4double xmin, xmax, ymin, ymax, zmin, zmax;
828 std::istringstream is(newValue);
829 is >> xmin >> xmax >> ymin >> ymax >> zmin >> zmax >> unitString;
831 xmin *= unit; xmax *= unit;
832 ymin *= unit; ymax *= unit;
833 zmin *= unit; zmax *= unit;
835 G4VisExtent visExtent(xmin, xmax, ymin, ymax, zmin, zmax);
836 Extent* extent =
new Extent(xmin, xmax, ymin, ymax, zmin, zmax);
843 const G4String& currentSceneName = pScene -> GetName ();
844 G4bool successful = pScene -> AddRunDurationModel (model, warn);
847 G4cout <<
"A benign model with extent "
849 <<
" has been added to scene \""
850 << currentSceneName <<
"\"."
863fExtent(xmin,xmax,ymin,ymax,zmin,zmax)
866void G4VisCommandSceneAddExtent::Extent::operator()
874 fpCommand -> SetGuidance (
"Add frame to current scene.");
877 parameter =
new G4UIparameter (
"size",
'd', omitable =
true);
878 parameter -> SetGuidance (
"Size of frame. 1 = full window.");
879 parameter -> SetParameterRange (
"size > 0 && size <=1");
880 parameter -> SetDefaultValue (0.97);
900 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
906 std::istringstream is(newValue);
915 const G4String& currentSceneName = pScene -> GetName ();
916 G4bool successful = pScene -> AddRunDurationModel (model, warn);
919 G4cout <<
"Frame has been added to scene \""
920 << currentSceneName <<
"\"."
929void G4VisCommandSceneAddFrame::Frame::operator()
933 frame.push_back(
G4Point3D( fSize, fSize, 0.));
934 frame.push_back(
G4Point3D(-fSize, fSize, 0.));
935 frame.push_back(
G4Point3D(-fSize, -fSize, 0.));
936 frame.push_back(
G4Point3D( fSize, -fSize, 0.));
937 frame.push_back(
G4Point3D( fSize, fSize, 0.));
942 sceneHandler.BeginPrimitives2D();
943 sceneHandler.AddPrimitive(frame);
944 sceneHandler.EndPrimitives2D();
954 (
"A representation of the source(s) of the General Particle Source"
955 "\nwill be added to current scene and drawn, if applicable.");
958 parameter =
new G4UIparameter(
"red_or_string",
's', omitable =
true);
959 parameter -> SetDefaultValue (
"1.");
961 parameter =
new G4UIparameter(
"green",
'd', omitable =
true);
962 parameter -> SetDefaultValue (0.);
964 parameter =
new G4UIparameter (
"blue",
'd', omitable =
true);
965 parameter -> SetDefaultValue (0.);
967 parameter =
new G4UIparameter (
"opacity",
'd', omitable =
true);
968 parameter -> SetDefaultValue (0.3);
988 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
995 std::istringstream iss(newValue);
996 iss >> redOrString >> green >> blue >> opacity;
1001 const G4String& currentSceneName = pScene -> GetName ();
1002 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1006 "A representation of the source(s) of the General Particle Source will be drawn"
1007 "\n in colour " << colour <<
" for scene \""
1008 << currentSceneName <<
"\" if applicable."
1021 fpCommand -> SetGuidance (
"Adds hits to current scene.");
1023 (
"Hits are drawn at end of event when the scene in which"
1024 "\nthey are added is current.");
1043 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
1049 const G4String& currentSceneName = pScene -> GetName ();
1050 G4bool successful = pScene -> AddEndOfEventModel (model, warn);
1053 G4cout <<
"Hits, if any, will be drawn at end of run in scene \""
1054 << currentSceneName <<
"\"."
1067 fpCommand -> SetGuidance (
"Adds line to current scene.");
1070 parameter =
new G4UIparameter (
"x1",
'd', omitable =
false);
1072 parameter =
new G4UIparameter (
"y1",
'd', omitable =
false);
1074 parameter =
new G4UIparameter (
"z1",
'd', omitable =
false);
1076 parameter =
new G4UIparameter (
"x2",
'd', omitable =
false);
1078 parameter =
new G4UIparameter (
"y2",
'd', omitable =
false);
1080 parameter =
new G4UIparameter (
"z2",
'd', omitable =
false);
1082 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
1103 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
1110 std::istringstream is(newValue);
1111 is >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> unitString;
1113 x1 *= unit; y1 *= unit; z1 *= unit;
1114 x2 *= unit; y2 *= unit; z2 *= unit;
1116 Line* line =
new Line(x1, y1, z1, x2, y2, z2,
1123 const G4String& currentSceneName = pScene -> GetName ();
1124 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1127 G4cout <<
"Line has been added to scene \""
1128 << currentSceneName <<
"\"."
1141 fWidth(width), fColour(colour)
1151void G4VisCommandSceneAddLine::Line::operator()
1154 sceneHandler.BeginPrimitives();
1155 sceneHandler.AddPrimitive(fPolyline);
1156 sceneHandler.EndPrimitives();
1163 fpCommand -> SetGuidance (
"Adds 2D line to current scene.");
1166 parameter =
new G4UIparameter (
"x1",
'd', omitable =
false);
1168 parameter =
new G4UIparameter (
"y1",
'd', omitable =
false);
1170 parameter =
new G4UIparameter (
"x2",
'd', omitable =
false);
1172 parameter =
new G4UIparameter (
"y2",
'd', omitable =
false);
1192 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
1198 std::istringstream is(newValue);
1199 is >> x1 >> y1 >> x2 >> y2;
1208 const G4String& currentSceneName = pScene -> GetName ();
1209 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1212 G4cout <<
"A 2D line has been added to scene \""
1213 << currentSceneName <<
"\"."
1226 fWidth(width), fColour(colour)
1236void G4VisCommandSceneAddLine2D::Line2D::operator()
1239 sceneHandler.BeginPrimitives2D();
1240 sceneHandler.AddPrimitive(fPolyline);
1241 sceneHandler.EndPrimitives2D();
1250 (
"Adds local axes to physical volume(s).");
1252 parameter =
new G4UIparameter (
"physical-volume-name",
's', omitable =
false);
1254 parameter =
new G4UIparameter (
"copy-no",
'i', omitable =
true);
1255 parameter -> SetGuidance (
"If negative, matches any copy no.");
1256 parameter -> SetDefaultValue (-1);
1265 return "world 0 -1";
1277 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
1284 std::istringstream is (newValue);
1285 is >>
name >> copyNo;
1287 std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
1292 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
1294 size_t nWorlds = transportationManager->
GetNoWorlds();
1295 for (
size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
1304 (&searchModel,
name, copyNo);
1306 for (
const auto& findings: searchScene.
GetFindings()) {
1307 findingsVector.push_back(findings);
1312 for (
const auto& findings: findingsVector) {
1315 const auto& extent = findings.fpFoundPV->GetLogicalVolume()->GetSolid()->GetExtent();
1316 const auto&
transform = findings.fFoundObjectTransformation;
1318 const G4double lengthMax = extent.GetExtentRadius()/2.;
1319 const G4double intLog10LengthMax = std::floor(std::log10(lengthMax));
1320 G4double length = std::pow(10,intLog10LengthMax);
1321 if (5.*length < lengthMax) length *= 5.;
1322 else if (2.*length < lengthMax) length *= 2.;
1325 axesModel->SetGlobalTag(
"LocalAxesModel");
1326 std::ostringstream oss; oss
1327 <<
"Local Axes for " << findings.fpFoundPV->GetName()
1328 <<
':' << findings.fFoundPVCopyNo <<
':' <<
id++;
1329 axesModel->SetGlobalDescription(oss.str());
1334 G4cout <<
"\"" << findings.fpFoundPV->GetName()
1335 <<
"\", copy no. " << findings.fFoundPVCopyNo
1336 <<
",\n found in searched volume \""
1337 << findings.fpSearchPV->GetName()
1338 <<
"\" at depth " << findings.fFoundDepth
1339 <<
",\n base path: \"" << findings.fFoundBasePVPath
1340 <<
"\".\n Local axes have been added to scene \""
1341 << pScene->
GetName() <<
"\".";
1343 G4cout <<
" With extent " << extent
1354 if (findingsVector.empty()) {
1356 G4cerr <<
"ERROR: Volume \"" <<
name <<
"\"";
1358 G4cerr <<
", copy no. " << copyNo <<
",";
1374 fpCommand -> SetGuidance (
"Adds a logical volume to the current scene,");
1376 (
"Shows boolean components (if any), voxels (if any), readout geometry"
1377 "\n (if any), local axes and overlaps (if any), under control of the"
1378 "\n appropriate flag."
1379 "\n Note: voxels are not constructed until start of run -"
1380 "\n \"/run/beamOn\". (For voxels without a run, \"/run/beamOn 0\".)");
1382 parameter =
new G4UIparameter (
"logical-volume-name",
's', omitable =
false);
1384 parameter =
new G4UIparameter (
"depth-of-descent",
'i', omitable =
true);
1385 parameter -> SetGuidance (
"Depth of descent of geometry hierarchy.");
1386 parameter -> SetDefaultValue (1);
1388 parameter =
new G4UIparameter (
"booleans-flag",
'b', omitable =
true);
1389 parameter -> SetDefaultValue (
true);
1391 parameter =
new G4UIparameter (
"voxels-flag",
'b', omitable =
true);
1392 parameter -> SetDefaultValue (
true);
1394 parameter =
new G4UIparameter (
"readout-flag",
'b', omitable =
true);
1395 parameter -> SetDefaultValue (
true);
1397 parameter =
new G4UIparameter (
"axes-flag",
'b', omitable =
true);
1398 parameter -> SetDefaultValue (
true);
1399 parameter -> SetGuidance (
"Set \"false\" to suppress axes.");
1401 parameter =
new G4UIparameter(
"check-overlap-flag",
'b', omitable =
true);
1403 parameter -> SetGuidance (
"Set \"false\" to suppress overlap check.");
1424 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
1430 G4int requestedDepthOfDescent;
1431 G4String booleansString, voxelsString, readoutString, axesString;
1433 std::istringstream is (newValue);
1434 is >>
name >> requestedDepthOfDescent
1435 >> booleansString >> voxelsString >> readoutString >> axesString
1446 if (pLV ==
nullptr)
return;
1448 const std::vector<G4Scene::Model>& rdModelList =
1449 pScene -> GetRunDurationModelList();
1450 std::vector<G4Scene::Model>::const_iterator i;
1451 for (i = rdModelList.begin(); i != rdModelList.end(); ++i) {
1452 if (i->fpModel->GetGlobalDescription().find(
"Volume") != std::string::npos)
break;
1454 if (i != rdModelList.end()) {
1456 G4cout <<
"There is already a volume, \""
1457 << i->fpModel->GetGlobalDescription()
1458 <<
"\",\n in the run-duration model list of scene \""
1459 << pScene -> GetName()
1460 <<
"\".\n Your logical volume must be the only volume in the scene."
1461 <<
"\n Create a new scene and try again:"
1462 <<
"\n /vis/specify " <<
name
1464 <<
"\n /vis/scene/create"
1465 <<
"\n /vis/scene/add/logicalVolume " <<
name
1466 <<
"\n /vis/sceneHandler/attach"
1467 <<
"\n (and also, if necessary, /vis/viewer/flush)"
1474 (pLV, requestedDepthOfDescent, booleans, voxels, readout, checkOverlaps);
1475 const G4String& currentSceneName = pScene -> GetName ();
1476 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1480 G4bool axesSuccessful =
false;
1483 const G4double axisLengthMax = radius / 2.;
1484 const G4double intLog10Length = std::floor(std::log10(axisLengthMax));
1485 G4double axisLength = std::pow(10,intLog10Length);
1486 if (5.*axisLength < axisLengthMax) axisLength *= 5.;
1487 else if (2.*axisLength < axisLengthMax) axisLength *= 2.;
1488 const G4double axisWidth = axisLength / 20.;
1490 axesSuccessful = pScene -> AddRunDurationModel (axesModel, warn);
1501 G4cout <<
"Logical volume \"" << pLV -> GetName ()
1502 <<
"\" with requested depth of descent "
1503 << requestedDepthOfDescent
1505 if (!booleans)
G4cout <<
"out";
1506 G4cout <<
" boolean components, with";
1507 if (!voxels)
G4cout <<
"out";
1508 G4cout <<
" voxels,\n with";
1509 if (!readout)
G4cout <<
"out";
1510 G4cout <<
" readout geometry and with";
1511 if (!checkOverlaps)
G4cout <<
"out";
1512 G4cout <<
" overlap checking"
1513 <<
"\n has been added to scene \"" << currentSceneName <<
"\".";
1515 if (axesSuccessful) {
1517 "\n Axes have also been added at the origin of local cooordinates.";
1520 "\n Axes have not been added for some reason possibly stated above.";
1540 fpCommand -> SetGuidance (
"Adds a G4 logo to the current scene.");
1542 (
"If \"unit\" is \"auto\", height is roughly one tenth of scene extent.");
1544 (
"\"direction\" is that of outward-facing normal to front face of logo."
1545 "\nIf \"direction\" is \"auto\", logo faces the user in the current viewer.");
1547 (
"\nIf \"placement\" is \"auto\", logo is placed at bottom right of screen"
1548 "\n when viewed from logo direction.");
1550 parameter =
new G4UIparameter (
"height",
'd', omitable =
true);
1553 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
1556 parameter =
new G4UIparameter (
"direction",
's', omitable =
true);
1560 parameter =
new G4UIparameter (
"red",
'd', omitable =
true);
1563 parameter =
new G4UIparameter (
"green",
'd', omitable =
true);
1566 parameter =
new G4UIparameter (
"blue",
'd', omitable =
true);
1569 parameter =
new G4UIparameter (
"placement",
's', omitable =
true);
1570 parameter -> SetParameterCandidates(
"auto manual");
1573 parameter =
new G4UIparameter (
"xmid",
'd', omitable =
true);
1576 parameter =
new G4UIparameter (
"ymid",
'd', omitable =
true);
1579 parameter =
new G4UIparameter (
"zmid",
'd', omitable =
true);
1582 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
1603 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
1610 <<
"ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
1621 "ERROR: G4VisCommandSceneAddLogo::SetNewValue: no viewer."
1622 "\n Auto direction needs a viewer."
1628 G4double userHeight, red, green, blue, xmid, ymid, zmid;
1629 G4String userHeightUnit, direction, placement, positionUnit;
1630 std::istringstream is (newValue);
1631 is >> userHeight >> userHeightUnit >> direction
1632 >> red >> green >> blue
1634 >> xmid >> ymid >> zmid >> positionUnit;
1638 if (userHeightUnit ==
"auto") {
1645 xmid *= unit; ymid *= unit; zmid *= unit;
1648 if (direction ==
"auto") {
1652 if (vp.
x() > vp.
y() && vp.
x() > vp.
z()) logoDirection = X;
1653 else if (vp.
x() < vp.
y() && vp.
x() < vp.
z()) logoDirection = minusX;
1654 else if (vp.
y() > vp.
x() && vp.
y() > vp.
z()) logoDirection =
Y;
1655 else if (vp.
y() < vp.
x() && vp.
y() < vp.
z()) logoDirection = minusY;
1656 else if (vp.
z() > vp.
x() && vp.
z() > vp.
y()) logoDirection =
Z;
1657 else if (vp.
z() < vp.
x() && vp.
z() < vp.
y()) logoDirection = minusZ;
1659 else if (direction[0] ==
'x') logoDirection = X;
1660 else if (direction[0] ==
'y') logoDirection =
Y;
1661 else if (direction[0] ==
'z') logoDirection =
Z;
1662 else if (direction[0] ==
'-') {
1663 if (direction[1] ==
'x') logoDirection = minusX;
1664 else if (direction[1] ==
'y') logoDirection = minusY;
1665 else if (direction[1] ==
'z') logoDirection = minusZ;
1668 G4cerr <<
"ERROR: Unrecogniseed direction: \""
1669 << direction <<
"\"." <<
G4endl;
1674 G4bool autoPlacing =
false;
if (placement ==
"auto") autoPlacing =
true;
1691 "WARNING: Existing scene does not yet have any extent."
1692 "\n Maybe you have not yet added any geometrical object."
1698 const G4double halfHeight(height / 2.);
1700 const G4double freeHeightFraction (1. + 2. * comfort);
1704 switch (logoDirection) {
1707 if (freeHeightFraction * (xmax - xmin) < height) room =
false;
1711 if (freeHeightFraction * (ymax - ymin) < height) room =
false;
1715 if (freeHeightFraction * (zmax - zmin) < height) room =
false;
1722 "WARNING: Not enough room in existing scene. Maybe logo is too large."
1729 "WARNING: The logo you have asked for is bigger than the existing"
1730 "\n scene. Maybe you have added it too soon. It is recommended that"
1731 "\n you add the logo last so that it can be correctly auto-positioned"
1732 "\n so as not to be obscured by any existing object and so that the"
1733 "\n view parameters can be correctly recalculated."
1738 G4double sxmid(xmid), symid(ymid), szmid(zmid);
1742 const G4double xComfort = comfort * (xmax - xmin);
1743 const G4double yComfort = comfort * (ymax - ymin);
1744 const G4double zComfort = comfort * (zmax - zmin);
1745 switch (logoDirection) {
1747 sxmid = xmax + halfHeight + xComfort;
1748 symid = ymin - yComfort;
1749 szmid = zmin - zComfort;
1752 sxmid = xmin - halfHeight - xComfort;
1753 symid = ymin - yComfort;
1754 szmid = zmax + zComfort;
1757 sxmid = xmin - xComfort;
1758 symid = ymax + halfHeight + yComfort;
1759 szmid = zmin - zComfort;
1762 sxmid = xmax + xComfort;
1763 symid = ymin - halfHeight - yComfort;
1764 szmid = zmin - zComfort;
1767 sxmid = xmax + xComfort;
1768 symid = ymin - yComfort;
1769 szmid = zmax + halfHeight + zComfort;
1772 sxmid = xmin - xComfort;
1773 symid = ymin - yComfort;
1774 szmid = zmin - halfHeight - zComfort;
1780 switch (logoDirection) {
1817 const G4String& currentSceneName = pScene -> GetName ();
1818 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1821 G4cout <<
"G4 Logo of height " << userHeight <<
' ' << userHeightUnit
1822 <<
", " << direction <<
"-direction, added to scene \""
1823 << currentSceneName <<
"\"";
1825 G4cout <<
"\n with extent " << extent
1852 const G4double xb = -h2, yb = f2 + w;
1853 const G4double dx = xt - xb, dy = yt - yb;
1857 const G4double d = std::sqrt(dx * dx + dy * dy);
1860 const G4double x8 = ((-ss * d - dx * (yt - y8)) / dy) + xt;
1862 G4double x9 = ((-(ss - w) * d - dx * (yt - y8)) / dy) + xt;
1864 const G4double xtr = ss - f1, ytr = -ss - f2 -w;
1865 x9 += xtr; y9 += ytr;
1890 G4Box bS2(
"bS2",ss,ss,
d2+2.*e);
1899 fp4 = logo4.CreatePolyhedron();
1908 fp4->SetVisAttributes(visAtts);
1918void G4VisCommandSceneAddLogo::G4Logo::operator()
1920 sceneHandler.BeginPrimitives();
1921 sceneHandler.AddPrimitive(*fpG);
1922 sceneHandler.AddPrimitive(*fp4);
1923 sceneHandler.EndPrimitives();
1931 fpCommand -> SetGuidance (
"Adds 2D logo to current scene.");
1933 parameter =
new G4UIparameter (
"size",
'i', omitable =
true);
1934 parameter -> SetGuidance (
"Screen size of text in pixels.");
1935 parameter -> SetDefaultValue (48);
1937 parameter =
new G4UIparameter (
"x-position",
'd', omitable =
true);
1938 parameter -> SetGuidance (
"x screen position in range -1 < x < 1.");
1939 parameter -> SetDefaultValue (-0.9);
1941 parameter =
new G4UIparameter (
"y-position",
'd', omitable =
true);
1942 parameter -> SetGuidance (
"y screen position in range -1 < y < 1.");
1943 parameter -> SetDefaultValue (-0.9);
1945 parameter =
new G4UIparameter (
"layout",
's', omitable =
true);
1946 parameter -> SetGuidance (
"Layout, i.e., adjustment: left|centre|right.");
1947 parameter -> SetDefaultValue (
"left");
1967 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
1975 std::istringstream is(newValue);
1976 is >> size >> x >> y >> layoutString;
1988 const G4String& currentSceneName = pScene -> GetName ();
1989 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1992 G4cout <<
"2D logo has been added to scene \""
1993 << currentSceneName <<
"\"."
2002void G4VisCommandSceneAddLogo2D::Logo2D::operator()
2010 sceneHandler.BeginPrimitives2D();
2011 sceneHandler.AddPrimitive(text);
2012 sceneHandler.EndPrimitives2D();
2020 (
"Adds magnetic field representation to current scene.");
2046 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
2051 G4int nDataPointsPerHalfScene;
2053 std::istringstream iss(newValue);
2054 iss >> nDataPointsPerHalfScene >> representation;
2057 if (representation ==
"lightArrow") {
2062 (nDataPointsPerHalfScene,modelRepresentation,
2066 const G4String& currentSceneName = pScene -> GetName ();
2067 G4bool successful = pScene -> AddRunDurationModel (model, warn);
2071 <<
"Magnetic field, if any, will be drawn in scene \""
2074 << nDataPointsPerHalfScene
2075 <<
" data points per half extent and with representation \""
2092 (
"Adds Primitive Scorer Hits (PSHits) to current scene.");
2094 (
"PSHits are drawn at end of run when the scene in which"
2095 "\nthey are added is current.");
2097 (
"Optional parameter specifies name of scoring map. By default all"
2098 "\nscoring maps registered with the G4ScoringManager are drawn.");
2099 fpCommand -> SetParameterName (
"mapname", omitable =
true);
2120 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
2126 const G4String& currentSceneName = pScene -> GetName ();
2127 G4bool successful = pScene -> AddEndOfRunModel (model, warn);
2130 if (newValue ==
"all") {
2131 G4cout <<
"All Primitive Scorer hits";
2133 G4cout <<
"Hits of Primitive Scorer \"" << newValue <<
'"';
2135 G4cout <<
" will be drawn at end of run in scene \""
2136 << currentSceneName <<
"\"."
2151 (
"Adds an annotated scale line to the current scene.");
2153 (
"If \"unit\" is \"auto\", length is roughly one tenth of the scene extent.");
2155 (
"If \"direction\" is \"auto\", scale is roughly in the plane of the current view.");
2157 (
"If \"placement\" is \"auto\", scale is placed at bottom left of current view."
2158 "\n Otherwise placed at (xmid,ymid,zmid).");
2160 (
"An annotated line in the specified direction with tick marks at the"
2161 "\nend. If autoPlacing is true it is required to be centred at the"
2162 "\nfront, right, bottom corner of the world space, comfortably outside"
2163 "\nthe existing bounding box/sphere so that existing objects do not"
2164 "\nobscure it. Otherwise it is required to be drawn with mid-point at"
2165 "\n(xmid, ymid, zmid)."
2167 "\nThe auto placing algorithm is (approx):"
2168 "\n x = xmin + (1 + comfort) * (xmax - xmin);"
2169 "\n y = ymin - comfort * (ymax - ymin);"
2170 "\n z = zmin + (1 + comfort) * (zmax - zmin);"
2171 "\n if direction == x then (x - length,y,z) to (x,y,z);"
2172 "\n if direction == y then (x,y,z) to (x,y + length,z);"
2173 "\n if direction == z then (x,y,z - length) to (x,y,z);"
2176 parameter =
new G4UIparameter (
"length",
'd', omitable =
true);
2179 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
2182 parameter =
new G4UIparameter (
"direction",
's', omitable =
true);
2186 parameter =
new G4UIparameter (
"red",
'd', omitable =
true);
2189 parameter =
new G4UIparameter (
"green",
'd', omitable =
true);
2192 parameter =
new G4UIparameter (
"blue",
'd', omitable =
true);
2195 parameter =
new G4UIparameter (
"placement",
's', omitable =
true);
2196 parameter -> SetParameterCandidates(
"auto manual");
2199 parameter =
new G4UIparameter (
"xmid",
'd', omitable =
true);
2202 parameter =
new G4UIparameter (
"ymid",
'd', omitable =
true);
2205 parameter =
new G4UIparameter (
"zmid",
'd', omitable =
true);
2208 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
2229 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
2236 <<
"ERROR: Scene has no extent. Add volumes or use \"/vis/scene/add/extent\"."
2243 G4double userLength, red, green, blue, xmid, ymid, zmid;
2244 G4String userLengthUnit, direction, placement, positionUnit;
2245 std::istringstream is (newValue);
2246 is >> userLength >> userLengthUnit >> direction
2247 >> red >> green >> blue
2249 >> xmid >> ymid >> zmid >> positionUnit;
2253 if (userLengthUnit ==
"auto") {
2255 const G4double intLog10Length = std::floor(std::log10(lengthMax));
2256 length = std::pow(10,intLog10Length);
2257 if (5.*length < lengthMax) length *= 5.;
2258 else if (2.*length < lengthMax) length *= 2.;
2265 xmid *= unit; ymid *= unit; zmid *= unit;
2268 if (direction[0] ==
'y') scaleDirection = Scale::y;
2269 if (direction[0] ==
'z') scaleDirection = Scale::z;
2275 "ERROR: G4VisCommandSceneAddScale::SetNewValue: no viewer."
2276 "\n Auto direction needs a viewer."
2287 if (direction ==
"auto") {
2288 if (std::abs(vp.
x()) > std::abs(vp.
y()) &&
2289 std::abs(vp.
x()) > std::abs(vp.
z())) {
2290 if (std::abs(up.
y()) > std::abs(up.
z())) scaleDirection = Scale::z;
2291 else scaleDirection = Scale::y;
2293 else if (std::abs(vp.
y()) > std::abs(vp.
x()) &&
2294 std::abs(vp.
y()) > std::abs(vp.
z())) {
2295 if (std::abs(up.
x()) > std::abs(up.
z())) scaleDirection = Scale::z;
2296 else scaleDirection = Scale::x;
2298 else if (std::abs(vp.
z()) > std::abs(vp.
x()) &&
2299 std::abs(vp.
z()) > std::abs(vp.
y())) {
2300 if (std::abs(up.
y()) > std::abs(up.
x())) scaleDirection = Scale::x;
2301 else scaleDirection = Scale::y;
2305 G4bool autoPlacing =
false;
if (placement ==
"auto") autoPlacing =
true;
2309 const G4double halfLength(length / 2.);
2311 const G4double freeLengthFraction (1. + 2. * comfort);
2326 "WARNING: Existing scene does not yet have any extent."
2327 "\n Maybe you have not yet added any geometrical object."
2334 switch (scaleDirection) {
2336 if (freeLengthFraction * (xmax - xmin) < length) room =
false;
2339 if (freeLengthFraction * (ymax - ymin) < length) room =
false;
2342 if (freeLengthFraction * (zmax - zmin) < length) room =
false;
2349 "WARNING: Not enough room in existing scene. Maybe scale is too long."
2356 "WARNING: The scale you have asked for is bigger than the existing"
2357 "\n scene. Maybe you have added it too soon. It is recommended that"
2358 "\n you add the scale last so that it can be correctly auto-positioned"
2359 "\n so as not to be obscured by any existing object and so that the"
2360 "\n view parameters can be correctly recalculated."
2388 G4double sxmid(xmid), symid(ymid), szmid(zmid);
2392 const G4double xComfort = comfort * (xmax - xmin);
2393 const G4double yComfort = comfort * (ymax - ymin);
2394 const G4double zComfort = comfort * (zmax - zmin);
2395 switch (scaleDirection) {
2398 sxmid = xmax + xComfort;
2399 symid = ymin - yComfort;
2400 szmid = zmin - zComfort;
2402 sxmid = xmin - xComfort;
2403 symid = ymin - yComfort;
2404 szmid = zmax + zComfort;
2409 sxmid = xmin - xComfort;
2410 symid = ymax + yComfort;
2411 szmid = zmin - zComfort;
2413 sxmid = xmax + xComfort;
2414 symid = ymin - yComfort;
2415 szmid = zmin - zComfort;
2420 sxmid = xmax + xComfort;
2421 symid = ymin - yComfort;
2422 szmid = zmax + zComfort;
2424 sxmid = xmin - xComfort;
2425 symid = ymin - yComfort;
2426 szmid = zmax + zComfort;
2436 switch (scaleDirection) {
2450 if (direction ==
"auto") {
2451 switch (scaleDirection) {
2474 const G4String& currentSceneName = pScene -> GetName ();
2475 G4bool successful = pScene -> AddRunDurationModel (model, warn);
2478 G4cout <<
"Scale of " << annotation
2479 <<
" added to scene \"" << currentSceneName <<
"\".";
2481 G4cout <<
"\n with extent " << scaleExtent
2501 const G4double halfLength(length / 2.);
2502 const G4double tickLength(length / 20.);
2520 fTick11.push_back(r1 + ticky);
2521 fTick11.push_back(r1 - ticky);
2522 fTick12.push_back(r1 + tickz);
2523 fTick12.push_back(r1 - tickz);
2524 fTick21.push_back(r2 + ticky);
2525 fTick21.push_back(r2 - ticky);
2526 fTick22.push_back(r2 + tickz);
2527 fTick22.push_back(r2 - tickz);
2535 G4Point3D textPosition(0., tickLength, 0.);
2542void G4VisCommandSceneAddScale::Scale::operator()
2546 sceneHandler.BeginPrimitives();
2547 sceneHandler.AddPrimitive(fScaleLine);
2548 sceneHandler.AddPrimitive(fTick11);
2549 sceneHandler.AddPrimitive(fTick12);
2550 sceneHandler.AddPrimitive(fTick21);
2551 sceneHandler.AddPrimitive(fTick22);
2552 sceneHandler.AddPrimitive(fText);
2553 sceneHandler.EndPrimitives();
2561 fpCommand -> SetGuidance (
"Adds text to current scene.");
2563 (
"Use \"/vis/set/textColour\" to set colour.");
2565 (
"Use \"/vis/set/textLayout\" to set layout:");
2576 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
2579 parameter =
new G4UIparameter (
"font_size",
'd', omitable =
true);
2583 parameter =
new G4UIparameter (
"x_offset",
'd', omitable =
true);
2587 parameter =
new G4UIparameter (
"y_offset",
'd', omitable =
true);
2591 parameter =
new G4UIparameter (
"text",
's', omitable =
true);
2592 parameter->
SetGuidance (
"The rest of the line is text.");
2613 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
2629 x *= unit; y *= unit; z *= unit;
2638 const G4String& currentSceneName = pScene -> GetName ();
2639 G4bool successful = pScene -> AddRunDurationModel (model, warn);
2642 G4cout <<
"Text \"" << text
2643 <<
"\" has been added to scene \"" << currentSceneName <<
"\"."
2658 fpCommand -> SetGuidance (
"Adds 2D text to current scene.");
2660 (
"Use \"/vis/set/textColour\" to set colour.");
2662 (
"Use \"/vis/set/textLayout\" to set layout:");
2670 parameter =
new G4UIparameter (
"font_size",
'd', omitable =
true);
2674 parameter =
new G4UIparameter (
"x_offset",
'd', omitable =
true);
2678 parameter =
new G4UIparameter (
"y_offset",
'd', omitable =
true);
2682 parameter =
new G4UIparameter (
"text",
's', omitable =
true);
2683 parameter->
SetGuidance (
"The rest of the line is text.");
2704 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
2729 const G4String& currentSceneName = pScene -> GetName ();
2730 G4bool successful = pScene -> AddRunDurationModel (model, warn);
2733 G4cout <<
"2D text \"" << text
2734 <<
"\" has been added to scene \"" << currentSceneName <<
"\"."
2747void G4VisCommandSceneAddText2D::G4Text2D::operator()
2749 sceneHandler.BeginPrimitives2D();
2750 sceneHandler.AddPrimitive(fText);
2751 sceneHandler.EndPrimitives2D();
2760 (
"/vis/scene/add/trajectories",
this);
2762 (
"Adds trajectories to current scene.");
2764 (
"Causes trajectories, if any, to be drawn at the end of processing an"
2765 "\nevent. Switches on trajectory storing and sets the"
2766 "\ndefault trajectory type.");
2768 (
"The command line parameter list determines the default trajectory type."
2769 "\nIf it contains the string \"smooth\", auxiliary inter-step points will"
2770 "\nbe inserted to improve the smoothness of the drawing of a curved"
2772 "\nIf it contains the string \"rich\", significant extra information will"
2773 "\nbe stored in the trajectory (G4RichTrajectory) amenable to modeling"
2774 "\nand filtering with \"/vis/modeling/trajectories/create/drawByAttribute\""
2775 "\nand \"/vis/filtering/trajectories/create/attributeFilter\" commands."
2776 "\nIt may contain both strings in any order.");
2778 (
"\nTo switch off trajectory storing: \"/tracking/storeTrajectory 0\"."
2779 "\nSee also \"/vis/scene/endOfEventAction\".");
2781 (
"Note: This only sets the default. Independently of the result of this"
2782 "\ncommand, a user may instantiate a trajectory that overrides this default"
2783 "\nin PreUserTrackingAction.");
2784 fpCommand -> SetParameterName (
"default-trajectory-type", omitable =
true);
2805 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
2809 const G4String& currentSceneName = pScene -> GetName ();
2813 if (newValue.find(
"smooth") != std::string::npos) smooth =
true;
2814 if (newValue.find(
"rich") != std::string::npos) rich =
true;
2815 if (newValue.size() && !(rich || smooth)) {
2817 G4cerr <<
"ERROR: Unrecognised parameter \"" << newValue <<
"\""
2818 "\n No action taken."
2826 G4int newVerbose = 2;
2829 if (smooth && rich) {
2830 UImanager->
ApplyCommand(
"/tracking/storeTrajectory 4");
2831 defaultTrajectoryType =
"G4RichTrajectory configured for smooth steps";
2832 }
else if (smooth) {
2833 UImanager->
ApplyCommand(
"/tracking/storeTrajectory 2");
2834 defaultTrajectoryType =
"G4SmoothTrajectory";
2836 UImanager->
ApplyCommand(
"/tracking/storeTrajectory 3");
2837 defaultTrajectoryType =
"G4RichTrajectory";
2839 UImanager->
ApplyCommand(
"/tracking/storeTrajectory 1");
2840 defaultTrajectoryType =
"G4Trajectory";
2846 "Attributes available for modeling and filtering with"
2847 "\n \"/vis/modeling/trajectories/create/drawByAttribute\" and"
2848 "\n \"/vis/filtering/trajectories/create/attributeFilter\" commands:"
2854 }
else if (smooth) {
2864 auto eoeModel = eoeList.begin();
2865 for (; eoeModel != eoeList.end(); ++eoeModel) {
2866 const auto* actualModel = eoeModel->fpModel;
2869 if (eoeModel == eoeList.end()) {
2872 pScene -> AddEndOfEventModel (model, warn);
2878 G4cout <<
"Default trajectory type " << defaultTrajectoryType
2879 <<
"\n will be used to store trajectories for scene \""
2880 << currentSceneName <<
"\"."
2886 "WARNING: Trajectory storing has been requested. This action may be"
2887 "\n reversed with \"/tracking/storeTrajectory 0\"."
2900 (
"Add named Vis User Action to current scene.");
2902 (
"Attempts to match search string to name of action - use unique sub-string.");
2904 (
"(Use /vis/list to see names of registered actions.)");
2906 (
"If name == \"all\" (default), all actions are added.");
2907 fpCommand -> SetParameterName(
"action-name", omitable =
true);
2927 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
2934 const std::vector<G4VisManager::UserVisAction>& runDurationUserVisActions =
2936 for (
size_t i = 0; i < runDurationUserVisActions.size(); i++) {
2937 const G4String&
name = runDurationUserVisActions[i].fName;
2938 G4VUserVisAction* visAction = runDurationUserVisActions[i].fpUserVisAction;
2939 if (newValue ==
"all" ||
name.find(newValue) != std::string::npos) {
2941 AddVisAction(
name,visAction,pScene,runDuration,verbosity);
2945 const std::vector<G4VisManager::UserVisAction>& endOfEventUserVisActions =
2947 for (
size_t i = 0; i < endOfEventUserVisActions.size(); i++) {
2948 const G4String&
name = endOfEventUserVisActions[i].fName;
2950 if (newValue ==
"all" ||
name.find(newValue) != std::string::npos) {
2952 AddVisAction(
name,visAction,pScene,endOfEvent,verbosity);
2956 const std::vector<G4VisManager::UserVisAction>& endOfRunUserVisActions =
2958 for (
size_t i = 0; i < endOfRunUserVisActions.size(); i++) {
2959 const G4String&
name = endOfRunUserVisActions[i].fName;
2961 if (newValue ==
"all" ||
name.find(newValue) != std::string::npos) {
2963 AddVisAction(
name,visAction,pScene,endOfRun,verbosity);
2969 G4cout <<
"WARNING: No User Vis Action registered." <<
G4endl;
2986 const std::map<G4VUserVisAction*,G4VisExtent>& visExtentMap =
2989 std::map<G4VUserVisAction*,G4VisExtent>::const_iterator i =
2990 visExtentMap.find(visAction);
2991 if (i != visExtentMap.end()) extent = i->second;
2995 <<
"WARNING: User Vis Action \"" <<
name <<
"\" extent is null."
3001 model->
SetType(
"User Vis Action");
3005 G4bool successful =
false;;
3008 successful = pScene -> AddRunDurationModel (model, warn);
3011 successful = pScene -> AddEndOfEventModel (model, warn);
3014 successful = pScene -> AddEndOfRunModel (model, warn);
3019 const G4String& currentSceneName = pScene -> GetName ();
3020 G4cout <<
"User Vis Action added to scene \""
3021 << currentSceneName <<
"\"";
3023 G4cout <<
"\n with extent " << extent;
3037 (
"Adds a physical volume to current scene, with optional clipping volume.");
3039 (
"If physical-volume-name is \"world\" (the default), the top of the"
3040 "\nmain geometry tree (material world) is added. If \"worlds\", the"
3041 "\ntops of all worlds - material world and parallel worlds, if any - are"
3042 "\nadded. Otherwise a search of all worlds is made.");
3044 (
"In the last case the names of all volumes in all worlds are matched"
3045 "\nagainst physical-volume-name. If this is of the form \"/regexp/\","
3046 "\nwhere regexp is a regular expression (see C++ regex), the match uses"
3047 "\nthe usual rules of regular expression matching. Otherwise an exact"
3048 "\nmatch is required."
3049 "\nFor example, \"/Shap/\" adds \"Shape1\" and \"Shape2\".");
3051 (
"It may help to see a textual representation of the geometry hierarchy of"
3052 "\nthe worlds. Try \"/vis/drawTree [worlds]\" or one of the driver/browser"
3053 "\ncombinations that have the required functionality, e.g., HepRepFile.");
3055 (
"If clip-volume-type is specified, the subsequent parameters are used to"
3056 "\nto define a clipping volume. For example,"
3057 "\n\"/vis/scene/add/volume ! ! ! -box km 0 1 0 1 0 1\" will draw the world"
3058 "\nwith the positive octant cut away. (If the Boolean Processor issues"
3059 "\nwarnings try replacing 0 by 0.000000001 or something.)");
3061 (
"If clip-volume-type is prepended with '-', the clip-volume is subtracted"
3062 "\n(cutaway). (This is the default if there is no prepended character.)"
3063 "\nIf '*' is prepended, the intersection of the physical-volume and the"
3064 "\nclip-volume is made. (You can make a section through the detector with"
3065 "\na thin box, for example).");
3067 (
"For \"box\", the parameters are xmin,xmax,ymin,ymax,zmin,zmax."
3068 "\nOnly \"box\" is programmed at present.");
3070 parameter =
new G4UIparameter (
"physical-volume-name",
's', omitable =
true);
3071 parameter -> SetDefaultValue (
"world");
3073 parameter =
new G4UIparameter (
"copy-no",
'i', omitable =
true);
3074 parameter -> SetGuidance (
"If negative, matches any copy no.");
3075 parameter -> SetDefaultValue (-1);
3077 parameter =
new G4UIparameter (
"depth-of-descent",
'i', omitable =
true);
3078 parameter -> SetGuidance
3079 (
"Depth of descent of geometry hierarchy. Default = unlimited depth.");
3082 parameter =
new G4UIparameter (
"clip-volume-type",
's', omitable =
true);
3083 parameter -> SetParameterCandidates(
"none box -box *box");
3084 parameter -> SetDefaultValue (
"none");
3085 parameter -> SetGuidance(
"[-|*]type. See general guidance.");
3087 parameter =
new G4UIparameter (
"parameter-unit",
's', omitable =
true);
3088 parameter -> SetDefaultValue (
"m");
3090 parameter =
new G4UIparameter (
"parameter-1",
'd', omitable =
true);
3091 parameter -> SetDefaultValue (0.);
3093 parameter =
new G4UIparameter (
"parameter-2",
'd', omitable =
true);
3094 parameter -> SetDefaultValue (0.);
3096 parameter =
new G4UIparameter (
"parameter-3",
'd', omitable =
true);
3097 parameter -> SetDefaultValue (0.);
3099 parameter =
new G4UIparameter (
"parameter-4",
'd', omitable =
true);
3100 parameter -> SetDefaultValue (0.);
3102 parameter =
new G4UIparameter (
"parameter-5",
'd', omitable =
true);
3103 parameter -> SetDefaultValue (0.);
3105 parameter =
new G4UIparameter (
"parameter-6",
'd', omitable =
true);
3106 parameter -> SetDefaultValue (0.);
3115 return "world 0 -1";
3127 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
3133 G4int copyNo, requestedDepthOfDescent;
3134 G4double param1, param2, param3, param4, param5, param6;
3135 std::istringstream is (newValue);
3136 is >>
name >> copyNo >> requestedDepthOfDescent
3137 >> clipVolumeType >> parameterUnit
3138 >> param1 >> param2 >> param3 >> param4 >> param5 >> param6;
3141 if (clipVolumeType[
size_t(0)] ==
'-') {
3142 clipVolumeType = clipVolumeType.substr(1);
3143 }
else if (clipVolumeType[
size_t(0)] ==
'*') {
3145 clipVolumeType = clipVolumeType.substr(1);
3148 param1 *= unit; param2 *= unit; param3 *= unit;
3149 param4 *= unit; param5 *= unit; param6 *= unit;
3152 if (clipVolumeType ==
"box") {
3153 const G4double dX = (param2 - param1) / 2.;
3154 const G4double dY = (param4 - param3) / 2.;
3155 const G4double dZ = (param6 - param5) / 2.;
3156 const G4double x0 = (param2 + param1) / 2.;
3157 const G4double y0 = (param4 + param3) / 2.;
3160 (
"_displaced_clipping_box",
3161 new G4Box(
"_clipping_box",dX,dY,dZ),
3168 size_t nWorlds = transportationManager->
GetNoWorlds();
3171 static G4bool warned =
false;
3172 if (!warned &&
name !=
"worlds") {
3174 "WARNING: Parallel worlds in operation. To visualise, specify"
3175 "\n \"worlds\" or the parallel world volume or sub-volume name"
3176 "\n and control visibility with /vis/geometry."
3178 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
3180 for (
size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
3181 G4cout <<
" World " << i <<
": " << (*iterWorld)->GetName()
3195 "ERROR: G4VisCommandSceneAddVolume::SetNewValue:"
3196 "\n No world. Maybe the geometry has not yet been defined."
3197 "\n Try \"/run/initialize\""
3203 std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
3215 G4bool useFullExtent =
false;
3223 if (
name ==
"world") {
3225 findingsVector.push_back
3228 }
else if (
name ==
"worlds") {
3233 "WARNING: G4VisCommandSceneAddVolume::SetNewValue:"
3234 "\n Parallel worlds requested but none exist."
3235 "\n Just adding material world."
3239 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
3241 for (
size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
3242 findingsVector.push_back
3244 (*iterWorld,*iterWorld));
3254 useFullExtent =
true;
3256 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
3258 for (
size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
3267 (&searchModel,
name, copyNo, requestedDepthOfDescent);
3269 for (
const auto& findings: searchScene.
GetFindings()) {
3270 findingsVector.push_back(findings);
3275 for (
const auto& findings: findingsVector) {
3277 findings.fpFoundPV->SetCopyNo(findings.fFoundPVCopyNo);
3279 (findings.fpFoundPV,
3280 requestedDepthOfDescent,
3281 findings.fFoundObjectTransformation,
3284 findings.fFoundBasePVPath);
3285 if (clippingSolid) {
3289 if (!foundPVModel->
Validate(warn))
return;
3294 G4cout <<
"\"" << findings.fpFoundPV->GetName()
3295 <<
"\", copy no. " << findings.fFoundPVCopyNo
3296 <<
",\n found in searched volume \""
3297 << findings.fpSearchPV->GetName()
3298 <<
"\" at depth " << findings.fFoundDepth
3299 <<
",\n base path: \"" << findings.fFoundBasePVPath
3300 <<
"\",\n with a requested depth of further descent of ";
3301 if (requestedDepthOfDescent < 0) {
3302 G4cout <<
"<0 (unlimited)";
3305 G4cout << requestedDepthOfDescent;
3307 G4cout <<
",\n has been added to scene \"" << pScene->
GetName() <<
"\"."
3315 if (findingsVector.empty()) {
3317 G4cerr <<
"ERROR: Volume \"" <<
name <<
"\"";
3319 G4cerr <<
", copy no. " << copyNo <<
",";
3335 fpCommand -> SetGuidance (
"Add a plotter to current scene.");
3354 G4cerr <<
"ERROR: No current scene. Please create one." <<
G4endl;
3363 const G4String& currentSceneName = pScene -> GetName ();
3364 G4bool successful = pScene -> AddRunDurationModel (model, warn);
3367 G4cout <<
"Arrow has been added to scene \"" << currentSceneName <<
"\"." <<
G4endl;
G4double Y(G4double density)
HepGeom::Point3D< G4double > G4Point3D
static constexpr double rad
static constexpr double pi
static constexpr double halfpi
static constexpr double deg
static const G4double angle[DIMMOTT]
CLHEP::Hep3Vector G4ThreeVector
HepGeom::Vector3D< G4double > G4Vector3D
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
HepRotation & rotateZ(double delta)
G4LogicalVolume * GetVolume(const G4String &name, G4bool verbose=true, G4bool reverseSearch=false) const
static G4LogicalVolumeStore * GetInstance()
void SetClippingSolid(G4VSolid *pClippingSolid)
G4bool Validate(G4bool warn)
void SetClippingMode(ClippingMode mode)
void DescribeYourselfTo(G4VGraphicsScene &)
const std::vector< Findings > & GetFindings() const
G4Plotter & GetPlotter(const G4String &a_name)
static G4PlotterManager & GetInstance()
G4Polyline & transform(const G4Transform3D &)
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
static G4RunManager * GetMasterRunManager()
const G4Run * GetCurrentRun() const
G4int GetNumberOfEventToBeProcessed() const
const std::vector< const G4Event * > * GetEventVector() const
G4bool AddRunDurationModel(G4VModel *, G4bool warn=false)
const G4VisExtent & GetExtent() const
const G4String & GetName() const
const std::vector< Model > & GetEndOfEventModelList() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
void SetOffset(double dx, double dy)
const std::map< G4String, G4AttDef > * GetAttDefs() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
size_t GetNoWorlds() const
G4UIcommand * FindPath(const char *commandPath) const
static G4double ValueOf(const char *unitName)
void SetParameter(G4UIparameter *const newParameter)
void SetGuidance(const char *aGuidance)
static G4bool ConvertToBool(const char *st)
G4UIcommandTree * GetTree() const
G4int ApplyCommand(const char *aCommand)
G4int GetVerboseLevel() const
static G4UImanager * GetUIpointer()
void SetVerboseLevel(G4int val)
G4double StoD(G4String s)
void SetDefaultValue(const char *theDefaultValue)
void SetGuidance(const char *theGuidance)
G4Polyhedron * CreatePolyhedron() const
void SetScreenSize(G4double)
void SetType(const G4String &)
void SetGlobalDescription(const G4String &)
void SetGlobalTag(const G4String &)
void SetExtent(const G4VisExtent &)
const G4VisExtent & GetExtent() const
const G4ViewParameters & GetViewParameters() const
static G4double fCurrentTextSize
void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity)
static G4Colour fCurrentTextColour
void CheckSceneAndNotifyHandlers(G4Scene *=nullptr)
static std::vector< G4PhysicalVolumesSearchScene::Findings > fCurrrentPVFindingsForField
void ConvertToColour(G4Colour &colour, const G4String &redOrString, G4double green, G4double blue, G4double opacity)
static G4VisManager * fpVisManager
static G4VisExtent fCurrentExtentForField
const G4String & ConvertToColourGuidance()
void CopyParametersFrom(const G4UIcommand *fromCmd, G4UIcommand *toCmd)
static G4int fCurrentArrow3DLineSegmentsPerCircle
static G4Text::Layout fCurrentTextLayout
static G4double fCurrentLineWidth
static G4Colour fCurrentColour
void CopyGuidanceFrom(const G4UIcommand *fromCmd, G4UIcommand *toCmd, G4int startLine=0)
const G4Vector3D & GetViewpointDirection() const
const G4Vector3D & GetUpVector() const
void SetColour(const G4Colour &)
void SetLineWidth(G4double)
void SetForceSolid(G4bool=true)
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandSceneAddArrow2D()
G4VisCommandSceneAddArrow2D()
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneAddArrow()
virtual ~G4VisCommandSceneAddArrow()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandSceneAddAxes()
virtual ~G4VisCommandSceneAddAxes()
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4VisCommandSceneAddDate()
G4VisCommandSceneAddDate()
G4VisCommandSceneAddDigis()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4VisCommandSceneAddDigis()
G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4VisCommandSceneAddElectricField()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandSceneAddElectricField()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneAddEventID()
virtual ~G4VisCommandSceneAddEventID()
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandSceneAddExtent()
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneAddExtent()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandSceneAddFrame()
G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4VisCommandSceneAddFrame()
virtual ~G4VisCommandSceneAddGPS()
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneAddGPS()
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandSceneAddHits()
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneAddHits()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandSceneAddLine2D()
virtual ~G4VisCommandSceneAddLine2D()
G4VisCommandSceneAddLine()
G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4VisCommandSceneAddLine()
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandSceneAddLocalAxes()
G4VisCommandSceneAddLocalAxes()
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneAddLogicalVolume()
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandSceneAddLogicalVolume()
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandSceneAddLogo2D()
G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4VisCommandSceneAddLogo2D()
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneAddLogo()
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandSceneAddLogo()
virtual ~G4VisCommandSceneAddMagneticField()
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneAddMagneticField()
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandSceneAddPSHits()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneAddPSHits()
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandSceneAddPlotter()
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneAddPlotter()
virtual ~G4VisCommandSceneAddScale()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandSceneAddScale()
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneAddText2D()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4VisCommandSceneAddText2D()
virtual ~G4VisCommandSceneAddText()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneAddText()
G4VisCommandSceneAddTrajectories()
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandSceneAddTrajectories()
G4String GetCurrentValue(G4UIcommand *command)
void AddVisAction(const G4String &name, G4VUserVisAction *, G4Scene *, ActionType, G4VisManager::Verbosity)
virtual ~G4VisCommandSceneAddUserAction()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandSceneAddUserAction()
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneAddVolume()
virtual ~G4VisCommandSceneAddVolume()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4double GetExtentRadius() const
G4VisExtent & Transform(const G4Transform3D &)
G4Scene * GetCurrentScene() const
const std::vector< UserVisAction > & GetRunDurationUserVisActions() const
const std::map< G4VUserVisAction *, G4VisExtent > & GetUserVisActionExtents() const
const std::vector< UserVisAction > & GetEndOfRunUserVisActions() const
G4VViewer * GetCurrentViewer() const
const std::vector< UserVisAction > & GetEndOfEventUserVisActions() const
static Verbosity GetVerbosity()
G4bool GetReviewingKeptEvents() const
void SetVisAttributes(const G4VisAttributes *)
BasicVector3D< T > & rotateZ(T a)
BasicVector3D< T > unit() const
const char * name(G4int ptype)
Arrow2D(G4double x1, G4double y1, G4double x2, G4double y2, G4double width, const G4Colour &colour)
G4Polyline fShaftPolyline
Extent(G4double xmin, G4double xmax, G4double ymin, G4double ymax, G4double zmin, G4double zmax)
Line2D(G4double x1, G4double y1, G4double x2, G4double y2, G4double width, const G4Colour &colour)
Line(G4double x1, G4double y1, G4double z1, G4double x2, G4double y2, G4double z2, G4double width, const G4Colour &colour)
G4Logo(G4double height, const G4VisAttributes &, const G4Transform3D &)
Scale(const G4VisAttributes &visAttribs, G4double length, const G4Transform3D &, const G4String &annotation, G4double annotationSize, const G4Colour &annotationColour)