// Function to process the Copy menu command. void copySelectedObjects() { if (!noAncestorDescendantSelections()) return; for (set<TransformNode*>::const_iterator iter = selections.begin(); iter != selections.end(); ++iter) { TransformNode* target = *iter; if (target == sceneRoot) { sceneRoot = new TransformNode(NULL); sceneRoot->addChild(target); target->setParent(sceneRoot); } TransformNode* parent = target->getParent(); TransformNode* newThing = target->clone(); parent->addChild(newThing); newThing->setParent(parent); target->translate(COPY_OFF_X, COPY_OFF_Y); } glutPostRedisplay(); }
// Function to process the Delete menu command. void deleteSelectedObjects() { if (lastSelected == NULL) return; if (!noAncestorDescendantSelections()) return; for (set<TransformNode*>::const_iterator iter = selections.begin(); iter != selections.end(); ++iter) { TransformNode* target = *iter; if (target == sceneRoot) { sceneRoot = new TransformNode(NULL); sceneRoot->addChild(target); target->setParent(sceneRoot); } target->getParent()->removeChild(target); delete target; } selections.clear(); glutPostRedisplay(); }