| 662 | } |
| 663 | |
| 664 | void NodeBase::setParent(var parentNode, int indexInParent) |
| 665 | { |
| 666 | checkValid(); |
| 667 | |
| 668 | ScopedValueSetter<bool> svs(isCurrentlyMoved, true); |
| 669 | |
| 670 | auto network = getRootNetwork(); |
| 671 | |
| 672 | // allow passing in the root network |
| 673 | if (parentNode.getObject() == network) |
| 674 | parentNode = var(network->getRootNode()); |
| 675 | |
| 676 | Parameter::ScopedAutomationPreserver sap(this); |
| 677 | |
| 678 | if(getValueTree().getParent().isValid()) |
| 679 | getValueTree().getParent().removeChild(getValueTree(), getUndoManager()); |
| 680 | |
| 681 | if (auto pNode = dynamic_cast<NodeContainer*>(network->get(parentNode).getObject())) |
| 682 | { |
| 683 | pNode->getNodeTree().addChild(getValueTree(), indexInParent, network->getUndoManager()); |
| 684 | } |
| 685 | |
| 686 | else |
| 687 | { |
| 688 | if (parentNode.toString().isNotEmpty()) |
| 689 | reportScriptError("parent node " + parentNode.toString() + " not found."); |
| 690 | |
| 691 | if (auto pNode = dynamic_cast<NodeContainer*>(getParentNode())) |
| 692 | { |
| 693 | pNode->getNodeTree().removeChild(getValueTree(), getUndoManager()); |
| 694 | } |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | var NodeBase::getParameter(var indexOrId) const |
| 699 | { |
no test coverage detected