1322 {
1323
1325
1327 if (!currentViewer) {
1330 "ERROR: G4VisCommandViewerInterpolate::SetNewValue: no current viewer."
1332 }
1333 return;
1334 }
1335
1337 G4int nInterpolationPoints;
1341
1342 std::istringstream iss (newValue);
1343 iss
1344 >> pattern
1345 >> nInterpolationPoints
1346 >> waitTimePerPointString
1347 >> timeUnit
1348 >> exportString;
1349 G4String waitTimePerPointDimString(waitTimePerPointString +
' ' + timeUnit);
1352 G4int waitTimePerPointmilliseconds = waitTimePerPoint/millisecond;
1353 if (waitTimePerPointmilliseconds < 0) waitTimePerPointmilliseconds = 0;
1354
1356
1357
1359
1360
1363
1364
1367
1368
1369
1373
1374 const G4int safety = 99;
1375 G4int safetyCount = 0;
1376 G4fs::path pathPattern = pattern.c_str();
1377
1378
1380 (pathPattern.parent_path().string().length() ?
1381 pathPattern.parent_path().string() :
1382 std::string("./"));
1383 G4fs::path parentPath = parentPathString.c_str();
1384
1385
1386 std::set<G4fs::path> paths;
1387
1388 if (G4fs::is_directory(pathPattern)) {
1389
1390
1391 for (const auto& path: G4fs::directory_iterator(pathPattern)) {
1392 if (safetyCount++ >= safety) break;
1393 paths.insert(path);
1394 }
1395
1396 } else {
1397
1398
1399
1400
1402 for (
G4int i = 0; i < (
G4int)pattern.length(); ++i) {
1403 if (pattern[i] == '.') {
1404 regexp_pattern += "\\.";
1405 } else if (pattern[i] == '*') {
1406 regexp_pattern += ".*";
1407 } else if (pattern[i] == '?') {
1408 regexp_pattern += "(.{1,1})";
1409 } else {
1410 regexp_pattern += pattern[i];
1411 }
1412 }
1413 std::regex regexp(regexp_pattern, std::regex_constants::basic | std::regex_constants::icase);
1414
1415 for (const auto& path: G4fs::directory_iterator(parentPath)) {
1416 const auto& pathname = path.path().relative_path().string();
1417 if (std::regex_match(pathname, regexp)) {
1418 if (safetyCount++ >= safety) break;
1419 paths.insert(path);
1420 }
1421 }
1422 }
1423
1424 if (safetyCount > safety) {
1427 "/vis/viewer/interpolate:"
1428 "\n the number of way points has been limited to the maximum currently allowed: "
1430 }
1431 }
1432
1433
1434 std::vector<G4ViewParameters> viewVector;
1435 for (const auto& path: paths) {
1436 uiManager->
ApplyCommand(
"/control/execute " + path.relative_path().string());
1438
1440 viewVector.push_back(vp);
1441 }
1442
1444 (currentViewer,viewVector,
1445 nInterpolationPoints,waitTimePerPointmilliseconds,exportString);
1446
1447
1450
1451
1455 G4cout <<
"Viewer \"" << currentViewer -> GetName () <<
"\""
1456 <<
" restored." <<
G4endl;
1457 }
1458}
G4GLOB_DLL std::ostream G4cout
static G4double ConvertToDimensionedDouble(const char *st)
G4int ApplyCommand(const char *aCommand)
G4int GetVerboseLevel() const
static G4UImanager * GetUIpointer()
void SetVerboseLevel(G4int val)
const G4ViewParameters & GetViewParameters() const
void SetViewParameters(const G4ViewParameters &vp)
static G4VisManager * fpVisManager
void InterpolateViews(G4VViewer *currentViewer, std::vector< G4ViewParameters > viewVector, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String exportString="")
void SetAutoRefresh(G4bool)
G4bool IsAutoRefresh() const
G4VViewer * GetCurrentViewer() const
static Verbosity GetVerbosity()
void SetVerboseLevel(G4int)