+ // check the selected value is a part of the context
+ if (aResult && !aNewShape.IsNull() && !aContextShape.IsNull() &&
+ !aContextShape.IsSame(aNewShape)) {
+ TopoDS_Shape aNewS = aNewShape;
+ // take only sub-shape of composite for checking
+ if (aNewS.ShapeType() == TopAbs_WIRE || aNewS.ShapeType() == TopAbs_SHELL ||
+ aNewS.ShapeType() == TopAbs_COMPOUND || aNewS.ShapeType() == TopAbs_COMPSOLID) {
+ TopoDS_Iterator anIter(aNewS);
+ if (anIter.More())
+ aNewS = anIter.Value();
+ }
+ bool anIsInside = false;
+ TopExp_Explorer anExp(aContextShape, aNewS.ShapeType());
+ for (; anExp.More() && !anIsInside; anExp.Next()) {
+ if (anExp.Current().IsSame(aNewS))
+ anIsInside = true;
+ }
+ if (!anIsInside) {
+ aResult = false;
+ aNewShape.Nullify();
+ setInvalidIfFalse(aSelLab, aResult);
+ }
+ }
+