]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for ParametersPlugin unit tests
authorazv <azv@opencascade.com>
Fri, 19 Aug 2016 13:41:38 +0000 (16:41 +0300)
committerazv <azv@opencascade.com>
Fri, 19 Aug 2016 13:41:38 +0000 (16:41 +0300)
src/ModelHighAPI/ModelHighAPI_Dumper.cpp
src/ModelHighAPI/ModelHighAPI_Dumper.h
src/ParametersAPI/ParametersAPI_Parameter.cpp
src/ParametersPlugin/Test/TestParameterChangeValue.py
src/ParametersPlugin/Test/TestParameterRename.py
src/PythonAPI/Test/TestSketcherSetParallel.py

index 4bfd11a38132c4ee088dd6ee41b1751db0814f07..0c28e02ec16fe9fce6f3b8c1a810cb82a978b89d 100644 (file)
@@ -81,7 +81,9 @@ void ModelHighAPI_Dumper::clearNotDumped()
   myNotDumpedEntities.clear();
 }
 
-const std::string& ModelHighAPI_Dumper::name(const EntityPtr& theEntity, bool theSaveNotDumped)
+const std::string& ModelHighAPI_Dumper::name(const EntityPtr& theEntity,
+                                             bool theSaveNotDumped,
+                                             bool theUseEntityName)
 {
   EntityNameMap::const_iterator aFound = myNames.find(theEntity);
   if (aFound != myNames.end())
@@ -112,14 +114,18 @@ const std::string& ModelHighAPI_Dumper::name(const EntityPtr& theEntity, bool th
     }
 
     // obtain default name for the feature
-    int aFullIndex = 0;
-    NbFeaturesMap::const_iterator aFIt = myFeatureCount.begin();
-    for (; aFIt != myFeatureCount.end(); ++aFIt) {
-      std::map<std::string, int>::const_iterator aFound = aFIt->second.find(aKind);
-      if (aFound != aFIt->second.end())
-        aFullIndex += aFound->second;
+    if (theUseEntityName)
+      aDefaultName << aName;
+    else {
+      int aFullIndex = 0;
+      NbFeaturesMap::const_iterator aFIt = myFeatureCount.begin();
+      for (; aFIt != myFeatureCount.end(); ++aFIt) {
+        std::map<std::string, int>::const_iterator aFound = aFIt->second.find(aKind);
+        if (aFound != aFIt->second.end())
+          aFullIndex += aFound->second;
+      }
+      aDefaultName << aKind << "_" << aFullIndex;
     }
-    aDefaultName << aKind << "_" << aFullIndex;
 
     // store names of results
     saveResultNames(aFeature);
index 11b6775a8e7f4fd481a78219bfac9c7b0a5fdae2..ed2834f4684f317e6ce8fb87eb11b8ec469d05ef 100644 (file)
@@ -84,9 +84,10 @@ public:
   /// Returns name of specified entity
   /// \param theEntity        [in] named entity
   /// \param theSaveNotDumped [in] if \c true, the entity should be stored as not dumped (will be dumped automatically)
+  /// \param theUseEntityName [in] if \c true, the entity name should be used "as is" without changing default name
   /// \return name of the entity
   MODELHIGHAPI_EXPORT
-  const std::string& name(const EntityPtr& theEntity, bool theSaveNotDumped = true);
+  const std::string& name(const EntityPtr& theEntity, bool theSaveNotDumped = true, bool theUseEntityName = false);
 
   /// Returns name of parent composite feature for specified entity
   MODELHIGHAPI_EXPORT
index d47448bce8f814a322c016d44817def700ad9722..03158e47d62dfe127c9019d7a67915fbb63325c5 100644 (file)
@@ -42,7 +42,7 @@ void ParametersAPI_Parameter::dump(ModelHighAPI_Dumper& theDumper) const
 {
   FeaturePtr aBase = feature();
   const std::string& aDocName = theDumper.name(aBase->document());
-  const std::string& aParamName = theDumper.name(aBase, false);
+  const std::string& aParamName = theDumper.name(aBase, false, true);
 
   AttributeStringPtr anExpr   = aBase->string(ParametersPlugin_Parameter::EXPRESSION_ID());
   AttributeStringPtr aComment = aBase->string(ParametersPlugin_Parameter::COMMENT_ID());
index c78775aee17bbd28d8891e9e1cb051148c45f919..d9941dad112085e00d5ac943d495db508f3ea6c0 100644 (file)
@@ -99,8 +99,10 @@ class TestParameterRename(unittest.TestCase):
         aStartPoint = geomDataAPI_Point2D(anOY.attribute("StartPoint"))
         anEndPoint = geomDataAPI_Point2D(anOY.attribute("EndPoint"))
         aStartPoint.setValue(0., 0.)
-        anEndPoint.SetValue(0., 100.)
-        anOY.selection("External").selectSubShape("EDGE", "OY")
+        anEndPoint.setValue(0., 100.)
+        anOYRes = modelAPI_Result(self.aDocument.objectByName("Construction", "OY"))
+        anOY.selection("External").setValue(anOYRes, anOYRes.shape())
+        anOY.execute()
         refattrB.setObject(modelAPI_ResultConstruction(anOY.firstResult()))
         value = aDistanceConstraint1.real("ConstraintValue")
         value.setText("x1 + 10.0")
@@ -114,8 +116,10 @@ class TestParameterRename(unittest.TestCase):
         aStartPoint = geomDataAPI_Point2D(anOX.attribute("StartPoint"))
         anEndPoint = geomDataAPI_Point2D(anOX.attribute("EndPoint"))
         aStartPoint.setValue(0., 0.)
-        anEndPoint.SetValue(100., 0.)
-        anOX.selection("External").selectSubShape("EDGE", "OX")
+        anEndPoint.setValue(100., 0.)
+        anOXRes = modelAPI_Result(self.aDocument.objectByName("Construction", "OX"))
+        anOX.selection("External").setValue(anOXRes, anOXRes.shape())
+        anOX.execute()
         refattrB.setObject(modelAPI_ResultConstruction(anOX.firstResult()))
         value = aDistanceConstraint2.real("ConstraintValue")
         value.setText("x1 + 20.0")
index 795ce9fe78335f3f41d934600ad2ddd73fc9c665..3343e3b86627df81ae408d67f5b727abea594927 100644 (file)
@@ -101,8 +101,10 @@ class TestParameterRename(unittest.TestCase):
         aStartPoint = geomDataAPI_Point2D(anOY.attribute("StartPoint"))
         anEndPoint = geomDataAPI_Point2D(anOY.attribute("EndPoint"))
         aStartPoint.setValue(0., 0.)
-        anEndPoint.SetValue(0., 100.)
-        anOY.selection("External").selectSubShape("EDGE", "OY")
+        anEndPoint.setValue(0., 100.)
+        anOYRes = modelAPI_Result(self.aDocument.objectByName("Construction", "OY"))
+        anOY.selection("External").setValue(anOYRes, anOYRes.shape())
+        anOY.execute()
         refattrB.setObject(modelAPI_ResultConstruction(anOY.firstResult()))
         valueX = aDistanceConstraint1.real("ConstraintValue")
         valueX.setText("x1 + 10.0")
@@ -116,8 +118,10 @@ class TestParameterRename(unittest.TestCase):
         aStartPoint = geomDataAPI_Point2D(anOX.attribute("StartPoint"))
         anEndPoint = geomDataAPI_Point2D(anOX.attribute("EndPoint"))
         aStartPoint.setValue(0., 0.)
-        anEndPoint.SetValue(100., 0.)
-        anOX.selection("External").selectSubShape("EDGE", "OX")
+        anEndPoint.setValue(100., 0.)
+        anOXRes = modelAPI_Result(self.aDocument.objectByName("Construction", "OX"))
+        anOX.selection("External").setValue(anOXRes, anOXRes.shape())
+        anOX.execute()
         refattrB.setObject(modelAPI_ResultConstruction(anOX.firstResult()))
         valueY = aDistanceConstraint2.real("ConstraintValue")
         valueY.setText("x1 + 20.0")
@@ -133,7 +137,7 @@ class TestParameterRename(unittest.TestCase):
 
         self.aCircleCenterX = valueX
         self.aCircleCenterY = valueY
-        sel.aCircleRadius = aRadiusConstraintAttr
+        self.aCircleRadius = aRadiusConstrAttr
 
         self.assertEqual(self.anCircleCentr.x(), 160.)
         self.assertEqual(self.anCircleCentr.y(), 170.)
index 9e440ab32cd6bd816eaab47a1d29b7a65a491e1c..859773b01d7297187d17d457b589922d697eacf7 100644 (file)
@@ -5,7 +5,7 @@ from TestSketcher import SketcherTestCase
 class SketcherSetParallel(SketcherTestCase):
     def runTest(self):
         l1 = self.sketch.addLine(0, 0, 0, 1)
-        l2 = self.sketch.addLine(0, 1, 1, 1)
+        l2 = self.sketch.addLine(0, 1, 1, 0)
         self.sketch.setParallel(l1, l2)
         model.do()