} else aResIter++;
}
- if (aResults.empty())
+ if (aResults.empty()) {
+ // check the context become concealed by operation which is earlier than this selection
+ std::list<ResultPtr> allRes;
+ ResultPtr aRoot = ModelAPI_Tools::bodyOwner(theContext, true);
+ if (!aRoot.get())
+ aRoot = theContext;
+ ResultBodyPtr aRootBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aRoot);
+ if (aRootBody.get()) {
+ ModelAPI_Tools::allSubs(aRootBody, allRes);
+ allRes.push_back(aRootBody);
+ } else
+ allRes.push_back(aRoot);
+
+ FeaturePtr aThisFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
+ for (std::list<ResultPtr>::iterator aSub = allRes.begin(); aSub != allRes.end(); aSub++) {
+ ResultPtr aResCont = *aSub;
+ const std::set<AttributePtr>& aRefs = aResCont->data()->refsToMe();
+ std::set<AttributePtr>::const_iterator aRef = aRefs.begin();
+ for (; 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 (aRefFeat == aThisFeature)
+ continue;
+ if (!ModelAPI_Session::get()->validators()->isConcealed(
+ aRefFeat->getKind(), (*aRef)->id()))
+ continue;
+ if (!theDoc->isLaterByDep(aRefFeat, aThisFeature)) {
+ return true; // feature conceals result, return true, so the context will be removed
+ }
+ }
+ }
return false; // no modifications found, must stay the same
+ }
// iterate all results to find further modifications
std::set<ResultPtr>::iterator aResIter = aResults.begin();
for(; aResIter != aResults.end(); aResIter++) {
return true; // theResults must be empty: everything is deleted
}
-void Model_AttributeSelection::updateInHistory()
+void Model_AttributeSelection::updateInHistory(bool& theRemove)
{
ResultPtr aContext = std::dynamic_pointer_cast<ModelAPI_Result>(myRef.value());
// only bodies and parts may be modified later in the history, don't do anything otherwise
}
}
if (aFirst) { // nothing was added, all results were deleted
- ResultPtr anEmptyContext;
- std::shared_ptr<GeomAPI_Shape> anEmptyShape;
- setValue(anEmptyContext, anEmptyShape); // nullify the selection
- return;
+ if (myParent) {
+ theRemove = true;
+ } else {
+ ResultPtr anEmptyContext;
+ std::shared_ptr<GeomAPI_Shape> anEmptyShape;
+ setValue(anEmptyContext, anEmptyShape); // nullify the selection
+ return;
+ }
}
}
}
/// Updates the arguments of selection if something was affected by creation
/// or reorder of features upper in the history line (issue #1757)
- MODEL_EXPORT virtual void updateInHistory();
+ /// Returns theRemove true if this attribute must be removed (become deleted)
+ MODEL_EXPORT virtual void updateInHistory(bool& theRemove);
// Implementation of the name generator method from the Selector package
// This method returns the context name by the label of the sub-selected shape
for (; aRefsIter != aRefs.end(); aRefsIter++) {
std::shared_ptr<Model_AttributeSelection> aSel =
std::dynamic_pointer_cast<Model_AttributeSelection>(*aRefsIter);
- aSel->updateInHistory();
+ bool aRemove = false;
+ aSel->updateInHistory(aRemove);
}
// update the selection list attributes if any
aRefs = (*anObj)->data()->attributes(ModelAPI_AttributeSelectionList::typeId());
for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
+ std::set<int> aRemoveSet;
std::shared_ptr<ModelAPI_AttributeSelectionList> aSel =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(*aRefsIter);
for(int a = aSel->size() - 1; a >= 0; a--) {
std::shared_ptr<Model_AttributeSelection> aSelAttr =
std::dynamic_pointer_cast<Model_AttributeSelection>(aSel->value(a));
- if (aSelAttr.get())
- aSelAttr->updateInHistory();
+ if (aSelAttr.get()) {
+ bool theRemove = false;
+ aSelAttr->updateInHistory(theRemove);
+ if (theRemove) {
+ aRemoveSet.insert(a);
+ }
+ }
}
+ aSel->remove(aRemoveSet);
}
}
}
Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_9r-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_14f-SketchLine_16r-SketchArc_3_2r-SketchLine_15f-SketchLine_13r-SketchArc_2_2r-SketchCircle_2_2r")], model.selection(), -165, 155)
Boolean_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_2_1")])
-Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "(Fuse_1_1/Modified_Face&Extrusion_1_1/To_Face)(Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2)(Fuse_1_1/Modified_Face&Sketch_1/SketchLine_5&Sketch_2/SketchLine_7)"))
+Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "(Fuse_1_1/Modified_Face&Extrusion_1_1/To_Face)(Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2)(Fuse_1_1/Modified_Face&Sketch_2/SketchLine_7&Sketch_1/SketchLine_5)"))
SketchLine_17 = Sketch_3.addLine(145, 0, 165, 0)
-SketchProjection_2 = Sketch_3.addProjection(model.selection("VERTEX", "[Fuse_1_1/Modified_Face&Extrusion_1_1/From_Face&Sketch_2/SketchLine_6][Fuse_1_1/Modified_Face&Sketch_1/SketchLine_1&Extrusion_2_1/To_Face][Fuse_1_1/Modified_Face&Sketch_1/SketchLine_5&Sketch_2/SketchLine_7]"))
+SketchProjection_2 = Sketch_3.addProjection(model.selection("VERTEX", "[Fuse_1_1/Modified_Face&Sketch_2/SketchLine_6&Extrusion_1_1/From_Face][Fuse_1_1/Modified_Face&Extrusion_2_1/To_Face&Sketch_1/SketchLine_1][Fuse_1_1/Modified_Face&Sketch_2/SketchLine_7&Sketch_1/SketchLine_5]"))
SketchPoint_2 = SketchProjection_2.createdFeature()
SketchConstraintCoincidence_23 = Sketch_3.setCoincident(SketchLine_17.endPoint(), SketchAPI_Point(SketchPoint_2).result())
SketchLine_18 = Sketch_3.addLine(165, 0, 165, -20)
SketchConstraintCoincidence_31 = Sketch_3.setCoincident(SketchLine_19.endPoint(), SketchArc_5.center())
SketchConstraintCoincidence_32 = Sketch_3.setCoincident(SketchLine_20.result(), SketchArc_5.endPoint())
SketchConstraintCoincidence_33 = Sketch_3.setCoincident(SketchArc_5.startPoint(), SketchLine_19.result())
-SketchLine_21 = Sketch_3.addLine(model.selection("EDGE", "[Fuse_1_1/Modified_Face&Extrusion_2_1/From_Face][(Fuse_1_1/Modified_Face&Extrusion_2_1/From_Face)(Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_8)(Fuse_1_1/Modified_Face&Sketch_1/SketchLine_5&Sketch_2/SketchLine_7)]"))
+SketchLine_21 = Sketch_3.addLine(model.selection("EDGE", "[Fuse_1_1/Modified_Face&Extrusion_2_1/From_Face][(Fuse_1_1/Modified_Face&Extrusion_2_1/From_Face)(Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_8)(Fuse_1_1/Modified_Face&Sketch_2/SketchLine_7&Sketch_1/SketchLine_5)]"))
SketchConstraintTangent_5 = Sketch_3.setTangent(SketchArc_5.results()[1], SketchLine_21.result())
model.do()
-ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchArc_4_2r-SketchLine_18r-SketchLine_17r")], model.selection(), model.selection("FACE", "Fuse_1_1/Modified_Face&Sketch_1/SketchLine_2&Sketch_2/SketchLine_9"), 0, model.selection(), 0, [model.selection("SOLID", "Fuse_1_1")])
-ExtrusionFuse_1 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchArc_4_2f-SketchLine_20r-SketchArc_5_2r-SketchLine_19r")], model.selection(), model.selection("FACE", "(Fuse_1_1/Modified_Face&Extrusion_2_1/From_Face)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_2&Sketch_2/SketchLine_9)(ExtrusionCut_1_1/Generated_Face&Sketch_3/SketchArc_4_2)(ExtrusionCut_1_1/Modified_Face&Extrusion_2_1/To_Face)(Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_8)"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")])
+ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchArc_4_2r-SketchLine_18r-SketchLine_17r")], model.selection(), model.selection("FACE", "Fuse_1_1/Modified_Face&Sketch_2/SketchLine_9&Sketch_1/SketchLine_2"), 0, model.selection(), 0, [model.selection("SOLID", "Fuse_1_1")])
+ExtrusionFuse_1 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchArc_4_2f-SketchLine_20r-SketchArc_5_2r-SketchLine_19r")], model.selection(), model.selection("FACE", "(Fuse_1_1/Modified_Face&Extrusion_2_1/From_Face)(ExtrusionCut_1_1/Modified_Face&Sketch_2/SketchLine_9&Sketch_1/SketchLine_2)(ExtrusionCut_1_1/Generated_Face&Sketch_3/SketchArc_4_2)(ExtrusionCut_1_1/Modified_Face&Extrusion_2_1/To_Face)(Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_8)"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")])
model.do()
model.end()