From f89745134c4ef9681dddbcf7ac5ab2a25d4831da Mon Sep 17 00:00:00 2001 From: mpv Date: Fri, 21 Aug 2015 10:56:56 +0300 Subject: [PATCH] Send "redisplay" signal when compsolid result become alone or with sub-elements --- src/Model/Model_AttributeRefList.cpp | 8 ++++++-- src/Model/Model_ResultCompSolid.cpp | 17 ++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Model/Model_AttributeRefList.cpp b/src/Model/Model_AttributeRefList.cpp index b29612521..bb9fa83e2 100644 --- a/src/Model/Model_AttributeRefList.cpp +++ b/src/Model/Model_AttributeRefList.cpp @@ -75,7 +75,7 @@ int Model_AttributeRefList::size(const bool theWithEmpty) const 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(); @@ -128,8 +128,12 @@ ObjectPtr Model_AttributeRefList::object(const int theIndex, const bool theWithE 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(); diff --git a/src/Model/Model_ResultCompSolid.cpp b/src/Model/Model_ResultCompSolid.cpp index 45dc68ae5..5209b2d68 100755 --- a/src/Model/Model_ResultCompSolid.cpp +++ b/src/Model/Model_ResultCompSolid.cpp @@ -109,11 +109,16 @@ bool Model_ResultCompSolid::isConcealed() void Model_ResultCompSolid::updateSubs(const std::shared_ptr& 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(); if (!aThisShape.IsNull() && (aThisShape.ShapeType() == TopAbs_COMPSOLID || aThisShape.ShapeType() == TopAbs_COMPOUND)) { + bool aWasEmpty = mySubs.empty(); Model_Objects* anObjects = std::dynamic_pointer_cast(document())->objects(); unsigned int aSubIndex = 0; TopExp_Explorer aSolids(aThisShape, TopAbs_SOLID); @@ -129,10 +134,6 @@ void Model_ResultCompSolid::updateSubs(const std::shared_ptr& the } 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); } @@ -144,11 +145,17 @@ void Model_ResultCompSolid::updateSubs(const std::shared_ptr& the 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); } } -- 2.39.2