From 479c515ea902e70caef5c4a37a1fefe0e198e381 Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 29 Jul 2019 13:43:30 +0300 Subject: [PATCH] Issue #2956: Use removeTemporaryValues method instead of reset. --- src/Model/Model_AttributeSelection.cpp | 20 ++++++++++++------- src/Model/Model_AttributeSelection.h | 2 +- src/ModuleBase/ModuleBase_WidgetValidated.cpp | 9 +++++++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 88a1610d5..e9c92ad53 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -103,10 +103,9 @@ const static std::string kWHOLE_FEATURE = "all-in-"; bool Model_AttributeSelection::setValue(const ObjectPtr& theContext, const std::shared_ptr& theSubShape, const bool theTemporarily) { - if (theTemporarily && - (!theContext.get() || theContext->groupName() != ModelAPI_Feature::group())) { + if (theTemporarily) { // just keep the stored without DF update - myTmpContext = std::dynamic_pointer_cast(theContext); + myTmpContext = theContext; myTmpSubShape = theSubShape; owner()->data()->sendAttributeUpdated(this); return true; @@ -313,7 +312,14 @@ std::shared_ptr Model_AttributeSelection::internalValue(CenterTyp // it is just reference to construction. return myTmpSubShape; } - return myTmpSubShape.get() ? myTmpSubShape : myTmpContext->shape(); + FeaturePtr aFeature = + std::dynamic_pointer_cast(myTmpContext); + if (aFeature.get()) { + // it is just reference to construction. + return myTmpSubShape; + } + return myTmpSubShape.get() ? myTmpSubShape : + std::dynamic_pointer_cast(myTmpContext)->shape(); } TDF_Label aSelLab = selectionLabel(); @@ -465,7 +471,7 @@ ResultPtr Model_AttributeSelection::context() return ResultPtr(); if (myTmpContext.get() || myTmpSubShape.get()) { - return myTmpContext; + return std::dynamic_pointer_cast(myTmpContext); } ResultPtr aResult = std::dynamic_pointer_cast(myRef.value()); @@ -495,8 +501,8 @@ ResultPtr Model_AttributeSelection::context() } FeaturePtr Model_AttributeSelection::contextFeature() { - if (myTmpContext.get() || myTmpSubShape.get()) { - return FeaturePtr(); // feature can not be selected temporarily + if (myTmpContext.get()) { + return std::dynamic_pointer_cast(myTmpContext); } return std::dynamic_pointer_cast(myRef.value()); } diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index 1896caa01..c3721e994 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -40,7 +40,7 @@ class Model_AttributeSelection : public ModelAPI_AttributeSelection, { Model_AttributeReference myRef; ///< The reference functionality re-usage /// temporarily storages to avoid keeping in the data structure if not needed - ResultPtr myTmpContext; + ObjectPtr myTmpContext; /// temporarily storages to avoid keeping in the data structure if not needed std::shared_ptr myTmpSubShape; /// temporarily storages to avoid keeping in the data structure if not needed diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index 7740f17f5..3664c25c1 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -141,7 +141,7 @@ bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrsPtr& } else aValid = false; - aSelectAttr->setValue(ObjectPtr(), GeomShapePtr(), true); + //aSelectAttr->setValue(ObjectPtr(), GeomShapePtr(), true); } else { ResultPtr aResult = aFeature->firstResult(); @@ -200,7 +200,12 @@ bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrsPtr& if (!aValid) { // Clear attribute if it still has selection AttributePtr anAttr = attribute(); - anAttr->reset(); + std::string aType = anAttr->attributeType(); + if (aType == ModelAPI_AttributeSelection::typeId()) { + AttributeSelectionPtr aSelectAttr = + std::dynamic_pointer_cast(anAttr); + aSelectAttr->removeTemporaryValues(); + } } return aValid; } -- 2.39.2