48 #ifdef G4VIS_USE_STD11
68 (
"Add cutaway plane to current viewer.");
71 parameter -> SetDefaultValue (0);
72 parameter -> SetGuidance (
"Coordinate of point on the plane.");
75 parameter -> SetDefaultValue (0);
76 parameter -> SetGuidance (
"Coordinate of point on the plane.");
79 parameter -> SetDefaultValue (0);
80 parameter -> SetGuidance (
"Coordinate of point on the plane.");
83 parameter -> SetDefaultValue (
"m");
84 parameter -> SetGuidance (
"Unit of point on the plane.");
87 parameter -> SetDefaultValue (1);
88 parameter -> SetGuidance (
"Component of plane normal.");
91 parameter -> SetDefaultValue (0);
92 parameter -> SetGuidance (
"Component of plane normal.");
95 parameter -> SetDefaultValue (0);
96 parameter -> SetGuidance (
"Component of plane normal.");
116 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
124 std::istringstream is (newValue);
125 is >> x >> y >> z >> unit >> nx >> ny >> nz;
127 x *= F; y *= F; z *= F;
132 G4cout <<
"Cutaway planes for viewer \"" << viewer->
GetName() <<
"\" now:";
134 for (
size_t i = 0; i < cutaways.size(); ++i)
135 G4cout <<
"\n " << i <<
": " << cutaways[i];
148 (
"Centre and zoom in on the given physical volume.");
150 (
"The names of all volumes in all worlds are matched against pv-name. If"
151 "\ncopy-no is supplied, it matches the copy number too. If pv-name is of the"
152 "\nform \"/regexp/\", where regexp is a regular expression (see C++ regex),"
153 "\nthe match uses the usual rules of regular expression matching."
154 "\nOtherwise an exact match is required."
155 "\nFor example, \"/Shap/\" matches \"Shape1\" and \"Shape2\".");
157 (
"It may help to see a textual representation of the geometry hierarchy of"
158 "\nthe worlds. Try \"/vis/drawTree [worlds]\" or one of the driver/browser"
159 "\ncombinations that have the required functionality, e.g., HepRepFile.");
161 (
"If there are more than one matching physical volumes they will all be"
162 "\nincluded. If this is not what you want, and what you want is to centre on a"
163 "\nparticular touchable, then select the touchable (\"/vis/set/touchable\") and"
164 "\nuse \"/vis/touchable/centreOn\". (You may need \"/vis/touchable/findPath\".)");
166 parameter =
new G4UIparameter(
"pv-name",
's',omitable =
false);
169 parameter =
new G4UIparameter(
"copy-no",
'i',omitable =
true);
171 parameter->
SetGuidance (
"Copy number. -1 means any or all copy numbers");
197 if (!currentViewer) {
200 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
208 std::istringstream is (newValue);
209 is >> pvName >> copyNo;
214 size_t nWorlds = transportationManager->
GetNoWorlds();
215 std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
216 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
218 for (
size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
224 for (
const auto& findings: searchScene.
GetFindings()) {
225 findingsVector.push_back(findings);
229 if (findingsVector.empty()) {
232 <<
"WARNING: Volume \"" << pvName <<
"\" ";
234 G4cerr <<
"copy number " << copyNo;
242 G4Scene tempScene(
"Centre Scene");
243 for (
const auto& findings: findingsVector) {
245 findings.fpFoundPV->SetCopyNo(findings.fFoundPVCopyNo);
252 findings.fFoundObjectTransformation,
255 findings.fFoundBasePVPath);
260 G4cout <<
"\"" << findings.fpFoundPV->GetName()
261 <<
"\", copy no. " << findings.fFoundPVCopyNo
262 <<
",\n found in searched volume \""
263 << findings.fpSearchPV->GetName()
264 <<
"\" at depth " << findings.fFoundDepth
265 <<
",\n base path: \"" << findings.fFoundBasePVPath
266 <<
",\n has been added to temporary scene \"" << tempScene.
GetName() <<
"\"."
273 delete sceneModel.fpModel;
297 <<
"Viewer \"" << currentViewer->
GetName()
300 G4cout <<
"and zoomed in";
302 G4cout <<
" on physical volume(s) \"" << pvName <<
'\"'
314 fpCommand -> SetGuidance(
"Change cutaway plane.");
317 parameter -> SetGuidance (
"Index of plane: 0, 1, 2.");
320 parameter -> SetDefaultValue (0);
321 parameter -> SetGuidance (
"Coordinate of point on the plane.");
324 parameter -> SetDefaultValue (0);
325 parameter -> SetGuidance (
"Coordinate of point on the plane.");
328 parameter -> SetDefaultValue (0);
329 parameter -> SetGuidance (
"Coordinate of point on the plane.");
332 parameter -> SetDefaultValue (
"m");
333 parameter -> SetGuidance (
"Unit of point on the plane.");
336 parameter -> SetDefaultValue (1);
337 parameter -> SetGuidance (
"Component of plane normal.");
340 parameter -> SetDefaultValue (0);
341 parameter -> SetGuidance (
"Component of plane normal.");
344 parameter -> SetDefaultValue (0);
345 parameter -> SetGuidance (
"Component of plane normal.");
365 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
374 std::istringstream is (newValue);
375 is >> index >> x >> y >> z >> unit >> nx >> ny >> nz;
377 x *= F; y *= F; z *= F;
383 G4cout <<
"Cutaway planes for viewer \"" << viewer->
GetName() <<
"\" now:";
385 for (
size_t i = 0; i < cutaways.size(); ++i)
386 G4cout <<
"\n " << i <<
": " << cutaways[i];
396 G4bool omitable, currentAsDefault;
398 fpCommand -> SetGuidance (
"Clears viewer.");
400 (
"By default, clears current viewer. Specified viewer becomes current."
401 "\n\"/vis/viewer/list\" to see possible viewer names.");
402 fpCommand -> SetParameterName (
"viewer-name",
404 currentAsDefault =
true);
413 return viewer ? viewer -> GetName () :
G4String(
"none");
424 G4cerr <<
"ERROR: Viewer \"" << clearName
425 <<
"\" not found - \"/vis/viewer/list\" to see possibilities."
435 G4cout <<
"Viewer \"" << clearName <<
"\" cleared." <<
G4endl;
444 (
"/vis/viewer/clearCutawayPlanes",
this);
445 fpCommand -> SetGuidance (
"Clear cutaway planes of current viewer.");
464 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
473 G4cout <<
"Cutaway planes for viewer \"" << viewer->
GetName()
474 <<
"\" now cleared." <<
G4endl;
483 G4bool omitable, currentAsDefault;
485 fpCommand -> SetGuidance (
"Clears transients from viewer.");
487 (
"By default, operates on current viewer. Specified viewer becomes current."
488 "\n\"/vis/viewer/list\" to see possible viewer names.");
489 fpCommand -> SetParameterName (
"viewer-name",
491 currentAsDefault =
true);
500 return viewer ? viewer -> GetName () :
G4String(
"none");
511 G4cerr <<
"ERROR: Viewer \"" << clearName
512 <<
"\" not found - \"/vis/viewer/list\" to see possibilities."
523 G4cout <<
"Viewer \"" << clearName <<
"\" cleared of transients."
533 (
"/vis/viewer/clearVisAttributesModifiers",
this);
534 fpCommand -> SetGuidance (
"Clear vis attribute modifiers of current viewer.");
535 fpCommand -> SetGuidance (
"(These are used for touchables, etc.)");
554 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
563 G4cout <<
"Vis attributes modifiers for viewer \"" << viewer->
GetName()
564 <<
"\" now cleared." <<
G4endl;
575 fpCommand -> SetGuidance (
"Clones viewer.");
577 (
"By default, clones current viewer. Clone becomes current."
578 "\nClone name, if not provided, is derived from the original name."
579 "\n\"/vis/viewer/list\" to see possible viewer names.");
581 parameter =
new G4UIparameter (
"original-viewer-name",
's', omitable =
true);
582 parameter -> SetCurrentAsDefault (
true);
584 parameter =
new G4UIparameter (
"clone-name",
's', omitable =
true);
585 parameter -> SetDefaultValue (
"none");
596 return "\"" + originalName +
"\"";
604 std::istringstream is (newValue);
609 while (is.get(c) && c ==
' '){}
611 while (is.get(c) && c !=
'"') {originalName +=
c;}
615 while (is.get(c) && c !=
' ') {originalName +=
c;}
621 if (!originalViewer) {
623 G4cerr <<
"ERROR: Viewer \"" << originalName
624 <<
"\" not found - \"/vis/viewer/list\" to see possibilities."
629 originalName = originalViewer->
GetName();
631 while (is.get(c) && c ==
' '){}
633 while (is.get(c) && c !=
'"') {cloneName +=
c;}
637 while (is.get(c) && c !=
' ') {cloneName +=
c;}
642 G4bool errorWhileNaming =
false;
643 if (cloneName ==
"none") {
646 cloneName = originalName;
647 std::ostringstream oss;
648 oss <<
'-' << subID++;
649 G4String::size_type lastDashPosition, nextSpacePosition;
650 if ((lastDashPosition = cloneName.rfind(
'-')) != G4String::npos &&
651 (nextSpacePosition = cloneName.find(
" ", lastDashPosition)) !=
653 cloneName.insert(nextSpacePosition, oss.str());
655 G4String::size_type spacePosition = cloneName.find(
' ');
656 if (spacePosition != G4String::npos)
657 cloneName.insert(spacePosition, oss.str());
659 errorWhileNaming =
true;
661 }
while (!errorWhileNaming &&
fpVisManager -> GetViewer (cloneName));
664 if (errorWhileNaming) {
666 G4cerr <<
"ERROR: While naming clone viewer \"" << cloneName
675 G4cerr <<
"ERROR: Putative clone viewer \"" << cloneName
676 <<
"\" already exists."
688 if (keepVerbose >= 2 ||
694 (
G4String(
"/vis/viewer/create ! \"" + cloneName +
"\" " + windowSizeHint));
699 G4cout <<
"Viewer \"" << originalName <<
"\" cloned." <<
G4endl;
700 G4cout <<
"Clone \"" << cloneName <<
"\" now current." <<
G4endl;
710 (
"If a volume has no vis attributes, colour it by density.");
712 (
"Provide algorithm number, e.g., \"1\" (or \"0\" to switch off)."
713 "\nThen a unit of density, e.g., \"g/cm3\"."
714 "\nThen parameters for the algorithm assumed to be densities in that unit.");
716 (
"Algorithm 1: Simple algorithm takes 3 parameters: d0, d1 and d2."
717 "\n Volumes with density < d0 are invisible."
718 "\n Volumes with d0 <= density < d1 have colour on range red->green."
719 "\n Volumes with d1 <= density < d2 have colour on range green->blue."
720 "\n Volumes with density > d2 are blue.");
723 parameter -> SetGuidance (
"Algorithm number (or \"0\" to switch off).");
724 parameter -> SetDefaultValue (1);
727 parameter -> SetGuidance (
"Unit of following densities, e.g., \"g/cm3\".");
728 parameter -> SetDefaultValue (
"g/cm3");
731 parameter -> SetGuidance (
"Density parameter 0");
732 parameter -> SetDefaultValue (0.5);
735 parameter -> SetGuidance (
"Density parameter 1");
736 parameter -> SetDefaultValue (3.0);
739 parameter -> SetGuidance (
"Density parameter 2.");
740 parameter -> SetDefaultValue (10.0);
760 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
767 G4int algorithmNumber;
770 std::istringstream is (newValue);
771 is >> algorithmNumber >> unit >> d0 >> d1 >>
d2;
773 if (algorithmNumber < 0 || algorithmNumber > 1) {
776 "ERROR: Unrecognised algorithm number: " << algorithmNumber
783 if (algorithmNumber > 0) {
784 const G4String where =
"G4VisCommandViewerColourByDensity::SetNewValue";
789 d0 *= valueOfUnit; d1 *= valueOfUnit; d2 *= valueOfUnit;
793 "ERROR: Unrecognised or inappropriate unit: " << unit
798 parameters.push_back(d0);
799 parameters.push_back(d1);
800 parameters.push_back(d2);
810 <<
" selected for viewer \"" << viewer->
GetName()
828 (
"Copy the camera-specific parameters from the specified viewer.");
830 (
"Note: To copy ALL view parameters, including scene modifications,"
831 "\nuse \"/vis/viewer/set/all\"");
832 fpCommand -> SetParameterName (
"from-viewer-name", omitable =
false);
848 if (!currentViewer) {
851 "ERROR: G4VisCommandsViewerCopyViewFrom::SetNewValue: no current viewer."
857 const G4String& fromViewerName = newValue;
861 G4cerr <<
"ERROR: Viewer \"" << fromViewerName
862 <<
"\" not found - \"/vis/viewer/list\" to see possibilities."
868 if (fromViewer == currentViewer) {
871 "WARNING: G4VisCommandsViewerSet::SetNewValue:"
872 "\n from-viewer and current viewer are identical."
893 G4cout <<
"Camera parameters of viewer \"" << currentViewer->
GetName()
894 <<
"\"\n set to those of viewer \"" << fromViewer->
GetName()
906 (
"Creates a viewer for the specified scene handler.");
908 (
"Default scene handler is the current scene handler. Invents a name"
909 "\nif not supplied. (Note: the system adds information to the name"
910 "\nfor identification - only the characters up to the first blank are"
911 "\nused for removing, selecting, etc.) This scene handler and viewer"
912 "\nbecome current.");
914 parameter =
new G4UIparameter (
"scene-handler",
's', omitable =
true);
915 parameter -> SetCurrentAsDefault (
true);
917 parameter =
new G4UIparameter (
"viewer-name",
's', omitable =
true);
918 parameter -> SetCurrentAsDefault (
true);
920 parameter =
new G4UIparameter (
"window-size-hint",
's', omitable =
true);
922 (
"integer (pixels) for square window placed by window manager or"
923 " X-Windows-type geometry string, e.g. 600x600-100+100");
933 std::ostringstream oss;
935 oss <<
"viewer-" <<
fId <<
" (";
937 oss << sceneHandler -> GetGraphicsSystem () -> GetName ();
940 oss <<
"no_scene_handlers";
950 if (currentSceneHandler) {
951 currentValue = currentSceneHandler -> GetName ();
954 currentValue =
"none";
961 currentValue +=
" 600";
972 std::istringstream is (newValue);
973 is >> sceneHandlerName;
978 while (is.get(c) && c ==
' '){}
980 while (is.get(c) && c !=
'"') {newName +=
c;}
984 while (is.get(c) && c !=
' ') {newName +=
c;}
990 is >> windowSizeHintString;
994 G4int nHandlers = sceneHandlerList.size ();
995 if (nHandlers <= 0) {
998 "ERROR: G4VisCommandViewerCreate::SetNewValue: no scene handlers."
999 "\n Create a scene handler with \"/vis/sceneHandler/create\""
1006 for (iHandler = 0; iHandler < nHandlers; iHandler++) {
1007 if (sceneHandlerList [iHandler] -> GetName () == sceneHandlerName)
break;
1010 if (iHandler < 0 || iHandler >= nHandlers) {
1014 G4cout <<
"G4VisCommandViewerCreate::SetNewValue:"
1015 " invalid scene handler specified."
1024 if (sceneHandler !=
fpVisManager -> GetCurrentSceneHandler ()) {
1030 if (newName ==
"") {
1033 if (newName == nextName)
fId++;
1036 for (
G4int ih = 0; ih < nHandlers; ih++) {
1038 const G4ViewerList& viewerList = sh -> GetViewerList ();
1039 for (
size_t iViewer = 0; iViewer < viewerList.size (); iViewer++) {
1040 if (viewerList [iViewer] -> GetShortName () == newShortName ) {
1042 G4cerr <<
"ERROR: Viewer \"" << newShortName <<
"\" already exists."
1054 fpVisManager -> CreateViewer (newName,windowSizeHintString);
1057 if (newViewer && newViewer -> GetName () == newName) {
1059 G4cout <<
"New viewer \"" << newName <<
"\" created." <<
G4endl;
1065 G4cerr <<
"ERROR: New viewer doesn\'t match!!! Curious!!" <<
G4endl;
1078 G4cout <<
"Issue /vis/viewer/refresh or flush to see effect."
1088 fDollyIncrement (0.),
1091 G4bool omitable, currentAsDefault;
1094 (
"/vis/viewer/dolly",
this);
1096 (
"Incremental dolly.");
1098 (
"Moves the camera incrementally towards target point.");
1101 currentAsDefault=
true);
1105 (
"/vis/viewer/dollyTo",
this);
1107 (
"Dolly to specific coordinate.");
1109 (
"Places the camera towards target point relative to standard camera point.");
1112 currentAsDefault=
true);
1129 return currentValue;
1139 if (!currentViewer) {
1142 "ERROR: G4VisCommandsViewerDolly::SetNewValue: no current viewer."
1169 G4bool omitable, currentAsDefault;
1172 (
"Compound command: \"/vis/viewer/refresh\" + \"/vis/viewer/update\".");
1174 (
"Useful for refreshing and initiating post-processing for graphics"
1175 "\nsystems which need post-processing. By default, acts on current"
1176 "\nviewer. \"/vis/viewer/list\" to see possible viewers. Viewer"
1177 "\nbecomes current.");
1178 fpCommand -> SetParameterName (
"viewer-name",
1180 currentAsDefault =
true);
1189 G4VViewer* viewer = fpVisManager -> GetCurrentViewer ();
1190 return viewer ? viewer -> GetName () :
G4String(
"none");
1201 G4cerr <<
"ERROR: Viewer \"" << flushName <<
"\"" <<
1202 " not found - \"/vis/viewer/list\"\n to see possibilities."
1210 G4int newVerbose(0);
1218 G4cout <<
"Viewer \"" << viewer -> GetName () <<
"\""
1219 <<
" flushed." <<
G4endl;
1229 (
"Interpolate views defined by the first argument, which can contain "
1230 "Unix-shell-style pattern matching characters such as '*', '?' and '[' "
1231 "- see \"man sh\" and look for \"Pattern Matching\". The contents "
1232 "of each file are assumed to be \"/vis/viewer\" commands "
1233 "that specify a particular view. The files are processed in alphanumeric "
1234 "order of filename. The files may be written by hand or produced by the "
1235 "\"/vis/viewer/save\" command.");
1237 (
"The default is to search the working directory for files with a .g4view "
1238 "extension. Another procedure is to assemble view files in a subdirectory, "
1239 "e.g., \"myviews\"; then they can be interpolated with\n"
1240 "\"/vis/viewer/interpolate myviews/*\".");
1242 (
"To export interpolated views to file for a future possible movie, "
1243 "write \"export\" as 5th parameter (OpenGL only).");
1245 parameter =
new G4UIparameter(
"pattern",
's', omitable =
true);
1246 parameter -> SetGuidance(
"Pattern that defines the view files.");
1247 parameter -> SetDefaultValue(
"*.g4view");
1249 parameter =
new G4UIparameter(
"no-of-points",
'i', omitable =
true);
1250 parameter -> SetGuidance (
"Number of interpolation points per interval.");
1251 parameter -> SetDefaultValue(50);
1253 parameter =
new G4UIparameter(
"wait-time",
's', omitable =
true);
1254 parameter -> SetGuidance(
"Wait time per interpolated point");
1255 parameter -> SetDefaultValue(
"20.");
1257 parameter =
new G4UIparameter(
"time-unit",
's', omitable =
true);
1258 parameter -> SetDefaultValue(
"millisecond");
1260 parameter =
new G4UIparameter(
"export",
's', omitable =
true);
1261 parameter -> SetDefaultValue(
"no");
1278 if (!currentViewer) {
1281 "ERROR: G4VisCommandViewerInterpolate::SetNewValue: no current viewer."
1288 G4int nInterpolationPoints;
1293 std::istringstream iss (newValue);
1296 >> nInterpolationPoints
1297 >> waitTimePerPointString
1300 G4String waitTimePerPointDimString(waitTimePerPointString +
' ' + timeUnit);
1304 if (waitTimePerPointmilliseconds < 0) waitTimePerPointmilliseconds = 0;
1326 std::vector<G4ViewParameters> viewVector;
1328 const G4int safety = 9999;
1329 G4int safetyCount = 0;
1335 G4String shellCommand =
"echo " + pattern;
1336 FILE *filelist = popen(shellCommand.c_str(),
"r");
1340 <<
"ERROR: G4VisCommandViewerInterpolate::SetNewValue:"
1341 <<
"\n Error obtaining pipe."
1348 const size_t BUFLENGTH = 999999;
1349 char buf[BUFLENGTH];
1350 char* result = std::fgets(buf, BUFLENGTH, filelist);
1352 std::istringstream fileliststream(result);
1353 while (fileliststream >> pathname
1354 && safetyCount++ < safety) {
1355 uiManager->
ApplyCommand(
"/control/execute " + pathname);
1359 viewVector.push_back(vp);
1364 #else // WIN32 (popen is not available in Windows)
1366 std::filesystem::path filePattern = pattern.c_str();
1371 std::string regexp_pattern(
"^" + filePattern.filename().string());
1372 std::string result_pattern =
"";
1374 size_t currentPos = 0;
1376 std::string currentReplacement =
"";
1377 size_t pos1 = regexp_pattern.find(
'.', nextPos);
1378 size_t pos2 = regexp_pattern.find(
'*', nextPos);
1379 size_t pos3 = regexp_pattern.find(
'?', nextPos);
1380 while ((pos1 != std::string::npos) || (pos2 != std::string::npos) || (pos3 != std::string::npos)) {
1382 currentReplacement =
"\\.";
1383 if (pos2 < nextPos) {
1385 currentReplacement =
".*";
1387 if (pos3 < nextPos) {
1389 currentReplacement =
"(.{1,1})";
1391 result_pattern += regexp_pattern.substr(currentPos, nextPos - currentPos) + currentReplacement;
1393 currentPos = nextPos;
1394 pos1 = regexp_pattern.find(
'.', currentPos);
1395 pos2 = regexp_pattern.find(
'*', currentPos);
1396 pos3 = regexp_pattern.find(
'?', currentPos);
1398 result_pattern += regexp_pattern.substr(currentPos);
1402 G4String parentPath(filePattern.parent_path().string().length() ? filePattern.parent_path().string() : std::string(
"./"));
1403 std::filesystem::path parentPathPattern = parentPath.c_str();
1405 std::regex result_pattern_regex (result_pattern, std::regex_constants::basic | std::regex_constants::icase);
1406 for (
auto iter = std::filesystem::directory_iterator(parentPathPattern);
1407 iter != std::filesystem::directory_iterator() && safetyCount++ < safety;
1410 const auto&
file = iter->path();
1413 if (std::regex_match(
filename, result_pattern_regex))
1419 viewVector.push_back(vp);
1425 if (safetyCount >= safety) {
1428 "/vis/viewer/interpolate:"
1429 "\n the number of way points exceeds the maximum currently allowed: "
1436 (currentViewer,viewVector,
1437 nInterpolationPoints,waitTimePerPointmilliseconds,exportString);
1447 G4cout <<
"Viewer \"" << currentViewer -> GetName () <<
"\""
1448 <<
" restored." <<
G4endl;
1457 fpCommand -> SetGuidance (
"Lists viewers(s).");
1459 (
"See \"/vis/verbose\" for definition of verbosity.");
1463 parameter -> SetDefaultValue (
"all");
1467 parameter -> SetDefaultValue (
"warnings");
1481 std::istringstream is (newValue);
1482 is >> name >> verbosityString;
1489 if (currentViewer) {
1490 currentViewerShortName = currentViewer -> GetShortName ();
1493 currentViewerShortName =
"none";
1498 G4int nHandlers = sceneHandlerList.size ();
1500 G4bool foundCurrent =
false;
1501 for (
int iHandler = 0; iHandler < nHandlers; iHandler++) {
1503 const G4ViewerList& viewerList = sceneHandler -> GetViewerList ();
1505 <<
"Scene handler \"" << sceneHandler -> GetName () <<
"\" ("
1507 const G4Scene* pScene = sceneHandler -> GetScene ();
1509 G4cout <<
", scene \"" << pScene -> GetName () <<
"\"";
1512 G4int nViewers = viewerList.size ();
1513 if (nViewers == 0) {
1514 G4cout <<
"\n No viewers for this scene handler." <<
G4endl;
1517 for (
int iViewer = 0; iViewer < nViewers; iViewer++) {
1518 const G4VViewer* thisViewer = viewerList [iViewer];
1519 G4String thisName = thisViewer -> GetName ();
1520 G4String thisShortName = thisViewer -> GetShortName ();
1521 if (name !=
"all") {
1522 if (thisShortName != shortName)
continue;
1526 if (thisShortName == currentViewerShortName) {
1527 foundCurrent =
true;
1533 G4cout <<
" viewer \"" << thisName <<
"\"";
1535 G4cout <<
"\n " << *thisViewer;
1542 if (!foundCurrent) {
1543 G4cout <<
"No valid current viewer - please create or select one."
1549 if (name !=
"all") {
1550 G4cout <<
" of name \"" << name <<
"\"";
1559 fPanIncrementRight (0.),
1560 fPanIncrementUp (0.),
1567 (
"/vis/viewer/pan",
this);
1569 (
"Incremental pan.");
1571 (
"Moves the camera incrementally right and up by these amounts (as seen"
1572 "\nfrom viewpoint direction).");
1574 parameter =
new G4UIparameter(
"right-increment",
'd', omitable =
true);
1575 parameter -> SetCurrentAsDefault (
true);
1577 parameter =
new G4UIparameter(
"up-increment",
'd', omitable =
true);
1578 parameter -> SetCurrentAsDefault (
true);
1580 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
1581 parameter -> SetDefaultValue (
"m");
1585 (
"/vis/viewer/panTo",
this);
1587 (
"Pan to specific coordinate.");
1589 (
"Places the camera in this position right and up relative to standard"
1590 "\ntarget point (as seen from viewpoint direction).");
1591 parameter =
new G4UIparameter(
"right",
'd', omitable =
true);
1592 parameter -> SetCurrentAsDefault (
true);
1595 parameter -> SetCurrentAsDefault (
true);
1597 parameter =
new G4UIparameter (
"unit",
's', omitable =
true);
1598 parameter -> SetDefaultValue (
"m");
1615 return currentValue;
1625 if (!currentViewer) {
1628 "ERROR: G4VisCommandsViewerPan::SetNewValue: no current viewer."
1656 G4bool omitable, currentAsDefault;
1658 fpCommand -> SetGuidance (
"Forces rebuild of graphical database.");
1660 (
"By default, acts on current viewer. \"/vis/viewer/list\""
1661 "\nto see possible viewers. Viewer becomes current.");
1662 fpCommand -> SetParameterName (
"viewer-name",
1664 currentAsDefault =
true);
1674 return viewer -> GetName ();
1690 G4cerr <<
"ERROR: Viewer \"" << rebuildName
1691 <<
"\" not found - \"/vis/viewer/list\" to see possibilities."
1698 if (!sceneHandler) {
1700 G4cerr <<
"ERROR: Viewer \"" << viewer->
GetName() <<
"\"" <<
1701 " has no scene handler - report serious bug."
1720 G4bool omitable, currentAsDefault;
1723 (
"Refreshes viewer.");
1725 (
"By default, acts on current viewer. \"/vis/viewer/list\""
1726 "\nto see possible viewers. Viewer becomes current.");
1727 fpCommand -> SetParameterName (
"viewer-name",
1729 currentAsDefault =
true);
1738 return viewer ? viewer -> GetName () :
G4String(
"none");
1750 G4cerr <<
"ERROR: Viewer \"" << refreshName <<
"\"" <<
1751 " not found - \"/vis/viewer/list\"\n to see possibilities."
1758 if (!sceneHandler) {
1760 G4cerr <<
"ERROR: Viewer \"" << refreshName <<
"\"" <<
1761 " has no scene handler - report serious bug."
1770 G4cout <<
"NOTE: SceneHandler \"" << sceneHandler->
GetName()
1771 <<
"\", to which viewer \"" << refreshName <<
"\"" <<
1772 "\n is attached, has no scene - \"/vis/scene/create\" and"
1773 " \"/vis/sceneHandler/attach\""
1774 "\n (or use compound command \"/vis/drawVolume\")."
1780 G4bool successful = scene -> AddWorldIfEmpty (warn);
1784 "WARNING: Scene is empty. Perhaps no geometry exists."
1785 "\n Try /run/initialize."
1796 G4cout <<
"Refreshing viewer \"" << viewer -> GetName () <<
"\"..."
1799 viewer -> SetView ();
1800 viewer -> ClearView ();
1801 viewer -> DrawView ();
1803 G4cout <<
"Viewer \"" << viewer -> GetName () <<
"\"" <<
" refreshed."
1804 "\n (You might also need \"/vis/viewer/update\".)" <<
G4endl;
1812 G4bool omitable, currentAsDefault;
1814 fpCommand -> SetGuidance (
"Resets viewer.");
1816 (
"By default, acts on current viewer. \"/vis/viewer/list\""
1817 "\nto see possible viewers. Viewer becomes current.");
1818 fpCommand -> SetParameterName (
"viewer-name",
1820 currentAsDefault =
true);
1830 return viewer -> GetName ();
1845 G4cerr <<
"ERROR: Viewer \"" << resetName
1846 <<
"\" not found - \"/vis/viewer/list\" to see possibilities."
1862 (
"Write commands that define the current view to file.");
1864 (
"Read them back into the same or any viewer with \"/control/execute\".");
1866 (
"If the filename is omitted the view is saved to a file "
1867 "\"g4_nn.g4view\", where nn is a sequential two-digit number.");
1869 (
"If the filename is \"-\", the data are written to G4cout.");
1871 (
"If you are wanting to save views for future interpolation a recommended "
1872 "procedure is: save views to \"g4_nn.g4view\", as above, then move the files "
1873 "into a sub-directory, say, \"views\", then interpolate with"
1874 "\"/vis/viewer/interpolate views/\" (note the trailing \'/\').");
1875 fpCommand -> SetParameterName (
"filename", omitable =
true);
1909 if (!currentViewer) {
1912 "ERROR: G4VisCommandsViewerSave::SetNewValue: no current viewer."
1919 if (!currentScene) {
1922 "ERROR: G4VisCommandsViewerSave::SetNewValue: no current scene."
1931 const std::vector<G4ModelingParameters::VisAttributesModifier>*
1934 std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator i;
1935 for (i = privateVAMs->begin(); i != privateVAMs->end(); ++i) {
1943 if (newValue.length() == 0) {
1945 const G4int maxNoOfFiles = 100;
1946 static G4int sequenceNumber = 0;
1947 if (sequenceNumber >= maxNoOfFiles) {
1950 <<
"ERROR: G4VisCommandsViewerSave::SetNewValue: Maximum number, "
1952 <<
", of files exceeded."
1957 std::ostringstream oss;
1958 oss << std::setw(2) << std::setfill(
'0') << sequenceNumber++;
1959 filename =
"g4_" + oss.str() +
".g4view";
1962 if (filename ==
"-") {
1964 WriteCommands(
G4cout,vp,stp);
1969 filename +=
".g4view";
1971 std::ofstream ofs(filename);
1975 "ERROR: G4VisCommandsViewerSave::SetNewValue: Trouble opening file \""
1976 << filename <<
"\"."
1982 WriteCommands(ofs,vp,stp);
1987 G4cout <<
"Viewer \"" << currentViewer -> GetName ()
1988 <<
"\"" <<
" saved to ";
1989 if (filename ==
"-") {
1992 G4cout <<
"file \'" << filename <<
"\"." <<
1993 "\n Read the view back into this or any viewer with"
1994 "\n \"/control/execute " << filename <<
"\" or use"
1995 "\n \"/vis/viewer/interpolate\" if you have several saved files -"
1996 "\n see \"help /vis/viewer/interpolate\" for guidance.";
2008 G4bool omitable, currentAsDefault;
2011 (
"/vis/viewer/scale",
this);
2012 fpCommandScale -> SetGuidance (
"Incremental (non-uniform) scaling.");
2014 (
"Multiplies components of current scaling by components of this factor."
2015 "\n Scales (x,y,z) by corresponding components of the resulting factor.");
2019 (
"x-scale-multiplier",
"y-scale-multiplier",
"z-scale-multiplier",
2020 omitable=
true, currentAsDefault=
true);
2023 (
"/vis/viewer/scaleTo",
this);
2026 (
"Scales (x,y,z) by corresponding components of this factor.");
2028 (
"x-scale-factor",
"y-scale-factor",
"z-scale-factor",
2029 omitable=
true, currentAsDefault=
true);
2045 return currentValue;
2055 if (!currentViewer) {
2058 "ERROR: G4VisCommandsViewerScale::SetNewValue: no current viewer."
2087 fpCommand -> SetGuidance (
"Selects viewer.");
2089 (
"Specify viewer by name. \"/vis/viewer/list\" to see possible viewers.");
2090 fpCommand -> SetParameterName (
"viewer-name", omitable =
false);
2110 G4cerr <<
"ERROR: Viewer \"" << selectName <<
"\"";
2111 G4cerr <<
" not found - \"/vis/viewer/list\""
2112 "\n to see possibilities."
2120 G4cout <<
"WARNING: Viewer \"" << viewer -> GetName () <<
"\""
2121 <<
" already selected." <<
G4endl;
2135 G4bool omitable, currentAsDefault;
2138 (
"Triggers graphical database post-processing for viewers"
2139 "\nusing that technique.");
2141 (
"For such viewers the view only becomes visible with this command."
2142 "\nBy default, acts on current viewer. \"/vis/viewer/list\""
2143 "\nto see possible viewers. Viewer becomes current.");
2144 fpCommand -> SetParameterName (
"viewer-name",
2146 currentAsDefault =
true);
2156 return viewer -> GetName ();
2173 "WARNING: command \"/vis/viewer/update\" could not be applied: no current viewer."
2180 if (!sceneHandler) {
2182 G4cerr <<
"ERROR: Viewer \"" << updateName <<
"\"" <<
2183 " has no scene handler - report serious bug."
2192 G4cout <<
"NOTE: SceneHandler \"" << sceneHandler->
GetName()
2193 <<
"\", to which viewer \"" << updateName <<
"\"" <<
2194 "\n is attached, has no scene - \"/vis/scene/create\" and"
2195 " \"/vis/sceneHandler/attach\""
2196 "\n (or use compound command \"/vis/drawVolume\")."
2203 G4cout <<
"Viewer \"" << viewer -> GetName () <<
"\"";
2206 viewer -> ShowView ();
2208 sceneHandler -> SetMarkForClearingTransientStore(
true);
2214 fZoomMultiplier (1.),
2217 G4bool omitable, currentAsDefault;
2220 (
"/vis/viewer/zoom",
this);
2223 (
"Multiplies current magnification by this factor.");
2226 currentAsDefault=
true);
2229 (
"/vis/viewer/zoomTo",
this);
2232 (
"Magnifies standard magnification by this factor.");
2235 currentAsDefault=
true);
2251 return currentValue;
2261 if (!currentViewer) {
2264 "ERROR: G4VisCommandsViewerZoom::SetNewValue: no current viewer."