Salome HOME
cosmétique
[modules/shaper.git] / src / PartSet / PartSet_Validators.cpp
index 979ef341c75b3ee54ea4c9dccf02de5995664d4d..bb6c980970e5b879551392954edfc7a1bc61a66c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -53,6 +53,8 @@
 #include <SketchPlugin_Point.h>
 #include <GeomAPI_Edge.h>
 
+#include <Locale_Convert.h>
+
 #include <list>
 #include <unordered_map>
 #ifdef _DEBUG
@@ -75,7 +77,7 @@ int shapesNbPoints(const ModuleBase_ISelection* theSelection)
   return aCount;
 }
 
-typedef std::unordered_map<GeomAbs_CurveType, int> ShapeQuantity;
+typedef std::unordered_map<int, int> ShapeQuantity;
 
 int shapesNbEdges(const ModuleBase_ISelection* theSelection, ShapeQuantity& theEdges)
 {
@@ -90,7 +92,7 @@ int shapesNbEdges(const ModuleBase_ISelection* theSelection, ShapeQuantity& theE
         Standard_Real aStart, aEnd;
         Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
         GeomAdaptor_Curve aAdaptor(aCurve);
-        theEdges[aAdaptor.GetType()] += 1;
+        theEdges[(int)aAdaptor.GetType()] += 1;
         aCount++;
       }
     }
@@ -435,8 +437,9 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
             continue;
           if (isObject) {
             if (aRef->object() == anObject) {
-              theError = errorMessage(EqualObjects, anObject.get() ? anObject->data()->name() : "",
-                                      theAttribute->id(), aRef->id());
+              theError = errorMessage(EqualObjects,
+                anObject.get() ? Locale::Convert::toString(anObject->data()->name()) : "",
+                theAttribute->id(), aRef->id());
               return false;
             }
           }
@@ -454,11 +457,11 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
     }
   }
   else if (anAttrType == ModelAPI_AttributeSelection::typeId()) {
-    AttributeSelectionPtr anAttr =
+    AttributeSelectionPtr anAttrSel =
       std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
-    ResultPtr aContext = anAttr->context();
-    FeaturePtr aContextFeature = anAttr->contextFeature();
-    GeomShapePtr aShape = anAttr->value();
+    ResultPtr aContext = anAttrSel->context();
+    FeaturePtr aContextFeature = anAttrSel->contextFeature();
+    GeomShapePtr aShape = anAttrSel->value();
 
     // Check selection attributes
     anAttrs = aFeature->data()->attributes(ModelAPI_AttributeSelection::typeId());
@@ -499,9 +502,9 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
     }
   }
   else if (anAttrType == ModelAPI_AttributeReference::typeId()) {
-    AttributeReferencePtr anAttr =
+    AttributeReferencePtr anAttrRef =
       std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
-    ObjectPtr anObject = anAttr->value();
+    ObjectPtr anObject = anAttrRef->value();
     // Check selection attributes
     anAttrs = aFeature->data()->attributes(ModelAPI_AttributeReference::typeId());
     if (anAttrs.size() > 0) {
@@ -512,13 +515,14 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
             std::dynamic_pointer_cast<ModelAPI_AttributeReference>(*anAttr);
           // check the object is already presented
           if (aRef->value() == anObject) {
-            theError = errorMessage(EqualObjects, anObject.get() ? anObject->data()->name() : "",
-                                    theAttribute->id(), aRef->id());
+            theError = errorMessage(EqualObjects,
+              anObject.get() ? Locale::Convert::toString(anObject->data()->name()) : "",
+              theAttribute->id(), aRef->id());
             return false;
           }
         }
-        return true;
       }
+      return true;
     }
   }
   else if(anAttrType == ModelAPI_AttributeSelectionList::typeId()) {
@@ -608,8 +612,9 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
             for (int j = 0; j < aRefSelList->size(); j++) {
               if (aCurSelObject == aRefSelList->object(j)) {
                 theError = errorMessage(EqualObjects,
-                              aCurSelObject.get() ? aCurSelObject->data()->name() : "",
-                              theAttribute->id(), aCurSelList->id());
+                  aCurSelObject.get()?
+                  Locale::Convert::toString(aCurSelObject->data()->name()) : "",
+                  theAttribute->id(), aCurSelList->id());
                 return false;
               }
             }
@@ -683,8 +688,6 @@ bool PartSet_CoincidentAttr::isValid(const AttributePtr& theAttribute,
 
   // there is a check whether the feature contains a point and a linear edge or two point values
   std::string aParamA = theArguments.front();
-  SessionPtr aMgr = ModelAPI_Session::get();
-  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
 
   FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
   AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
@@ -715,13 +718,13 @@ bool PartSet_CoincidentAttr::isValid(const AttributePtr& theAttribute,
         AttributePtr aAR = aRAttr->attr();
         if (aAR->id() != SketchPlugin_Arc::CENTER_ID()) // ignore constraint to center of arc
           aCoinList.insert(aConstrFeature);
-          QList<bool> anIsAttributes;
-          PartSet_Tools::findCoincidences(aConstrFeature, aCoinsideLines, aCoins,
-                                          SketchPlugin_ConstraintCoincidence::ENTITY_A(),
-                                          anIsAttributes);
-          PartSet_Tools::findCoincidences(aConstrFeature, aCoinsideLines, aCoins,
-                                          SketchPlugin_ConstraintCoincidence::ENTITY_B(),
-                                          anIsAttributes);
+        QList<bool> anIsAttributes;
+        PartSet_Tools::findCoincidences(aConstrFeature, aCoinsideLines, aCoins,
+                                        SketchPlugin_ConstraintCoincidence::ENTITY_A(),
+                                        anIsAttributes);
+        PartSet_Tools::findCoincidences(aConstrFeature, aCoinsideLines, aCoins,
+                                        SketchPlugin_ConstraintCoincidence::ENTITY_B(),
+                                        anIsAttributes);
       }
     }
     // if there is no coincidence then it is not valid