MCPcopy Create free account
hub / github.com/begla/Intrinsic / onPopulateNodeTree

Method onPopulateNodeTree

IntrinsicEd/src/IntrinsicEdNodeViewTreeWidget.cpp:76–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76void IntrinsicEdNodeViewTreeWidget::onPopulateNodeTree()
77{
78 // Store the current collapsed state of the tree
79 for (auto it = _itemToNodeMap.begin(); it != _itemToNodeMap.end(); ++it)
80 {
81 QTreeWidgetItem* item = it->first;
82 _nodeCollapsedState[it->second] = !item->isExpanded();
83 }
84
85 clear();
86 _nodeToItemMap.clear();
87 _itemToNodeMap.clear();
88
89 for (uint32_t i = 0u; i < Components::NodeManager::getSortedNodeCount(); ++i)
90 {
91 Components::NodeRef nodeRef =
92 Components::NodeManager::getSortedNodeAtIndex(i);
93
94 // Hide spawned nodes
95 // TODO: Visualize them separately
96 if ((Components::NodeManager::_flags(nodeRef) &
97 Components::NodeFlags::Flags::kSpawned) > 0u)
98 continue;
99
100 Entity::EntityRef entityRef = Components::NodeManager::_entity(nodeRef);
101 const Name& name = Entity::EntityManager::_name(entityRef);
102
103 QTreeWidgetItem* item = nullptr;
104 QString nodeTitle = name.getString().c_str();
105
106 if (!Components::NodeManager::_parent(nodeRef).isValid())
107 {
108 item = new QTreeWidgetItem(this);
109 _nodeToItemMap[nodeRef] = item;
110
111 item->setIcon(0, IntrinsicEd::getIcon("RootNode"));
112 }
113 else
114 {
115 Components::NodeRef parentNodeRef =
116 Components::NodeManager::_parent(nodeRef);
117 QTreeWidgetItem* parentItem = _nodeToItemMap[parentNodeRef];
118
119 item = new QTreeWidgetItem(parentItem);
120 _nodeToItemMap[nodeRef] = item;
121
122 // Use the first component found as an icon
123 QIcon iconToUse = IntrinsicEd::getIcon("Node");
124 for (auto it = Application::_componentManagerMapping.begin();
125 it != Application::_componentManagerMapping.end(); ++it)
126 {
127 const Name& compName = it->first;
128
129 // Don't count nodes
130 if (compName == "Node")
131 continue;
132
133 Dod::Components::ComponentManagerEntry& entry = it->second;

Callers 1

populateNodeTreeMethod · 0.80

Calls 3

clearMethod · 0.80
getStringMethod · 0.80
isValidMethod · 0.45

Tested by

no test coverage detected