From: mpv Date: Thu, 18 Dec 2014 12:21:01 +0000 (+0300) Subject: Fix for the placement issue: limit the scope of the naming selection by the current... X-Git-Tag: V_0.7.0_rc1~68 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e54c40f3e8b7b29298cc61d52b29bdb5c0252d69;p=modules%2Fshaper.git Fix for the placement issue: limit the scope of the naming selection by the current feature history --- diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index d708eecd4..16c6a25bf 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include using namespace std; /// adeed to the index in the packed map to signalize that the vertex of edge is seleted @@ -104,6 +106,29 @@ void Model_AttributeSelection::setObject(const std::shared_ptr& myRef.setObject(theObject); } +TDF_LabelMap& Model_AttributeSelection::scope() +{ + if (myScope.IsEmpty()) { // create a new scope if not yet done + // gets all labels with named shapes that are bofore this feature label (before in history) + TDF_Label aFeatureLab = std::dynamic_pointer_cast( + owner()->data())->label().Father(); + int aFeatureID = aFeatureLab.Tag(); + TDF_ChildIterator aFeaturesIter(aFeatureLab.Father()); + for(; aFeaturesIter.More(); aFeaturesIter.Next()) { + if (aFeaturesIter.Value().Tag() >= aFeatureID) // the left labels are created later + break; + TDF_ChildIDIterator aNSIter(aFeaturesIter.Value(), TNaming_NamedShape::GetID(), 1); + for(; aNSIter.More(); aNSIter.Next()) { + Handle(TNaming_NamedShape) aNS = Handle(TNaming_NamedShape)::DownCast(aNSIter.Value()); + if (!aNS.IsNull() && aNS->Evolution() != TNaming_SELECTED) { + myScope.Add(aNS->Label()); + } + } + } + } + return myScope; +} + bool Model_AttributeSelection::update() { ResultPtr aContext = context(); @@ -111,8 +136,7 @@ bool Model_AttributeSelection::update() if (aContext->groupName() == ModelAPI_ResultBody::group()) { // body: just a named shape, use selection mechanism from OCCT TNaming_Selector aSelector(selectionLabel()); - TDF_LabelMap aScope; // empty means the whole document - bool aResult = aSelector.Solve(aScope) == Standard_True; + bool aResult = aSelector.Solve(scope()) == Standard_True; owner()->data()->sendAttributeUpdated(this); return aResult; } else if (aContext->groupName() == ModelAPI_ResultConstruction::group()) { diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index 801a69e51..bc6933d39 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -10,6 +10,7 @@ #include "Model.h" #include "Model_AttributeReference.h" #include +#include /**\class Model_AttributeSelection * \ingroup DataModel @@ -19,6 +20,7 @@ class Model_AttributeSelection : public ModelAPI_AttributeSelection { Model_AttributeReference myRef; ///< The reference functionality reusage + TDF_LabelMap myScope; ///< the map of valid labels for naming selection solving public: /// Defines the result and its selected sub-shape MODEL_EXPORT virtual void setValue( @@ -53,6 +55,9 @@ protected: /// Note: there must be no attributes stored at the same label because Selector clears this lab TDF_Label selectionLabel(); + /// Returns the prepared map of valid labels for naming selection solving (creates if not exists) + TDF_LabelMap& scope(); + friend class Model_Data; friend class Model_AttributeSelectionList; };