ObjectPtr aObject = aObjects.first();
if ((!mySelectedObject) && (!aObject))
return;
+ // Check that object is not already selected
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;
+
+ if (myFeature) {
+ // We can not select a result of our feature
+ const std::list<boost::shared_ptr<ModelAPI_Result>>& aResList = myFeature->results();
+ std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aIt;
+ for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) {
+ if ((*aIt) == aRes)
+ return;
+ }
+ }
+ // Check that object belongs to active document or PartSet
+ DocumentPtr aDoc = aRes->document();
+ SessionPtr aMgr = ModelAPI_Session::get();
+ if (!(aDoc == aMgr->activeDocument()) || (aDoc == aMgr->moduleDocument()))
+ return;
+
// Check that the result has a shape
GeomShapePtr aShape = ModelAPI_Tools::shape(aRes);
if (!aShape)
return;
}
setObject(aObject, aShape);
+ activateSelection(false);
emit focusOutWidget(this);
}
}
bool ModuleBase_WidgetShapeSelector::isAccepted(const ObjectPtr theResult) const
{
ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theResult);
- if (myFeature) {
- // We can not select a result of our feature
- const std::list<boost::shared_ptr<ModelAPI_Result>>& aRes = myFeature->results();
- std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aIt;
- for (aIt = aRes.cbegin(); aIt != aRes.cend(); ++aIt) {
- if ((*aIt) == aResult)
- return false;
- }
- }
- // Check that object belongs to active document or PartSet
- DocumentPtr aDoc = aResult->document();
- SessionPtr aMgr = ModelAPI_Session::get();
- if (!(aDoc == aMgr->activeDocument()) || (aDoc == aMgr->moduleDocument()))
- return false;
// Check that the shape of necessary type
boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);