* Improve AttributeSelectionList to cash whole selected features as well as the results.
* Avoid sending EVENT_UPDATE_SELECTION until all the features will obtain their "disabled" flag.
bool GeomAPI_Shape::isSame(const std::shared_ptr<GeomAPI_Shape> theShape) const
{
- if (!theShape.get())
- return false;
+ bool isNullShape = !theShape.get() || theShape->isNull();;
if (isNull())
- return theShape->isNull();
- if (theShape->isNull())
+ return isNullShape;
+ if (isNullShape)
return false;
return MY_SHAPE->IsSame(theShape->impl<TopoDS_Shape>()) == Standard_True;
}
if (myIsCashed && !theTemporarily) {
- ResultPtr aResContext = std::dynamic_pointer_cast<ModelAPI_Result>(theContext);
- if (aResContext.get())
- myCash[aResContext].push_back(theSubShape);
+ myCash[theContext].push_back(theSubShape);
}
int aNewTag = mySize->Get() + 1;
if (!aShapes->get())
return true;
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aContext->first);
- if (aRes.get() && (*aShapes)->isSame(aRes->shape()))
+ FeaturePtr aFeat = std::dynamic_pointer_cast<ModelAPI_Feature>(aContext->first);
+ if ((aRes.get() && (*aShapes)->isSame(aRes->shape())) || aFeat.get())
return true;
} else {
// we need to call here isSame instead of isEqual to do not check shapes orientation
for(int anIndex = size() - 1; anIndex >= 0; anIndex--) {
AttributeSelectionPtr anAttr = value(anIndex);
if (anAttr.get()) {
- myCash[anAttr->context()].push_back(anAttr->value());
+ myCash[anAttr->contextObject()].push_back(anAttr->value());
}
}
}
myIsSetCurrentFeature = false;
// unblock the flush signals and up them after this
aLoop->activateFlushes(isActive);
+
+ static Events_ID kUpdatedSel = aLoop->eventByName(EVENT_UPDATE_SELECTION);
+ aLoop->flush(kUpdatedSel);
}
void Model_Document::setCurrentFeatureUp()
(*aResIter)->setDisabled(*aResIter, false);
}
// update selection for the case something was updated higher in the history
- // while this feature was disabled
+ // while this feature was disabled, but avoid flushing it immediately and
+ // wait while all the previous features update myIsDisabled flag
+ // (flush will be called by the document)
static Events_Loop* aLoop = Events_Loop::loop();
static Events_ID kUpdatedSel = aLoop->eventByName(EVENT_UPDATE_SELECTION);
static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
- aECreator->sendUpdated(data()->owner(), kUpdatedSel, false);
+ aECreator->sendUpdated(data()->owner(), kUpdatedSel, true);
}
return true;
}
if (aType == ModelAPI_AttributeSelectionList::typeId()) {
AttributeSelectionListPtr aSelectionListAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
- aHasObject = aSelectionListAttr->isInList(aResult, theShape, theTemporarily);
+ aHasObject = aSelectionListAttr->isInList(theObject, theShape, theTemporarily);
}
else if (aType == ModelAPI_AttributeRefList::typeId()) {
AttributeRefListPtr aRefListAttr =
AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
for (int i = 0; i < aSelectionListAttr->size(); i++) {
AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
- //aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->contextObject());
- //if (!aFeature.get()) { // Feature can not be found as geometry selection
- bool aFound = findInSelection(
- anAttr->contextObject(), anAttr->value(), aGeomSelection, myWorkshop);
- if (!aFound)
- anIndicesToBeRemoved.insert(i);
-// }
+ ObjectPtr aContextObject = anAttr->contextObject();
+ GeomShapePtr aShape;
+ aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aContextObject);
+ if (!aFeature.get())
+ aShape = anAttr->value();
+
+ bool aFound = findInSelection(aContextObject, aShape, aGeomSelection, myWorkshop);
+ if (!aFound)
+ anIndicesToBeRemoved.insert(i);
}
isDone = anIndicesToBeRemoved.size() > 0;
if (isDone)