+ return aShapeTypes;
+}
+
+//********************************************************************
+QList<ModuleBase_ViewerPrsPtr> ModuleBase_WidgetSelector::getAttributeSelection() const
+{
+ return QList<ModuleBase_ViewerPrsPtr>();
+}
+
+//********************************************************************
+bool ModuleBase_WidgetSelector::acceptSubShape(const GeomShapePtr& theShape,
+ const ResultPtr& theResult) const
+{
+ bool aValid = false;
+
+ GeomShapePtr aShape = theShape;
+
+ QIntList aShapeTypes = getShapeTypes();
+ if (aShapeTypes.empty()) {
+ aValid = true;
+ return aValid;
+ }
+ // when the SHAPE type is provided by XML as Object, the whole result shape should be selected.
+ //if (!aShape.get() && aShapeTypes.contains(ModuleBase_ResultPrs::Sel_Result)) {
+ // In case of selection of a feature aShape could be not NULL, but result has to be selected
+ if (aShapeTypes.contains(ModuleBase_ResultPrs::Sel_Result)) {
+ aValid = true;
+ return aValid;
+ }
+
+ if (!aShape.get() && theResult.get()) {
+ if (theResult.get())
+ aShape = theResult->shape();
+ }
+ TopAbs_ShapeEnum aShapeType = TopAbs_SHAPE;
+ if (aShape.get()) {
+ // Check that the selection corresponds to selection type
+ TopoDS_Shape aTopoShape = aShape->impl<TopoDS_Shape>();
+ if (!aTopoShape.IsNull()) {
+ aShapeType = aTopoShape.ShapeType();
+ // for compounds check sub-shapes: it may be compound of needed type:
+ // Booleans may produce compounds of Solids
+ if (aShapeType == TopAbs_COMPOUND) {
+ aShapeType = ModuleBase_Tools::getCompoundSubType(aTopoShape);
+ }
+ }
+ }
+
+ QIntList::const_iterator anIt = aShapeTypes.begin(), aLast = aShapeTypes.end();
+ for (; anIt != aLast && !aValid; anIt++) {
+ TopAbs_ShapeEnum aCurrentShapeType = (TopAbs_ShapeEnum)*anIt;
+ if (aShapeType == aCurrentShapeType)
+ aValid = true;
+ else if (aCurrentShapeType == 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;
+ }