Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Validators.cpp
index be031014be35ffe25bd16063926ab80ee7db74ae..5f27c10ce8af8fc3a349e28e890b610f396bff35 100644 (file)
@@ -44,7 +44,7 @@ bool FeaturesPlugin_ValidatorPipePath::isValid(const AttributePtr& theAttribute,
                                                const std::list<std::string>& theArguments,
                                                Events_InfoMessage& theError) const
 {
-  AttributeSelectionPtr aPathAttrSelection = 
+  AttributeSelectionPtr aPathAttrSelection =
     std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
   if(!aPathAttrSelection.get()) {
     theError = "Error: This validator can only work with path selector in \"Pipe\" feature.";
@@ -58,7 +58,7 @@ bool FeaturesPlugin_ValidatorPipePath::isValid(const AttributePtr& theAttribute,
     return false;
   }
   GeomShapePtr aContextShape = aContext->shape();
-  if(aPathShape.get() && aPathShape->shapeType() == GeomAPI_Shape::WIRE && 
+  if(aPathShape.get() && aPathShape->shapeType() == GeomAPI_Shape::WIRE &&
       !aPathShape->isEqual(aContextShape)) {
     theError = "Error: Local selection of wires not allowed.";
     return false;
@@ -108,7 +108,7 @@ bool FeaturesPlugin_ValidatorPipeLocations::isValid(
     return false;
   }
 
-  if(aLocationsSelectionList->size() > 0 && 
+  if(aLocationsSelectionList->size() > 0 &&
      aLocationsSelectionList->size() != aBaseObjectsSelectionList->size()) {
     theError = "Error: Number of locations should be the same as base objects.";
     return false;
@@ -118,7 +118,7 @@ bool FeaturesPlugin_ValidatorPipeLocations::isValid(
 }
 
 //==================================================================================================
-bool FeaturesPlugin_ValidatorPipeLocations::isNotObligatory(std::string theFeature, 
+bool FeaturesPlugin_ValidatorPipeLocations::isNotObligatory(std::string theFeature,
                                                             std::string theAttribute)
 {
   return false;
@@ -157,10 +157,10 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theA
         return false;
       }
 
-      ResultConstructionPtr aResultConstruction = 
+      ResultConstructionPtr aResultConstruction =
         std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
       if(!aResultConstruction.get()) {
-        // It is not a result construction. 
+        // It is not a result construction.
         // If shape is compound check that it contains only faces and edges.
         GeomShapePtr aShape = aSelectionAttr->value();
         if(!aShape.get()) {
@@ -187,8 +187,8 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theA
         // Whole sketch selected.
         if(aSelectedSketchesFromObjects.find(aResultConstruction) !=
             aSelectedSketchesFromObjects.cend()) {
-          theError = "Error: Object from this sketch is already selected. \
- Sketch is not allowed for selection.";
+          theError = "Error: Object from this sketch is already selected. "
                    "Sketch is not allowed for selection.";
           return false;
         }
 
@@ -196,8 +196,8 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theA
       } else {
         // Object from sketch selected.
         if(aSelectedSketches.find(aResultConstruction) != aSelectedSketches.cend()) {
-          theError = "Error: Whole sketch with this object is already selected. \
- Don't allow to select this object.";
+          theError = "Error: Whole sketch with this object is already selected. "
                    "Don't allow to select this object.";
           return false;
         }
 
@@ -209,7 +209,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theA
           }
 
           if(aSelectedWiresFromObjects.isBound(aWire)) {
-            theError = 
+            theError =
               "Error: Objects with such wire already selected. Don't allow to select this object.";
             return false;
           }
@@ -236,7 +236,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute
 
   std::string anAttributeType = theAttribute->attributeType();
   if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
-    AttributeSelectionListPtr aListAttr = 
+    AttributeSelectionListPtr aListAttr =
       std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
     for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
       // If at least one attribute is invalid, the result is false.
@@ -246,7 +246,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute
     }
   } else if(anAttributeType == ModelAPI_AttributeSelection::typeId()) {
     // Getting context.
-    AttributeSelectionPtr anAttr = 
+    AttributeSelectionPtr anAttr =
       std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
     ResultPtr aContext = anAttr->context();
     if(!aContext.get()) {
@@ -264,7 +264,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute
       return false;
     }
 
-    ResultConstructionPtr aConstruction = 
+    ResultConstructionPtr aConstruction =
       std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
     if(aConstruction.get()) {
       // Construciotn selected. Check that is is not infinite.
@@ -280,7 +280,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute
         }
       } else {
         // Shape on construction selected. Check that it is a face or wire.
-        if(aShape->shapeType() == GeomAPI_Shape::WIRE || 
+        if(aShape->shapeType() == GeomAPI_Shape::WIRE ||
            aShape->shapeType() == GeomAPI_Shape::FACE) {
           return true;
         }
@@ -299,9 +299,9 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute
     // Check that object is a shape with allowed type.
     GeomValidators_ShapeType aShapeTypeValidator;
     if(!aShapeTypeValidator.isValid(anAttr, theArguments, theError)) {
-      theError = "Error: Selected shape has unacceptable type. Acceptable types are: faces or \
- wires on sketch, whole sketch(if it has at least one face), \
- and whole objects with shape types: %1";
+      theError = "Error: Selected shape has unacceptable type. Acceptable types are: faces or "
+                 "wires on sketch, whole sketch(if it has at least one face), "
                "and whole objects with shape types: %1";
       std::string anArgumentString;
       for(auto anIt = theArguments.cbegin(); anIt != theArguments.cend(); ++anIt) {
         if (!anArgumentString.empty())
@@ -380,7 +380,7 @@ bool FeaturesPlugin_ValidatorExtrusionDir::isValid(
     return false;
   }
 
-  std::list<std::string>::const_iterator 
+  std::list<std::string>::const_iterator
     anArgsIt = theArguments.begin(), aLast = theArguments.end();
 
   AttributePtr aCheckAttribute = theFeature->attribute(*anArgsIt);
@@ -401,8 +401,8 @@ bool FeaturesPlugin_ValidatorExtrusionDir::isValid(
   if(!aDirShape.get()) {
     // Check that dir can be empty.
     if(!isShapesCanBeEmpty(aCheckAttribute, theError)) {
-      theError = "Error: Base objects list contains vertex or edge, so attribute \"%1\" \
- can not be used with default value. Select direction for extrusion.";
+      theError = "Error: Base objects list contains vertex or edge, so attribute \"%1\" "
                "can not be used with default value. Select direction for extrusion.";
       theError.arg(*anArgsIt);
       return false;
     } else {
@@ -413,7 +413,7 @@ bool FeaturesPlugin_ValidatorExtrusionDir::isValid(
   std::shared_ptr<GeomAPI_Edge> aDirEdge(new GeomAPI_Edge(aDirShape));
 
   // If faces selected check that direction not parallel with them.
-  AttributeSelectionListPtr aListAttr = 
+  AttributeSelectionListPtr aListAttr =
     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aCheckAttribute);
   for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
     AttributeSelectionPtr anAttr = aListAttr->value(anIndex);
@@ -422,9 +422,9 @@ bool FeaturesPlugin_ValidatorExtrusionDir::isValid(
       aShapeInList = anAttr->context()->shape();
     }
     bool isParallel = true;
-    if(aShapeInList->shapeType() == GeomAPI_Shape::FACE || 
+    if(aShapeInList->shapeType() == GeomAPI_Shape::FACE ||
        aShapeInList->shapeType() == GeomAPI_Shape::SHELL) {
-      for(GeomAPI_ShapeExplorer 
+      for(GeomAPI_ShapeExplorer
           anExp(aShapeInList, GeomAPI_Shape::FACE); anExp.more(); anExp.next()) {
         std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(anExp.current()));
         isParallel = GeomAlgoAPI_ShapeTools::isParallel(aDirEdge, aFace);
@@ -433,7 +433,7 @@ bool FeaturesPlugin_ValidatorExtrusionDir::isValid(
         }
       }
     } else if(aShapeInList->shapeType() == GeomAPI_Shape::COMPOUND) {
-      std::shared_ptr<GeomAPI_PlanarEdges> aPlanarEdges = 
+      std::shared_ptr<GeomAPI_PlanarEdges> aPlanarEdges =
         std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aShapeInList);
       if(aPlanarEdges.get()) {
         std::shared_ptr<GeomAPI_Dir> aSketchDir = aPlanarEdges->norm();
@@ -450,7 +450,7 @@ bool FeaturesPlugin_ValidatorExtrusionDir::isValid(
       isParallel = false;
     }
     if(isParallel) {
-      theError = 
+      theError =
         "Error: Direction is parallel to one of the selected face or face on selected shell.";
       return false;
     }
@@ -460,7 +460,7 @@ bool FeaturesPlugin_ValidatorExtrusionDir::isValid(
 }
 
 //==================================================================================================
-bool FeaturesPlugin_ValidatorExtrusionDir::isNotObligatory(std::string theFeature, 
+bool FeaturesPlugin_ValidatorExtrusionDir::isNotObligatory(std::string theFeature,
                                                            std::string theAttribute)
 {
   return false;
@@ -476,7 +476,7 @@ bool FeaturesPlugin_ValidatorExtrusionDir::isShapesCanBeEmpty(const AttributePtr
 
   std::string anAttributeType = theAttribute->attributeType();
   if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
-    AttributeSelectionListPtr aListAttr = 
+    AttributeSelectionListPtr aListAttr =
       std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
     for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
       // If at least one attribute is invalid, the result is false.
@@ -486,7 +486,7 @@ bool FeaturesPlugin_ValidatorExtrusionDir::isShapesCanBeEmpty(const AttributePtr
     }
   } else if(anAttributeType == ModelAPI_AttributeSelection::typeId()) {
     // Getting context.
-    AttributeSelectionPtr anAttr = 
+    AttributeSelectionPtr anAttr =
       std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
     ResultPtr aContext = anAttr->context();
     if(!aContext.get()) {
@@ -519,10 +519,10 @@ bool FeaturesPlugin_ValidatorBooleanSelection::isValid(const AttributePtr& theAt
                                                        const std::list<std::string>& theArguments,
                                                        Events_InfoMessage& theError) const
 {
-  AttributeSelectionListPtr anAttrSelectionList = 
+  AttributeSelectionListPtr anAttrSelectionList =
     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
   if(!anAttrSelectionList.get()) {
-    theError = 
+    theError =
       "Error: This validator can only work with selection list attributes in \"Boolean\" feature.";
     return false;
   }
@@ -589,7 +589,7 @@ bool FeaturesPlugin_ValidatorPartitionSelection::isValid(const AttributePtr& the
                                                        const std::list<std::string>& theArguments,
                                                        Events_InfoMessage& theError) const
 {
-  AttributeSelectionListPtr anAttrSelectionList = 
+  AttributeSelectionListPtr anAttrSelectionList =
     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
   if(!anAttrSelectionList.get()) {
     theError = "Error: This validator can only work with selection list in \"Partition\" feature.";
@@ -610,14 +610,14 @@ bool FeaturesPlugin_ValidatorPartitionSelection::isValid(const AttributePtr& the
     }
 
     ResultPtr aContext = aSelectAttr->context();
-    ResultConstructionPtr aResultConstruction = 
+    ResultConstructionPtr aResultConstruction =
       std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
     if(aResultConstruction.get()) {
       theError = "Error: Only body shapes and construction planes are allowed for selection.";
       return false;
     }
 
-    ResultCompSolidPtr aResultCompsolid = 
+    ResultCompSolidPtr aResultCompsolid =
       std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aContext);
     if(aResultCompsolid.get()) {
       continue;
@@ -636,10 +636,10 @@ bool FeaturesPlugin_ValidatorRemoveSubShapesSelection::isValid(const AttributePt
                                                      const std::list<std::string>& theArguments,
                                                      Events_InfoMessage& theError) const
 {
-  AttributeSelectionListPtr aSubShapesAttrList = 
+  AttributeSelectionListPtr aSubShapesAttrList =
     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
   if(!aSubShapesAttrList.get()) {
-    theError = 
+    theError =
       "Error: This validator can only work with selection list in \"Remove Sub-Shapes\" feature.";
     return false;
   }
@@ -752,7 +752,7 @@ bool FeaturesPlugin_ValidatorUnionSelection::isValid(const AttributePtr& theAttr
                                                      const std::list<std::string>& theArguments,
                                                      Events_InfoMessage& theError) const
 {
-  AttributeSelectionListPtr aBaseObjectsAttrList = 
+  AttributeSelectionListPtr aBaseObjectsAttrList =
     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
   if(!aBaseObjectsAttrList.get()) {
     theError = "Error: This validator can only work with selection list in \"%1\" feature.";
@@ -763,7 +763,7 @@ bool FeaturesPlugin_ValidatorUnionSelection::isValid(const AttributePtr& theAttr
   for(int anIndex = 0; anIndex < aBaseObjectsAttrList->size(); ++anIndex) {
     bool isSameFound = false;
     AttributeSelectionPtr anAttrSelectionInList = aBaseObjectsAttrList->value(anIndex);
-    ResultCompSolidPtr aResult = 
+    ResultCompSolidPtr aResult =
       std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(anAttrSelectionInList->context());
     if(!aResult.get()) {
       continue;
@@ -791,7 +791,7 @@ bool FeaturesPlugin_ValidatorUnionArguments::isValid(
   }
 
   // Get base objects attribute list.
-  AttributeSelectionListPtr aBaseObejctsAttrList = 
+  AttributeSelectionListPtr aBaseObejctsAttrList =
     theFeature->selectionList(FeaturesPlugin_Union::BASE_OBJECTS_ID());
   if(!aBaseObejctsAttrList.get()) {
     theError = "Error: Could not get \"%1\" attribute.";