From: nds Date: Thu, 3 Nov 2016 10:09:45 +0000 (+0300) Subject: #1821 Axis by two plains: problem in selection update X-Git-Tag: V_2.6.0~122 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2e00b9d5d2a6833475ff12078e8a50bdca014119;p=modules%2Fshaper.git #1821 Axis by two plains: problem in selection update cash of temporary values should be cleared by widget deactivate --- diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index cf482e2df..1ee049900 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -181,6 +181,14 @@ void Model_AttributeSelection::setValue(const ResultPtr& theContext, owner()->data()->sendAttributeUpdated(this); } +void Model_AttributeSelection::removeTemporaryValues() +{ + if (myTmpContext.get() || myTmpSubShape.get()) { + myTmpContext.reset(); + myTmpSubShape.reset(); + } +} + std::shared_ptr Model_AttributeSelection::value() { GeomShapePtr aResult; diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index 0d329e644..720cfa79d 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -35,6 +35,9 @@ public: const ResultPtr& theContext, const std::shared_ptr& theSubShape, const bool theTemporarily = false); + /// Reset temporary stored values + virtual void removeTemporaryValues(); + /// Returns the selected subshape MODEL_EXPORT virtual std::shared_ptr value(); diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index 81ce0984c..0e3943f93 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -75,6 +75,13 @@ void Model_AttributeSelectionList::append( owner()->data()->sendAttributeUpdated(this); } +void Model_AttributeSelectionList::removeTemporaryValues() +{ + if (myTmpAttr.get()) { + myTmpAttr.reset(); + } +} + void Model_AttributeSelectionList::removeLast() { int anOldSize = mySize->Get(); diff --git a/src/Model/Model_AttributeSelectionList.h b/src/Model/Model_AttributeSelectionList.h index c3b50a3d7..0caf621b1 100644 --- a/src/Model/Model_AttributeSelectionList.h +++ b/src/Model/Model_AttributeSelectionList.h @@ -45,6 +45,9 @@ public: /// The type of shape is taken from the current selection type if the given is empty MODEL_EXPORT virtual void append(const std::string theNamingName, const std::string& theType=""); + /// Reset temporary stored values + virtual void removeTemporaryValues(); + /// Removes the last element in the list MODEL_EXPORT virtual void removeLast(); diff --git a/src/ModelAPI/ModelAPI_AttributeSelection.h b/src/ModelAPI/ModelAPI_AttributeSelection.h index 99c53b61a..cc9862d88 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelection.h +++ b/src/ModelAPI/ModelAPI_AttributeSelection.h @@ -27,6 +27,9 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute const ResultPtr& theContext, const std::shared_ptr& theSubShape, const bool theTemporarily = false) = 0; + /// Reset temporary stored values + virtual void removeTemporaryValues() = 0; + /// Returns the selected subshape virtual std::shared_ptr value() = 0; diff --git a/src/ModelAPI/ModelAPI_AttributeSelectionList.h b/src/ModelAPI/ModelAPI_AttributeSelectionList.h index aa2e72915..c5fe4c934 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelectionList.h +++ b/src/ModelAPI/ModelAPI_AttributeSelectionList.h @@ -32,6 +32,9 @@ class ModelAPI_AttributeSelectionList : public ModelAPI_Attribute /// The type of shape is taken from the current selection type if the given is empty virtual void append(const std::string theNamingName, const std::string& theType = "") = 0; + /// Reset temporary stored values + virtual void removeTemporaryValues() = 0; + /// Removes the last element in the list virtual void removeLast() = 0; diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index 7e0eb3f0f..fda60cc0e 100755 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -19,6 +19,8 @@ #include #include +#include +#include #include @@ -204,7 +206,20 @@ void ModuleBase_WidgetSelector::deactivate() ModuleBase_ModelWidget::deactivate(); disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); activateSelectionAndFilters(false); - ModuleBase_ModelWidget::deactivate(); + + /// clear temporary cash + AttributePtr anAttribute = attribute(); + std::string aType = anAttribute->attributeType(); + if (anAttribute->attributeType() == ModelAPI_AttributeSelection::typeId()) { + AttributeSelectionPtr aSelectAttr = + std::dynamic_pointer_cast(anAttribute); + aSelectAttr->removeTemporaryValues(); + } + else if (anAttribute->attributeType() == ModelAPI_AttributeSelectionList::typeId()) { + AttributeSelectionListPtr aSelectAttr = + std::dynamic_pointer_cast(anAttribute); + aSelectAttr->removeTemporaryValues(); + } } //********************************************************************