616 {
617
619
621 std::istringstream is (newValue);
622
623
624
625 char c = ' ';
626 while (is.get(c) && c == ' '){}
627 if (c == '"') {
628 while (is.get(c) && c != '"') {originalName += c;}
629 }
630 else {
631 originalName += c;
632 while (is.get(c) && c != ' ') {originalName += c;}
633 }
634 G4StrUtil::strip(originalName, ' ');
635 G4StrUtil::strip(originalName, '"');
636
638 if (!originalViewer) {
640 G4warn <<
"ERROR: Viewer \"" << originalName
641 << "\" not found - \"/vis/viewer/list\" to see possibilities."
643 }
644 return;
645 }
646 originalName = originalViewer->
GetName();
647
648 while (is.get(c) && c == ' '){}
649 if (c == '"') {
650 while (is.get(c) && c != '"') {cloneName += c;}
651 }
652 else {
653 cloneName += c;
654 while (is.get(c) && c != ' ') {cloneName += c;}
655 }
656 G4StrUtil::strip(cloneName, ' ');
657 G4StrUtil::strip(cloneName, '"');
658
659 G4bool errorWhileNaming =
false;
660 if (cloneName == "none") {
662 do {
663 cloneName = originalName;
664 std::ostringstream oss;
665 oss << '-' << subID++;
666 G4String::size_type lastDashPosition, nextSpacePosition;
667 if ((lastDashPosition = cloneName.rfind('-')) != G4String::npos &&
668 (nextSpacePosition = cloneName.find(" ", lastDashPosition)) !=
669 G4String::npos) {
670 cloneName.insert(nextSpacePosition, oss.str());
671 } else {
672 G4String::size_type spacePosition = cloneName.find(' ');
673 if (spacePosition != G4String::npos)
674 cloneName.insert(spacePosition, oss.str());
675 else
676 errorWhileNaming = true;
677 }
678 }
while (!errorWhileNaming &&
fpVisManager -> GetViewer (cloneName));
679 }
680
681 if (errorWhileNaming) {
683 G4warn <<
"ERROR: While naming clone viewer \"" << cloneName
684 << "\"."
686 }
687 return;
688 }
689
692 G4warn <<
"ERROR: Putative clone viewer \"" << cloneName
693 << "\" already exists."
695 }
696 return;
697 }
698
701
705 (
G4String(
"/vis/viewer/create ! \"" + cloneName +
"\" " + windowSizeHint));
707
709 G4cout <<
"Viewer \"" << originalName <<
"\" cloned." <<
G4endl;
710 G4cout <<
"Clone \"" << cloneName <<
"\" now current." <<
G4endl;
711 }
712}
G4GLOB_DLL std::ostream G4cout
G4int ApplyCommand(const char *aCommand)
static G4UImanager * GetUIpointer()
const G4String & GetName() const
const G4ViewParameters & GetViewParameters() const
const G4String & GetXGeometryString() const
static Verbosity GetVerbosity()