X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeSelectionList.cpp;h=9fb4124075eac962de1a6d8b15a7770541194003;hb=88be48ed1ea478b9d9d6ac2d965092418ef4dae6;hp=5207a112024deb535b0e860b5e072f7b7dea05e5;hpb=1c530eba1d76c012cfc61df1c21694e62f203d94;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index 5207a1120..9fb412407 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -24,6 +24,7 @@ #include "Model_Events.h" #include "Model_Data.h" +#include #include #include @@ -41,7 +42,7 @@ #include void Model_AttributeSelectionList::append( - const ResultPtr& theContext, const std::shared_ptr& theSubShape, + const ObjectPtr& theContext, const std::shared_ptr& theSubShape, const bool theTemporarily) { // do not use the degenerated edge as a shape, a list is not incremented in this case @@ -53,7 +54,9 @@ void Model_AttributeSelectionList::append( } if (myIsCashed && !theTemporarily) { - myCash[theContext].push_back(theSubShape); + ResultPtr aResContext = std::dynamic_pointer_cast(theContext); + if (aResContext.get()) + myCash[aResContext].push_back(theSubShape); } int aNewTag = mySize->Get() + 1; @@ -76,7 +79,7 @@ void Model_AttributeSelectionList::append( } void Model_AttributeSelectionList::append( - const std::string theNamingName, const std::string& theType) + const std::string& theNamingName, const std::string& theType) { int aNewTag = mySize->Get() + 1; TDF_Label aNewLab = mySize->Label().FindChild(aNewTag); @@ -93,6 +96,41 @@ void Model_AttributeSelectionList::append( owner()->data()->sendAttributeUpdated(this); } +void Model_AttributeSelectionList::append(const GeomPointPtr& thePoint, const std::string& theType) +{ + int aNewTag = mySize->Get() + 1; + TDF_Label aNewLab = mySize->Label().FindChild(aNewTag); + + std::shared_ptr aNewAttr = + std::shared_ptr(new Model_AttributeSelection(aNewLab)); + if (owner()) { + aNewAttr->setObject(owner()); + aNewAttr->setParent(this); + } + aNewAttr->setID(id()); + mySize->Set(aNewTag); + aNewAttr->selectSubShape(theType, thePoint); + owner()->data()->sendAttributeUpdated(this); +} + +void Model_AttributeSelectionList::append(const std::string& theType, + const std::string& theContextName, const int theIndex) +{ + int aNewTag = mySize->Get() + 1; + TDF_Label aNewLab = mySize->Label().FindChild(aNewTag); + + std::shared_ptr aNewAttr = + std::shared_ptr(new Model_AttributeSelection(aNewLab)); + if (owner()) { + aNewAttr->setObject(owner()); + aNewAttr->setParent(this); + } + aNewAttr->setID(id()); + mySize->Set(aNewTag); + aNewAttr->selectSubShape(theType, theContextName, theIndex); + owner()->data()->sendAttributeUpdated(this); +} + void Model_AttributeSelectionList::removeTemporaryValues() { if (myTmpAttr.get()) { @@ -225,28 +263,31 @@ int Model_AttributeSelectionList::size() return mySize->Get(); } -bool Model_AttributeSelectionList::isInList(const ResultPtr& theContext, +bool Model_AttributeSelectionList::isInList(const ObjectPtr& theContext, const std::shared_ptr& theSubShape, const bool theTemporarily) { + ResultPtr aResCont = std::dynamic_pointer_cast(theContext); if (myIsCashed) { // the cashing is active - std::map > >::iterator aContext = - myCash.find(theContext); - if (aContext != myCash.end()) { - // iterate shapes because "isSame" method must be called for each shape - std::list >::iterator aShapes = aContext->second.begin(); - for(; aShapes != aContext->second.end(); aShapes++) { - if (!theSubShape.get()) { - if (!aShapes->get() || (*aShapes)->isSame(aContext->first->shape())) - return true; - } else { - // we need to call here isSame instead of isEqual to do not check shapes orientation - if (theSubShape->isSame(*aShapes)) - return true; + if (aResCont.get()) { + std::map > >::iterator aContext = + myCash.find(aResCont); + if (aContext != myCash.end()) { + // iterate shapes because "isSame" method must be called for each shape + std::list >::iterator aShapes = aContext->second.begin(); + for(; aShapes != aContext->second.end(); aShapes++) { + if (!theSubShape.get()) { + if (!aShapes->get() || (*aShapes)->isSame(aContext->first->shape())) + return true; + } else { + // we need to call here isSame instead of isEqual to do not check shapes orientation + if (theSubShape->isSame(*aShapes)) + return true; + } } } + return false; } - return false; } // no-cash method for(int anIndex = size() - 1; anIndex >= 0; anIndex--) { @@ -255,7 +296,7 @@ bool Model_AttributeSelectionList::isInList(const ResultPtr& theContext, if (anAttr->context() == theContext) { // contexts are equal, so, check that values are also std::shared_ptr aValue = anAttr->value(); if (!theSubShape.get()) { - if (!aValue.get() || aValue->isSame(theContext->shape())) { // both are null + if (!aValue.get() || (aResCont.get() && aValue->isSame(aResCont->shape()))) {// both null return true; } } else {