47 #ifdef G4VIS_USE_STD11
67 RefreshIfRequired(viewer);
74 if (sceneHandler && sceneHandler->
GetScene()) {
80 G4cout <<
"Issue /vis/viewer/refresh or flush to see effect."
91 fpCommand =
new G4UIcommand (
"/vis/viewer/addCutawayPlane",
this);
92 fpCommand -> SetGuidance
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];
171 fpCommand =
new G4UIcommand (
"/vis/viewer/changeCutawayPlane",
this);
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.");
257 fpCommand -> SetGuidance
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.");
344 fpCommand -> SetGuidance
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;
432 fpCommand =
new G4UIcommand (
"/vis/viewer/clone",
this);
433 fpCommand -> SetGuidance (
"Clones viewer.");
434 fpCommand -> SetGuidance
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);
441 fpCommand -> SetParameter (parameter);
442 parameter =
new G4UIparameter (
"clone-name",
's', omitable =
true);
443 parameter -> SetDefaultValue (
"none");
444 fpCommand -> SetParameter (parameter);
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;
567 fpCommand -> SetGuidance
568 (
"Copy the camera-specific parameters from the specified viewer.");
569 fpCommand -> SetGuidance
570 (
"Note: To copy scene modifications - style, etc. - please use"
571 "\n\"/vis/viewer/set/all\"");
572 fpCommand -> SetParameterName (
"from-viewer-name", omitable =
false);
588 if (!currentViewer) {
591 "ERROR: G4VisCommandsViewerCopyViewFrom::SetNewValue: no current viewer."
597 const G4String& fromViewerName = newValue;
601 G4cerr <<
"ERROR: Viewer \"" << fromViewerName
602 <<
"\" not found - \"/vis/viewer/list\" to see possibilities."
608 if (fromViewer == currentViewer) {
611 "WARNING: G4VisCommandsViewerSet::SetNewValue:"
612 "\n from-viewer and current viewer are identical."
633 G4cout <<
"Camera parameters of viewer \"" << currentViewer->
GetName()
634 <<
"\"\n set to those of viewer \"" << fromViewer->
GetName()
644 fpCommand =
new G4UIcommand (
"/vis/viewer/create",
this);
645 fpCommand -> SetGuidance
646 (
"Creates a viewer for the specified scene handler.");
647 fpCommand -> SetGuidance
648 (
"Default scene handler is the current scene handler. Invents a name"
649 "\nif not supplied. (Note: the system adds information to the name"
650 "\nfor identification - only the characters up to the first blank are"
651 "\nused for removing, selecting, etc.) This scene handler and viewer"
652 "\nbecome current.");
654 parameter =
new G4UIparameter (
"scene-handler",
's', omitable =
true);
655 parameter -> SetCurrentAsDefault (
true);
656 fpCommand -> SetParameter (parameter);
657 parameter =
new G4UIparameter (
"viewer-name",
's', omitable =
true);
658 parameter -> SetCurrentAsDefault (
true);
659 fpCommand -> SetParameter (parameter);
660 parameter =
new G4UIparameter (
"window-size-hint",
's', omitable =
true);
662 (
"integer (pixels) for square window placed by window manager or"
663 " X-Windows-type geometry string, e.g. 600x600-100+100");
665 fpCommand -> SetParameter (parameter);
672 G4String G4VisCommandViewerCreate::NextName () {
673 std::ostringstream oss;
675 oss <<
"viewer-" << fId <<
" (";
677 oss << sceneHandler -> GetGraphicsSystem () -> GetName ();
680 oss <<
"no_scene_handlers";
690 if (currentSceneHandler) {
691 currentValue = currentSceneHandler -> GetName ();
694 currentValue =
"none";
698 currentValue += NextName ();
701 currentValue +=
" 600";
712 std::istringstream is (newValue);
713 is >> sceneHandlerName;
718 while (is.get(c) && c ==
' '){}
720 while (is.get(c) && c !=
'"') {newName +=
c;}
724 while (is.get(c) && c !=
' ') {newName +=
c;}
730 is >> windowSizeHintString;
734 G4int nHandlers = sceneHandlerList.size ();
735 if (nHandlers <= 0) {
738 "ERROR: G4VisCommandViewerCreate::SetNewValue: no scene handlers."
739 "\n Create a scene handler with \"/vis/sceneHandler/create\""
746 for (iHandler = 0; iHandler < nHandlers; iHandler++) {
747 if (sceneHandlerList [iHandler] -> GetName () == sceneHandlerName)
break;
750 if (iHandler < 0 || iHandler >= nHandlers) {
754 G4cout <<
"G4VisCommandViewerCreate::SetNewValue:"
755 " invalid scene handler specified."
764 if (sceneHandler !=
fpVisManager -> GetCurrentSceneHandler ()) {
773 if (newName == nextName) fId++;
776 for (
G4int ih = 0; ih < nHandlers; ih++) {
778 const G4ViewerList& viewerList = sh -> GetViewerList ();
779 for (
size_t iViewer = 0; iViewer < viewerList.size (); iViewer++) {
780 if (viewerList [iViewer] -> GetShortName () == newShortName ) {
782 G4cerr <<
"ERROR: Viewer \"" << newShortName <<
"\" already exists."
794 fpVisManager -> CreateViewer (newName,windowSizeHintString);
797 if (newViewer && newViewer -> GetName () == newName) {
799 G4cout <<
"New viewer \"" << newName <<
"\" created." <<
G4endl;
805 G4cerr <<
"ERROR: New viewer doesn\'t match!!! Curious!!" <<
G4endl;
818 G4cout <<
"Issue /vis/viewer/refresh or flush to see effect."
828 fDollyIncrement (0.),
831 G4bool omitable, currentAsDefault;
834 (
"/vis/viewer/dolly",
this);
835 fpCommandDolly -> SetGuidance
836 (
"Incremental dolly.");
837 fpCommandDolly -> SetGuidance
838 (
"Moves the camera incrementally towards target point.");
839 fpCommandDolly -> SetParameterName(
"increment",
841 currentAsDefault=
true);
842 fpCommandDolly -> SetDefaultUnit(
"m");
845 (
"/vis/viewer/dollyTo",
this);
846 fpCommandDollyTo -> SetGuidance
847 (
"Dolly to specific coordinate.");
848 fpCommandDollyTo -> SetGuidance
849 (
"Places the camera towards target point relative to standard camera point.");
850 fpCommandDollyTo -> SetParameterName(
"distance",
852 currentAsDefault=
true);
853 fpCommandDollyTo -> SetDefaultUnit(
"m");
857 delete fpCommandDolly;
858 delete fpCommandDollyTo;
863 if (command == fpCommandDolly) {
866 else if (command == fpCommandDollyTo) {
879 if (!currentViewer) {
882 "ERROR: G4VisCommandsViewerDolly::SetNewValue: no current viewer."
890 if (command == fpCommandDolly) {
894 else if (command == fpCommandDollyTo) {
909 G4bool omitable, currentAsDefault;
911 fpCommand -> SetGuidance
912 (
"Compound command: \"/vis/viewer/refresh\" + \"/vis/viewer/update\".");
913 fpCommand -> SetGuidance
914 (
"Useful for refreshing and initiating post-processing for graphics"
915 "\nsystems which need post-processing. By default, acts on current"
916 "\nviewer. \"/vis/viewer/list\" to see possible viewers. Viewer"
917 "\nbecomes current.");
918 fpCommand -> SetParameterName (
"viewer-name",
920 currentAsDefault =
true);
929 G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
930 return viewer ? viewer -> GetName () :
G4String(
"none");
941 G4cerr <<
"ERROR: Viewer \"" << flushName <<
"\"" <<
942 " not found - \"/vis/viewer/list\"\n to see possibilities."
958 G4cout <<
"Viewer \"" << viewer -> GetName () <<
"\""
967 fpCommand =
new G4UIcommand (
"/vis/viewer/interpolate",
this);
968 fpCommand -> SetGuidance
969 (
"Interpolate views defined by the first argument, which can contain "
970 "Unix-shell-style pattern matching characters such as '*', '?' and '[' "
971 "- see \"man sh\" and look for \"Pattern Matching\". The contents "
972 "of each file are assumed to be \"/vis/viewer\" commands "
973 "that specify a particular view. The files are processed in alphanumeric "
974 "order of filename. The files may be written by hand or produced by the "
975 "\"/vis/viewer/save\" command.");
976 fpCommand -> SetGuidance
977 (
"The default is to search the working directory for files with a .g4view "
978 "extension. Another procedure is to assemble view files in a subdirectory, "
979 "e.g., \"myviews\"; then they can be interpolated with\n"
980 "\"/vis/viewer/interpolate myviews/*\".");
981 fpCommand -> SetGuidance
982 (
"To export interpolated views to file for a future possible movie, "
983 "write \"export\" as 5th parameter (OpenGL only).");
985 parameter =
new G4UIparameter(
"pattern",
's', omitable =
true);
986 parameter -> SetGuidance(
"Pattern that defines the view files.");
987 parameter -> SetDefaultValue(
"*.g4view");
988 fpCommand -> SetParameter(parameter);
989 parameter =
new G4UIparameter(
"no-of-points",
'i', omitable =
true);
990 parameter -> SetGuidance (
"Number of interpolation points per interval.");
991 parameter -> SetDefaultValue(50);
992 fpCommand -> SetParameter(parameter);
993 parameter =
new G4UIparameter(
"wait-time",
's', omitable =
true);
994 parameter -> SetGuidance(
"Wait time per interpolated point");
995 parameter -> SetDefaultValue(
"20.");
996 fpCommand -> SetParameter(parameter);
997 parameter =
new G4UIparameter(
"time-unit",
's', omitable =
true);
998 parameter -> SetDefaultValue(
"millisecond");
999 fpCommand -> SetParameter (parameter);
1000 parameter =
new G4UIparameter(
"export",
's', omitable =
true);
1001 parameter -> SetDefaultValue(
"no");
1002 fpCommand -> SetParameter (parameter);
1018 if (!currentViewer) {
1021 "ERROR: G4VisCommandViewerInterpolate::SetNewValue: no current viewer."
1028 G4int nInterpolationPoints;
1033 std::istringstream iss (newValue);
1036 >> nInterpolationPoints
1037 >> waitTimePerPointString
1040 G4String waitTimePerPointDimString(waitTimePerPointString +
' ' + timeUnit);
1044 if (waitTimePerPointmilliseconds < 0) waitTimePerPointmilliseconds = 0;
1066 std::vector<G4ViewParameters> viewVector;
1068 const G4int safety = 9999;
1069 G4int safetyCount = 0;
1075 G4String shellCommand =
"echo " + pattern;
1076 FILE *filelist = popen(shellCommand.c_str(),
"r");
1080 <<
"ERROR: G4VisCommandViewerInterpolate::SetNewValue:"
1081 <<
"\n Error obtaining pipe."
1088 const size_t BUFLENGTH = 999999;
1089 char buf[BUFLENGTH];
1090 fgets(buf, BUFLENGTH, filelist);
1091 std::istringstream fileliststream(buf);
1092 while (fileliststream >> pathname
1093 && safetyCount++ < safety) {
1094 uiManager->
ApplyCommand(
"/control/execute " + pathname);
1099 #else // WIN32 (popen is not available in Windows)
1101 std::experimental::filesystem::v1::path filePattern(pattern);
1106 std::string regexp_pattern(
"^" + filePattern.filename().string());
1107 std::string result_pattern =
"";
1109 size_t currentPos = 0;
1111 std::string currentReplacement =
"";
1112 size_t pos1 = regexp_pattern.find(
'.', nextPos);
1113 size_t pos2 = regexp_pattern.find(
'*', nextPos);
1114 size_t pos3 = regexp_pattern.find(
'?', nextPos);
1115 while ((pos1 != std::string::npos) || (pos2 != std::string::npos) || (pos3 != std::string::npos)) {
1117 currentReplacement =
"\\.";
1118 if (pos2 < nextPos) {
1120 currentReplacement =
".*";
1122 if (pos3 < nextPos) {
1124 currentReplacement =
"(.{1,1})";
1126 result_pattern += regexp_pattern.substr(currentPos, nextPos - currentPos) + currentReplacement;
1128 currentPos = nextPos;
1129 pos1 = regexp_pattern.find(
'.', currentPos);
1130 pos2 = regexp_pattern.find(
'*', currentPos);
1131 pos3 = regexp_pattern.find(
'?', currentPos);
1133 result_pattern += regexp_pattern.substr(currentPos);
1137 G4String parentPath(filePattern.parent_path().string().length() ? filePattern.parent_path().string() : std::string(
"./"));
1139 std::regex result_pattern_regex (result_pattern, std::regex_constants::basic | std::regex_constants::icase);
1140 for (
auto iter = std::experimental::filesystem::v1::directory_iterator(parentPath);
1141 iter != std::experimental::filesystem::v1::directory_iterator() && safetyCount++ < safety;
1144 const auto& file = iter->path();
1146 G4String filename(file.filename().string());
1147 if (std::regex_match(filename, result_pattern_regex))
1149 uiManager->
ApplyCommand(
"/control/execute " + filename);
1156 if (safetyCount >= safety) {
1159 "/vis/viewer/interpolate:"
1160 "\n the number of way points exceeds the maximum currently allowed: "
1176 if (exportString ==
"export" &&
1179 #ifdef G4VIS_USE_STD11
1180 if (waitTimePerPointmilliseconds > 0)
1181 std::this_thread::sleep_for(std::chrono::milliseconds(waitTimePerPointmilliseconds));
1183 }
while (safetyCount++ < safety);
1193 G4cout <<
"Viewer \"" << currentViewer -> GetName () <<
"\""
1194 <<
" restored." <<
G4endl;
1202 fpCommand =
new G4UIcommand (
"/vis/viewer/list",
this);
1203 fpCommand -> SetGuidance (
"Lists viewers(s).");
1204 fpCommand -> SetGuidance
1205 (
"See \"/vis/verbose\" for definition of verbosity.");
1209 parameter -> SetDefaultValue (
"all");
1210 fpCommand -> SetParameter (parameter);
1213 parameter -> SetDefaultValue (
"warnings");
1214 fpCommand -> SetParameter (parameter);
1227 std::istringstream is (newValue);
1228 is >> name >> verbosityString;
1235 if (currentViewer) {
1236 currentViewerShortName = currentViewer -> GetShortName ();
1239 currentViewerShortName =
"none";
1244 G4int nHandlers = sceneHandlerList.size ();
1246 G4bool foundCurrent =
false;
1247 for (
int iHandler = 0; iHandler < nHandlers; iHandler++) {
1249 const G4ViewerList& viewerList = sceneHandler -> GetViewerList ();
1251 <<
"Scene handler \"" << sceneHandler -> GetName () <<
"\" ("
1253 const G4Scene* pScene = sceneHandler -> GetScene ();
1255 G4cout <<
", scene \"" << pScene -> GetName () <<
"\"";
1258 G4int nViewers = viewerList.size ();
1259 if (nViewers == 0) {
1260 G4cout <<
"\n No viewers for this scene handler." <<
G4endl;
1263 for (
int iViewer = 0; iViewer < nViewers; iViewer++) {
1264 const G4VViewer* thisViewer = viewerList [iViewer];
1265 G4String thisName = thisViewer -> GetName ();
1266 G4String thisShortName = thisViewer -> GetShortName ();
1267 if (name !=
"all") {
1268 if (thisShortName != shortName)
continue;
1272 if (thisShortName == currentViewerShortName) {
1273 foundCurrent =
true;
1279 G4cout <<
" viewer \"" << thisName <<
"\"";
1281 G4cout <<
"\n " << *thisViewer;
1288 if (!foundCurrent) {
1289 G4cout <<
"No valid current viewer - please create or select one."
1295 if (name !=
"all") {
1296 G4cout <<
" of name \"" << name <<
"\"";
1305 fPanIncrementRight (0.),
1306 fPanIncrementUp (0.),
1313 (
"/vis/viewer/pan",
this);
1314 fpCommandPan -> SetGuidance
1315 (
"Incremental pan.");
1316 fpCommandPan -> SetGuidance
1317 (
"Moves the camera incrementally right and up by these amounts (as seen"
1318 "\nfrom viewpoint direction).");
1320 parameter =
new G4UIparameter(
"right-increment",
'd', omitable =
true);
1321 parameter -> SetCurrentAsDefault (
true);
1322 fpCommandPan -> SetParameter (parameter);
1323 parameter =
new G4UIparameter(
"up-increment",
'd', omitable =
true);
1324 parameter -> SetCurrentAsDefault (
true);
1325 fpCommandPan -> SetParameter (parameter);
1326 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
1327 parameter -> SetDefaultValue (
"m");
1328 fpCommandPan -> SetParameter (parameter);
1331 (
"/vis/viewer/panTo",
this);
1332 fpCommandPanTo -> SetGuidance
1333 (
"Pan to specific coordinate.");
1334 fpCommandPanTo -> SetGuidance
1335 (
"Places the camera in this position right and up relative to standard"
1336 "\ntarget point (as seen from viewpoint direction).");
1337 parameter =
new G4UIparameter(
"right",
'd', omitable =
true);
1338 parameter -> SetCurrentAsDefault (
true);
1339 fpCommandPanTo -> SetParameter (parameter);
1341 parameter -> SetCurrentAsDefault (
true);
1342 fpCommandPanTo -> SetParameter (parameter);
1343 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
1344 parameter -> SetDefaultValue (
"m");
1345 fpCommandPanTo -> SetParameter (parameter);
1349 delete fpCommandPan;
1350 delete fpCommandPanTo;
1355 if (command == fpCommandPan) {
1356 currentValue =
ConvertToString(fPanIncrementRight, fPanIncrementUp,
"m");
1358 else if (command == fpCommandPanTo) {
1361 return currentValue;
1371 if (!currentViewer) {
1374 "ERROR: G4VisCommandsViewerPan::SetNewValue: no current viewer."
1382 if (command == fpCommandPan) {
1386 else if (command == fpCommandPanTo) {
1388 vp.
SetPan(fPanToRight, fPanToUp);
1402 G4bool omitable, currentAsDefault;
1404 fpCommand -> SetGuidance (
"Forces rebuild of graphical database.");
1405 fpCommand -> SetGuidance
1406 (
"By default, acts on current viewer. \"/vis/viewer/list\""
1407 "\nto see possible viewers. Viewer becomes current.");
1408 fpCommand -> SetParameterName (
"viewer-name",
1410 currentAsDefault =
true);
1420 return viewer -> GetName ();
1436 G4cerr <<
"ERROR: Viewer \"" << rebuildName
1437 <<
"\" not found - \"/vis/viewer/list\" to see possibilities."
1444 if (!sceneHandler) {
1446 G4cerr <<
"ERROR: Viewer \"" << viewer->
GetName() <<
"\"" <<
1447 " has no scene handler - report serious bug."
1466 G4bool omitable, currentAsDefault;
1468 fpCommand -> SetGuidance
1469 (
"Refreshes viewer.");
1470 fpCommand -> SetGuidance
1471 (
"By default, acts on current viewer. \"/vis/viewer/list\""
1472 "\nto see possible viewers. Viewer becomes current.");
1473 fpCommand -> SetParameterName (
"viewer-name",
1475 currentAsDefault =
true);
1484 return viewer ? viewer -> GetName () :
G4String(
"none");
1496 G4cerr <<
"ERROR: Viewer \"" << refreshName <<
"\"" <<
1497 " not found - \"/vis/viewer/list\"\n to see possibilities."
1504 if (!sceneHandler) {
1506 G4cerr <<
"ERROR: Viewer \"" << refreshName <<
"\"" <<
1507 " has no scene handler - report serious bug."
1516 G4cout <<
"NOTE: SceneHandler \"" << sceneHandler->
GetName()
1517 <<
"\", to which viewer \"" << refreshName <<
"\"" <<
1518 "\n is attached, has no scene - \"/vis/scene/create\" and"
1519 " \"/vis/sceneHandler/attach\""
1520 "\n (or use compound command \"/vis/drawVolume\")."
1526 G4bool successful = scene -> AddWorldIfEmpty (warn);
1530 "WARNING: Scene is empty. Perhaps no geometry exists."
1531 "\n Try /run/initialize."
1542 G4cout <<
"Refreshing viewer \"" << viewer -> GetName () <<
"\"..."
1545 viewer -> SetView ();
1546 viewer -> ClearView ();
1547 viewer -> DrawView ();
1549 G4cout <<
"Viewer \"" << viewer -> GetName () <<
"\"" <<
" refreshed."
1550 "\n (You might also need \"/vis/viewer/update\".)" <<
G4endl;
1558 G4bool omitable, currentAsDefault;
1560 fpCommand -> SetGuidance (
"Resets viewer.");
1561 fpCommand -> SetGuidance
1562 (
"By default, acts on current viewer. \"/vis/viewer/list\""
1563 "\nto see possible viewers. Viewer becomes current.");
1564 fpCommand -> SetParameterName (
"viewer-name",
1566 currentAsDefault =
true);
1576 return viewer -> GetName ();
1591 G4cerr <<
"ERROR: Viewer \"" << resetName
1592 <<
"\" not found - \"/vis/viewer/list\" to see possibilities."
1607 fpCommand -> SetGuidance
1608 (
"Write commands that define the current view to file.");
1609 fpCommand -> SetGuidance
1610 (
"Read them back into the same or any viewer with \"/control/execute\".");
1611 fpCommand -> SetGuidance
1612 (
"If the filename is omitted the view is saved to a file "
1613 "\"g4_nn.g4view\", where nn is a sequential two-digit number.");
1614 fpCommand -> SetGuidance
1615 (
"If the filename is \"-\", the data are written to G4cout.");
1616 fpCommand -> SetGuidance
1617 (
"If you are wanting to save views for future interpolation a recommended "
1618 "procedure is: save views to \"g4_nn.g4view\", as above, then move the files "
1619 "into a sub-directory, say, \"views\", then interpolate with"
1620 "\"/vis/viewer/interpolate views/\" (note the trailing \'/\').");
1621 fpCommand -> SetParameterName (
"filename", omitable =
true);
1622 fpCommand -> SetDefaultValue (
"");
1654 if (!currentViewer) {
1657 "ERROR: G4VisCommandsViewerSave::SetNewValue: no current viewer."
1664 if (!currentScene) {
1667 "ERROR: G4VisCommandsViewerSave::SetNewValue: no current scene."
1676 const std::vector<G4ModelingParameters::VisAttributesModifier>*
1679 std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator i;
1680 for (i = privateVAMs->begin(); i != privateVAMs->end(); ++i) {
1687 if (newValue.length() == 0) {
1689 const G4int maxNoOfFiles = 100;
1690 static G4int sequenceNumber = 0;
1691 if (sequenceNumber >= maxNoOfFiles) {
1694 <<
"ERROR: G4VisCommandsViewerSave::SetNewValue: Maximum number, "
1696 <<
", of files exceeded."
1701 std::ostringstream oss;
1702 oss << std::setw(2) << std::setfill(
'0') << sequenceNumber++;
1703 filename =
"g4_" + oss.str() +
".g4view";
1706 if (filename ==
"-") {
1708 WriteCommands(
G4cout,vp,stp);
1711 std::ofstream ofs(filename);
1715 "ERROR: G4VisCommandsViewerSave::SetNewValue: Trouble opening file \""
1716 << filename <<
"\"."
1722 WriteCommands(ofs,vp,stp);
1727 G4cout <<
"Viewer \"" << currentViewer -> GetName ()
1728 <<
"\"" <<
" saved to ";
1729 if (filename ==
"-") {
1732 G4cout <<
"file \'" << filename <<
"\"." <<
1733 "\n Read the view back into this or any viewer with"
1734 "\n \"/control/execute " << filename <<
"\" or use"
1735 "\n \"/vis/viewer/interpolate\" if you have several saved files -"
1736 "\n see \"help /vis/viewer/interpolate\" for guidance.";
1748 G4bool omitable, currentAsDefault;
1751 (
"/vis/viewer/scale",
this);
1752 fpCommandScale -> SetGuidance (
"Incremental (non-uniform) scaling.");
1753 fpCommandScale -> SetGuidance
1754 (
"Multiplies components of current scaling by components of this factor."
1755 "\n Scales (x,y,z) by corresponding components of the resulting factor.");
1756 fpCommandScale -> SetGuidance
1758 fpCommandScale -> SetParameterName
1759 (
"x-scale-multiplier",
"y-scale-multiplier",
"z-scale-multiplier",
1760 omitable=
true, currentAsDefault=
true);
1763 (
"/vis/viewer/scaleTo",
this);
1764 fpCommandScaleTo -> SetGuidance (
"Absolute (non-uniform) scaling.");
1765 fpCommandScaleTo -> SetGuidance
1766 (
"Scales (x,y,z) by corresponding components of this factor.");
1767 fpCommandScaleTo -> SetParameterName
1768 (
"x-scale-factor",
"y-scale-factor",
"z-scale-factor",
1769 omitable=
true, currentAsDefault=
true);
1773 delete fpCommandScale;
1774 delete fpCommandScaleTo;
1779 if (command == fpCommandScale) {
1782 else if (command == fpCommandScaleTo) {
1785 return currentValue;
1795 if (!currentViewer) {
1798 "ERROR: G4VisCommandsViewerScale::SetNewValue: no current viewer."
1806 if (command == fpCommandScale) {
1810 else if (command == fpCommandScaleTo) {
1827 fpCommand -> SetGuidance (
"Selects viewer.");
1828 fpCommand -> SetGuidance
1829 (
"Specify viewer by name. \"/vis/viewer/list\" to see possible viewers.");
1830 fpCommand -> SetParameterName (
"viewer-name", omitable =
false);
1850 G4cerr <<
"ERROR: Viewer \"" << selectName <<
"\"";
1851 G4cerr <<
" not found - \"/vis/viewer/list\""
1852 "\n to see possibilities."
1860 G4cout <<
"WARNING: Viewer \"" << viewer -> GetName () <<
"\""
1861 <<
" already selected." <<
G4endl;
1875 G4bool omitable, currentAsDefault;
1877 fpCommand -> SetGuidance
1878 (
"Triggers graphical database post-processing for viewers"
1879 "\nusing that technique.");
1880 fpCommand -> SetGuidance
1881 (
"For such viewers the view only becomes visible with this command."
1882 "\nBy default, acts on current viewer. \"/vis/viewer/list\""
1883 "\nto see possible viewers. Viewer becomes current.");
1884 fpCommand -> SetParameterName (
"viewer-name",
1886 currentAsDefault =
true);
1896 return viewer -> GetName ();
1913 "WARNING: command \"/vis/viewer/update\" could not be applied: no current viewer."
1920 if (!sceneHandler) {
1922 G4cerr <<
"ERROR: Viewer \"" << updateName <<
"\"" <<
1923 " has no scene handler - report serious bug."
1932 G4cout <<
"NOTE: SceneHandler \"" << sceneHandler->
GetName()
1933 <<
"\", to which viewer \"" << updateName <<
"\"" <<
1934 "\n is attached, has no scene - \"/vis/scene/create\" and"
1935 " \"/vis/sceneHandler/attach\""
1936 "\n (or use compound command \"/vis/drawVolume\")."
1943 G4cout <<
"Viewer \"" << viewer -> GetName () <<
"\"";
1946 viewer -> ShowView ();
1948 sceneHandler -> SetMarkForClearingTransientStore(
true);
1954 fZoomMultiplier (1.),
1957 G4bool omitable, currentAsDefault;
1960 (
"/vis/viewer/zoom",
this);
1961 fpCommandZoom -> SetGuidance (
"Incremental zoom.");
1962 fpCommandZoom -> SetGuidance
1963 (
"Multiplies current magnification by this factor.");
1964 fpCommandZoom -> SetParameterName(
"multiplier",
1966 currentAsDefault=
true);
1969 (
"/vis/viewer/zoomTo",
this);
1970 fpCommandZoomTo -> SetGuidance (
"Absolute zoom.");
1971 fpCommandZoomTo -> SetGuidance
1972 (
"Magnifies standard magnification by this factor.");
1973 fpCommandZoomTo -> SetParameterName(
"factor",
1975 currentAsDefault=
true);
1979 delete fpCommandZoom;
1980 delete fpCommandZoomTo;
1985 if (command == fpCommandZoom) {
1988 else if (command == fpCommandZoomTo) {
1991 return currentValue;
2001 if (!currentViewer) {
2004 "ERROR: G4VisCommandsViewerZoom::SetNewValue: no current viewer."
2012 if (command == fpCommandZoom) {
2016 else if (command == fpCommandZoomTo) {
const G4String & GetName() const
G4String GetCurrentValue(G4UIcommand *command)
void SetParameter(G4UIparameter *const newParameter)
G4String TouchableCommands() const
G4String GetCurrentValue(G4UIcommand *command)
G4double GetZoomFactor() const
G4VisCommandViewerClone()
void IncrementPan(G4double right, G4double up)
void ClearCutawayPlanes()
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandViewerAddCutawayPlane()
void AddCutawayPlane(const G4Plane3D &cutawayPlane)
G4VisCommandViewerInterpolate()
G4double GetDolly() const
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetLightpointDirection(const G4Vector3D &lightpointDirection)
void SetPan(G4double right, G4double up)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetScaleFactor(const G4Vector3D &scaleFactor)
CLHEP::Hep3Vector G4ThreeVector
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual void ClearView()=0
G4VisCommandViewerCopyViewFrom()
G4String strip(G4int strip_Type=trailing, char c=' ')
void UpdateVisManagerScene(const G4String &sceneName="")
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandViewerInterpolate()
virtual ~G4VisCommandViewerClearTransients()
void SetVerboseLevel(G4int)
virtual ~G4VisCommandViewerChangeCutawayPlane()
void SetNewValue(G4UIcommand *command, G4String newValue)
G4VisCommandViewerUpdate()
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
void SetUpVector(const G4Vector3D &upVector)
const G4ViewParameters & GetViewParameters() const
virtual ~G4VisCommandViewerClear()
void SetDefaultValue(const char *theDefaultValue)
static G4String ConvertToString(G4bool boolVal)
const G4String & GetName() const
G4String SceneModifyingCommands() const
void SetViewParameters(const G4ViewParameters &vp)
void SetViewParameters(G4VViewer *, const G4ViewParameters &)
virtual ~G4VisCommandViewerFlush()
HepGeom::Point3D< G4double > G4Point3D
const G4Planes & GetCutawayPlanes() const
void SetNewValue(G4UIcommand *command, G4String newValue)
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
static G4double GetNewDoubleValue(const char *paramString)
G4int GetVerboseLevel() const
const G4String & GetName() const
static Verbosity GetVerbosityValue(const G4String &)
static G4double ConvertToDimensionedDouble(const char *st)
void SetVerboseLevel(G4int val)
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetLightsMoveWithCamera(G4bool moves)
void ClearVisAttributesModifiers()
G4String GetCurrentValue(G4UIcommand *command)
const G4Point3D & GetCurrentTargetPoint() const
G4VisCommandViewerClearVisAttributesModifiers()
static G4UImanager * GetUIpointer()
G4VisCommandViewerScale()
virtual ~G4VisCommandViewerClearCutawayPlanes()
const G4Vector3D & GetLightpointDirection() const
const G4String & GetXGeometryString() const
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
const G4Vector3D & GetViewpointDirection() const
G4GLOB_DLL std::ostream G4cout
void SetZoomFactor(G4double zoomFactor)
static G4ThreeVector GetNew3VectorValue(const char *paramString)
void ChangeCutawayPlane(size_t index, const G4Plane3D &cutawayPlane)
G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4VisCommandViewerSelect()
const G4Point3D & GetStandardTargetPoint() const
virtual ~G4VisCommandViewerRebuild()
void SetNewValue(G4UIcommand *command, G4String newValue)
std::vector< G4Plane3D > G4Planes
static G4double GetNewDoubleValue(const char *paramString)
const std::vector< Model > & GetRunDurationModelList() const
virtual ~G4VisCommandViewerUpdate()
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandViewerCreate()
void ResetTransientsDrawnFlags()
void SetCurrentTargetPoint(const G4Point3D ¤tTargetPoint)
void SetDolly(G4double dolly)
G4VGraphicsSystem * GetGraphicsSystem() const
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandViewerRefresh()
void SetFieldHalfAngle(G4double fieldHalfAngle)
G4VisCommandViewerReset()
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
const G4String & GetNickname() const
G4String GetCurrentValue(G4UIcommand *command)
G4String DrawingStyleCommands() const
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandViewerClearVisAttributesModifiers()
G4VisCommandViewerChangeCutawayPlane()
G4bool contains(const std::string &) const
void RefreshIfRequired(G4VViewer *)
void SetAutoRefresh(G4bool)
G4Scene * GetScene() const
void MultiplyZoomFactor(G4double zoomFactorMultiplier)
G4VisCommandViewerRebuild()
virtual ~G4VisCommandViewerDolly()
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
G4VisCommandViewerDolly()
G4VSceneHandler * GetSceneHandler() const
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
void SetNewValue(G4UIcommand *command, G4String newValue)
const G4Vector3D & GetScaleFactor() const
virtual ~G4VisCommandViewerScale()
virtual const std::vector< G4ModelingParameters::VisAttributesModifier > * GetPrivateVisAttributesModifiers() const
static G4String ConvertToString(G4double x, G4double y, const char *unitName)
static G4double ValueOf(const char *unitName)
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandViewerFlush()
virtual ~G4VisCommandViewerList()
virtual ~G4VisCommandViewerClone()
static constexpr double millisecond
static Verbosity GetVerbosity()
G4String GetCurrentValue(G4UIcommand *command)
virtual ~G4VVisCommandViewer()
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
G4VisCommandViewerSelect()
G4VisCommandViewerClear()
HepGeom::Plane3D< G4double > G4Plane3D
G4String CameraAndLightingCommands(const G4Point3D standardTargetPoint) const
G4bool GetLightsMoveWithCamera() const
G4VViewer * GetCurrentViewer() const
G4double GetFieldHalfAngle() const
void SetNewValue(G4UIcommand *command, G4String newValue)
void MultiplyScaleFactor(const G4Vector3D &scaleFactorMultiplier)
virtual ~G4VisCommandViewerCopyViewFrom()
virtual void ClearTransientStore()
virtual ~G4VisCommandViewerSave()
G4VisCommandViewerClearTransients()
void SetGuidance(const char *theGuidance)
static G4ViewParameters * CatmullRomCubicSplineInterpolation(const std::vector< G4ViewParameters > &views, G4int nInterpolationPoints=50)
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
const G4Vector3D & GetUpVector() const
virtual ~G4VisCommandViewerReset()
static void ConvertToDoublePair(const G4String ¶mString, G4double &xval, G4double &yval)
virtual ~G4VisCommandViewerZoom()
G4VisCommandViewerRefresh()
virtual ~G4VisCommandViewerPan()
void SetMarkForClearingTransientStore(G4bool)
G4bool IsAutoRefresh() const
void IncrementDolly(G4double dollyIncrement)
void SetViewpointDirection(const G4Vector3D &viewpointDirection)
G4int ApplyCommand(const char *aCommand)
G4VisCommandViewerClearCutawayPlanes()
G4String GetCurrentValue(G4UIcommand *command)
virtual void FinishView()
G4GLOB_DLL std::ostream G4cerr
G4String GetCurrentValue(G4UIcommand *command)
G4String GetCurrentValue(G4UIcommand *command)
HepGeom::Normal3D< G4double > G4Normal3D
G4VisCommandViewerCreate()
virtual void DrawView()=0
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValue)
static G4VisManager * fpVisManager
void SetNewValue(G4UIcommand *command, G4String newValue)
virtual ~G4VisCommandViewerAddCutawayPlane()