Salome HOME
Provide shape selector with possibility to work with AttributeRefAttrPtr
[modules/shaper.git] / src / Model / Model_FeatureValidator.cpp
index bcc09d11e13002fbef87b969afac32f1fba66894..b34f03edd8f69c946d24c9e2c827f8e6db71309c 100644 (file)
@@ -9,14 +9,16 @@
 #include <ModelAPI_Object.h>
 
 #include <list>
-#include <boost/shared_ptr.hpp>
+#include <memory>
 
-bool Model_FeatureValidator::isValid(const boost::shared_ptr<ModelAPI_Feature>& theFeature,
+bool Model_FeatureValidator::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
   const std::list<std::string>& theArguments) const
 {
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  if (!aData)
-    return false;
+  std::shared_ptr<ModelAPI_Data> 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 = "";
@@ -24,10 +26,10 @@ bool Model_FeatureValidator::isValid(const boost::shared_ptr<ModelAPI_Feature>&
   std::list<std::string>::iterator it = aLtAttributes.begin();
   for (; it != aLtAttributes.end(); it++) {
     AttributePtr anAttr = aData->attribute(*it);
-    if (!anAttr->isInitialized()) {
+    if (!anAttr->isInitialized()) { // attribute is not initialized
       std::map<std::string, std::set<std::string> >::const_iterator aFeatureFind = 
         myNotObligatory.find(theFeature->getKind());
-      if (aFeatureFind == myNotObligatory.end() ||
+      if (aFeatureFind == myNotObligatory.end() || // and it is obligatory for filling
           aFeatureFind->second.find(*it) == aFeatureFind->second.end()) {
         return false;
       }
@@ -41,3 +43,9 @@ void Model_FeatureValidator::registerNotObligatory(std::string theFeature, std::
   std::set<std::string>& anAttrs = myNotObligatory[theFeature];
   anAttrs.insert(theAttribute);
 }
+
+bool Model_FeatureValidator::isNotObligatory(std::string theFeature, std::string theAttribute)
+{
+  std::set<std::string>& anAttrs = myNotObligatory[theFeature];
+  return anAttrs.find(theAttribute) != anAttrs.end();
+}