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

Method getSubObjectList

src/App/DocumentObject.cpp:1220–1265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1218} // namespace
1219
1220std::vector<DocumentObject*> DocumentObject::getSubObjectList(const char* subname,
1221 std::vector<int>* const subsizes,
1222 bool flatten) const
1223{
1224 std::vector<DocumentObject*> res;
1225 res.push_back(const_cast<DocumentObject*>(this));
1226 if (subsizes) {
1227 subsizes->push_back(0);
1228 }
1229 if (!subname || (subname[0] == '\0')) {
1230 return res;
1231 }
1232 auto element = Data::findElementName(subname);
1233 std::string sub(subname, element - subname);
1234 App::DocumentObject* container = nullptr;
1235
1236 bool lastChild = false;
1237 if (flatten) {
1238 auto linked = getLinkedObject();
1239 if (linked->getExtensionByType<App::GeoFeatureGroupExtension>(true)) {
1240 container = const_cast<DocumentObject*>(this);
1241 }
1242 else if (auto grp = App::GeoFeatureGroupExtension::getGroupOfObject(linked)) {
1243 container = grp;
1244 lastChild = true;
1245 }
1246 }
1247 for (auto pos = sub.find('.'); pos != std::string::npos; pos = sub.find('.', pos + 1)) {
1248 char subTail = sub[pos + 1];
1249 sub[pos + 1] = '\0';
1250 auto sobj = getSubObject(sub.c_str());
1251 if (!sobj || !sobj->isAttachedToDocument()) {
1252 continue;
1253 }
1254
1255 if (flatten) {
1256 res = getSubObjectListFlatten(res, subsizes, sobj, &container, lastChild);
1257 }
1258 res.push_back(sobj);
1259 if (subsizes) {
1260 subsizes->push_back((int)pos + 1);
1261 }
1262 sub[pos + 1] = subTail;
1263 }
1264 return res;
1265}
1266
1267std::vector<std::string> DocumentObject::getSubObjects(int reason) const
1268{

Callers 8

getObjectInfoMethod · 0.45
findSubObjectListMethod · 0.45
forwardToLinkMethod · 0.45
doActionMethod · 0.45
findItemMethod · 0.45
get_all_dependentMethod · 0.45
getLocatedShapeFunction · 0.45
TEST_FFunction · 0.45

Calls 5

getSubObjectListFlattenFunction · 0.85
push_backMethod · 0.45
findMethod · 0.45
c_strMethod · 0.45
isAttachedToDocumentMethod · 0.45

Tested by

no test coverage detected