App/GeoFeatureGroup: derive from DocumentObjectGroup

Refactor GeoFeatureGroup and derive it from DocumentObjectGroup rather
than GeoFeatureObject to unify code of those two classes.
This commit is contained in:
Alexander Golubev
2015-08-28 00:09:41 +03:00
committed by Stefan Tröger
parent 78de2a193a
commit e26c6174ac
18 changed files with 167 additions and 439 deletions

View File

@@ -103,12 +103,18 @@ DocumentObject *DocumentObjectGroup::getObject(const char *Name) const
return 0;
}
bool DocumentObjectGroup::hasObject(const DocumentObject* obj) const
bool DocumentObjectGroup::hasObject(const DocumentObject* obj, bool recursive) const
{
const std::vector<DocumentObject*>& grp = Group.getValues();
for (std::vector<DocumentObject*>::const_iterator it = grp.begin(); it != grp.end(); ++it) {
if (*it == obj)
if (*it == obj) {
return true;
} else if ( recursive && (*it)->isDerivedFrom (App::DocumentObjectGroup::getTypeId()) ) {
App::DocumentObjectGroup *subGroup = static_cast<App::DocumentObjectGroup *> (*it);
if (subGroup->hasObject (obj, recursive)) {
return true;
}
}
}
return false;