예제 #1
0
파일: fragmentTree.C 프로젝트: wijnen/ear
void groupMarkers(Wt::WTreeTable *markerTree)
{
 	Wt::WTreeNode *parent;
	Wt::WTreeNode *newNode;
	std::set<Wt::WTreeNode*> unSortedselectedNodes =markerTree->tree()->selectedNodes();
	std::vector<Wt::WTreeNode*> selectedNodes ( unSortedselectedNodes.begin(), unSortedselectedNodes.end());
	std::sort(selectedNodes.begin(),selectedNodes.end(), fragmentAbeforeB); 
 
	std::vector< Wt::WTreeNode*> siblings;
 	
	Wt::WTreeNode *firstNode = *selectedNodes.begin();
	if(firstNode == markerTree->tree()->treeRoot())
	{
		return;
	}
	parent = firstNode->parentNode();
	newNode = MyTreeTableNode::addNode(0 ,"Group" ,-1,-1);
	siblings = parent->childNodes();
	int index = std::find(siblings.begin(), siblings.end(), firstNode) - siblings.begin();
	parent->insertChildNode(index, newNode);
	for(auto node:selectedNodes)
	{
		parent->removeChildNode(node);
		newNode->addChildNode(node);
	}

}
예제 #2
0
파일: fragmentTree.C 프로젝트: wijnen/ear
void ungroupMarkers(Wt::WTreeTable *markerTree)
{
	std::vector< Wt::WTreeNode*> siblings;
	Wt::WTreeNode *parent;
	Wt::WTreeNode *grandparent;
	std::vector< Wt::WTreeNode*> uncles; //My parents siblings
	int index = 0;

	std::set<Wt::WTreeNode*> unSortedselectedNodes = markerTree->tree()->selectedNodes();
	std::vector<Wt::WTreeNode*> selectedNodes ( unSortedselectedNodes.begin(), unSortedselectedNodes.end());
	std::sort(selectedNodes.begin(),selectedNodes.end(), fragmentAbeforeB);
 
	Wt::WTreeNode *firstNode = *selectedNodes.begin();
	Wt::WTreeNode *lastNode = *selectedNodes.rbegin(); //Note, the reverse of the beginning is not the end
	parent = firstNode->parentNode();
	if(parent == markerTree->tree()->treeRoot())
	{
		return;
	}
	siblings = parent->childNodes();

	if(firstNode != siblings.front() and lastNode != siblings.back())
	{ 
		return;
	}
	grandparent = parent->parentNode();
	uncles = grandparent->childNodes();
	index = std::find(uncles.begin(), uncles.end(), parent) - uncles.begin();
	if (firstNode == siblings.front() and lastNode != siblings.back())
	{
		index--;
	}
	for (auto node:selectedNodes)
	{
		parent->removeChildNode(node);
		index++;
		grandparent->insertChildNode(index,node);
	}

}