From: mpv Date: Thu, 21 May 2015 11:37:51 +0000 (+0300) Subject: Make order in enabling/disabling sub-elements of not active sketch X-Git-Tag: V_1.2.0~123^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=182ef2125296294187cf8da27dc36d6415083140;p=modules%2Fshaper.git Make order in enabling/disabling sub-elements of not active sketch --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index e5c87013e..252122719 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -570,8 +570,10 @@ void Model_Document::removeFeature(FeaturePtr theFeature) if (theFeature == currentFeature(false)) { int aCurrentIndex = index(theFeature); if (aCurrentIndex != -1) { - setCurrentFeature(std::dynamic_pointer_cast( - object(ModelAPI_Feature::group(), aCurrentIndex - 1)), false); + ObjectPtr aPrevObj; + if (aCurrentIndex != 0) + aPrevObj = object(ModelAPI_Feature::group(), aCurrentIndex - 1); + setCurrentFeature(std::dynamic_pointer_cast(aPrevObj), false); } } myObjs->removeFeature(theFeature); @@ -655,6 +657,7 @@ void Model_Document::setCurrentFeature(std::shared_ptr theCurr const bool theVisible) { TDF_Label aRefLab = generalLabel().FindChild(TAG_CURRENT_FEATURE); + CompositeFeaturePtr aMain; // main feature that may nest the new current if (theCurrent.get()) { /* if (theVisible) { // make features below which are not in history also enabled: sketch subs @@ -674,7 +677,8 @@ void Model_Document::setCurrentFeature(std::shared_ptr theCurr CompositeFeaturePtr aComposite = std::dynamic_pointer_cast((*aRefToMe)->owner()); if (aComposite.get() && aComposite->isSub(theCurrent)) { - theCurrent = aComposite; + aMain = aComposite; + break; } } @@ -695,10 +699,6 @@ void Model_Document::setCurrentFeature(std::shared_ptr theCurr static Events_Loop* aLoop = Events_Loop::loop(); static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); - // if the current feature is composite features, all sub-features also must be enabled - CompositeFeaturePtr aCurComp = std::dynamic_pointer_cast(theCurrent); - - bool aPassed = false; // flag that the current object is already passed in cycle FeaturePtr anIter = myObjs->lastFeature(); for(; anIter.get(); anIter = myObjs->nextFeature(anIter, true)) { @@ -706,7 +706,7 @@ void Model_Document::setCurrentFeature(std::shared_ptr theCurr if (anIter == theCurrent) aPassed = true; bool aDisabledFlag = !aPassed; - if (aCurComp.get() && aCurComp->isSub(anIter)) + if (aMain.get() && aMain->isSub(anIter)) aDisabledFlag = false; if (anIter->setDisabled(aDisabledFlag)) { // state of feature is changed => so feature become updated diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index e87508864..2dafa8929 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -600,6 +600,15 @@ void Model_Objects::synchronizeBackRefs() std::shared_ptr aRefData = std::dynamic_pointer_cast((*aRefTo)->data()); aRefData->addBackReference(aFeature, aRefsIter->first); // here the Concealed flag is updated + // update enable/disable status: the nested status must be equal to the composite + CompositeFeaturePtr aComp = + std::dynamic_pointer_cast(aFeature); + if (aComp.get()) { + FeaturePtr aReferenced = std::dynamic_pointer_cast(*aRefTo); + if (aReferenced.get()) { + aReferenced->setDisabled(aComp->isDisabled()); + } + } } } }