本文整理汇总了C++中NodeTree类的典型用法代码示例。如果您正苦于以下问题:C++ NodeTree类的具体用法?C++ NodeTree怎么用?C++ NodeTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyTree
void copyTree(VisualNode* node_t, NodeTree& tree_t,
const VisualNode* node_s, const NodeTree& tree_s) {
auto& na_t = tree_t.getNA();
const auto& na_s = tree_s.getNA();
stack<VisualNode*> stk_t;
stack<const VisualNode*> stk_s;
stk_s.push(node_s);
stk_t.push(node_t);
while (stk_s.size() > 0) {
const VisualNode* n = stk_s.top(); stk_s.pop();
VisualNode* next = stk_t.top(); stk_t.pop();
auto kids = n->getNumberOfChildren();
next->setNumberOfChildren(kids, na_t);
next->setStatus(n->getStatus());
next->dirtyUp(na_t);
for (auto i = 0u; i < kids; ++i) {
stk_s.push(n->getChild(na_s, i));
stk_t.push(next->getChild(na_t, i));
}
}
}
示例2: Search
void MainWindow::Search(wxTreeItemId search,bool toogle)
{
wxTreeItemIdValue cookie;
NodeTree *itemData = search.IsOk() ? (NodeTree *) tree->GetItemData(search)
:NULL;
if(itemData->getTipo()==N_World )
if(itemData->pointer.world->getNumObjects()!=0)
Search(tree->GetFirstChild(search,cookie),toogle);
if(itemData->menus.menu_positionable)
{
if(itemData->menus.menu_composed || itemData->pointer.positionableentity->getOwner()->getClassName()=="World")
{
if(toogle)
itemData->pointer.positionableentity->setDrawReferenceSystem();
else
itemData->pointer.positionableentity->setDrawReferenceSystem(false);
if(itemData->menus.menu_composed)
if(itemData->pointer.composedentity->getNumObjects()>0)
Search(tree->GetFirstChild(search,cookie),toogle);
}
}
if(tree->GetLastChild(tree->GetItemParent(search))==search)
return;
Search(tree->GetNextSibling(search),toogle);
}
示例3: calculateMaxDepth
int calculateMaxDepth(const NodeTree& nt) {
const auto& na = nt.getNA();
const auto* root = nt.getRoot();
return calcDepth(na, root);
}
示例4: ShowSelection
void MainWindow::ShowSelection(wxCommandEvent& event)
{
int id=event.GetId();
bool d_box=toolbar->GetToolState(id);
NodeTree *itemData = tree->GetSelection().IsOk() ? (NodeTree *) tree->GetItemData(tree->GetSelection())
:NULL;
if(d_box)
{
tree->SetShowSelection(true);
if(!tree->GetSelection().IsOk()) return;
if(itemData->menus.menu_solid && tree->GetSelection()!=tree->GetRootItem())
{
itemData->pointer.solidentity->setDrawBox(true);
itemData->getSimu()->getChild()->Refresh();
}
}
else
{
tree->SetShowSelection(false);
if(!tree->GetSelection().IsOk()) return;
if(itemData->menus.menu_solid && tree->GetSelection()!=tree->GetRootItem())
{
itemData->pointer.solidentity->setDrawBox(false);
itemData->getSimu()->getChild()->Refresh();
}
}
}
示例5: highlightSubtrees
void highlightSubtrees(NodeTree& nt, const std::vector<VisualNode*>& nodes) {
QMutexLocker lock(&nt.getMutex());
auto& na = nt.getNA();
auto* root = nt.getRoot();
root->unhideAll(na);
{
QMutexLocker lock(&nt.getLayoutMutex());
root->layout(na);
}
// unhighlight all
applyToEachNode(nt, [](VisualNode* n) {
n->setHighlighted(false);
});
for (auto node : nodes) {
node->setHighlighted(true);
}
// TODO: hide not highlighted
// HideNotHighlightedCursor hnhc(root, na);
// PostorderNodeVisitor<HideNotHighlightedCursor>(hnhc).run();
nt.treeModified();
}
示例6: applyToEachNodePO
void applyToEachNodePO(NodeTree& nt, const NodeAction& action) {
/// PO-traversal requires two stacks
std::stack<VisualNode*> stk_1;
std::stack<VisualNode*> stk_2;
auto* root = nt.getRoot();
auto& na = nt.getNA();
stk_1.push(root);
while (stk_1.size() > 0) {
auto* node = stk_1.top(); stk_1.pop();
stk_2.push(node);
for (auto i = 0u; i < node->getNumberOfChildren(); ++i) {
auto kid = node->getChild(na, i);
stk_1.push(kid);
}
}
while (stk_2.size() > 0) {
auto* node = stk_2.top(); stk_2.pop();
action(node);
}
}
示例7: while
std::vector<NodeTree<int>*>* GraphStructuredStack::getReachable(NodeTree<int>* start, int length) {
std::vector<NodeTree<int>*>* reachableList = new std::vector<NodeTree<int>*>();
std::queue<NodeTree<int>*> currentNodes;
std::queue<NodeTree<int>*> nextNodes;
currentNodes.push(start);
for (int i = 0; i < length; i++) {
while (!currentNodes.empty()) {
NodeTree<int>* currentNode = currentNodes.front();
currentNodes.pop();
std::vector<NodeTree<int>*> children = currentNode->getChildren();
//std::cout << currentNode->getData() << " has children ";
for (std::vector<NodeTree<int>*>::size_type j = 0; j < children.size(); j++) {
std::cout << children[j]->getData() << " ";
nextNodes.push(children[j]);
}
std::cout << std::endl;
}
currentNodes = nextNodes;
//No clear function, so go through and remove
while(!nextNodes.empty())
nextNodes.pop();
}
while (!currentNodes.empty()) {
reachableList->push_back(currentNodes.front());
//std::cout << currentNodes.front()->getData() << " is reachable from " << start->getData() << " by length " << length << std::endl;
currentNodes.pop();
}
return reachableList;
}
示例8: it
void HuffmanCompression::getCarEncode(){
codeTable = new QMap<char,QString>;
QListIterator<NodeTree*> it(*externalNodesList);
while(it.hasNext()){
NodeTree *n = it.next();
QString str = goThroughBranch(n);
codeTable->insert(n->getCharacter(),str);
}
}
示例9: getPath
//get path from root to node at index
NodeTree* getPath(unsigned int index){
RRTNode* node = _nodes[index];
NodeTree* path = new NodeTree(node);
while(node->getParent() != NULL)
{
path->addNode(node); // insert
node = node->getParent();
}
path->addNode(node);
// std::reverse(path->_nodes.begin(),path->_nodes.end());
return path;
}
示例10: NodeTree
void HuffmanCompression::unify(NodeTree *nodeL,NodeTree *nodeR){
unsigned int weight = nodeL->getweight()+nodeR->getweight();
NodeTree *tree = new NodeTree();
nodeL->setType(Constants::LEFT);
nodeR->setType(Constants::RIGHT);
nodeR->setParent(tree);
nodeL->setParent(tree);
tree->setLeft(nodeL);
tree->setRight(nodeR);
tree->setType(Constants::ROOT);
tree->setWeight(weight);
list->insert(tree);
if(list->size()==1)
return;
unify(list->getFirst(),list->getFirst());
}
示例11: addChildren
void addChildren(VisualNode* node, NodeTree& nt, int kids) {
auto& na = nt.getNA();
node->setNumberOfChildren(kids, na);
node->dirtyUp(na);
auto& stats = nt.getStatistics();
stats.undetermined += kids;
int depth = tree_utils::calculateDepth(nt, *node) + 1;
int new_depth = depth + 1;
stats.maxDepth = std::max(stats.maxDepth, new_depth);
};
示例12: applyToEachNode
void applyToEachNode(NodeTree& nt, const NodeAction& action) {
auto& na = nt.getNA();
for (int i = 0; i < na.size(); ++i) {
action(na[i]);
}
}
示例13: WXUNUSED
void MainWindow::OnRobotSimPanelCtrl(wxCommandEvent& WXUNUSED(event))
{
wxTreeItemId itemId = tree->GetSelection();
NodeTree *itemData = itemId.IsOk() ? (NodeTree *) tree->GetItemData(itemId):NULL;
if(itemData->pointer.robotsim)
{
if(managewindow->CheckWindowsExist(itemData))
{
RobotSimPanel* robotSimCtrl;
robotSimCtrl = new RobotSimPanel(this,wxID_ANY,wxT("Move all Joints"),itemData);
robotSimCtrl->getTitle()->SetLabel(wxString(itemData->getNameTree()));
robotSimCtrl->setManageWindow(managewindow);
robotSimCtrl->Show(true);
wxLogStatus(wxT("Robot Sim Panel"));
}
}
}
示例14: calculateDepth
int calculateDepth(const NodeTree& nt, const VisualNode& node) {
int count = 0;
auto it = &node;
auto& na = nt.getNA();
while ( (it = it->getParent(na)) ) { count++; }
return count;
}
示例15: recursiveHierarchy
static void recursiveHierarchy(NodeTree& tree, CSFile *csf, int idx, int cloneoffset)
{
for (int i = 0; i < csf->nodes[idx].numChildren; i++){
tree.setNodeParent((NodeTree::nodeID)csf->nodes[idx].children[i] + cloneoffset,(NodeTree::nodeID)idx + cloneoffset);
}
for (int i = 0; i < csf->nodes[idx].numChildren; i++){
recursiveHierarchy(tree,csf,csf->nodes[idx].children[i],cloneoffset);
}
}