- if (ModuleBase_ShapeDocumentFilter::IsOk(theOwner)) {
- if (theOwner->HasSelectable()) {
- Handle(AIS_InteractiveObject) aAisObj =
- Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
- if (!aAisObj.IsNull()) {
- std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
- aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
- ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
- if (aObj) {
+ bool aValid = true;
+ ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation();
+ // the shapes from different documents should be provided if there is no started operation
+ // in order to show/hide results
+ if (anOperation) {
+ aValid = false;
+ if (ModuleBase_ShapeDocumentFilter::IsOk(theOwner)) {
+ std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+ if (theOwner->HasSelectable()) {
+ Handle(AIS_InteractiveObject) aAisObj =
+ Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+ if (!aAisObj.IsNull()) {
+ aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
+ }
+ }
+ ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
+ if (aObj) {
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+ // result of parts belongs to PartSet document and can be selected only when PartSet is active
+ // in order to do not select the result of the active part.
+ if (aResult.get() && aResult->groupName() == ModelAPI_ResultPart::group()) {
+ SessionPtr aMgr = ModelAPI_Session::get();
+ aValid = aMgr->activeDocument() == aMgr->moduleDocument();
+ }
+ else {