Esempio n. 1
0
void ChangeNodeHeirarchy::StorePreviousParents()
{
	for (HierarchyTreeNode::HIERARCHYTREENODESIDLIST::iterator iter = items.begin();
		 iter != items.end();
		 ++iter)
	{
		HierarchyTreeNode* node = HierarchyTreeController::Instance()->GetTree().GetNode((*iter));
		if (!node)
		{
			continue;
		}
		
		HierarchyTreeNode* parentNode = node->GetParent();
		if (!parentNode)
		{
			continue;
		}
		
		HierarchyTreeNode::HIERARCHYTREENODEID addAfter = HierarchyTreeNode::HIERARCHYTREENODEID_EMPTY;
		HierarchyTreeNode::HIERARCHYTREENODEID lastId = HierarchyTreeNode::HIERARCHYTREENODEID_EMPTY;
		const HierarchyTreeNode::HIERARCHYTREENODESLIST& childs = parentNode->GetChildNodes();
		for (HierarchyTreeNode::HIERARCHYTREENODESLIST::const_iterator citer = childs.begin();
			 citer != childs.end();
			 ++citer)
		{
			if (node == (*citer))
				addAfter = lastId;
			lastId = (*citer)->GetId();
		}
		
		// The Previous Parents are stored in the "item ID - parent ID" map.
		this->previousParents.insert(std::make_pair(*iter, PreviousState(parentNode->GetId(), addAfter)));
	}
}
Esempio n. 2
0
void ChangeNodeHeirarchy::Execute()
{
	HierarchyTreeNode* targetNode = HierarchyTreeController::Instance()->GetTree().GetNode(targetNodeID);
	HierarchyTreeNode* insertAfterNode = HierarchyTreeController::Instance()->GetTree().GetNode(afterNodeID);
	if (!targetNode)
	{
		// Possible in Redo case if some changes in tree were made.
		return;
	}

	
	for (HierarchyTreeNode::HIERARCHYTREENODESIDLIST::iterator iter = items.begin();
		 iter != items.end();
		 ++iter)
	{
		HierarchyTreeNode* node = HierarchyTreeController::Instance()->GetTree().GetNode((*iter));
		if (node)
		{
			if (dynamic_cast<HierarchyTreeScreenNode*>(node))
			{
				HierarchyTreeNode* sourceNode = node->GetParent();

				if (sourceNode != targetNode)
				{
					HierarchyTreeNode::HIERARCHYTREENODESLIST screens;
					screens.push_back(node);
					HierarchyTreeController::Instance()->DeleteNodesFiles(screens);
				}
			}

			//YZ backlight parent rect
			bool isNodeSelected = false;
			HierarchyTreeControlNode* controlNode = dynamic_cast<HierarchyTreeControlNode*>(node);
			if (controlNode)
			{
				isNodeSelected = HierarchyTreeController::Instance()->IsControlSelected(controlNode);
				HierarchyTreeController::Instance()->UnselectControl(controlNode);
			}

			node->SetParent(targetNode, insertAfterNode);
			//insertAfterNode = node;
			
			if (isNodeSelected)
			{
				HierarchyTreeController::Instance()->SelectControl(controlNode);
			}
		}
	}
	
	HierarchyTreeController::Instance()->EmitHierarchyTreeUpdated(false);
	HierarchyTreeController::Instance()->ResetSelectedControl();
}
Esempio n. 3
0
void CreateControlCommand::PrepareRedoInformation()
{
	// Clone the current control node, remember the pointer to the previous node in the list
	// to restore the position of the node removed in case of Redo.
	HierarchyTreeNode* createdNode = HierarchyTreeController::Instance()->GetTree().GetNode(this->createdControlID);
	if (!createdNode || !createdNode->GetParent())
	{
		this->redoNode = NULL;
		return;
	}
	
	createdNode->PrepareRemoveFromSceneInformation();
	this->redoNode = createdNode;
}
Esempio n. 4
0
void DeleteSelectedNodeCommand::PrepareRedoInformation()
{
	// Remember the nodes which will be removed from the scene.
	for (HierarchyTreeNode::HIERARCHYTREENODESLIST::iterator iter = this->nodes.begin();
		 iter != this->nodes.end(); iter ++)
	{
		HierarchyTreeNode* nodeToRedo = (*iter);
		if (!nodeToRedo || !nodeToRedo->GetParent())
		{
			continue;
		}

		nodeToRedo->PrepareRemoveFromSceneInformation();
		this->redoNodes.push_back(nodeToRedo);
	}
}
Esempio n. 5
0
DeleteSelectedNodeCommand::DeleteSelectedNodeCommand(const HierarchyTreeNode::HIERARCHYTREENODESLIST& nodes, bool needDeleteFiles)
{
	this->nodes = nodes;
	this->deleteFiles = needDeleteFiles;

	DVASSERT(nodes.empty() == false);
	HierarchyTreeNode* itemNode = nodes.front();

	DetectType(itemNode);

	if (type == TYPE_AGGREGATOR)
	{
		StoreParentsOfRemovingAggregatorControls(nodes);
	}

	parentId = itemNode->GetParent()->GetId();
}
Esempio n. 6
0
HierarchyTreeScreenNode* HierarchyTreeController::GetScreenNodeForNode(HierarchyTreeNode* node)
{
	bool foundScreen = false;
	HierarchyTreeNode* screen = node->GetParent();
	do
	{
		if (dynamic_cast<HierarchyTreeScreenNode*>(screen))
		{
			foundScreen = true;
		}
		else
		{
			screen = screen->GetParent();
		}
	} while (!foundScreen && screen);

	if (foundScreen)
	{
		return dynamic_cast<HierarchyTreeScreenNode*>(screen);
	}

	return NULL;
}