From: mpv Date: Wed, 1 Jul 2015 08:06:32 +0000 (+0300) Subject: Added ability to deselect objects on edit in Boolean operation and reselect them... X-Git-Tag: V_1.3.0~142 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5a0c0a41e24da95c81aee2e110f655fc721dfbb8;p=modules%2Fshaper.git Added ability to deselect objects on edit in Boolean operation and reselect them once again: immediately remove the concealment flag --- diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index 3b67df9eb..ae079d7a1 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -96,7 +96,15 @@ void Model_AttributeSelectionList::clear() mySize->Set(0); TDF_ChildIterator aSubIter(mySize->Label()); for(; aSubIter.More(); aSubIter.Next()) { - aSubIter.Value().ForgetAllAttributes(Standard_True); + TDF_Label aLab = aSubIter.Value(); + std::shared_ptr aNewAttr = + std::shared_ptr(new Model_AttributeSelection(aLab)); + if (owner()) { + aNewAttr->setObject(owner()); + } + REMOVE_BACK_REF(aNewAttr->context()); + + aLab.ForgetAllAttributes(Standard_True); } owner()->data()->sendAttributeUpdated(this); } diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 4546128eb..ae09db9b0 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -321,6 +321,31 @@ void Model_Data::removeBackReference(FeaturePtr theFeature, std::string theAttrI return; myRefsToMe.erase(anAttribute); + + // remove concealment immideately: on deselection it must be posible to reselect in GUI the same + if (ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) { + std::set::iterator aRefsIter = myRefsToMe.begin(); + for(; aRefsIter != myRefsToMe.end(); aRefsIter++) { + if (aRefsIter->get()) { + FeaturePtr aFeature = std::dynamic_pointer_cast((*aRefsIter)->owner()); + if (aFeature.get()) { + if (ModelAPI_Session::get()->validators()->isConcealed( + aFeature->getKind(), (*aRefsIter)->id())) { + return; // it is still concealed, nothing to do + } + } + } + } + // thus, no concealment references anymore => make not-concealed + std::shared_ptr aRes = + std::dynamic_pointer_cast(myObject); + if (aRes.get()) { + aRes->setIsConcealed(false); + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); + ModelAPI_EventCreator::get()->sendUpdated(aRes, anEvent); + Events_Loop::loop()->flush(anEvent); + } + } } void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID, diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h index fba3cd500..9b46312b8 100644 --- a/src/Model/Model_Data.h +++ b/src/Model/Model_Data.h @@ -69,6 +69,7 @@ class Model_Data : public ModelAPI_Data friend class Model_AttributeRefAttr; friend class Model_AttributeRefList; friend class Model_AttributeSelection; + friend class Model_AttributeSelectionList; public: /// The simplest constructor. "setLabel" must be called just after to initialize correctly. diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 5d27392b9..1361a931a 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -339,10 +339,9 @@ ObjectPtr Model_Objects::object(TDF_Label theLabel) ObjectPtr Model_Objects::object(const std::string& theGroupID, const int theIndex) { - createHistory(theGroupID); - //TODO: mpv stabilization hotfix - if (myHistory[theGroupID].size() <= (const unsigned int)theIndex) + if (theIndex == -1) return ObjectPtr(); + createHistory(theGroupID); return myHistory[theGroupID][theIndex]; }