X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_FeatureValidator.cpp;h=9f3ab4a1305e9dd08e70a551a58eb4c160c10eb4;hb=d4a163b94d27eddb09d6bbe1cec96c9c25042282;hp=dd28371d775ffb84868fe277c2a7d6f6e7ca94b8;hpb=0ae9b65878cc8fef5e30a35d9917faee46c4257d;p=modules%2Fshaper.git diff --git a/src/Model/Model_FeatureValidator.cpp b/src/Model/Model_FeatureValidator.cpp index dd28371d7..9f3ab4a13 100644 --- a/src/Model/Model_FeatureValidator.cpp +++ b/src/Model/Model_FeatureValidator.cpp @@ -9,22 +9,43 @@ #include #include -#include +#include -bool Model_FeatureValidator::isValid(const boost::shared_ptr& theFeature, +bool Model_FeatureValidator::isValid(const std::shared_ptr& theFeature, const std::list& theArguments) const { - boost::shared_ptr aData = theFeature->data(); - if (!aData) - return false; + std::shared_ptr aData = theFeature->data(); + // "Action" features has no data, but still valid. e.g "Remove Part" + if (!aData) { + return theFeature->isAction(); + } if (!aData->isValid()) return false; const std::string kAllTypes = ""; - std::list aLtAttributes = aData->attributes(kAllTypes); - std::list::iterator it = aLtAttributes.begin(); + std::list aLtAttributes = aData->attributesIDs(kAllTypes); + std::list::iterator it = aLtAttributes.begin(); for (; it != aLtAttributes.end(); it++) { - if (!(*it)->isInitialized()) - return false; + AttributePtr anAttr = aData->attribute(*it); + if (!anAttr->isInitialized()) { + std::map >::const_iterator aFeatureFind = + myNotObligatory.find(theFeature->getKind()); + if (aFeatureFind == myNotObligatory.end() || + aFeatureFind->second.find(*it) == aFeatureFind->second.end()) { + return false; + } + } } return true; } + +void Model_FeatureValidator::registerNotObligatory(std::string theFeature, std::string theAttribute) +{ + std::set& anAttrs = myNotObligatory[theFeature]; + anAttrs.insert(theAttribute); +} + +bool Model_FeatureValidator::isNotObligatory(std::string theFeature, std::string theAttribute) +{ + std::set& anAttrs = myNotObligatory[theFeature]; + return anAttrs.find(theAttribute) != anAttrs.end(); +}