#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Tools.h>
+#include <ModelAPI_ResultBody.h>
#include <Config_WidgetAPI.h>
#include <Events_Error.h>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <list>
-#include <stdexcept>
-#include <xstring>
+#include <string>
typedef QMap<QString, TopAbs_ShapeEnum> ShapeTypes;
static ShapeTypes MyShapeTypes;
boost::shared_ptr<ModelAPI_AttributeSelection> aSelect =
boost::dynamic_pointer_cast<ModelAPI_AttributeSelection>(aData->attribute(attributeID()));
- ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(mySelectedObject);
- if (aBody)
+ ResultPtr aBody = boost::dynamic_pointer_cast<ModelAPI_Result>(mySelectedObject);
+ if (aBody) {
aSelect->setValue(aBody, myShape);
+ updateObject(myFeature);
+ return true;
+ }
} else {
boost::shared_ptr<ModelAPI_AttributeReference> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(aData->attribute(attributeID()));
if (!(aObject && aObject->isSame(mySelectedObject))) {
aRef->setValue(mySelectedObject);
updateObject(myFeature);
+ return true;
}
}
- return true;
+ return false;
}
//********************************************************************
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;
- myWorkshop->selection()->selectedShapes(aShapeList);
+ std::list<ObjectPtr> aOwners;
+ myWorkshop->selection()->selectedShapes(aShapeList, aOwners);
if (aShapeList.Extent() > 0) {
aShape = boost::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
aShape->setImpl(new TopoDS_Shape(aShapeList.First()));
if (!myUseSubShapes) {
static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TOHIDE);
ModelAPI_EventCreator::get()->sendUpdated(mySelectedObject, anEvent);
- Events_Loop::loop()->flush(anEvent);
}
}
updateSelectionName();