@@ -94,7 +94,7 @@ bool ExtensionContainer::hasExtension(const std::string& name) const {
|
||||
}
|
||||
|
||||
|
||||
Extension* ExtensionContainer::getExtension(Base::Type t) {
|
||||
Extension* ExtensionContainer::getExtension(Base::Type t) const {
|
||||
|
||||
auto result = _extensions.find(t);
|
||||
if(result == _extensions.end()) {
|
||||
@@ -115,7 +115,7 @@ bool ExtensionContainer::hasExtensions() const {
|
||||
return !_extensions.empty();
|
||||
}
|
||||
|
||||
Extension* ExtensionContainer::getExtension(const std::string& name) {
|
||||
Extension* ExtensionContainer::getExtension(const std::string& name) const {
|
||||
|
||||
//and for types derived from it, as they can be cast to the extension
|
||||
for(auto entry : _extensions) {
|
||||
|
||||
@@ -127,12 +127,12 @@ public:
|
||||
bool hasExtension(Base::Type) const; //returns first of type (or derived from) and throws otherwise
|
||||
bool hasExtension(const std::string& name) const; //this version does not check derived classes
|
||||
bool hasExtensions() const;
|
||||
App::Extension* getExtension(Base::Type); //returns first of type (or derived from) and throws otherwise
|
||||
App::Extension* getExtension(const std::string& name); //this version does not check derived classes
|
||||
App::Extension* getExtension(Base::Type) const;
|
||||
App::Extension* getExtension(const std::string& name) const; //this version does not check derived classes
|
||||
|
||||
//returns first of type (or derived from) and throws otherwise
|
||||
template<typename ExtensionT>
|
||||
ExtensionT* getExtensionByType() {
|
||||
ExtensionT* getExtensionByType() const {
|
||||
return dynamic_cast<ExtensionT*>(getExtension(ExtensionT::getExtensionClassTypeId()));
|
||||
};
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ std::vector<App::DocumentObject*> GeoFeatureGroupExtension::getGeoSubObjects ()
|
||||
std::set<App::DocumentObject*> nextSearchSet;
|
||||
for ( auto obj: curSearchSet) {
|
||||
if ( isNonGeoGroup (obj) ) {
|
||||
const App::DocumentObjectGroup *grp = static_cast<const App::DocumentObjectGroup *> (obj);
|
||||
auto *grp = obj->getExtensionByType<App::GroupExtension>();
|
||||
// Check if we havent already processed the element may happen in case of nontree structure
|
||||
// Note: if the condition is false this generally indicates malformed structure
|
||||
if ( processedGroups.find (grp) == processedGroups.end() ) {
|
||||
@@ -127,7 +127,7 @@ bool GeoFeatureGroupExtension::geoHasObject (const DocumentObject* obj) const {
|
||||
std::set<const App::DocumentObject*> nextSearchSet;
|
||||
for ( auto obj: curSearchSet) {
|
||||
if ( isNonGeoGroup (obj) ) {
|
||||
const App::DocumentObjectGroup *grp = static_cast<const App::DocumentObjectGroup *> (obj);
|
||||
auto *grp = obj->getExtensionByType<App::GroupExtension>();
|
||||
if ( processedGroups.find (grp) == processedGroups.end() ) {
|
||||
processedGroups.insert ( grp );
|
||||
const auto & objs = grp->Group.getValues();
|
||||
@@ -148,11 +148,11 @@ DocumentObject* GeoFeatureGroupExtension::getGroupOfObject(const DocumentObject*
|
||||
GeoFeatureGroupExtension* grp = (*it)->getExtensionByType<GeoFeatureGroupExtension>();
|
||||
if ( indirect ) {
|
||||
if (grp->geoHasObject(obj)) {
|
||||
return dynamic_cast<App::DocumentObject*>(grp);
|
||||
return grp->getExtendedObject();
|
||||
}
|
||||
} else {
|
||||
if (grp->hasObject(obj)) {
|
||||
return dynamic_cast<App::DocumentObject*>(grp);
|
||||
return grp->getExtendedObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
|
||||
/// Returns true if the given DocumentObject is DocumentObjectGroup but not GeoFeatureGroup
|
||||
static bool isNonGeoGroup(const DocumentObject* obj) {
|
||||
return obj->hasExtension(GroupExtension::getExtensionClassTypeId()) &
|
||||
return obj->hasExtension(GroupExtension::getExtensionClassTypeId()) &&
|
||||
!obj->hasExtension(GeoFeatureGroupExtension::getExtensionClassTypeId());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -99,7 +99,12 @@ std::vector< App::DocumentObject* > ViewProviderGeoFeatureGroupExtension::getLin
|
||||
if(!obj)
|
||||
return std::vector< App::DocumentObject* >();
|
||||
|
||||
//we get all linked objects, and that recursively
|
||||
//if the object is a geofeaturegroup than all dependencies belong to that CS, we are not allowed
|
||||
//to grap them
|
||||
if(obj->hasExtension(App::GeoFeatureGroupExtension::getExtensionClassTypeId()))
|
||||
return std::vector< App::DocumentObject* >();
|
||||
|
||||
//we get all linked objects
|
||||
std::vector< App::DocumentObject* > result;
|
||||
std::vector<App::Property*> list;
|
||||
obj->getPropertyList(list);
|
||||
@@ -123,7 +128,7 @@ std::vector< App::DocumentObject* > ViewProviderGeoFeatureGroupExtension::getLin
|
||||
|
||||
//collect all dependencies of those objects
|
||||
std::vector< App::DocumentObject* > links;
|
||||
for(App::DocumentObject *obj : result) {
|
||||
for(App::DocumentObject *obj : result) {
|
||||
auto vec = getLinkedObjects(obj);
|
||||
links.insert(links.end(), vec.begin(), vec.end());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user