//********************************************************************
bool ModuleBase_WidgetMultiSelector::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
{
- const TopoDS_Shape& aTDSShape = thePrs.shape();
- if (aTDSShape.IsNull())
- return false;
- GeomShapePtr aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
- aShape->setImpl(new TopoDS_Shape(aTDSShape));
+ ResultPtr aResult;
+ if (!thePrs.owner().IsNull()) {
+ ObjectPtr anObject = myWorkshop->selection()->getSelectableObject(thePrs.owner());
+ aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+ }
+ else {
+ aResult = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs.object());
+ }
+
- ObjectPtr anObject = myWorkshop->selection()->getSelectableObject(thePrs.owner());
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (myFeature) {
// We can not select a result of our feature
const std::list<ResultPtr>& aResList = myFeature->results();
DataPtr aData = myFeature->data();
AttributeSelectionListPtr aSelectionListAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
- if (aShape->isEqual(aResult->shape()))
- aSelectionListAttr->append(aResult, GeomShapePtr());
- else
- aSelectionListAttr->append(aResult, aShape);
+ const TopoDS_Shape& aTDSShape = thePrs.shape();
+ // if only result is selected, an empty shape is set to the model
+ if (aTDSShape.IsNull()) {
+ aSelectionListAttr->append(aResult, GeomShapePtr());
+ }
+ else {
+ GeomShapePtr aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(aTDSShape));
+ // We can not select a result of our feature
+ if (aShape->isEqual(aResult->shape()))
+ aSelectionListAttr->append(aResult, GeomShapePtr());
+ else
+ aSelectionListAttr->append(aResult, aShape);
+ }
return true;
}
{
activateShapeSelection();
QObjectPtrList anEmptyList;
+ // This method will call Selection changed event which will call onSelectionChanged
+ // To clear mySelection, myListControl and storeValue()
+ // So, we don't need to call it
myWorkshop->setSelected(anEmptyList);
- // Clear mySelection, myListControl and storeValue()
- onSelectionChanged();
}
//********************************************************************
void ModuleBase_WidgetMultiSelector::onSelectionChanged()
{
- QList<ModuleBase_ViewerPrs> aSelected = myWorkshop->selection()->getSelected();
+ QList<ModuleBase_ViewerPrs> aSelected = getSelectedEntitiesOrObjects(myWorkshop->selection());
DataPtr aData = myFeature->data();
AttributeSelectionListPtr aSelectionListAttr =