コード例 #1
0
ファイル: drawing.cpp プロジェクト: zuchermann/GraphicsClass
// Function to verify that no ancestor of the last selected node 
// is a member of the selection set. 
bool noParentAncestorSelections()
{
	TransformNode* current = lastSelected->getParent();
	while (current)
	{
		if (selections.find(current) != selections.end())
		{
			cerr << "Operation not valid for selection set." << endl;
			cerr << "An ancestor of the last selected item is also selected." << endl;
			return false;
		}
		current = current->getParent();
	}
	return true;
}
コード例 #2
0
ファイル: drawing.cpp プロジェクト: zuchermann/GraphicsClass
// Function to verify that selection set includes no two nodes, one of
// which is an ancestor of the other. 
bool noAncestorDescendantSelections()
{
	for (set<TransformNode*>::const_iterator iter = selections.begin();
	iter != selections.end();
		++iter)
	{
		TransformNode* current = (*iter)->getParent();
		while (current)
		{
			if (selections.find(current) != selections.end())
			{
				cerr << "Operation not valid for selection set." << endl;
				cerr << "An ancestor of a selected item is also selected." << endl;
				return false;
			}
			current = current->getParent();
		}
	}
	return true;
}
コード例 #3
0
ファイル: drawing.cpp プロジェクト: zuchermann/GraphicsClass
// 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();
}
コード例 #4
0
ファイル: drawing.cpp プロジェクト: zuchermann/GraphicsClass
// 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();
}