Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetShapeSelector.cpp
index 1de73631a75a822059f694ee04595d6f7d59c3e3..bd5e54e707b51b445aeeaad5f50eb4cac305047b 100644 (file)
@@ -23,6 +23,7 @@
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_ResultBody.h>
 #include <Config_WidgetAPI.h>
 #include <Events_Error.h>
 
@@ -46,8 +47,7 @@
 #include <boost/smart_ptr/shared_ptr.hpp>
 
 #include <list>
-#include <stdexcept>
-#include <xstring>
+#include <string>
 
 typedef QMap<QString, TopAbs_ShapeEnum> ShapeTypes;
 static ShapeTypes MyShapeTypes;
@@ -189,9 +189,16 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged()
       return;
     if (mySelectedObject && aObject && mySelectedObject->isSame(aObject))
       return;
+    // Check that the selected object is result (others can not be accepted)
+    ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+    if (!aRes)
+      return;
+    // Check that the result has a shape
+    GeomShapePtr aShape = ModelAPI_Tools::shape(aRes);
+    if (!aShape)
+      return;
 
     // Get sub-shapes from local selection
-    boost::shared_ptr<GeomAPI_Shape> aShape;
     if (myUseSubShapes) {
       NCollection_List<TopoDS_Shape> aShapeList;
       std::list<ObjectPtr> aOwners;