MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / getTreeRootObjects

Method getTreeRootObjects

src/Gui/Document.cpp:3173–3200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3171}
3172
3173std::vector<App::DocumentObject*> Document::getTreeRootObjects() const
3174{
3175 std::vector<App::DocumentObject*> docObjects = d->_pcDocument->getObjects();
3176 std::unordered_map<App::DocumentObject*, bool> rootMap;
3177 for (auto it : docObjects) {
3178 rootMap[it] = true;
3179 }
3180
3181 for (auto obj : docObjects) {
3182 ViewProvider* vp = Application::Instance->getViewProvider(obj);
3183 if (!vp) {
3184 continue;
3185 }
3186
3187 std::vector<App::DocumentObject*> children = vp->claimChildren();
3188 for (auto child : children) {
3189 rootMap[child] = false;
3190 }
3191 }
3192
3193 std::vector<App::DocumentObject*> rootObjs;
3194 for (const auto& it : rootMap) {
3195 if (it.second) {
3196 rootObjs.push_back(it.first);
3197 }
3198 }
3199 return rootObjs;
3200}

Callers 2

sortDroppedObjectsMethod · 0.45
buildObjectsListMethod · 0.45

Calls 4

getObjectsMethod · 0.45
getViewProviderMethod · 0.45
claimChildrenMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected