47 #ifdef G4VIS_USE_STD11
67 RefreshIfRequired(viewer);
74 if (sceneHandler && sceneHandler->
GetScene()) {
80 G4cout <<
"Issue /vis/viewer/refresh or flush to see effect."
93 (
"Add cutaway plane to current viewer.");
96 parameter -> SetDefaultValue (0);
97 parameter -> SetGuidance (
"Coordinate of point on the plane.");
100 parameter -> SetDefaultValue (0);
101 parameter -> SetGuidance (
"Coordinate of point on the plane.");
104 parameter -> SetDefaultValue (0);
105 parameter -> SetGuidance (
"Coordinate of point on the plane.");
108 parameter -> SetDefaultValue (
"m");
109 parameter -> SetGuidance (
"Unit of point on the plane.");
112 parameter -> SetDefaultValue (1);
113 parameter -> SetGuidance (
"Component of plane normal.");
116 parameter -> SetDefaultValue (0);
117 parameter -> SetGuidance (
"Component of plane normal.");
120 parameter -> SetDefaultValue (0);
121 parameter -> SetGuidance (
"Component of plane normal.");
141 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
149 std::istringstream is (newValue);
150 is >> x >> y >> z >> unit >> nx >> ny >> nz;
152 x *= F; y *= F; z *= F;
157 G4cout <<
"Cutaway planes for viewer \"" << viewer->
GetName() <<
"\" now:";
159 for (
size_t i = 0; i < cutaways.size(); ++i)
160 G4cout <<
"\n " << i <<
": " << cutaways[i];
172 fpCommand -> SetGuidance(
"Change cutaway plane.");
175 parameter -> SetGuidance (
"Index of plane: 0, 1, 2.");
178 parameter -> SetDefaultValue (0);
179 parameter -> SetGuidance (
"Coordinate of point on the plane.");
182 parameter -> SetDefaultValue (0);
183 parameter -> SetGuidance (
"Coordinate of point on the plane.");
186 parameter -> SetDefaultValue (0);
187 parameter -> SetGuidance (
"Coordinate of point on the plane.");
190 parameter -> SetDefaultValue (
"m");
191 parameter -> SetGuidance (
"Unit of point on the plane.");
194 parameter -> SetDefaultValue (1);
195 parameter -> SetGuidance (
"Component of plane normal.");
198 parameter -> SetDefaultValue (0);
199 parameter -> SetGuidance (
"Component of plane normal.");
202 parameter -> SetDefaultValue (0);
203 parameter -> SetGuidance (
"Component of plane normal.");
223 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
232 std::istringstream is (newValue);
233 is >> index >> x >> y >> z >> unit >> nx >> ny >> nz;
235 x *= F; y *= F; z *= F;
241 G4cout <<
"Cutaway planes for viewer \"" << viewer->
GetName() <<
"\" now:";
243 for (
size_t i = 0; i < cutaways.size(); ++i)
244 G4cout <<
"\n " << i <<
": " << cutaways[i];
254 G4bool omitable, currentAsDefault;
256 fpCommand -> SetGuidance (
"Clears viewer.");
258 (
"By default, clears current viewer. Specified viewer becomes current."
259 "\n\"/vis/viewer/list\" to see possible viewer names.");
260 fpCommand -> SetParameterName (
"viewer-name",
262 currentAsDefault =
true);
271 return viewer ? viewer -> GetName () :
G4String(
"none");
282 G4cerr <<
"ERROR: Viewer \"" << clearName
283 <<
"\" not found - \"/vis/viewer/list\" to see possibilities."
293 G4cout <<
"Viewer \"" << clearName <<
"\" cleared." <<
G4endl;
302 (
"/vis/viewer/clearCutawayPlanes",
this);
303 fpCommand -> SetGuidance (
"Clear cutaway planes of current viewer.");
322 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
331 G4cout <<
"Cutaway planes for viewer \"" << viewer->
GetName()
332 <<
"\" now cleared." <<
G4endl;
341 G4bool omitable, currentAsDefault;
343 fpCommand -> SetGuidance (
"Clears transients from viewer.");
345 (
"By default, operates on current viewer. Specified viewer becomes current."
346 "\n\"/vis/viewer/list\" to see possible viewer names.");
347 fpCommand -> SetParameterName (
"viewer-name",
349 currentAsDefault =
true);
358 return viewer ? viewer -> GetName () :
G4String(
"none");
369 G4cerr <<
"ERROR: Viewer \"" << clearName
370 <<
"\" not found - \"/vis/viewer/list\" to see possibilities."
381 G4cout <<
"Viewer \"" << clearName <<
"\" cleared of transients."
391 (
"/vis/viewer/clearVisAttributesModifiers",
this);
392 fpCommand -> SetGuidance (
"Clear vis attribute modifiers of current viewer.");
393 fpCommand -> SetGuidance (
"(These are used for touchables, etc.)");
412 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
421 G4cout <<
"Vis attributes modifiers for viewer \"" << viewer->
GetName()
422 <<
"\" now cleared." <<
G4endl;
433 fpCommand -> SetGuidance (
"Clones viewer.");
435 (
"By default, clones current viewer. Clone becomes current."
436 "\nClone name, if not provided, is derived from the original name."
437 "\n\"/vis/viewer/list\" to see possible viewer names.");
439 parameter =
new G4UIparameter (
"original-viewer-name",
's', omitable =
true);
440 parameter -> SetCurrentAsDefault (
true);
442 parameter =
new G4UIparameter (
"clone-name",
's', omitable =
true);
443 parameter -> SetDefaultValue (
"none");
454 return "\"" + originalName +
"\"";
462 std::istringstream is (newValue);
467 while (is.get(c) && c ==
' '){}
469 while (is.get(c) && c !=
'"') {originalName += c;}
473 while (is.get(c) && c !=
' ') {originalName += c;}
479 if (!originalViewer) {
481 G4cerr <<
"ERROR: Viewer \"" << originalName
482 <<
"\" not found - \"/vis/viewer/list\" to see possibilities."
487 originalName = originalViewer->
GetName();
489 while (is.get(c) && c ==
' '){}
491 while (is.get(c) && c !=
'"') {cloneName += c;}
495 while (is.get(c) && c !=
' ') {cloneName += c;}
500 G4bool errorWhileNaming =
false;
501 if (cloneName ==
"none") {
504 cloneName = originalName;
505 std::ostringstream oss;
506 oss <<
'-' << subID++;
507 G4String::size_type lastDashPosition, nextSpacePosition;
508 if ((lastDashPosition = cloneName.rfind(
'-')) != G4String::npos &&
509 (nextSpacePosition = cloneName.find(
" ", lastDashPosition)) !=
511 cloneName.insert(nextSpacePosition, oss.str());
513 G4String::size_type spacePosition = cloneName.find(
' ');
514 if (spacePosition != G4String::npos)
515 cloneName.insert(spacePosition, oss.str());
517 errorWhileNaming =
true;
519 }
while (!errorWhileNaming &&
fpVisManager -> GetViewer (cloneName));
522 if (errorWhileNaming) {
524 G4cerr <<
"ERROR: While naming clone viewer \"" << cloneName
533 G4cerr <<
"ERROR: Putative clone viewer \"" << cloneName
534 <<
"\" already exists."
546 if (keepVerbose >= 2 ||
552 (
G4String(
"/vis/viewer/create ! \"" + cloneName +
"\" " + windowSizeHint));
557 G4cout <<
"Viewer \"" << originalName <<
"\" cloned." <<
G4endl;
558 G4cout <<
"Clone \"" << cloneName <<
"\" now current." <<
G4endl;
568 (
"If a volume has no vis attributes, colour it by density.");
570 (
"Provide algorithm number, e.g., \"1\" (or \"0\" to switch off)."
571 "\nThen a unit of density, e.g., \"g/cm3\"."
572 "\nThen parameters for the algorithm assumed to be densities in that unit.");
574 (
"Algorithm 1: Simple algorithm takes 3 parameters: d0, d1 and d2."
575 "\nVolumes with density < d0 are invisible."
576 "\nVolumes with d0 <= density < d1 have colour on range red->green."
577 "\nVolumes with d1 <= density < d2 have colour on range green->blue."
578 "\nVolumes with density > d2 are blue.");
581 parameter -> SetDefaultValue (0);
582 parameter -> SetGuidance (
"Algorithm number (or \"0\" to switch off).");
585 parameter -> SetDefaultValue (
"g/cm3");
586 parameter -> SetGuidance (
"Unit of following densities, e.g., \"g/cm3\".");
589 parameter -> SetDefaultValue (0.);
590 parameter -> SetGuidance (
"Density parameter 0.");
593 parameter -> SetDefaultValue (0.);
594 parameter -> SetGuidance (
"Density parameter 1.");
597 parameter -> SetDefaultValue (0.);
598 parameter -> SetGuidance (
"Density parameter 2.");
618 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
625 G4int algorithmNumber;
628 std::istringstream is (newValue);
629 is >> algorithmNumber >> unit >> d0 >> d1 >>
d2;
631 if (algorithmNumber < 0 || algorithmNumber > 1) {
634 "ERROR: Unrecognised algorithm number: " << algorithmNumber
640 std::vector<G4double> parameters;
641 if (algorithmNumber > 0) {
642 const G4String where =
"G4VisCommandViewerColourByDensity::SetNewValue";
647 d0 *= valueOfUnit; d1 *= valueOfUnit; d2 *= valueOfUnit;
651 "ERROR: Unrecognised or inappropriate unit: " << unit
656 parameters.push_back(d0);
657 parameters.push_back(d1);
658 parameters.push_back(d2);
668 <<
" selected for viewer \"" << viewer->
GetName()
686 (
"Copy the camera-specific parameters from the specified viewer.");
688 (
"Note: To copy ALL view parameters, including scene modifications,"
689 "\nuse \"/vis/viewer/set/all\"");
690 fpCommand -> SetParameterName (
"from-viewer-name", omitable =
false);
706 if (!currentViewer) {
709 "ERROR: G4VisCommandsViewerCopyViewFrom::SetNewValue: no current viewer."
715 const G4String& fromViewerName = newValue;
719 G4cerr <<
"ERROR: Viewer \"" << fromViewerName
720 <<
"\" not found - \"/vis/viewer/list\" to see possibilities."
726 if (fromViewer == currentViewer) {
729 "WARNING: G4VisCommandsViewerSet::SetNewValue:"
730 "\n from-viewer and current viewer are identical."
751 G4cout <<
"Camera parameters of viewer \"" << currentViewer->
GetName()
752 <<
"\"\n set to those of viewer \"" << fromViewer->
GetName()
764 (
"Creates a viewer for the specified scene handler.");
766 (
"Default scene handler is the current scene handler. Invents a name"
767 "\nif not supplied. (Note: the system adds information to the name"
768 "\nfor identification - only the characters up to the first blank are"
769 "\nused for removing, selecting, etc.) This scene handler and viewer"
770 "\nbecome current.");
772 parameter =
new G4UIparameter (
"scene-handler",
's', omitable =
true);
773 parameter -> SetCurrentAsDefault (
true);
775 parameter =
new G4UIparameter (
"viewer-name",
's', omitable =
true);
776 parameter -> SetCurrentAsDefault (
true);
778 parameter =
new G4UIparameter (
"window-size-hint",
's', omitable =
true);
780 (
"integer (pixels) for square window placed by window manager or"
781 " X-Windows-type geometry string, e.g. 600x600-100+100");
791 std::ostringstream oss;
793 oss <<
"viewer-" <<
fId <<
" (";
795 oss << sceneHandler -> GetGraphicsSystem () -> GetName ();
798 oss <<
"no_scene_handlers";
808 if (currentSceneHandler) {
809 currentValue = currentSceneHandler -> GetName ();
812 currentValue =
"none";
819 currentValue +=
" 600";
830 std::istringstream is (newValue);
831 is >> sceneHandlerName;
836 while (is.get(c) && c ==
' '){}
838 while (is.get(c) && c !=
'"') {newName += c;}
842 while (is.get(c) && c !=
' ') {newName += c;}
848 is >> windowSizeHintString;
852 G4int nHandlers = sceneHandlerList.size ();
853 if (nHandlers <= 0) {
856 "ERROR: G4VisCommandViewerCreate::SetNewValue: no scene handlers."
857 "\n Create a scene handler with \"/vis/sceneHandler/create\""
864 for (iHandler = 0; iHandler < nHandlers; iHandler++) {
865 if (sceneHandlerList [iHandler] -> GetName () == sceneHandlerName)
break;
868 if (iHandler < 0 || iHandler >= nHandlers) {
872 G4cout <<
"G4VisCommandViewerCreate::SetNewValue:"
873 " invalid scene handler specified."
882 if (sceneHandler !=
fpVisManager -> GetCurrentSceneHandler ()) {
891 if (newName == nextName)
fId++;
894 for (
G4int ih = 0; ih < nHandlers; ih++) {
896 const G4ViewerList& viewerList = sh -> GetViewerList ();
897 for (
size_t iViewer = 0; iViewer < viewerList.size (); iViewer++) {
898 if (viewerList [iViewer] -> GetShortName () == newShortName ) {
900 G4cerr <<
"ERROR: Viewer \"" << newShortName <<
"\" already exists."
912 fpVisManager -> CreateViewer (newName,windowSizeHintString);
915 if (newViewer && newViewer -> GetName () == newName) {
917 G4cout <<
"New viewer \"" << newName <<
"\" created." <<
G4endl;
923 G4cerr <<
"ERROR: New viewer doesn\'t match!!! Curious!!" <<
G4endl;
936 G4cout <<
"Issue /vis/viewer/refresh or flush to see effect."
946 fDollyIncrement (0.),
949 G4bool omitable, currentAsDefault;
952 (
"/vis/viewer/dolly",
this);
954 (
"Incremental dolly.");
956 (
"Moves the camera incrementally towards target point.");
959 currentAsDefault=
true);
963 (
"/vis/viewer/dollyTo",
this);
965 (
"Dolly to specific coordinate.");
967 (
"Places the camera towards target point relative to standard camera point.");
970 currentAsDefault=
true);
997 if (!currentViewer) {
1000 "ERROR: G4VisCommandsViewerDolly::SetNewValue: no current viewer."
1027 G4bool omitable, currentAsDefault;
1030 (
"Compound command: \"/vis/viewer/refresh\" + \"/vis/viewer/update\".");
1032 (
"Useful for refreshing and initiating post-processing for graphics"
1033 "\nsystems which need post-processing. By default, acts on current"
1034 "\nviewer. \"/vis/viewer/list\" to see possible viewers. Viewer"
1035 "\nbecomes current.");
1036 fpCommand -> SetParameterName (
"viewer-name",
1038 currentAsDefault =
true);
1047 G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
1048 return viewer ? viewer -> GetName () :
G4String(
"none");
1059 G4cerr <<
"ERROR: Viewer \"" << flushName <<
"\"" <<
1060 " not found - \"/vis/viewer/list\"\n to see possibilities."
1068 G4int newVerbose(0);
1076 G4cout <<
"Viewer \"" << viewer -> GetName () <<
"\""
1077 <<
" flushed." <<
G4endl;
1087 (
"Interpolate views defined by the first argument, which can contain "
1088 "Unix-shell-style pattern matching characters such as '*', '?' and '[' "
1089 "- see \"man sh\" and look for \"Pattern Matching\". The contents "
1090 "of each file are assumed to be \"/vis/viewer\" commands "
1091 "that specify a particular view. The files are processed in alphanumeric "
1092 "order of filename. The files may be written by hand or produced by the "
1093 "\"/vis/viewer/save\" command.");
1095 (
"The default is to search the working directory for files with a .g4view "
1096 "extension. Another procedure is to assemble view files in a subdirectory, "
1097 "e.g., \"myviews\"; then they can be interpolated with\n"
1098 "\"/vis/viewer/interpolate myviews/*\".");
1100 (
"To export interpolated views to file for a future possible movie, "
1101 "write \"export\" as 5th parameter (OpenGL only).");
1103 parameter =
new G4UIparameter(
"pattern",
's', omitable =
true);
1104 parameter -> SetGuidance(
"Pattern that defines the view files.");
1105 parameter -> SetDefaultValue(
"*.g4view");
1107 parameter =
new G4UIparameter(
"no-of-points",
'i', omitable =
true);
1108 parameter -> SetGuidance (
"Number of interpolation points per interval.");
1109 parameter -> SetDefaultValue(50);
1111 parameter =
new G4UIparameter(
"wait-time",
's', omitable =
true);
1112 parameter -> SetGuidance(
"Wait time per interpolated point");
1113 parameter -> SetDefaultValue(
"20.");
1115 parameter =
new G4UIparameter(
"time-unit",
's', omitable =
true);
1116 parameter -> SetDefaultValue(
"millisecond");
1118 parameter =
new G4UIparameter(
"export",
's', omitable =
true);
1119 parameter -> SetDefaultValue(
"no");
1136 if (!currentViewer) {
1139 "ERROR: G4VisCommandViewerInterpolate::SetNewValue: no current viewer."
1146 G4int nInterpolationPoints;
1151 std::istringstream iss (newValue);
1154 >> nInterpolationPoints
1155 >> waitTimePerPointString
1158 G4String waitTimePerPointDimString(waitTimePerPointString +
' ' + timeUnit);
1162 if (waitTimePerPointmilliseconds < 0) waitTimePerPointmilliseconds = 0;
1184 std::vector<G4ViewParameters> viewVector;
1186 const G4int safety = 9999;
1187 G4int safetyCount = 0;
1193 G4String shellCommand =
"echo " + pattern;
1194 FILE *filelist = popen(shellCommand.c_str(),
"r");
1198 <<
"ERROR: G4VisCommandViewerInterpolate::SetNewValue:"
1199 <<
"\n Error obtaining pipe."
1206 const size_t BUFLENGTH = 999999;
1207 char buf[BUFLENGTH];
1208 fgets(buf, BUFLENGTH, filelist);
1209 std::istringstream fileliststream(buf);
1210 while (fileliststream >> pathname
1211 && safetyCount++ < safety) {
1212 uiManager->
ApplyCommand(
"/control/execute " + pathname);
1217 #else // WIN32 (popen is not available in Windows)
1219 std::experimental::filesystem::v1::path filePattern(pattern);
1224 std::string regexp_pattern(
"^" + filePattern.filename().string());
1225 std::string result_pattern =
"";
1227 size_t currentPos = 0;
1229 std::string currentReplacement =
"";
1230 size_t pos1 = regexp_pattern.find(
'.', nextPos);
1231 size_t pos2 = regexp_pattern.find(
'*', nextPos);
1232 size_t pos3 = regexp_pattern.find(
'?', nextPos);
1233 while ((pos1 != std::string::npos) || (pos2 != std::string::npos) || (pos3 != std::string::npos)) {
1235 currentReplacement =
"\\.";
1236 if (pos2 < nextPos) {
1238 currentReplacement =
".*";
1240 if (pos3 < nextPos) {
1242 currentReplacement =
"(.{1,1})";
1244 result_pattern += regexp_pattern.substr(currentPos, nextPos - currentPos) + currentReplacement;
1246 currentPos = nextPos;
1247 pos1 = regexp_pattern.find(
'.', currentPos);
1248 pos2 = regexp_pattern.find(
'*', currentPos);
1249 pos3 = regexp_pattern.find(
'?', currentPos);
1251 result_pattern += regexp_pattern.substr(currentPos);
1255 G4String parentPath(filePattern.parent_path().string().length() ? filePattern.parent_path().string() : std::string(
"./"));
1257 std::regex result_pattern_regex (result_pattern, std::regex_constants::basic | std::regex_constants::icase);
1258 for (
auto iter = std::experimental::filesystem::v1::directory_iterator(parentPath);
1259 iter != std::experimental::filesystem::v1::directory_iterator() && safetyCount++ < safety;
1262 const auto&
file = iter->path();
1265 if (std::regex_match(filename, result_pattern_regex))
1267 uiManager->
ApplyCommand(
"/control/execute " + filename);
1274 if (safetyCount >= safety) {
1277 "/vis/viewer/interpolate:"
1278 "\n the number of way points exceeds the maximum currently allowed: "
1294 if (exportString ==
"export" &&
1300 #ifdef G4VIS_USE_STD11
1301 if (waitTimePerPointmilliseconds > 0)
1302 std::this_thread::sleep_for(std::chrono::milliseconds(waitTimePerPointmilliseconds));
1304 }
while (safetyCount++ < safety);
1314 G4cout <<
"Viewer \"" << currentViewer -> GetName () <<
"\""
1315 <<
" restored." <<
G4endl;
1324 fpCommand -> SetGuidance (
"Lists viewers(s).");
1326 (
"See \"/vis/verbose\" for definition of verbosity.");
1330 parameter -> SetDefaultValue (
"all");
1334 parameter -> SetDefaultValue (
"warnings");
1348 std::istringstream is (newValue);
1349 is >> name >> verbosityString;
1356 if (currentViewer) {
1357 currentViewerShortName = currentViewer -> GetShortName ();
1360 currentViewerShortName =
"none";
1365 G4int nHandlers = sceneHandlerList.size ();
1367 G4bool foundCurrent =
false;
1368 for (
int iHandler = 0; iHandler < nHandlers; iHandler++) {
1370 const G4ViewerList& viewerList = sceneHandler -> GetViewerList ();
1372 <<
"Scene handler \"" << sceneHandler -> GetName () <<
"\" ("
1374 const G4Scene* pScene = sceneHandler -> GetScene ();
1376 G4cout <<
", scene \"" << pScene -> GetName () <<
"\"";
1379 G4int nViewers = viewerList.size ();
1380 if (nViewers == 0) {
1381 G4cout <<
"\n No viewers for this scene handler." <<
G4endl;
1384 for (
int iViewer = 0; iViewer < nViewers; iViewer++) {
1385 const G4VViewer* thisViewer = viewerList [iViewer];
1386 G4String thisName = thisViewer -> GetName ();
1387 G4String thisShortName = thisViewer -> GetShortName ();
1388 if (name !=
"all") {
1389 if (thisShortName != shortName)
continue;
1393 if (thisShortName == currentViewerShortName) {
1394 foundCurrent =
true;
1400 G4cout <<
" viewer \"" << thisName <<
"\"";
1402 G4cout <<
"\n " << *thisViewer;
1409 if (!foundCurrent) {
1410 G4cout <<
"No valid current viewer - please create or select one."
1416 if (name !=
"all") {
1417 G4cout <<
" of name \"" << name <<
"\"";
1426 fPanIncrementRight (0.),
1427 fPanIncrementUp (0.),
1434 (
"/vis/viewer/pan",
this);
1436 (
"Incremental pan.");
1438 (
"Moves the camera incrementally right and up by these amounts (as seen"
1439 "\nfrom viewpoint direction).");
1441 parameter =
new G4UIparameter(
"right-increment",
'd', omitable =
true);
1442 parameter -> SetCurrentAsDefault (
true);
1444 parameter =
new G4UIparameter(
"up-increment",
'd', omitable =
true);
1445 parameter -> SetCurrentAsDefault (
true);
1447 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
1448 parameter -> SetDefaultValue (
"m");
1452 (
"/vis/viewer/panTo",
this);
1454 (
"Pan to specific coordinate.");
1456 (
"Places the camera in this position right and up relative to standard"
1457 "\ntarget point (as seen from viewpoint direction).");
1458 parameter =
new G4UIparameter(
"right",
'd', omitable =
true);
1459 parameter -> SetCurrentAsDefault (
true);
1462 parameter -> SetCurrentAsDefault (
true);
1464 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
1465 parameter -> SetDefaultValue (
"m");
1482 return currentValue;
1492 if (!currentViewer) {
1495 "ERROR: G4VisCommandsViewerPan::SetNewValue: no current viewer."
1523 G4bool omitable, currentAsDefault;
1525 fpCommand -> SetGuidance (
"Forces rebuild of graphical database.");
1527 (
"By default, acts on current viewer. \"/vis/viewer/list\""
1528 "\nto see possible viewers. Viewer becomes current.");
1529 fpCommand -> SetParameterName (
"viewer-name",
1531 currentAsDefault =
true);
1541 return viewer -> GetName ();
1557 G4cerr <<
"ERROR: Viewer \"" << rebuildName
1558 <<
"\" not found - \"/vis/viewer/list\" to see possibilities."
1565 if (!sceneHandler) {
1567 G4cerr <<
"ERROR: Viewer \"" << viewer->
GetName() <<
"\"" <<
1568 " has no scene handler - report serious bug."
1587 G4bool omitable, currentAsDefault;
1590 (
"Refreshes viewer.");
1592 (
"By default, acts on current viewer. \"/vis/viewer/list\""
1593 "\nto see possible viewers. Viewer becomes current.");
1594 fpCommand -> SetParameterName (
"viewer-name",
1596 currentAsDefault =
true);
1605 return viewer ? viewer -> GetName () :
G4String(
"none");
1617 G4cerr <<
"ERROR: Viewer \"" << refreshName <<
"\"" <<
1618 " not found - \"/vis/viewer/list\"\n to see possibilities."
1625 if (!sceneHandler) {
1627 G4cerr <<
"ERROR: Viewer \"" << refreshName <<
"\"" <<
1628 " has no scene handler - report serious bug."
1637 G4cout <<
"NOTE: SceneHandler \"" << sceneHandler->
GetName()
1638 <<
"\", to which viewer \"" << refreshName <<
"\"" <<
1639 "\n is attached, has no scene - \"/vis/scene/create\" and"
1640 " \"/vis/sceneHandler/attach\""
1641 "\n (or use compound command \"/vis/drawVolume\")."
1647 G4bool successful = scene -> AddWorldIfEmpty (warn);
1651 "WARNING: Scene is empty. Perhaps no geometry exists."
1652 "\n Try /run/initialize."
1663 G4cout <<
"Refreshing viewer \"" << viewer -> GetName () <<
"\"..."
1666 viewer -> SetView ();
1667 viewer -> ClearView ();
1668 viewer -> DrawView ();
1670 G4cout <<
"Viewer \"" << viewer -> GetName () <<
"\"" <<
" refreshed."
1671 "\n (You might also need \"/vis/viewer/update\".)" <<
G4endl;
1679 G4bool omitable, currentAsDefault;
1681 fpCommand -> SetGuidance (
"Resets viewer.");
1683 (
"By default, acts on current viewer. \"/vis/viewer/list\""
1684 "\nto see possible viewers. Viewer becomes current.");
1685 fpCommand -> SetParameterName (
"viewer-name",
1687 currentAsDefault =
true);
1697 return viewer -> GetName ();
1712 G4cerr <<
"ERROR: Viewer \"" << resetName
1713 <<
"\" not found - \"/vis/viewer/list\" to see possibilities."
1729 (
"Write commands that define the current view to file.");
1731 (
"Read them back into the same or any viewer with \"/control/execute\".");
1733 (
"If the filename is omitted the view is saved to a file "
1734 "\"g4_nn.g4view\", where nn is a sequential two-digit number.");
1736 (
"If the filename is \"-\", the data are written to G4cout.");
1738 (
"If you are wanting to save views for future interpolation a recommended "
1739 "procedure is: save views to \"g4_nn.g4view\", as above, then move the files "
1740 "into a sub-directory, say, \"views\", then interpolate with"
1741 "\"/vis/viewer/interpolate views/\" (note the trailing \'/\').");
1742 fpCommand -> SetParameterName (
"filename", omitable =
true);
1776 if (!currentViewer) {
1779 "ERROR: G4VisCommandsViewerSave::SetNewValue: no current viewer."
1786 if (!currentScene) {
1789 "ERROR: G4VisCommandsViewerSave::SetNewValue: no current scene."
1798 const std::vector<G4ModelingParameters::VisAttributesModifier>*
1801 std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator i;
1802 for (i = privateVAMs->begin(); i != privateVAMs->end(); ++i) {
1810 if (newValue.length() == 0) {
1812 const G4int maxNoOfFiles = 100;
1813 static G4int sequenceNumber = 0;
1814 if (sequenceNumber >= maxNoOfFiles) {
1817 <<
"ERROR: G4VisCommandsViewerSave::SetNewValue: Maximum number, "
1819 <<
", of files exceeded."
1824 std::ostringstream oss;
1825 oss << std::setw(2) << std::setfill(
'0') << sequenceNumber++;
1826 filename =
"g4_" + oss.str() +
".g4view";
1829 if (filename ==
"-") {
1831 WriteCommands(
G4cout,vp,stp);
1836 filename +=
".g4view";
1838 std::ofstream ofs(filename);
1842 "ERROR: G4VisCommandsViewerSave::SetNewValue: Trouble opening file \""
1843 << filename <<
"\"."
1849 WriteCommands(ofs,vp,stp);
1854 G4cout <<
"Viewer \"" << currentViewer -> GetName ()
1855 <<
"\"" <<
" saved to ";
1856 if (filename ==
"-") {
1859 G4cout <<
"file \'" << filename <<
"\"." <<
1860 "\n Read the view back into this or any viewer with"
1861 "\n \"/control/execute " << filename <<
"\" or use"
1862 "\n \"/vis/viewer/interpolate\" if you have several saved files -"
1863 "\n see \"help /vis/viewer/interpolate\" for guidance.";
1875 G4bool omitable, currentAsDefault;
1878 (
"/vis/viewer/scale",
this);
1879 fpCommandScale -> SetGuidance (
"Incremental (non-uniform) scaling.");
1881 (
"Multiplies components of current scaling by components of this factor."
1882 "\n Scales (x,y,z) by corresponding components of the resulting factor.");
1886 (
"x-scale-multiplier",
"y-scale-multiplier",
"z-scale-multiplier",
1887 omitable=
true, currentAsDefault=
true);
1890 (
"/vis/viewer/scaleTo",
this);
1893 (
"Scales (x,y,z) by corresponding components of this factor.");
1895 (
"x-scale-factor",
"y-scale-factor",
"z-scale-factor",
1896 omitable=
true, currentAsDefault=
true);
1912 return currentValue;
1922 if (!currentViewer) {
1925 "ERROR: G4VisCommandsViewerScale::SetNewValue: no current viewer."
1954 fpCommand -> SetGuidance (
"Selects viewer.");
1956 (
"Specify viewer by name. \"/vis/viewer/list\" to see possible viewers.");
1957 fpCommand -> SetParameterName (
"viewer-name", omitable =
false);
1977 G4cerr <<
"ERROR: Viewer \"" << selectName <<
"\"";
1978 G4cerr <<
" not found - \"/vis/viewer/list\""
1979 "\n to see possibilities."
1987 G4cout <<
"WARNING: Viewer \"" << viewer -> GetName () <<
"\""
1988 <<
" already selected." <<
G4endl;
2002 G4bool omitable, currentAsDefault;
2005 (
"Triggers graphical database post-processing for viewers"
2006 "\nusing that technique.");
2008 (
"For such viewers the view only becomes visible with this command."
2009 "\nBy default, acts on current viewer. \"/vis/viewer/list\""
2010 "\nto see possible viewers. Viewer becomes current.");
2011 fpCommand -> SetParameterName (
"viewer-name",
2013 currentAsDefault =
true);
2023 return viewer -> GetName ();
2040 "WARNING: command \"/vis/viewer/update\" could not be applied: no current viewer."
2047 if (!sceneHandler) {
2049 G4cerr <<
"ERROR: Viewer \"" << updateName <<
"\"" <<
2050 " has no scene handler - report serious bug."
2059 G4cout <<
"NOTE: SceneHandler \"" << sceneHandler->
GetName()
2060 <<
"\", to which viewer \"" << updateName <<
"\"" <<
2061 "\n is attached, has no scene - \"/vis/scene/create\" and"
2062 " \"/vis/sceneHandler/attach\""
2063 "\n (or use compound command \"/vis/drawVolume\")."
2070 G4cout <<
"Viewer \"" << viewer -> GetName () <<
"\"";
2073 viewer -> ShowView ();
2075 sceneHandler -> SetMarkForClearingTransientStore(
true);
2081 fZoomMultiplier (1.),
2084 G4bool omitable, currentAsDefault;
2087 (
"/vis/viewer/zoom",
this);
2090 (
"Multiplies current magnification by this factor.");
2093 currentAsDefault=
true);
2096 (
"/vis/viewer/zoomTo",
this);
2099 (
"Magnifies standard magnification by this factor.");
2102 currentAsDefault=
true);
2118 return currentValue;
2128 if (!currentViewer) {
2131 "ERROR: G4VisCommandsViewerZoom::SetNewValue: no current viewer."
const G4String & GetName() const
const std::vector< Model > & GetRunDurationModelList() const
static G4double ValueOf(const char *unitName)
void ClearCutawayPlanes()
G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4VisCommandViewerClearTransients()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4UIcmdWithAString * fpCommand
void AddCutawayPlane(const G4Plane3D &cutawayPlane)
const G4String & GetNickname() const
virtual void FinishView()
virtual ~G4VisCommandViewerFlush()
virtual ~G4VisCommandViewerZoom()
CLHEP::Hep3Vector G4ThreeVector
G4UIcmdWithAString * fpCommand
G4String GetCurrentValue(G4UIcommand *command)
void SetFieldHalfAngle(G4double fieldHalfAngle)
G4String GetCurrentValue(G4UIcommand *command)
G4double fPanIncrementRight
void ResetTransientsDrawnFlags()
G4VisCommandViewerFlush()
virtual ~G4VisCommandViewerScale()
G4String GetCurrentValue(G4UIcommand *command)
G4UIcommand * fpCommandPanTo
void SetNewValue(G4UIcommand *command, G4String newValue)
G4UIcmdWithAString * fpCommand
G4String GetCurrentValue(G4UIcommand *command)
static Verbosity GetVerbosityValue(const G4String &)
static G4String ConvertToString(G4double x, G4double y, const char *unitName)
void SetCBDParameters(const std::vector< G4double > &)
void IncrementDolly(G4double dollyIncrement)
const G4Point3D & GetCurrentTargetPoint() const
G4int ApplyCommand(const char *aCommand)
G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4VisCommandViewerPan()
void SetScaleFactor(const G4Vector3D &scaleFactor)
G4UIcmdWithAString * fpCommand
G4VisCommandViewerClearCutawayPlanes()
void SetNewValue(G4UIcommand *command, G4String newValue)
void ChangeCutawayPlane(size_t index, const G4Plane3D &cutawayPlane)
void SetLightsMoveWithCamera(G4bool moves)
static constexpr double millisecond
G4VisCommandViewerClearTransients()
void SetViewParameters(G4VViewer *, const G4ViewParameters &)
G4VisCommandViewerColourByDensity()
const G4Vector3D & GetUpVector() const
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandViewerInterpolate()
virtual ~G4VisCommandViewerDolly()
void SetViewParameters(const G4ViewParameters &vp)
virtual ~G4VVisCommandViewer()
virtual void ClearTransientStore()
void SetNewValue(G4UIcommand *command, G4String newValue)
static G4double GetNewDoubleValue(const char *paramString)
const G4ViewParameters & GetViewParameters() const
static G4ViewParameters * CatmullRomCubicSplineInterpolation(const std::vector< G4ViewParameters > &views, G4int nInterpolationPoints=50)
G4String GetCurrentValue(G4UIcommand *command)
virtual void DrawView()=0
G4String CameraAndLightingCommands(const G4Point3D standardTargetPoint) const
G4UIcmdWithAString * fpCommand
void SetGuidance(const char *theGuidance)
void SetVerboseLevel(G4int val)
G4VisCommandViewerSelect()
static G4UImanager * GetUIpointer()
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
void SetLightpointDirection(const G4Vector3D &lightpointDirection)
void SetVerboseLevel(G4int)
G4String GetCurrentValue(G4UIcommand *command)
void UpdateVisManagerScene(const G4String &sceneName="")
const std::vector< G4double > & GetCBDParameters() const
const G4Vector3D & GetScaleFactor() const
G4VisCommandViewerUpdate()
virtual ~G4VisCommandViewerClearVisAttributesModifiers()
void SetParameter(G4UIparameter *const newParameter)
G4String GetCurrentValue(G4UIcommand *command)
G4double GetZoomFactor() const
G4UIcmdWithoutParameter * fpCommand
const G4Vector3D & GetLightpointDirection() const
virtual ~G4VisCommandViewerSave()
const G4Vector3D & GetViewpointDirection() const
void SetDefaultValue(const char *theDefaultValue)
static G4double GetNewDoubleValue(const char *paramString)
G4bool GetLightsMoveWithCamera() const
G4VSceneHandler * GetSceneHandler() const
G4String TimeWindowCommands() const
const G4String & GetXGeometryString() const
G4VisCommandViewerRefresh()
G4UIcmdWithAString * fpCommand
G4String TouchableCommands() const
virtual ~G4VisCommandViewerCopyViewFrom()
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandViewerClone()
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandViewerList()
void SetUpVector(const G4Vector3D &upVector)
const G4String & GetName() const
G4String GetCurrentValue(G4UIcommand *command)
G4int GetCBDAlgorithmNumber() const
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VViewer * GetCurrentViewer() const
void SetPan(G4double right, G4double up)
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandViewerAddCutawayPlane()
HepGeom::Normal3D< G4double > G4Normal3D
void IncrementPan(G4double right, G4double up)
G4UIcmdWithADoubleAndUnit * fpCommandDolly
G4double GetDolly() const
G4String strip(G4int strip_Type=trailing, char c=' ')
G4VisCommandViewerChangeCutawayPlane()
static Verbosity GetVerbosity()
virtual void ClearView()=0
G4UIcmdWithoutParameter * fpCommand
G4double GetFieldHalfAngle() const
void SetNewValue(G4UIcommand *command, G4String newValue)
HepGeom::Plane3D< G4double > G4Plane3D
const G4String & GetName() const
void SetNewValue(G4UIcommand *command, G4String newValue)
G4bool contains(const std::string &) const
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandViewerClone()
G4GLOB_DLL std::ostream G4cerr
virtual ~G4VisCommandViewerClear()
G4String GetCurrentValue(G4UIcommand *command)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4bool IsAutoRefresh() const
void SetCurrentTargetPoint(const G4Point3D ¤tTargetPoint)
static G4String ConvertToString(G4bool boolVal)
void RefreshIfRequired(G4VViewer *)
G4VisCommandViewerCreate()
virtual ~G4VisCommandViewerRefresh()
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandViewerClear()
const G4Planes & GetCutawayPlanes() const
G4UIcmdWithAString * fpCommand
void SetNewValue(G4UIcommand *command, G4String newValue)
void MultiplyZoomFactor(G4double zoomFactorMultiplier)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VGraphicsSystem * GetGraphicsSystem() const
G4bool ProvideValueOfUnit(const G4String &where, const G4String &unit, const G4String &category, G4double &value)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4UIcmdWithADoubleAndUnit * fpCommandDollyTo
G4UIcmdWithAString * fpCommand
G4UIcmdWithAString * fpCommand
G4VisCommandViewerDolly()
G4String GetCurrentValue(G4UIcommand *command)
void SetCBDAlgorithmNumber(G4int)
G4int GetVerboseLevel() const
virtual ~G4VisCommandViewerChangeCutawayPlane()
G4String GetCurrentValue(G4UIcommand *command)
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
G4String SceneModifyingCommands() const
G4String GetCurrentValue(G4UIcommand *command)
G4GLOB_DLL std::ostream G4cout
void SetDolly(G4double dolly)
G4UIcmdWithADouble * fpCommandZoom
virtual ~G4VisCommandViewerAddCutawayPlane()
virtual ~G4VisCommandViewerColourByDensity()
virtual const std::vector< G4ModelingParameters::VisAttributesModifier > * GetPrivateVisAttributesModifiers() const
void ClearVisAttributesModifiers()
G4UIcmdWith3Vector * fpCommandScale
void MultiplyScaleFactor(const G4Vector3D &scaleFactorMultiplier)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
const G4Point3D & GetStandardTargetPoint() const
G4UIcmdWith3Vector * fpCommandScaleTo
static G4double ConvertToDimensionedDouble(const char *st)
virtual ~G4VisCommandViewerInterpolate()
G4UIcmdWithADouble * fpCommandZoomTo
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetZoomFactor(G4double zoomFactor)
static G4VisManager * fpVisManager
virtual ~G4VisCommandViewerCreate()
virtual ~G4VisCommandViewerUpdate()
HepGeom::Point3D< G4double > G4Point3D
G4Vector3D fScaleMultiplier
G4VisCommandViewerScale()
G4String GetCurrentValue(G4UIcommand *command)
void SetAutoRefresh(G4bool)
G4String DrawingStyleCommands() const
std::vector< G4Plane3D > G4Planes
virtual ~G4VisCommandViewerSelect()
G4String GetCurrentValue(G4UIcommand *command)
void SetViewpointDirection(const G4Vector3D &viewpointDirection)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4Scene * GetScene() const
G4VisCommandViewerCopyViewFrom()
virtual ~G4VisCommandViewerClearCutawayPlanes()
G4VisCommandViewerReset()
G4VisCommandViewerClearVisAttributesModifiers()
G4UIcommand * fpCommandPan
static G4bool ConvertToDoublePair(const G4String ¶mString, G4double &xval, G4double &yval)
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandViewerReset()
void SetMarkForClearingTransientStore(G4bool)
G4UIcmdWithAString * fpCommand
G4VisCommandViewerRebuild()
virtual ~G4VisCommandViewerRebuild()