bool isOldShape = isOldContext &&
(theSubShape == anOldShape || (theSubShape && anOldShape && theSubShape->isEqual(anOldShape)));
if (isOldShape) return false; // shape is the same, so context is also unchanged
+ bool aToUnblock = false;
// update the referenced object if needed
if (!isOldContext) {
- myRef.setValue(theContext);
+ aToUnblock = !owner()->data()->blockSendAttributeUpdated(true);
+ myRef.setValue(theContext);
}
// do noth use naming if selected shape is result shape itself, but not sub-shape
TDF_Label aRefLab = myRef.myRef->Label();
aSelLab.ForgetAllAttributes(true);
myRef.myRef = TDF_Reference::Set(aSelLab.Father(), aSelLab.Father());
+ if (aToUnblock)
+ owner()->data()->blockSendAttributeUpdated(false);
return false;
}
if (theContext->groupName() == ModelAPI_ResultBody::group()) {
}
owner()->data()->sendAttributeUpdated(this);
+
+ if (aToUnblock)
+ owner()->data()->blockSendAttributeUpdated(false);
+
return true;
}
std::shared_ptr<GeomAPI_Shape> Model_AttributeSelection::value()
{
+ if (!ModelAPI_AttributeSelection::isInitialized() && !myTmpContext.get() && !myTmpSubShape.get())
+ return std::shared_ptr<GeomAPI_Shape>();
CenterType aType = NOT_CENTER;
std::shared_ptr<GeomAPI_Shape> aResult = internalValue(aType);
return centerByEdge(aResult, aType);
ModelAPI_AttributeSelection::setID(theID);
}
-ResultPtr Model_AttributeSelection::context() {
+ResultPtr Model_AttributeSelection::context()
+{
+ if (!ModelAPI_AttributeSelection::isInitialized() && !myTmpContext.get() && !myTmpSubShape.get())
+ return ResultPtr();
+
if (myTmpContext.get() || myTmpSubShape.get()) {
return myTmpContext;
}
}
}
// for group Scope is not limitet: this is always up to date objects
- bool isGroup = aFeature.get() && aFeature->getKind() == "Group";
+ // 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;
+ //if (isGroup) aMePassed = false;
bool isInScope = !aMePassed;
if (!isInScope && aComposite.get()) {
// try to add sub-elements of composite if this is composite
if (aCont.get() && aShapeToBeSelected.get()) {
ResultCompSolidPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aCont);
if (aComp && aComp->numberOfSubs()) {
- for(int aSubNum = aComp->numberOfSubs() - 1; aSubNum >= 0; aSubNum--) {
+ for(int aSubNum = 0; aSubNum < aComp->numberOfSubs(); aSubNum++) {
ResultPtr aSub = aComp->subResult(aSubNum);
if (aSub && aSub->shape().get() && aSub->shape()->isSubShape(aShapeToBeSelected)) {
aCont = aSub;
// try to find the latest active result that must be used instead of the selected
// to set the active context (like in GUI selection), not concealed one
bool aFindNewContext = true;
- while(aFindNewContext && aCont.get() && aShapeToBeSelected.get()) {
+ while(aFindNewContext && aCont.get()) {
aFindNewContext = false;
- const std::set<AttributePtr>& aRefs = aCont->data()->refsToMe();
- std::set<AttributePtr>::const_iterator aRef = aRefs.begin();
- for(; !aFindNewContext && aRef != aRefs.end(); aRef++) {
- if (!aRef->get() || !(*aRef)->owner().get())
- continue;
- // concealed attribute only
- FeaturePtr aRefFeat = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRef)->owner());
- if (!ModelAPI_Session::get()->validators()->isConcealed(
- aRefFeat->getKind(), (*aRef)->id()))
- continue;
- // search the feature result that contains sub-shape selected
- std::list<std::shared_ptr<ModelAPI_Result> > aResults;
- ModelAPI_Tools::allResults(aRefFeat, aResults);
- std::list<std::shared_ptr<ModelAPI_Result> >::reverse_iterator aResIter =
- aResults.rbegin(); // iterate from the end to find the sub-solid first than compsolid
- for(; aResIter != aResults.rend(); aResIter++) {
- if (!aResIter->get() || !(*aResIter)->data()->isValid() || (*aResIter)->isDisabled())
+ // take references to all results: root one, any sub
+ ResultCompSolidPtr aCompContext = ModelAPI_Tools::compSolidOwner(aCont);
+ int aSubsSize = (aCompContext.get() ? aCompContext->numberOfSubs() : 0) + 1;
+ for(int aResultNum = 0; aResultNum < aSubsSize; aResultNum++) {
+ ResultPtr aResCont = aCont;
+ if (aCompContext.get())
+ if (aResultNum == aSubsSize - 1)
+ aResCont = aCompContext;
+ else aResCont = aCompContext->subResult(aResultNum);
+ const std::set<AttributePtr>& aRefs = aResCont->data()->refsToMe();
+ std::set<AttributePtr>::const_iterator aRef = aRefs.begin();
+ for(; !aFindNewContext && aRef != aRefs.end(); aRef++) {
+ if (!aRef->get() || !(*aRef)->owner().get())
continue;
- GeomShapePtr aShape = (*aResIter)->shape();
- if (aShape.get() && aShape->isSubShape(aShapeToBeSelected, false)) {
- aCont = *aResIter; // found new context (produced from this) with same subshape
- //if (!aShape->isSubShape(aShapeToBeSelected, true)) // take context orientation
- // aShapeToBeSelected->setOrientation();
- aFindNewContext = true; // continue searching futher
- break;
+ // concealed attribute only
+ FeaturePtr aRefFeat = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRef)->owner());
+ if (!ModelAPI_Session::get()->validators()->isConcealed(
+ aRefFeat->getKind(), (*aRef)->id()))
+ continue;
+ // search the feature result that contains sub-shape selected
+ std::list<std::shared_ptr<ModelAPI_Result> > aResults;
+
+ // take all sub-results or one result
+ const std::list<std::shared_ptr<ModelAPI_Result> >& aFResults = aRefFeat->results();
+ std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aFResults.begin();
+ for (; aRIter != aFResults.cend(); aRIter++) {
+ // iterate sub-bodies of compsolid
+ ResultCompSolidPtr aComp =
+ std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aRIter);
+ if (aComp.get() && aComp->numberOfSubs() > 0) {
+ int aNumSub = aComp->numberOfSubs();
+ for(int a = 0; a < aNumSub; a++) {
+ aResults.push_back(aComp->subResult(a));
+ }
+ } else {
+ aResults.push_back(*aRIter);
+ }
+ }
+ std::list<std::shared_ptr<ModelAPI_Result> >::iterator aResIter = aResults.begin();
+ for(; aResIter != aResults.end(); aResIter++) {
+ if (!aResIter->get() || !(*aResIter)->data()->isValid() || (*aResIter)->isDisabled())
+ continue;
+ GeomShapePtr aShape = (*aResIter)->shape();
+ GeomShapePtr aSelectedShape =
+ aShapeToBeSelected.get() ? aShapeToBeSelected : aCont->shape();
+ if (aShape.get() && aShape->isSubShape(aSelectedShape, false)) {
+ aCont = *aResIter; // found new context (produced from this) with same subshape
+ //if (!aShape->isSubShape(aShapeToBeSelected, true)) // take context orientation
+ // aShapeToBeSelected->setOrientation();
+ aFindNewContext = true; // continue searching futher
+ break;
+ }
}
}
}
{
std::set<ResultPtr> aResults; // to avoid duplicates, new context, null if deleted
TopTools_ListOfShape aResContShapes;
- TNaming_SameShapeIterator aModifIter(theContShape, theAccessLabel);
- for(; aModifIter.More(); aModifIter.Next()) {
- TDF_Label anObjLab = aModifIter.Label().Father();
- ResultPtr aModifierObj = std::dynamic_pointer_cast<ModelAPI_Result>
- (theDoc->objects()->object(anObjLab));
- if (!aModifierObj.get()) {
- // #2241: shape may be sub-element of new object, not main (shell created from faces)
- if (!anObjLab.IsRoot())
- aModifierObj = std::dynamic_pointer_cast<ModelAPI_Result>
- (theDoc->objects()->object(anObjLab.Father()));
- if (!aModifierObj.get())
+ // iterate context and shape, but also if it is sub-shape of main shape, check also it
+ TopTools_ListOfShape aContextList;
+ aContextList.Append(theContShape);
+ if (theContext.get()) {
+ ResultPtr aComposite = ModelAPI_Tools::compSolidOwner(theContext);
+ if (aComposite.get() && aComposite->shape().get() && !aComposite->shape()->isNull())
+ aContextList.Append(aComposite->shape()->impl<TopoDS_Shape>());
+ }
+ for(TopTools_ListOfShape::Iterator aContIter(aContextList); aContIter.More(); aContIter.Next()) {
+ TNaming_SameShapeIterator aModifIter(aContIter.ChangeValue(), theAccessLabel);
+ for(; aModifIter.More(); aModifIter.Next()) {
+ TDF_Label anObjLab = aModifIter.Label().Father();
+ ResultPtr aModifierObj = std::dynamic_pointer_cast<ModelAPI_Result>
+ (theDoc->objects()->object(anObjLab));
+ if (!aModifierObj.get()) {
+ // #2241: shape may be sub-element of new object, not main (shell created from faces)
+ if (!anObjLab.IsRoot())
+ aModifierObj = std::dynamic_pointer_cast<ModelAPI_Result>
+ (theDoc->objects()->object(anObjLab.Father()));
+ if (!aModifierObj.get())
+ continue;
+ }
+ FeaturePtr aModifierFeat = theDoc->feature(aModifierObj);
+ if (!aModifierFeat.get())
continue;
- }
- FeaturePtr aModifierFeat = theDoc->feature(aModifierObj);
- if (!aModifierFeat.get())
- continue;
- FeaturePtr aThisFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
- if (aModifierFeat == aThisFeature || theDoc->objects()->isLater(aModifierFeat, aThisFeature))
- continue; // the modifier feature is later than this, so, should not be used
- FeaturePtr aCurrentModifierFeat = theDoc->feature(theContext);
- if (aCurrentModifierFeat == aModifierFeat ||
- theDoc->objects()->isLater(aCurrentModifierFeat, aModifierFeat))
- continue; // the current modifier is later than the found, so, useless
- Handle(TNaming_NamedShape) aNewNS;
- aModifIter.Label().FindAttribute(TNaming_NamedShape::GetID(), aNewNS);
- if (aNewNS->Evolution() == TNaming_MODIFY || aNewNS->Evolution() == TNaming_GENERATED) {
- aResults.insert(aModifierObj);
- //TNaming_Iterator aPairIter(aNewNS);
- //aResContShapes.Append(aPairIter.NewShape());
- aResContShapes.Append(aModifierObj->shape()->impl<TopoDS_Shape>());
- } else if (aNewNS->Evolution() == TNaming_DELETE) { // a shape was deleted => result is empty
- aResults.insert(ResultPtr());
- } else { // not-precessed modification => don't support it
- continue;
+ FeaturePtr aThisFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
+ if (aModifierFeat == aThisFeature || theDoc->objects()->isLater(aModifierFeat, aThisFeature))
+ continue; // the modifier feature is later than this, so, should not be used
+ FeaturePtr aCurrentModifierFeat = theDoc->feature(theContext);
+ if (aCurrentModifierFeat == aModifierFeat ||
+ theDoc->objects()->isLater(aCurrentModifierFeat, aModifierFeat))
+ continue; // the current modifier is later than the found, so, useless
+ Handle(TNaming_NamedShape) aNewNS;
+ aModifIter.Label().FindAttribute(TNaming_NamedShape::GetID(), aNewNS);
+ if (aNewNS->Evolution() == TNaming_MODIFY || aNewNS->Evolution() == TNaming_GENERATED) {
+ aResults.insert(aModifierObj);
+ //TNaming_Iterator aPairIter(aNewNS);
+ //aResContShapes.Append(aPairIter.NewShape());
+ aResContShapes.Append(aModifierObj->shape()->impl<TopoDS_Shape>());
+ } else if (aNewNS->Evolution() == TNaming_DELETE) { // a shape was deleted => result is empty
+ aResults.insert(ResultPtr());
+ } else { // not-precessed modification => don't support it
+ continue;
+ }
}
}
if (aResults.empty())