Salome HOME
Issue #1724: Let use Middle constraint when a one line or point is selected
[modules/shaper.git] / src / BuildPlugin / BuildPlugin_Validators.cpp
index b3ede6d602d88b1c9bfd2610841ceb9d5202a293..b75c77e54577815bc538f8c895dc3b0dd0abdb90 100644 (file)
 #include <GeomValidators_FeatureKind.h>
 #include <GeomValidators_ShapeType.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 
 //=================================================================================================
 bool BuildPlugin_ValidatorBaseForBuild::isValid(const AttributePtr& theAttribute,
                                                 const std::list<std::string>& theArguments,
-                                                std::string& theError) const
+                                                Events_InfoMessage& theError) const
 {
   // Get base objects list.
   if(theAttribute->attributeType() != ModelAPI_AttributeSelectionList::typeId()) {
-    Events_Error::send("Error: BuildPlugin_ValidatorBaseForBuild does not support attribute type \""
-      + theAttribute->attributeType() + "\"\n Only \"" + ModelAPI_AttributeSelectionList::typeId()
-      + "\" supported.");
+    std::string aMsg = "Error: BuildPlugin_ValidatorBaseForBuild does not support attribute type '%1'\nOnly '%2' is supported.";
+    Events_InfoMessage("BuildPlugin_Validators", aMsg).
+      arg(theAttribute->attributeType()).arg(ModelAPI_AttributeSelectionList::typeId()).send();
     return false;
   }
   AttributeSelectionListPtr aSelectionList =
@@ -109,17 +109,18 @@ bool BuildPlugin_ValidatorBaseForBuild::isValid(const AttributePtr& theAttribute
 //=================================================================================================
 bool BuildPlugin_ValidatorBaseForWire::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                                const std::list<std::string>& theArguments,
-                                               std::string& theError) const
+                                               Events_InfoMessage& theError) const
 {
   // Get attribute.
   if(theArguments.size() != 1) {
-    Events_Error::send("Error: BuildPlugin_ValidatorBaseForWire should be used only with "
-      "1 parameter (ID of base objects list).");
+    std::string aMsg = "Error: BuildPlugin_ValidatorBaseForWire should be used only with 1 parameter (ID of base objects list).";
+    Events_InfoMessage("BuildPlugin_Validators", aMsg).send();
     return false;
   }
   AttributeSelectionListPtr aSelectionList = theFeature->selectionList(theArguments.front());
   if(!aSelectionList.get()) {
-    theError = "Empty attribute \"" + theArguments.front() + "\".";
+    theError = "Empty attribute \"%1\".";
+    theError.arg(theArguments.front());
     return false;
   }
 
@@ -154,17 +155,19 @@ bool BuildPlugin_ValidatorBaseForWire::isNotObligatory(std::string theFeature, s
 //=================================================================================================
 bool BuildPlugin_ValidatorBaseForFace::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                                const std::list<std::string>& theArguments,
-                                               std::string& theError) const
+                                               Events_InfoMessage& theError) const
 {
   // Get attribute.
   if(theArguments.size() != 1) {
-    Events_Error::send("Error: BuildPlugin_ValidatorBaseForFace should be used only with "
-      "1 parameter (ID of base objects list).");
+    std::string aMsg = "Error: BuildPlugin_ValidatorBaseForFace should be used only with "
+      "1 parameter (ID of base objects list).";
+    Events_InfoMessage("BuildPlugin_Validators", aMsg).send();
     return false;
   }
   AttributeSelectionListPtr aSelectionList = theFeature->selectionList(theArguments.front());
   if(!aSelectionList.get()) {
-    theError = "Empty attribute \"" + theArguments.front() + "\".";
+    theError = "Empty attribute \"%1\".";
+    theError.arg(theArguments.front());
     return false;
   }
 
@@ -228,19 +231,21 @@ bool BuildPlugin_ValidatorBaseForFace::isNotObligatory(std::string theFeature, s
 //=================================================================================================
 bool BuildPlugin_ValidatorSubShapesSelection::isValid(const AttributePtr& theAttribute,
                                                       const std::list<std::string>& theArguments,
-                                                      std::string& theError) const
+                                                      Events_InfoMessage& theError) const
 {
   if(theArguments.size() != 1) {
-    Events_Error::send("Error: BuildPlugin_ValidatorSubShapesSelection should be used only with "
-      "1 parameter(Sketch feature id).");
+    std::string aMsg = "Error: BuildPlugin_ValidatorSubShapesSelection should be used only with "
+      "1 parameter(Sketch feature id).";
+    Events_InfoMessage("BuildPlugin_Validators", aMsg).send();
     return false;
   }
 
   // Get base objects list.
   if(theAttribute->attributeType() != ModelAPI_AttributeSelectionList::typeId()) {
-    Events_Error::send("Error: BuildPlugin_ValidatorSubShapesSelection does not support attribute type \""
-      + theAttribute->attributeType() + "\"\n Only \"" + ModelAPI_AttributeSelectionList::typeId()
-      + "\" supported.");
+    std::string aMsg = "Error: BuildPlugin_ValidatorSubShapesSelection does not support attribute type \""
+      "%1\"\n Only \"%2\" supported.";
+    Events_InfoMessage("BuildPlugin_Validators", aMsg).
+      arg(theAttribute->attributeType()).arg(ModelAPI_AttributeSelectionList::typeId()).send();
     return false;
   }
   AttributeSelectionListPtr aSelectionList =