Salome HOME
Issue #2998: Add help description for automatic creation of constraints
[modules/shaper.git] / src / FiltersPlugin / FiltersPlugin_Selection.cpp
index e2dd91f01930ef2a488f482183f1f2fabf2fbbb1..7fe056aba5aee9fadbf2b5d2f65023ac9b21a4e8 100644 (file)
 
 #include "FiltersPlugin_Selection.h"
 
-#include <ModelAPI_Session.h>
 #include <ModelAPI_AttributeBoolean.h>
 #include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_FiltersFactory.h>
+#include <ModelAPI_Session.h>
 
 // identifier of the reverse flag of a filter
 static const std::string kReverseAttrID("");
@@ -71,7 +72,9 @@ bool FiltersPlugin_Selection::isReversed(const std::string theFilterID)
 {
   std::string anAttrID = theFilterID + kFilterSeparator + kReverseAttrID;
   std::shared_ptr<ModelAPI_AttributeBoolean> aBool = boolean(anAttrID);
-  return aBool->value();
+  if (aBool.get())
+    return aBool->value();
+  return false;
 }
 
 std::list<AttributePtr> FiltersPlugin_Selection::filterArgs(const std::string theFilterID) const
@@ -120,7 +123,8 @@ void FiltersPlugin_Selection::initAttributes()
       std::shared_ptr<ModelAPI_AttributeBoolean> aBool =
         std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(data()->addFloatingAttribute(
           kReverseAttrID, ModelAPI_AttributeBoolean::typeId(), *aFIt));
-      aBool->setValue(false); // not reversed by default
+      if (!aBool->isInitialized())
+        aBool->setValue(false); // not reversed by default
       ModelAPI_FiltersArgs anArgs;
       anArgs.setFeature(std::dynamic_pointer_cast<ModelAPI_FiltersFeature>(data()->owner()));
       anArgs.setFilter(*aFIt);