-TDF_LabelMap& Model_AttributeSelection::scope()
-{
- if (myScope.IsEmpty()) { // create a new scope if not yet done
- // gets all features with named shapes that are before this feature label (before in history)
- DocumentPtr aMyDoc = owner()->document();
- std::list<std::shared_ptr<ModelAPI_Feature> > allFeatures = aMyDoc->allFeatures();
- std::list<std::shared_ptr<ModelAPI_Feature> >::iterator aFIter = allFeatures.begin();
- bool aMePassed = false;
- CompositeFeaturePtr aComposite =
- std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(owner());
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
- CompositeFeaturePtr aCompositeOwner, aCompositeOwnerOwner;
- if (aFeature.get()) {
- aCompositeOwner = ModelAPI_Tools::compositeOwner(aFeature);
- if (aCompositeOwner.get()) {
- aCompositeOwnerOwner = ModelAPI_Tools::compositeOwner(aCompositeOwner);
- }
- }
- // for group Scope is not limitet: this is always up to date objects
- // this causes problem in galeries.py
- //bool isGroup = aFeature.get() && aFeature->getKind() == "Group";
- for(; aFIter != allFeatures.end(); aFIter++) {
- if (*aFIter == owner()) { // the left features are created later (except subs of composite)
- aMePassed = true;
- continue;
- }
- //if (isGroup) aMePassed = false;
- bool isInScope = !aMePassed;
- if (!isInScope && aComposite.get()) {
- // try to add sub-elements of composite if this is composite
- if (aComposite->isSub(*aFIter))
- isInScope = true;
- }
- // remove the composite-owner of this feature (sketch in extrusion-cut)
- if (isInScope && (aCompositeOwner == *aFIter || aCompositeOwnerOwner == *aFIter))
- isInScope = false;
-
- if (isInScope && aFIter->get() && (*aFIter)->data()->isValid()) {
- TDF_Label aFeatureLab = std::dynamic_pointer_cast<Model_Data>(
- (*aFIter)->data())->label().Father();
- TDF_ChildIDIterator aNSIter(aFeatureLab, TNaming_NamedShape::GetID(), true);
- for(; aNSIter.More(); aNSIter.Next()) {
- Handle(TNaming_NamedShape) aNS = Handle(TNaming_NamedShape)::DownCast(aNSIter.Value());
- if (!aNS.IsNull() && aNS->Evolution() != TNaming_SELECTED) {
- myScope.Add(aNS->Label());
- }
- }
- }
- }
- // also add all naming labels created for external constructions
- std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(aMyDoc);
- TDF_Label anExtDocLab = aDoc->extConstructionsLabel();
- TDF_ChildIDIterator aNSIter(anExtDocLab, TNaming_NamedShape::GetID(), true);
- for(; aNSIter.More(); aNSIter.Next()) {
- Handle(TNaming_NamedShape) aNS = Handle(TNaming_NamedShape)::DownCast(aNSIter.Value());
- if (!aNS.IsNull() && aNS->Evolution() != TNaming_SELECTED) {
- myScope.Add(aNS->Label());
- }
- }
- }
- return myScope;
-}
-