80 static void G4VisCommandsSceneAddUnsuccessful
84 "WARNING: For some reason, possibly mentioned above, it has not been"
85 "\n possible to add to the scene."
93 fpCommand =
new G4UIcommand(
"/vis/scene/add/arrow",
this);
94 fpCommand -> SetGuidance (
"Adds arrow to current scene.");
98 fpCommand -> SetParameter (parameter);
100 fpCommand -> SetParameter (parameter);
102 fpCommand -> SetParameter (parameter);
104 fpCommand -> SetParameter (parameter);
106 fpCommand -> SetParameter (parameter);
108 fpCommand -> SetParameter (parameter);
109 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
130 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
137 std::istringstream is(newValue);
138 is >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> unitString;
140 x1 *= unit; y1 *= unit; z1 *= unit;
141 x2 *= unit; y2 *= unit; z2 *= unit;
149 (x1, y1, z1, x2, y2, z2,
152 const G4String& currentSceneName = pScene -> GetName ();
153 G4bool successful = pScene -> AddRunDurationModel (model, warn);
156 G4cout <<
"Arrow has been added to scene \""
157 << currentSceneName <<
"\"."
161 else G4VisCommandsSceneAddUnsuccessful(verbosity);
168 fpCommand =
new G4UIcommand(
"/vis/scene/add/arrow2D",
this);
169 fpCommand -> SetGuidance (
"Adds 2D arrow to current scene.");
173 fpCommand -> SetParameter (parameter);
175 fpCommand -> SetParameter (parameter);
177 fpCommand -> SetParameter (parameter);
179 fpCommand -> SetParameter (parameter);
198 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
204 std::istringstream is(newValue);
205 is >> x1 >> y1 >> x2 >>
y2;
207 Arrow2D* arrow2D =
new Arrow2D
214 const G4String& currentSceneName = pScene -> GetName ();
215 G4bool successful = pScene -> AddRunDurationModel (model, warn);
218 G4cout <<
"A 2D arrow has been added to scene \""
219 << currentSceneName <<
"\"."
223 else G4VisCommandsSceneAddUnsuccessful(verbosity);
227 G4VisCommandSceneAddArrow2D::Arrow2D::Arrow2D
231 fWidth(width), fColour(colour)
233 fShaftPolyline.push_back(
G4Point3D(x1,y1,0));
234 fShaftPolyline.push_back(
G4Point3D(x2,y2,0));
236 G4Vector3D arrowPointLeftDirection(arrowDirection);
237 arrowPointLeftDirection.rotateZ(150.*
deg);
238 G4Vector3D arrowPointRightDirection(arrowDirection);
239 arrowPointRightDirection.rotateZ(-150.*
deg);
240 fHeadPolyline.push_back(
G4Point3D(x2,y2,0)+0.04*arrowPointLeftDirection);
241 fHeadPolyline.push_back(
G4Point3D(x2,y2,0));
242 fHeadPolyline.push_back(
G4Point3D(x2,y2,0)+0.04*arrowPointRightDirection);
246 fShaftPolyline.SetVisAttributes(va);
247 fHeadPolyline.SetVisAttributes(va);
250 void G4VisCommandSceneAddArrow2D::Arrow2D::operator()
253 sceneHandler.BeginPrimitives2D();
254 sceneHandler.AddPrimitive(fShaftPolyline);
255 sceneHandler.AddPrimitive(fHeadPolyline);
256 sceneHandler.EndPrimitives2D();
263 fpCommand =
new G4UIcommand (
"/vis/scene/add/axes",
this);
264 fpCommand -> SetGuidance (
"Add axes.");
265 fpCommand -> SetGuidance
266 (
"Draws axes at (x0, y0, z0) of given length and colour.");
267 fpCommand -> SetGuidance
268 (
"If \"unitcolour\" is \"auto\", x, y and z will be red, green and blue"
269 "\n respectively. Otherwise choose from the pre-defined text-specified"
270 "\n colours - see information printed by the vis manager at start-up or"
271 "\n use \"/vis/list\".");
272 fpCommand -> SetGuidance
273 (
"If \"length\" is negative, it is set to about 25% of scene extent.");
284 parameter =
new G4UIparameter (
"length",
'd', omitable =
true);
287 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
290 parameter =
new G4UIparameter (
"unitcolour",
's', omitable =
true);
311 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
318 std::istringstream is (newValue);
319 is >> x0 >> y0 >> z0 >> length >> unitString >> colourString;
322 x0 *= unit; y0 *= unit; z0 *= unit;
326 G4double intLog10Length = std::floor(std::log10(length));
327 length = std::pow(10,intLog10Length);
337 if (arrowWidth > length/50.) arrowWidth = length/50.;
340 (x0, y0, z0, length, arrowWidth, colourString, newValue);
342 G4bool successful = pScene -> AddRunDurationModel (model, warn);
343 const G4String& currentSceneName = pScene -> GetName ();
346 G4cout <<
"Axes have been added to scene \"" << currentSceneName <<
"\"."
350 else G4VisCommandsSceneAddUnsuccessful(verbosity);
358 fpCommand =
new G4UIcommand (
"/vis/scene/add/date",
this);
359 fpCommand -> SetGuidance (
"Adds date to current scene.");
360 fpCommand -> SetGuidance
361 (
"If \"date\"is omitted, the current date and time is drawn."
362 "\nOtherwise, the string, including the rest of the line, is drawn.");
364 parameter =
new G4UIparameter (
"size",
'i', omitable =
true);
365 parameter -> SetGuidance (
"Screen size of text in pixels.");
366 parameter -> SetDefaultValue (18);
367 fpCommand -> SetParameter (parameter);
368 parameter =
new G4UIparameter (
"x-position",
'd', omitable =
true);
369 parameter -> SetGuidance (
"x screen position in range -1 < x < 1.");
370 parameter -> SetDefaultValue (0.95);
371 fpCommand -> SetParameter (parameter);
372 parameter =
new G4UIparameter (
"y-position",
'd', omitable =
true);
373 parameter -> SetGuidance (
"y screen position in range -1 < y < 1.");
374 parameter -> SetDefaultValue (0.9);
375 fpCommand -> SetParameter (parameter);
376 parameter =
new G4UIparameter (
"layout",
's', omitable =
true);
377 parameter -> SetGuidance (
"Layout, i.e., adjustment: left|centre|right.");
378 parameter -> SetDefaultValue (
"right");
379 fpCommand -> SetParameter (parameter);
380 parameter =
new G4UIparameter (
"date",
's', omitable =
true);
381 parameter -> SetDefaultValue (
"-");
382 fpCommand -> SetParameter (parameter);
401 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
409 std::istringstream is(newValue);
410 is >> size >> x >> y >> layoutString >> dateString;
412 const size_t NREMAINDER = 100;
413 char remainder[NREMAINDER];
414 is.getline(remainder, NREMAINDER);
415 dateString += remainder;
421 Date* date =
new Date(
fpVisManager, size, x, y, layout, dateString);
427 const G4String& currentSceneName = pScene -> GetName ();
428 G4bool successful = pScene -> AddRunDurationModel (model, warn);
431 G4cout <<
"Date has been added to scene \""
432 << currentSceneName <<
"\"."
436 else G4VisCommandsSceneAddUnsuccessful(verbosity);
440 void G4VisCommandSceneAddDate::Date::operator()
445 time = fTimer.GetClockTime();
450 std::string::size_type i = time.rfind(
'\n');
451 if (i != std::string::npos) time.erase(i);
453 text.SetScreenSize(fSize);
454 text.SetLayout(fLayout);
456 text.SetVisAttributes(textAtts);
457 sceneHandler.BeginPrimitives2D();
458 sceneHandler.AddPrimitive(text);
459 sceneHandler.EndPrimitives2D();
466 fpCommand -> SetGuidance (
"Adds digis to current scene.");
467 fpCommand -> SetGuidance
468 (
"Digis are drawn at end of event when the scene in which"
469 "\nthey are added is current.");
488 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
494 const G4String& currentSceneName = pScene -> GetName ();
495 G4bool successful = pScene -> AddEndOfEventModel (model, warn);
498 G4cout <<
"Digis, if any, will be drawn at end of run in scene \""
499 << currentSceneName <<
"\"."
503 else G4VisCommandsSceneAddUnsuccessful(verbosity);
511 fpCommand =
new G4UIcommand (
"/vis/scene/add/eventID",
this);
512 fpCommand -> SetGuidance (
"Adds eventID to current scene.");
513 fpCommand -> SetGuidance
514 (
"Run and event numbers are drawn at end of event or run when"
515 "\n the scene in which they are added is current.");
517 parameter =
new G4UIparameter (
"size",
'i', omitable =
true);
518 parameter -> SetGuidance (
"Screen size of text in pixels.");
519 parameter -> SetDefaultValue (18);
520 fpCommand -> SetParameter (parameter);
521 parameter =
new G4UIparameter (
"x-position",
'd', omitable =
true);
522 parameter -> SetGuidance (
"x screen position in range -1 < x < 1.");
523 parameter -> SetDefaultValue (-0.95);
524 fpCommand -> SetParameter (parameter);
525 parameter =
new G4UIparameter (
"y-position",
'd', omitable =
true);
526 parameter -> SetGuidance (
"y screen position in range -1 < y < 1.");
527 parameter -> SetDefaultValue (0.9);
528 fpCommand -> SetParameter (parameter);
529 parameter =
new G4UIparameter (
"layout",
's', omitable =
true);
530 parameter -> SetGuidance (
"Layout, i.e., adjustment: left|centre|right.");
531 parameter -> SetDefaultValue (
"left");
532 fpCommand -> SetParameter (parameter);
551 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
559 std::istringstream is(newValue);
560 is >> size >> x >> y >> layoutString;
567 EventID* eventID =
new EventID(
fpVisManager, size, x, y, layout);
573 const G4String& currentSceneName = pScene -> GetName ();
574 G4bool successful = pScene -> AddEndOfEventModel (model, warn);
577 G4cout <<
"EventID has been added to scene \""
578 << currentSceneName <<
"\"."
582 else G4VisCommandsSceneAddUnsuccessful(verbosity);
586 void G4VisCommandSceneAddEventID::EventID::operator()
589 const G4Run* currentRun = 0;
593 G4VModel*
model = fpVisManager->GetCurrentSceneHandler()->GetModel();
595 const G4Event* currentEvent = 0;
602 G4cout <<
"ERROR: No model defined for this SceneHandler : "
603 << fpVisManager->GetCurrentSceneHandler()->GetName()
607 if (currentRun && currentEvent) {
610 std::ostringstream oss;
611 if (fpVisManager->GetCurrentScene()->GetRefreshAtEndOfEvent()) {
612 oss <<
"Run " << runID <<
" Event " << eventID;
620 const std::vector<const G4Event*>* events =
622 if (events) nEvents = events->size();
624 if (eventID < nEvents - 1)
return;
626 oss <<
"Run " << runID <<
" (" << nEvents <<
" event";
627 if (nEvents != 1) oss <<
's';
633 text.SetLayout(fLayout);
635 text.SetVisAttributes(textAtts);
636 sceneHandler.BeginPrimitives2D();
637 sceneHandler.AddPrimitive(text);
638 sceneHandler.EndPrimitives2D();
645 fpCommand =
new G4UIcommand(
"/vis/scene/add/frame",
this);
646 fpCommand -> SetGuidance (
"Adds frame to current scene.");
649 parameter =
new G4UIparameter (
"size",
'd', omitable =
true);
650 parameter -> SetGuidance (
"Size of frame. 1 = full window.");
651 parameter -> SetParameterRange (
"size > 0 && size <=1");
652 parameter -> SetDefaultValue (0.97);
653 fpCommand -> SetParameter (parameter);
672 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
678 std::istringstream is(newValue);
687 const G4String& currentSceneName = pScene -> GetName ();
688 G4bool successful = pScene -> AddRunDurationModel (model, warn);
691 G4cout <<
"Frame has been added to scene \""
692 << currentSceneName <<
"\"."
696 else G4VisCommandsSceneAddUnsuccessful(verbosity);
700 void G4VisCommandSceneAddFrame::Frame::operator()
704 frame.push_back(
G4Point3D( fSize, fSize, 0.));
705 frame.push_back(
G4Point3D(-fSize, fSize, 0.));
706 frame.push_back(
G4Point3D(-fSize, -fSize, 0.));
707 frame.push_back(
G4Point3D( fSize, -fSize, 0.));
708 frame.push_back(
G4Point3D( fSize, fSize, 0.));
713 sceneHandler.BeginPrimitives2D();
714 sceneHandler.AddPrimitive(frame);
715 sceneHandler.EndPrimitives2D();
722 fpCommand -> SetGuidance (
"Adds hits to current scene.");
723 fpCommand -> SetGuidance
724 (
"Hits are drawn at end of event when the scene in which"
725 "\nthey are added is current.");
744 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
750 const G4String& currentSceneName = pScene -> GetName ();
751 G4bool successful = pScene -> AddEndOfEventModel (model, warn);
754 G4cout <<
"Hits, if any, will be drawn at end of run in scene \""
755 << currentSceneName <<
"\"."
759 else G4VisCommandsSceneAddUnsuccessful(verbosity);
766 fpCommand =
new G4UIcommand(
"/vis/scene/add/line",
this);
767 fpCommand -> SetGuidance (
"Adds line to current scene.");
771 fpCommand -> SetParameter (parameter);
773 fpCommand -> SetParameter (parameter);
775 fpCommand -> SetParameter (parameter);
777 fpCommand -> SetParameter (parameter);
779 fpCommand -> SetParameter (parameter);
781 fpCommand -> SetParameter (parameter);
782 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
803 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
810 std::istringstream is(newValue);
811 is >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> unitString;
813 x1 *= unit; y1 *= unit; z1 *= unit;
814 x2 *= unit; y2 *= unit; z2 *= unit;
816 Line* line =
new Line(x1, y1, z1, x2, y2, z2,
823 const G4String& currentSceneName = pScene -> GetName ();
824 G4bool successful = pScene -> AddRunDurationModel (model, warn);
827 G4cout <<
"Line has been added to scene \""
828 << currentSceneName <<
"\"."
832 else G4VisCommandsSceneAddUnsuccessful(verbosity);
836 G4VisCommandSceneAddLine::Line::Line
840 fWidth(width), fColour(colour)
842 fPolyline.push_back(
G4Point3D(x1,y1,z1));
843 fPolyline.push_back(
G4Point3D(x2,y2,z2));
847 fPolyline.SetVisAttributes(va);
850 void G4VisCommandSceneAddLine::Line::operator()
853 sceneHandler.BeginPrimitives();
854 sceneHandler.AddPrimitive(fPolyline);
855 sceneHandler.EndPrimitives();
861 fpCommand =
new G4UIcommand(
"/vis/scene/add/line2D",
this);
862 fpCommand -> SetGuidance (
"Adds 2D line to current scene.");
866 fpCommand -> SetParameter (parameter);
868 fpCommand -> SetParameter (parameter);
870 fpCommand -> SetParameter (parameter);
872 fpCommand -> SetParameter (parameter);
891 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
897 std::istringstream is(newValue);
898 is >> x1 >> y1 >> x2 >>
y2;
900 Line2D* line2D =
new Line2D
907 const G4String& currentSceneName = pScene -> GetName ();
908 G4bool successful = pScene -> AddRunDurationModel (model, warn);
911 G4cout <<
"A 2D line has been added to scene \""
912 << currentSceneName <<
"\"."
916 else G4VisCommandsSceneAddUnsuccessful(verbosity);
920 G4VisCommandSceneAddLine2D::Line2D::Line2D
924 fWidth(width), fColour(colour)
931 fPolyline.SetVisAttributes(va);
934 void G4VisCommandSceneAddLine2D::Line2D::operator()
937 sceneHandler.BeginPrimitives2D();
938 sceneHandler.AddPrimitive(fPolyline);
939 sceneHandler.EndPrimitives2D();
946 fpCommand =
new G4UIcommand (
"/vis/scene/add/logicalVolume",
this);
947 fpCommand -> SetGuidance (
"Adds a logical volume to the current scene,");
948 fpCommand -> SetGuidance
949 (
"Shows boolean components (if any), voxels (if any) and readout geometry"
950 "\n(if any). Note: voxels are not constructed until start of run -"
951 "\n \"/run/beamOn\".");
953 parameter =
new G4UIparameter (
"logical-volume-name",
's', omitable =
false);
954 fpCommand -> SetParameter (parameter);
955 parameter =
new G4UIparameter (
"depth-of-descent",
'i', omitable =
true);
956 parameter -> SetGuidance (
"Depth of descent of geometry hierarchy.");
957 parameter -> SetDefaultValue (1);
958 fpCommand -> SetParameter (parameter);
959 parameter =
new G4UIparameter (
"booleans-flag",
'b', omitable =
true);
960 parameter -> SetDefaultValue (
true);
961 fpCommand -> SetParameter (parameter);
962 parameter =
new G4UIparameter (
"voxels-flag",
'b', omitable =
true);
963 parameter -> SetDefaultValue (
true);
964 fpCommand -> SetParameter (parameter);
965 parameter =
new G4UIparameter (
"readout-flag",
'b', omitable =
true);
966 parameter -> SetDefaultValue (
true);
967 fpCommand -> SetParameter (parameter);
987 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
993 G4int requestedDepthOfDescent;
994 G4String booleansString, voxelsString, readoutString;
995 std::istringstream is (newValue);
996 is >> name >> requestedDepthOfDescent
997 >> booleansString >> voxelsString >> readoutString;
1003 int nLV = pLVStore -> size ();
1006 for (iLV = 0; iLV < nLV; iLV++ ) {
1007 pLV = (*pLVStore) [iLV];
1008 if (pLV -> GetName () == name)
break;
1012 G4cout <<
"ERROR: Logical volume " << name
1013 <<
" not found in logical volume store." <<
G4endl;
1018 const std::vector<G4Scene::Model>& rdModelList = pScene -> GetRunDurationModelList();
1019 std::vector<G4Scene::Model>::const_iterator i;
1020 for (i = rdModelList.begin(); i != rdModelList.end(); ++i) {
1021 if (i->fpModel->GetGlobalDescription().find(
"Volume") != std::string::npos)
break;
1023 if (i != rdModelList.end()) {
1025 G4cout <<
"There is already a volume, \""
1026 << i->fpModel->GetGlobalDescription()
1027 <<
"\",\n in the run-duration model list of scene \""
1028 << pScene -> GetName()
1029 <<
"\".\n Your logical volume must be the only volume in the scene."
1030 <<
"\n Create a new scene and try again:"
1031 <<
"\n /vis/specify " << name
1033 <<
"\n /vis/scene/create"
1034 <<
"\n /vis/scene/add/logicalVolume " << name
1035 <<
"\n /vis/sceneHandler/attach"
1036 <<
"\n (and also, if necessary, /vis/viewer/flush)"
1042 (pLV, requestedDepthOfDescent, booleans, voxels, readout);
1043 const G4String& currentSceneName = pScene -> GetName ();
1044 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1047 G4cout <<
"Logical volume \"" << pLV -> GetName ()
1048 <<
" with requested depth of descent "
1049 << requestedDepthOfDescent
1051 if (!booleans)
G4cout <<
"out";
1052 G4cout <<
" boolean components, with";
1053 if (!voxels)
G4cout <<
"out";
1054 G4cout <<
" voxels and with";
1055 if (!readout)
G4cout <<
"out";
1056 G4cout <<
" readout geometry,"
1057 <<
"\n has been added to scene \"" << currentSceneName <<
"\"."
1062 G4VisCommandsSceneAddUnsuccessful(verbosity);
1074 fpCommand =
new G4UIcommand (
"/vis/scene/add/logo",
this);
1075 fpCommand -> SetGuidance (
"Adds a G4 logo to the current scene.");
1076 fpCommand -> SetGuidance
1077 (
"If \"unit\" is \"auto\", height is roughly one tenth of scene extent.");
1078 fpCommand -> SetGuidance
1079 (
"\"direction\" is that of outward-facing normal to front face of logo."
1080 "\nIf \"direction\" is \"auto\", logo faces the user in the current viewer.");
1081 fpCommand -> SetGuidance
1082 (
"\nIf \"placement\" is \"auto\", logo is placed at bottom right of screen"
1083 "\n when viewed from logo direction.");
1085 parameter =
new G4UIparameter (
"height",
'd', omitable =
true);
1088 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
1091 parameter =
new G4UIparameter (
"direction",
's', omitable =
true);
1095 parameter =
new G4UIparameter (
"red",
'd', omitable =
true);
1098 parameter =
new G4UIparameter (
"green",
'd', omitable =
true);
1101 parameter =
new G4UIparameter (
"blue",
'd', omitable =
true);
1104 parameter =
new G4UIparameter (
"placement",
's', omitable =
true);
1105 parameter -> SetParameterCandidates(
"auto manual");
1108 parameter =
new G4UIparameter (
"xmid",
'd', omitable =
true);
1111 parameter =
new G4UIparameter (
"ymid",
'd', omitable =
true);
1114 parameter =
new G4UIparameter (
"zmid",
'd', omitable =
true);
1117 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
1138 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
1147 "ERROR: G4VisCommandSceneAddLogo::SetNewValue: no viewer."
1148 "\n Auto direction needs a viewer."
1155 G4String userHeightUnit, direction, auto_manual, positionUnit;
1156 std::istringstream is (newValue);
1157 is >> userHeight >> userHeightUnit >> direction
1158 >> red >> green >> blue
1160 >> xmid >> ymid >> zmid >> positionUnit;
1164 if (userHeightUnit ==
"auto") {
1171 xmid *= unit; ymid *= unit; zmid *= unit;
1173 Direction logoDirection = X;
1174 if (direction ==
"auto") {
1178 if (vp.
x() > vp.
y() && vp.
x() > vp.
z()) logoDirection = X;
1179 else if (vp.
x() < vp.
y() && vp.
x() < vp.
z()) logoDirection = minusX;
1180 else if (vp.
y() > vp.
x() && vp.
y() > vp.
z()) logoDirection = Y;
1181 else if (vp.
y() < vp.
x() && vp.
y() < vp.
z()) logoDirection = minusY;
1182 else if (vp.
z() > vp.
x() && vp.
z() > vp.
y()) logoDirection = Z;
1183 else if (vp.
z() < vp.
x() && vp.
z() < vp.
y()) logoDirection = minusZ;
1185 else if (direction(0) ==
'x') logoDirection = X;
1186 else if (direction(0) ==
'y') logoDirection = Y;
1187 else if (direction(0) ==
'z') logoDirection = Z;
1188 else if (direction(0) ==
'-') {
1189 if (direction(1) ==
'x') logoDirection = minusX;
1190 else if (direction(1) ==
'y') logoDirection = minusY;
1191 else if (direction(1) ==
'z') logoDirection = minusZ;
1194 G4cout <<
"ERROR: Unrecogniseed direction: \""
1195 << direction <<
"\"." <<
G4endl;
1200 G4bool autoPlacing =
false;
if (auto_manual ==
"auto") autoPlacing =
true;
1217 "WARNING: Existing scene does not yet have any extent."
1218 "\n Maybe you have not yet added any geometrical object."
1224 const G4double halfHeight(height / 2.);
1226 const G4double freeHeightFraction (1. + 2. * comfort);
1230 switch (logoDirection) {
1233 if (freeHeightFraction * (xmax - xmin) < height) room =
false;
break;
1236 if (freeHeightFraction * (ymax - ymin) < height) room =
false;
break;
1239 if (freeHeightFraction * (zmax - zmin) < height) room =
false;
break;
1245 "WARNING: Not enough room in existing scene. Maybe logo is too large."
1252 "WARNING: The logo you have asked for is bigger than the existing"
1253 "\n scene. Maybe you have added it too soon. It is recommended that"
1254 "\n you add the logo last so that it can be correctly auto-positioned"
1255 "\n so as not to be obscured by any existing object and so that the"
1256 "\n view parameters can be correctly recalculated."
1261 G4double sxmid(xmid), symid(ymid), szmid(zmid);
1265 const G4double xComfort = comfort * (xmax - xmin);
1266 const G4double yComfort = comfort * (ymax - ymin);
1267 const G4double zComfort = comfort * (zmax - zmin);
1268 switch (logoDirection) {
1270 sxmid = xmax + halfHeight + xComfort;
1271 symid = ymin - yComfort;
1272 szmid = zmin - zComfort;
1275 sxmid = xmin - halfHeight - xComfort;
1276 symid = ymin - yComfort;
1277 szmid = zmax + zComfort;
1280 sxmid = xmin - xComfort;
1281 symid = ymax + halfHeight + yComfort;
1282 szmid = zmin - zComfort;
1285 sxmid = xmax + xComfort;
1286 symid = ymin - halfHeight - yComfort;
1287 szmid = zmin - zComfort;
1290 sxmid = xmax + xComfort;
1291 symid = ymin - yComfort;
1292 szmid = zmax + halfHeight + zComfort;
1295 sxmid = xmin - xComfort;
1296 symid = ymin - yComfort;
1297 szmid = zmin - halfHeight - zComfort;
1303 switch (logoDirection) {
1328 G4Logo* logo =
new G4Logo(height,visAtts);
1343 const G4String& currentSceneName = pScene -> GetName ();
1344 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1347 G4cout <<
"G4 Logo of height " << userHeight <<
' ' << userHeightUnit
1348 <<
", " << direction <<
"-direction, added to scene \""
1349 << currentSceneName <<
"\"";
1351 G4cout <<
"\n with extent " << extent
1358 else G4VisCommandsSceneAddUnsuccessful(verbosity);
1362 G4VisCommandSceneAddLogo::G4Logo::G4Logo
1379 const G4double dx = xt - xb, dy = yt - yb;
1380 const G4double angle = std::atan2(dy,dx);
1383 const G4double d = std::sqrt(dx * dx + dy * dy);
1386 const G4double x8 = ((-ss * d - dx * (yt - y8)) / dy) + xt;
1388 G4double x9 = ((-(ss - w) * d - dx * (yt - y8)) / dy) + xt;
1390 const G4double xtr = ss -
f1, ytr = -ss - f2 -w;
1391 x9 += xtr; y9 += ytr;
1395 G4Box bG(
"bG",w2,ro2,d2);
1397 fpG = logoG.CreatePolyhedron();
1398 fpG->SetVisAttributes(&fVisAtts);
1402 G4Box b1(
"b1",h2,h2,d2);
1403 G4Box bS(
"bS",ss,ss,d2+e);
1404 G4Box bS2(
"bS2",ss,ss,d2+2.*e);
1413 fp4 = logo4.CreatePolyhedron();
1422 fp4->SetVisAttributes(&fVisAtts);
1426 G4VisCommandSceneAddLogo::G4Logo::~G4Logo() {
1431 void G4VisCommandSceneAddLogo::G4Logo::operator()
1433 sceneHandler.BeginPrimitives(transform);
1434 sceneHandler.AddPrimitive(*fpG);
1435 sceneHandler.AddPrimitive(*fp4);
1436 sceneHandler.EndPrimitives();
1443 fpCommand =
new G4UIcommand (
"/vis/scene/add/logo2D",
this);
1444 fpCommand -> SetGuidance (
"Adds 2D logo to current scene.");
1446 parameter =
new G4UIparameter (
"size",
'i', omitable =
true);
1447 parameter -> SetGuidance (
"Screen size of text in pixels.");
1448 parameter -> SetDefaultValue (48);
1449 fpCommand -> SetParameter (parameter);
1450 parameter =
new G4UIparameter (
"x-position",
'd', omitable =
true);
1451 parameter -> SetGuidance (
"x screen position in range -1 < x < 1.");
1452 parameter -> SetDefaultValue (-0.9);
1453 fpCommand -> SetParameter (parameter);
1454 parameter =
new G4UIparameter (
"y-position",
'd', omitable =
true);
1455 parameter -> SetGuidance (
"y screen position in range -1 < y < 1.");
1456 parameter -> SetDefaultValue (-0.9);
1457 fpCommand -> SetParameter (parameter);
1458 parameter =
new G4UIparameter (
"layout",
's', omitable =
true);
1459 parameter -> SetGuidance (
"Layout, i.e., adjustment: left|centre|right.");
1460 parameter -> SetDefaultValue (
"left");
1461 fpCommand -> SetParameter (parameter);
1480 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
1488 std::istringstream is(newValue);
1489 is >> size >> x >> y >> layoutString;
1495 Logo2D* logo2D =
new Logo2D(
fpVisManager, size, x, y, layout);
1501 const G4String& currentSceneName = pScene -> GetName ();
1502 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1505 G4cout <<
"2D logo has been added to scene \""
1506 << currentSceneName <<
"\"."
1510 else G4VisCommandsSceneAddUnsuccessful(verbosity);
1514 void G4VisCommandSceneAddLogo2D::Logo2D::operator()
1518 text.SetScreenSize(fSize);
1519 text.SetLayout(fLayout);
1521 text.SetVisAttributes(textAtts);
1522 sceneHandler.BeginPrimitives2D();
1523 sceneHandler.AddPrimitive(text);
1524 sceneHandler.EndPrimitives2D();
1534 fpCommand -> SetGuidance
1535 (
"Adds magnetic field representation to current scene.");
1536 fpCommand -> SetGuidance
1537 (
"The parameter is no. of data points per half scene. So, possibly, at"
1538 "\nmaximum, the number of data points sampled is (2*n+1)^3, which can grow"
1539 "\nlarge--be warned!"
1540 "\nYou might find that your scene is cluttered by thousands of arrows for"
1541 "\nthe default number of data points, so try reducing to 2 or 3, e.g:"
1542 "\n /vis/scene/add/magneticField 3"
1543 "\nor, if only a small part of the scene has a field:"
1544 "\n /vis/scene/add/magneticField 50 # or more");
1545 fpCommand -> SetGuidance
1546 (
"In the arrow representation, the length of the arrow is proporational"
1547 "\nto the magnitude of the field and the colour is mapped onto the range"
1548 "\nas a fraction of the maximum magnitude: 0->0.5->1 is blue->green->red.");
1565 G4Scene* pScene = fpVisManager->GetCurrentScene();
1568 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
1573 G4int nDataPointsPerHalfScene = fpCommand->GetNewIntValue(newValue);
1577 const G4String& currentSceneName = pScene -> GetName ();
1578 G4bool successful = pScene -> AddRunDurationModel (model, warn);
1581 G4cout <<
"Magnetic field, if any, will be drawn in scene \""
1584 << nDataPointsPerHalfScene <<
" data points per half scene."
1588 else G4VisCommandsSceneAddUnsuccessful(verbosity);
1589 UpdateVisManagerScene (currentSceneName);
1597 fpCommand -> SetGuidance
1598 (
"Adds Primitive Scorer Hits (PSHits) to current scene.");
1599 fpCommand -> SetGuidance
1600 (
"PSHits are drawn at end of run when the scene in which"
1601 "\nthey are added is current.");
1602 fpCommand -> SetGuidance
1603 (
"Optional parameter specifies name of scoring map. By default all"
1604 "\nscoring maps registered with the G4ScoringManager are drawn.");
1605 fpCommand -> SetParameterName (
"mapname", omitable =
true);
1606 fpCommand -> SetDefaultValue (
"all");
1623 G4Scene* pScene = fpVisManager->GetCurrentScene();
1626 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
1632 const G4String& currentSceneName = pScene -> GetName ();
1633 G4bool successful = pScene -> AddEndOfRunModel (model, warn);
1636 if (newValue ==
"all") {
1637 G4cout <<
"All Primitive Scorer hits";
1639 G4cout <<
"Hits of Primitive Scorer \"" << newValue <<
'"';
1641 G4cout <<
" will be drawn at end of run in scene \""
1642 << currentSceneName <<
"\"."
1646 else G4VisCommandsSceneAddUnsuccessful(verbosity);
1647 UpdateVisManagerScene (currentSceneName);
1654 fpCommand =
new G4UIcommand (
"/vis/scene/add/scale",
this);
1655 fpCommand -> SetGuidance
1656 (
"Adds an annotated scale line to the current scene.");
1657 fpCommand -> SetGuidance
1658 (
"If \"unit\" is \"auto\", length is roughly one tenth of the scene extent.");
1659 fpCommand -> SetGuidance
1660 (
"If \"direction\" is \"auto\", scale is roughly in the plane of the current view.");
1661 fpCommand -> SetGuidance
1662 (
"If \"placement\" is \"auto\", scale is placed at bottom left of current view."
1663 "\n Otherwise placed at (xmid,ymid,zmid).");
1666 parameter =
new G4UIparameter (
"length",
'd', omitable =
true);
1669 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
1672 parameter =
new G4UIparameter (
"direction",
's', omitable =
true);
1676 parameter =
new G4UIparameter (
"red",
'd', omitable =
true);
1679 parameter =
new G4UIparameter (
"green",
'd', omitable =
true);
1682 parameter =
new G4UIparameter (
"blue",
'd', omitable =
true);
1685 parameter =
new G4UIparameter (
"placement",
's', omitable =
true);
1686 parameter -> SetParameterCandidates(
"auto manual");
1689 parameter =
new G4UIparameter (
"xmid",
'd', omitable =
true);
1692 parameter =
new G4UIparameter (
"ymid",
'd', omitable =
true);
1695 parameter =
new G4UIparameter (
"zmid",
'd', omitable =
true);
1698 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
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."
1843 false, xmid, ymid, zmid);
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);
2020 fpCommand =
new G4UIcommand (
"/vis/scene/add/text",
this);
2021 fpCommand -> SetGuidance (
"Adds text to current scene.");
2022 fpCommand -> SetGuidance
2023 (
"Use \"/vis/set/textColour\" to set colour.");
2024 fpCommand -> SetGuidance
2025 (
"Use \"/vis/set/textLayout\" to set layout:");
2036 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
2039 parameter =
new G4UIparameter (
"font_size",
'd', omitable =
true);
2043 parameter =
new G4UIparameter (
"x_offset",
'd', omitable =
true);
2047 parameter =
new G4UIparameter (
"y_offset",
'd', omitable =
true);
2051 parameter =
new G4UIparameter (
"text",
's', omitable =
true);
2052 parameter->
SetGuidance (
"The rest of the line is text.");
2073 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
2089 x *= unit; y *= unit; z *= unit;
2098 const G4String& currentSceneName = pScene -> GetName ();
2099 G4bool successful = pScene -> AddRunDurationModel (model, warn);
2102 G4cout <<
"Text \"" << text
2103 <<
"\" has been added to scene \"" << currentSceneName <<
"\"."
2107 else G4VisCommandsSceneAddUnsuccessful(verbosity);
2116 fpCommand =
new G4UIcommand (
"/vis/scene/add/text2D",
this);
2117 fpCommand -> SetGuidance (
"Adds 2D text to current scene.");
2118 fpCommand -> SetGuidance
2119 (
"Use \"/vis/set/textColour\" to set colour.");
2120 fpCommand -> SetGuidance
2121 (
"Use \"/vis/set/textLayout\" to set layout:");
2129 parameter =
new G4UIparameter (
"font_size",
'd', omitable =
true);
2133 parameter =
new G4UIparameter (
"x_offset",
'd', omitable =
true);
2137 parameter =
new G4UIparameter (
"y_offset",
'd', omitable =
true);
2141 parameter =
new G4UIparameter (
"text",
's', omitable =
true);
2142 parameter->
SetGuidance (
"The rest of the line is text.");
2163 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
2182 G4Text2D* g4text2D =
new G4Text2D(g4text);
2188 const G4String& currentSceneName = pScene -> GetName ();
2189 G4bool successful = pScene -> AddRunDurationModel (model, warn);
2192 G4cout <<
"2D text \"" << text
2193 <<
"\" has been added to scene \"" << currentSceneName <<
"\"."
2197 else G4VisCommandsSceneAddUnsuccessful(verbosity);
2201 G4VisCommandSceneAddText2D::G4Text2D::G4Text2D(
const G4Text& text):
2205 void G4VisCommandSceneAddText2D::G4Text2D::operator()
2207 sceneHandler.BeginPrimitives2D(transform);
2208 sceneHandler.AddPrimitive(fText);
2209 sceneHandler.EndPrimitives2D();
2218 (
"/vis/scene/add/trajectories",
this);
2219 fpCommand -> SetGuidance
2220 (
"Adds trajectories to current scene.");
2221 fpCommand -> SetGuidance
2222 (
"Causes trajectories, if any, to be drawn at the end of processing an"
2223 "\nevent. Switches on trajectory storing and sets the"
2224 "\ndefault trajectory type.");
2225 fpCommand -> SetGuidance
2226 (
"The command line parameter list determines the default trajectory type."
2227 "\nIf it contains the string \"smooth\", auxiliary inter-step points will"
2228 "\nbe inserted to improve the smoothness of the drawing of a curved"
2230 "\nIf it contains the string \"rich\", significant extra information will"
2231 "\nbe stored in the trajectory (G4RichTrajectory) amenable to modeling"
2232 "\nand filtering with \"/vis/modeling/trajectories/create/drawByAttribute\""
2233 "\nand \"/vis/filtering/trajectories/create/attributeFilter\" commands."
2234 "\nIt may contain both strings in any order.");
2235 fpCommand -> SetGuidance
2236 (
"\nTo switch off trajectory storing: \"/tracking/storeTrajectory 0\"."
2237 "\nSee also \"/vis/scene/endOfEventAction\".");
2238 fpCommand -> SetGuidance
2239 (
"Note: This only sets the default. Independently of the result of this"
2240 "\ncommand, a user may instantiate a trajectory that overrides this default"
2241 "\nin PreUserTrackingAction.");
2242 fpCommand -> SetParameterName (
"default-trajectory-type", omitable =
true);
2243 fpCommand -> SetDefaultValue (
"");
2263 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
2270 if (newValue.find(
"smooth") != std::string::npos) smooth =
true;
2271 if (newValue.find(
"rich") != std::string::npos) rich =
true;
2272 if (newValue.size() && !(rich || smooth)) {
2274 G4cout <<
"ERROR: Unrecognised parameter \"" << newValue <<
"\""
2275 "\n No action taken."
2283 G4int newVerbose = 2;
2286 if (smooth && rich) {
2287 UImanager->
ApplyCommand(
"/tracking/storeTrajectory 4");
2288 defaultTrajectoryType =
"G4RichTrajectory configured for smooth steps";
2289 }
else if (smooth) {
2290 UImanager->
ApplyCommand(
"/tracking/storeTrajectory 2");
2291 defaultTrajectoryType =
"G4SmoothTrajectory";
2293 UImanager->
ApplyCommand(
"/tracking/storeTrajectory 3");
2294 defaultTrajectoryType =
"G4RichTrajectory";
2296 UImanager->
ApplyCommand(
"/tracking/storeTrajectory 1");
2297 defaultTrajectoryType =
"G4Trajectory";
2303 "Attributes available for modeling and filtering with"
2304 "\n \"/vis/modeling/trajectories/create/drawByAttribute\" and"
2305 "\n \"/vis/filtering/trajectories/create/attributeFilter\" commands:"
2311 }
else if (smooth) {
2321 const G4String& currentSceneName = pScene -> GetName ();
2322 pScene -> AddEndOfEventModel (model, warn);
2325 G4cout <<
"Default trajectory type " << defaultTrajectoryType
2326 <<
"\n will be used to store trajectories for scene \""
2327 << currentSceneName <<
"\"."
2333 "WARNING: Trajectory storing has been requested. This action may be"
2334 "\n reversed with \"/tracking/storeTrajectory 0\"."
2345 fpCommand -> SetGuidance
2346 (
"Add named Vis User Action to current scene.");
2347 fpCommand -> SetGuidance
2348 (
"Attempts to match search string to name of action - use unique sub-string.");
2349 fpCommand -> SetGuidance
2350 (
"(Use /vis/list to see names of registered actions.)");
2351 fpCommand -> SetGuidance
2352 (
"If name == \"all\" (default), all actions are added.");
2353 fpCommand -> SetParameterName(
"action-name", omitable =
true);
2354 fpCommand -> SetDefaultValue(
"all");
2370 G4Scene* pScene = fpVisManager->GetCurrentScene();
2373 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
2380 const std::vector<G4VisManager::UserVisAction>& runDurationUserVisActions =
2381 fpVisManager->GetRunDurationUserVisActions();
2382 for (
size_t i = 0; i < runDurationUserVisActions.size(); i++) {
2383 const G4String&
name = runDurationUserVisActions[i].fName;
2384 G4VUserVisAction* visAction = runDurationUserVisActions[i].fpUserVisAction;
2385 if (newValue ==
"all" || name.find(newValue) != std::string::npos) {
2387 AddVisAction(name,visAction,pScene,runDuration,verbosity);
2391 const std::vector<G4VisManager::UserVisAction>& endOfEventUserVisActions =
2392 fpVisManager->GetEndOfEventUserVisActions();
2393 for (
size_t i = 0; i < endOfEventUserVisActions.size(); i++) {
2394 const G4String&
name = endOfEventUserVisActions[i].fName;
2396 if (newValue ==
"all" || name.find(newValue) != std::string::npos) {
2398 AddVisAction(name,visAction,pScene,endOfEvent,verbosity);
2402 const std::vector<G4VisManager::UserVisAction>& endOfRunUserVisActions =
2403 fpVisManager->GetEndOfRunUserVisActions();
2404 for (
size_t i = 0; i < endOfRunUserVisActions.size(); i++) {
2405 const G4String&
name = endOfRunUserVisActions[i].fName;
2407 if (newValue ==
"all" || name.find(newValue) != std::string::npos) {
2409 AddVisAction(name,visAction,pScene,endOfRun,verbosity);
2415 G4cout <<
"WARNING: No User Vis Action registered." <<
G4endl;
2420 const G4String& currentSceneName = pScene -> GetName ();
2421 UpdateVisManagerScene (currentSceneName);
2424 void G4VisCommandSceneAddUserAction::AddVisAction
2428 G4VisCommandSceneAddUserAction::ActionType type,
2433 const std::map<G4VUserVisAction*,G4VisExtent>& visExtentMap =
2436 std::map<G4VUserVisAction*,G4VisExtent>::const_iterator i =
2437 visExtentMap.find(visAction);
2438 if (i != visExtentMap.end()) extent = i->second;
2441 G4cout <<
"WARNING: User Vis Action extent is null." <<
G4endl;
2446 model->
SetType(
"User Vis Action");
2450 G4bool successful =
false;;
2453 successful = pScene -> AddRunDurationModel (model, warn);
2456 successful = pScene -> AddEndOfEventModel (model, warn);
2459 successful = pScene -> AddEndOfRunModel (model, warn);
2463 const G4String& currentSceneName = pScene -> GetName ();
2464 G4cout <<
"User Vis Action added to scene \""
2465 << currentSceneName <<
"\"";
2467 G4cout <<
"\n with extent " << extent;
2477 fpCommand =
new G4UIcommand (
"/vis/scene/add/volume",
this);
2478 fpCommand -> SetGuidance
2479 (
"Adds a physical volume to current scene, with optional clipping volume.");
2480 fpCommand -> SetGuidance
2481 (
"If physical-volume-name is \"world\" (the default), the top of the"
2482 "\nmain geometry tree (material world) is added. If \"worlds\", the"
2483 "\ntop of all worlds - material world and parallel worlds, if any - are"
2484 "\nadded. Otherwise a search of all worlds is made, taking the first"
2485 "\nmatching occurence only. To see a representation of the geometry"
2486 "\nhierarchy of the worlds, try \"/vis/drawTree [worlds]\" or one of the"
2487 "\ndriver/browser combinations that have the required functionality, e.g., HepRep.");
2488 fpCommand -> SetGuidance
2489 (
"If clip-volume-type is specified, the subsequent parameters are used to"
2490 "\nto define a clipping volume. For example,"
2491 "\n\"vis/scene/add/volume ! ! ! -box km 0 1 0 1 0 1\" will draw the world"
2492 "\nwith the positive octant cut away.");
2493 fpCommand -> SetGuidance
2494 (
"If clip-volume-type is prepended with '-', the clip-volume is subtracted"
2495 "\n(cutaway). (This is the default if there is no prepended character.)"
2496 "\nIf '*' is prepended, the intersection of the physical-volume and the"
2497 "\nclip-volume is made. (You can make a section/DCUT with a thin box, for"
2499 fpCommand -> SetGuidance
2500 (
"For \"box\", the parameters are xmin,xmax,ymin,ymax,zmin,zmax."
2501 "\nOnly \"box\" is programmed at present.");
2503 parameter =
new G4UIparameter (
"physical-volume-name",
's', omitable =
true);
2504 parameter -> SetDefaultValue (
"world");
2505 fpCommand -> SetParameter (parameter);
2506 parameter =
new G4UIparameter (
"copy-no",
'i', omitable =
true);
2507 parameter -> SetGuidance
2508 (
"If negative, matches any copy no. First name match is taken.");
2509 parameter -> SetDefaultValue (-1);
2510 fpCommand -> SetParameter (parameter);
2511 parameter =
new G4UIparameter (
"depth-of-descent",
'i', omitable =
true);
2512 parameter -> SetGuidance
2513 (
"Depth of descent of geometry hierarchy. Default = unlimited depth.");
2515 fpCommand -> SetParameter (parameter);
2516 parameter =
new G4UIparameter (
"clip-volume-type",
's', omitable =
true);
2517 parameter -> SetParameterCandidates(
"none box -box *box");
2518 parameter -> SetDefaultValue (
"none");
2519 parameter -> SetGuidance(
"[-|*]type. See general guidance.");
2520 fpCommand -> SetParameter (parameter);
2521 parameter =
new G4UIparameter (
"parameter-unit",
's', omitable =
true);
2522 parameter -> SetDefaultValue (
"m");
2523 fpCommand -> SetParameter (parameter);
2524 parameter =
new G4UIparameter (
"parameter-1",
'd', omitable =
true);
2525 parameter -> SetDefaultValue (0.);
2526 fpCommand -> SetParameter (parameter);
2527 parameter =
new G4UIparameter (
"parameter-2",
'd', omitable =
true);
2528 parameter -> SetDefaultValue (0.);
2529 fpCommand -> SetParameter (parameter);
2530 parameter =
new G4UIparameter (
"parameter-3",
'd', omitable =
true);
2531 parameter -> SetDefaultValue (0.);
2532 fpCommand -> SetParameter (parameter);
2533 parameter =
new G4UIparameter (
"parameter-4",
'd', omitable =
true);
2534 parameter -> SetDefaultValue (0.);
2535 fpCommand -> SetParameter (parameter);
2536 parameter =
new G4UIparameter (
"parameter-5",
'd', omitable =
true);
2537 parameter -> SetDefaultValue (0.);
2538 fpCommand -> SetParameter (parameter);
2539 parameter =
new G4UIparameter (
"parameter-6",
'd', omitable =
true);
2540 parameter -> SetDefaultValue (0.);
2541 fpCommand -> SetParameter (parameter);
2549 return "world 0 -1";
2561 G4cout <<
"ERROR: No current scene. Please create one." <<
G4endl;
2567 G4int copyNo, requestedDepthOfDescent;
2568 G4double param1, param2, param3, param4, param5, param6;
2569 std::istringstream is (newValue);
2570 is >> name >> copyNo >> requestedDepthOfDescent
2571 >> clipVolumeType >> parameterUnit
2572 >> param1 >> param2 >> param3 >> param4 >> param5 >> param6;
2575 if (clipVolumeType[
size_t(0)] ==
'-') {
2576 clipVolumeType = clipVolumeType.substr(1);
2577 }
else if (clipVolumeType[
size_t(0)] ==
'*') {
2579 clipVolumeType = clipVolumeType.substr(1);
2582 param1 *= unit; param2 *= unit; param3 *= unit;
2583 param4 *= unit; param5 *= unit; param6 *= unit;
2588 size_t nWorlds = transportationManager->
GetNoWorlds();
2591 static G4bool warned =
false;
2592 if (!warned && name !=
"worlds") {
2594 "WARNING: Parallel worlds in operation. To visualise, specify"
2595 "\n \"worlds\" or the parallel world volume or sub-volume name"
2596 "\n and control visibility with /vis/geometry."
2598 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2600 for (
size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2601 G4cout <<
" World " << i <<
": " << (*iterWorld)->GetName()
2614 "ERROR: G4VisCommandSceneAddVolume::SetNewValue:"
2615 "\n No world. Maybe the geometry has not yet been defined."
2616 "\n Try \"/run/initialize\""
2622 const std::vector<G4Scene::Model>& rdModelList = pScene -> GetRunDurationModelList();
2623 std::vector<G4Scene::Model>::const_iterator it;
2624 for (it = rdModelList.begin(); it != rdModelList.end(); ++it) {
2625 if (it->fpModel->GetGlobalDescription().find(
"G4PhysicalVolumeModel")
2626 != std::string::npos) {
2630 if (it != rdModelList.end()) {
2632 G4cout <<
"WARNING: There is already a volume, \""
2633 << it -> fpModel -> GetGlobalDescription()
2634 <<
"\",\n in the run-duration model list of scene \""
2635 << pScene -> GetName()
2636 <<
"\".\n To get a clean scene:"
2637 <<
"\n /vis/drawVolume " << name
2639 <<
"\n /vis/scene/create"
2640 <<
"\n /vis/scene/add/volume " << name
2641 <<
"\n /vis/sceneHandler/attach"
2642 <<
"\n (and also, if necessary, /vis/viewer/flush)"
2648 std::vector<G4PhysicalVolumeModel*> models;
2649 std::vector<G4VPhysicalVolume*> foundVolumes;
2652 typedef std::vector<PVNodeID>
PVPath;
2653 PVPath foundFullPVPath;
2654 std::vector<G4int> foundDepths;
2655 std::vector<G4Transform3D> transformations;
2657 if (name ==
"world") {
2661 foundVolumes.push_back(world);
2662 foundDepths.push_back(0);
2665 }
else if (name ==
"worlds") {
2670 "WARNING: G4VisCommandSceneAddVolume::SetNewValue:"
2671 "\n Parallel worlds requested but none exist."
2672 "\n Just adding material world."
2676 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2678 for (
size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2681 foundVolumes.push_back(*iterWorld);
2682 foundDepths.push_back(0);
2688 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
2690 for (
size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
2698 foundWorld = *iterWorld;
2699 foundVolumes.push_back(foundVolume);
2707 if (foundVolumes.size()) {
2708 for (
size_t i = 0; i < foundVolumes.size(); ++i) {
2710 (foundVolumes[i], requestedDepthOfDescent, transformations[i]);
2711 foundFullPVPath.pop_back();
2713 models.push_back(foundPVModel);
2717 G4cout <<
"ERROR: Volume \"" << name <<
"\"";
2719 G4cout <<
", copy no. " << copyNo <<
",";
2727 if (clipVolumeType ==
"box") {
2728 const G4double dX = (param2 - param1) / 2.;
2729 const G4double dY = (param4 - param3) / 2.;
2730 const G4double dZ = (param6 - param5) / 2.;
2731 const G4double x0 = (param2 + param1) / 2.;
2732 const G4double y0 = (param4 + param3) / 2.;
2736 (
"_displaced_clipping_box",
2737 new G4Box(
"_clipping_box",dX,dY,dZ),
2739 for (
size_t i = 0; i < foundVolumes.size(); ++i) {
2740 models[i]->SetClippingSolid(clippingSolid);
2741 models[i]->SetClippingMode(clippingMode);
2745 const G4String& currentSceneName = pScene -> GetName ();
2747 for (
size_t i = 0; i < foundVolumes.size(); ++i) {
2748 G4bool successful = pScene -> AddRunDurationModel (models[i], warn);
2752 G4cout <<
"First occurrence of \""
2753 << foundVolumes[i] -> GetName ()
2756 G4cout <<
", copy no. " << copyNo <<
",";
2761 G4cout <<
"at depth " << foundDepths[i]
2762 <<
",\n with a requested depth of further descent of ";
2763 if (requestedDepthOfDescent < 0) {
2764 G4cout <<
"<0 (unlimited)";
2767 G4cout << requestedDepthOfDescent;
2769 G4cout <<
",\n has been added to scene \"" << currentSceneName <<
"\"."
2776 G4VisCommandsSceneAddUnsuccessful(verbosity);
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetParameter(G4UIparameter *const newParameter)
virtual ~G4VisCommandSceneAddDate()
G4String GetCurrentValue(G4UIcommand *command)
void SetColour(const G4Colour &)
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
void SetGlobalTag(const G4String &)
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandSceneAddLine()
G4String GetCurrentValue(G4UIcommand *command)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
CLHEP::Hep3Vector G4ThreeVector
static G4Colour fCurrentColour
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
void UpdateVisManagerScene(const G4String &sceneName="")
G4String GetCurrentValue(G4UIcommand *command)
void SetLineWidth(G4double)
BasicVector3D< T > unit() const
virtual ~G4VisCommandSceneAddLogicalVolume()
static G4Text::Layout fCurrentTextLayout
virtual ~G4VisCommandSceneAddPSHits()
const G4ViewParameters & GetViewParameters() const
virtual ~G4VisCommandSceneAddMagneticField()
virtual ~G4VisCommandSceneAddHits()
const G4ModelingParameters * GetModelingParameters() const
G4VisCommandSceneAddText()
void SetDefaultValue(const char *theDefaultValue)
G4VisCommandSceneAddLine()
const std::vector< const G4Event * > * GetEventVector() const
G4VisCommandSceneAddTrajectories()
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
HepGeom::Point3D< G4double > G4Point3D
HepGeom::Vector3D< G4double > G4Vector3D
G4VisCommandSceneAddAxes()
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void SetForceSolid(G4bool)
void SetExtent(const G4VisExtent &)
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
G4int GetVerboseLevel() const
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandSceneAddLogo2D()
void SetModelingParameters(const G4ModelingParameters *)
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
const G4Run * GetCurrentRun() const
G4VisCommandSceneAddFrame()
void SetVerboseLevel(G4int val)
virtual ~G4VisCommandSceneAddAxes()
G4VisCommandSceneAddUserAction()
void SetTransformation(const G4Transform3D &)
static G4UImanager * GetUIpointer()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4VisCommandSceneAddFrame()
static G4StateManager * GetStateManager()
G4double GetExtentRadius() const
G4VisCommandSceneAddText2D()
const G4Vector3D & GetViewpointDirection() const
void SetNewValue(G4UIcommand *command, G4String newValue)
G4GLOB_DLL std::ostream G4cout
const G4Event * GetEvent() const
void SetNewValue(G4UIcommand *command, G4String newValue)
const G4VisExtent & GetExtent() const
G4VisCommandSceneAddLogicalVolume()
G4VisCommandSceneAddDigis()
const G4String & GetName() const
void SetNewValue(G4UIcommand *command, G4String newValue)
static G4bool ConvertToBool(const char *st)
virtual ~G4VisCommandSceneAddScale()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandSceneAddHits()
G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID
G4int GetFoundDepth() const
G4VisCommandSceneAddScale()
G4String GetCurrentValue(G4UIcommand *command)
void SetType(const G4String &)
static const G4String & GetGuidanceString()
static G4LogicalVolumeStore * GetInstance()
virtual ~G4VisCommandSceneAddText2D()
const XML_Char XML_Content * model
G4VisCommandSceneAddLogo()
std::vector< PVNodeID > PVPath
G4ApplicationState GetCurrentState() const
const std::map< G4VUserVisAction *, G4VisExtent > & GetUserVisActionExtents() const
void SetBaseFullPVPath(const std::vector< G4PhysicalVolumeNodeID > &baseFullPVPath)
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
void SetVisAttributes(const G4VisAttributes *)
virtual ~G4VisCommandSceneAddLine2D()
virtual ~G4VisCommandSceneAddArrow2D()
static G4TransportationManager * GetTransportationManager()
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandSceneAddPSHits()
static G4RunManager * GetRunManager()
const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > & GetFoundFullPVPath() const
virtual ~G4VisCommandSceneAddDigis()
G4String GetCurrentValue(G4UIcommand *command)
void SetOffset(double dx, double dy)
G4VisCommandSceneAddArrow()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandSceneAddLine2D()
G4double StoD(G4String s)
static G4double ValueOf(const char *unitName)
G4VisCommandSceneAddEventID()
virtual ~G4VisCommandSceneAddText()
G4VPhysicalVolume * GetFoundVolume() const
const std::map< G4String, G4AttDef > * GetAttDefs() const
G4String GetCurrentValue(G4UIcommand *command)
static G4double fCurrentLineWidth
static G4Colour fCurrentTextColour
static Verbosity GetVerbosity()
virtual ~G4VisCommandSceneAddLogo()
HepRotation & rotateZ(double delta)
virtual ~G4VisCommandSceneAddTrajectories()
G4int GetNumberOfEventToBeProcessed() const
size_t GetNoWorlds() const
G4VisCommandSceneAddVolume()
G4VisCommandSceneAddArrow2D()
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandSceneAddDate()
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VViewer * GetCurrentViewer() const
void SetDefaultValue(G4int defVal)
const G4Transform3D & GetFoundTransformation() const
virtual ~G4VisCommandSceneAddVolume()
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4VisCommandSceneAddEventID()
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandSceneAddMagneticField()
void SetGuidance(const char *theGuidance)
const G4Vector3D & GetUpVector() const
G4String GetCurrentValue(G4UIcommand *command)
void SetGlobalDescription(const G4String &)
G4String GetCurrentValue(G4UIcommand *command)
G4int ApplyCommand(const char *aCommand)
G4Scene * GetCurrentScene() const
virtual ~G4VisCommandSceneAddUserAction()
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetScreenSize(G4double)
virtual ~G4VisCommandSceneAddArrow()
void DescribeYourselfTo(G4VGraphicsScene &)
G4VisCommandSceneAddLogo2D()
static G4VisManager * fpVisManager
virtual const std::map< G4String, G4AttDef > * GetAttDefs() const