bool Model_AttributeRefList::isInitialized()
{
- if (size() == 0) { // empty list is not initialized list: sketch will be not valid after add/undo
+ if (size(false) == 0) { // empty list is not initialized list: sketch will be not valid after add/undo
return false;
}
return ModelAPI_AttributeRefList::isInitialized();
for (TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) {
if (theWithEmpty || !aLIter.Value().IsNull())
anIndex++;
- if (anIndex == theIndex)
+ if (anIndex == theIndex) {
+ if (aLIter.Value().IsNull()) { // null label => null sub
+ return ObjectPtr();
+ }
return aDoc->objects()->object(aLIter.Value());
+ }
}
}
return ObjectPtr();
void Model_ResultCompSolid::updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape)
{
+ static Events_Loop* aLoop = Events_Loop::loop();
+ static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ static Events_ID EVENT_UPD = aLoop->eventByName(EVENT_OBJECT_UPDATED);
+ static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
// iterate all sub-solids of compsolid to make sub-results synchronized with them
TopoDS_Shape aThisShape;
if (theThisShape.get()) aThisShape = theThisShape->impl<TopoDS_Shape>();
if (!aThisShape.IsNull() && (aThisShape.ShapeType() == TopAbs_COMPSOLID ||
aThisShape.ShapeType() == TopAbs_COMPOUND)) {
+ bool aWasEmpty = mySubs.empty();
Model_Objects* anObjects = std::dynamic_pointer_cast<Model_Document>(document())->objects();
unsigned int aSubIndex = 0;
TopExp_Explorer aSolids(aThisShape, TopAbs_SOLID);
}
if (!aSolidShape->isEqual(aSub->shape())) {
aSub->store(aSolidShape);
- static Events_Loop* aLoop = Events_Loop::loop();
- static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
- static Events_ID EVENT_UPD = aLoop->eventByName(EVENT_OBJECT_UPDATED);
- static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
aECreator->sendUpdated(aSub, EVENT_DISP);
aECreator->sendUpdated(aSub, EVENT_UPD);
}
anErased->setDisabled(anErased, true);
mySubs.pop_back();
}
- } else { // erase all subs
+ if (aWasEmpty) { // erase all subs
+ // redisplay this because result with and without subs are displayed differently
+ aECreator->sendUpdated(data()->owner(), EVENT_DISP);
+ }
+ } else if (!mySubs.empty()) { // erase all subs
while(!mySubs.empty()) {
ResultBodyPtr anErased = *(mySubs.rbegin());
anErased->setDisabled(anErased, true);
mySubs.pop_back();
}
+ // redisplay this because result with and without subs are displayed differently
+ aECreator->sendUpdated(data()->owner(), EVENT_DISP);
}
}