X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_FeatureValidator.cpp;h=b34f03edd8f69c946d24c9e2c827f8e6db71309c;hb=d44d8df10835d69a2616b426a8529fcf5555c9cd;hp=b4b4fb8cc975a6e0a1ea0ee138d3e9a2f5b859e8;hpb=542c9d721fbef80eb2040ef248fdd431cad2e631;p=modules%2Fshaper.git diff --git a/src/Model/Model_FeatureValidator.cpp b/src/Model/Model_FeatureValidator.cpp index b4b4fb8cc..b34f03edd 100644 --- a/src/Model/Model_FeatureValidator.cpp +++ b/src/Model/Model_FeatureValidator.cpp @@ -9,19 +9,43 @@ #include #include -#include +#include -bool Model_FeatureValidator::isValid(const boost::shared_ptr& theFeature) const +bool Model_FeatureValidator::isValid(const std::shared_ptr& theFeature, + const std::list& theArguments) const { - boost::shared_ptr aData = theFeature->data(); + 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()) { // attribute is not initialized + std::map >::const_iterator aFeatureFind = + myNotObligatory.find(theFeature->getKind()); + if (aFeatureFind == myNotObligatory.end() || // and it is obligatory for filling + 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(); +}