1306 {
1307
1309
1311 if (!currentViewer) {
1314 "ERROR: G4VisCommandViewerInterpolate::SetNewValue: no current viewer."
1316 }
1317 return;
1318 }
1319
1321 G4int nInterpolationPoints;
1325
1326 std::istringstream iss (newValue);
1327 iss
1328 >> pattern
1329 >> nInterpolationPoints
1330 >> waitTimePerPointString
1331 >> timeUnit
1332 >> exportString;
1333 G4String waitTimePerPointDimString(waitTimePerPointString +
' ' + timeUnit);
1336 G4int waitTimePerPointmilliseconds = waitTimePerPoint/millisecond;
1337 if (waitTimePerPointmilliseconds < 0) waitTimePerPointmilliseconds = 0;
1338
1340
1341
1343
1344
1347
1348
1351
1352
1353
1357
1358 const G4int safety = 99;
1359 G4int safetyCount = 0;
1360 G4fs::path pathPattern = pattern.c_str();
1361
1362
1364 (pathPattern.parent_path().string().length() ?
1365 pathPattern.parent_path().string() :
1366 std::string("./"));
1367 G4fs::path parentPath = parentPathString.c_str();
1368
1369
1370 std::set<G4fs::path> paths;
1371
1372 if (G4fs::is_directory(pathPattern)) {
1373
1374
1375 for (const auto& path: G4fs::directory_iterator(pathPattern)) {
1376 if (safetyCount++ >= safety) break;
1377 paths.insert(path);
1378 }
1379
1380 } else {
1381
1382
1383
1384
1386 for (
G4int i = 0; i < (
G4int)pattern.length(); ++i) {
1387 if (pattern[i] == '.') {
1388 regexp_pattern += "\\.";
1389 } else if (pattern[i] == '*') {
1390 regexp_pattern += ".*";
1391 } else if (pattern[i] == '?') {
1392 regexp_pattern += "(.{1,1})";
1393 } else {
1394 regexp_pattern += pattern[i];
1395 }
1396 }
1397 std::regex regexp(regexp_pattern, std::regex_constants::basic | std::regex_constants::icase);
1398
1399 for (const auto& path: G4fs::directory_iterator(parentPath)) {
1400 const auto& pathname = path.path().relative_path().string();
1401 if (std::regex_match(pathname, regexp)) {
1402 if (safetyCount++ >= safety) break;
1403 paths.insert(path);
1404 }
1405 }
1406 }
1407
1408 if (safetyCount > safety) {
1411 "/vis/viewer/interpolate:"
1412 "\n the number of way points has been limited to the maximum currently allowed: "
1414 }
1415 }
1416
1417
1418 std::vector<G4ViewParameters> viewVector;
1419 for (const auto& path: paths) {
1420 uiManager->
ApplyCommand(
"/control/execute " + path.relative_path().string());
1422
1424 viewVector.push_back(vp);
1425 }
1426
1428 (currentViewer,viewVector,
1429 nInterpolationPoints,waitTimePerPointmilliseconds,exportString);
1430
1431
1434
1435
1439 G4cout <<
"Viewer \"" << currentViewer -> GetName () <<
"\""
1440 <<
" restored." <<
G4endl;
1441 }
1442}
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)