- else {
- aValid = false;
- TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
- QIntList aShapeTypes = getShapeTypes();
-
- QIntList::const_iterator anIt = aShapeTypes.begin(), aLast = aShapeTypes.end();
- for (; anIt != aLast; anIt++) {
- if (aShapeType == *anIt)
- aValid = true;
+ TopAbs_ShapeEnum aShapeType = TopAbs_SHAPE;
+ if (aShape.get()) {
+ // Check that the selection corresponds to selection type
+ TopoDS_Shape aTopoShape = aShape->impl<TopoDS_Shape>();
+ aShapeType = aTopoShape.ShapeType();
+ }
+
+ QIntList aShapeTypes = getShapeTypes();
+ QIntList::const_iterator anIt = aShapeTypes.begin(), aLast = aShapeTypes.end();
+ for (; anIt != aLast; anIt++) {
+ if (aShapeType == *anIt)
+ aValid = true;
+ else if (*anIt == TopAbs_FACE) {
+ // try to process the construction shape only if there is no a selected shape in the viewer
+ if (!theShape.get() && theResult.get()) {
+ ResultConstructionPtr aCResult =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult);
+ aValid = aCResult.get() && aCResult->facesNum() > 0;
+ }