Salome HOME
#816 In multi-rotation, be able to put the total angle or the step angle
authornds <nds@opencascade.com>
Wed, 11 Nov 2015 12:26:56 +0000 (15:26 +0300)
committernds <nds@opencascade.com>
Wed, 11 Nov 2015 12:29:27 +0000 (15:29 +0300)
Unit-test scripts correction.

src/SketchPlugin/Test/TestMultiRotation.py
src/SketchPlugin/Test/TestMultiTranslation.py

index bee56e4a86bc33ac320bab8bf42e6a78b298b524..358fd408b66182aaa7e9853557a7e5ca8e056c55 100644 (file)
@@ -4,9 +4,10 @@
         
     SketchPlugin_MultiRotation
         static const std::string MY_CONSTRAINT_ROTATION_ID("SketchMultiRotation");
-        data()->addAttribute(START_POINT_ID(), GeomDataAPI_Point2D::typeId());
-        data()->addAttribute(END_POINT_ID(), GeomDataAPI_Point2D::typeId());
-        data()->addAttribute(NUMBER_OF_COPIES_ID(), ModelAPI_AttributeInteger::typeId());
+        data()->addAttribute(ANGLE_TYPE(), ModelAPI_AttributeString::typeId());
+        data()->addAttribute(ANGLE_ID(), ModelAPI_AttributeDouble::typeId());
+        data()->addAttribute(ANGLE_FULL_ID(), ModelAPI_AttributeDouble::typeId());
+        data()->addAttribute(NUMBER_OF_OBJECTS_ID(), ModelAPI_AttributeInteger::typeId());
         data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefList::typeId());
         data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId());
         data()->addAttribute(ROTATION_LIST_ID(), ModelAPI_AttributeRefList::typeId());
@@ -34,7 +35,7 @@ def createSketch(theSketch):
     theSketch.execute()
     return allFeatures
     
-def checkRotation(theObjects, theNbCopies, theCenterX, theCenterY, theAngle):
+def checkRotation(theObjects, theNbObjects, theCenterX, theCenterY, theAngle):
     # Verify distances of the objects and the number of copies
     aFeatures = []
     aSize = theObjects.size()
@@ -48,7 +49,7 @@ def checkRotation(theObjects, theNbCopies, theCenterX, theCenterY, theAngle):
     anInd = 0 
     for feat, next in zip(aFeatures[:-1], aFeatures[1:]):
         anInd = anInd + 1
-        if (anInd > theNbCopies):
+        if (anInd > theNbObjects-1):
             anInd = 0
             continue
         assert(feat.getKind() == next.getKind())
@@ -74,7 +75,7 @@ def checkRotation(theObjects, theNbCopies, theCenterX, theCenterY, theAngle):
             aLocCosA = (aDirX1 * aDirX2 + aDirY1 * aDirY2) / aLen1 / aLen2
             assert(math.fabs(aLocCosA - cosA) < 1.e-10)
     # Check the number of copies is as planed
-    assert(anInd == theNbCopies)
+    assert(anInd == theNbObjects-1)
 
 
 #=========================================================================
@@ -120,12 +121,16 @@ for aFeature in aFeaturesList:
     aResult = modelAPI_ResultConstruction(aFeature.lastResult())
     assert(aResult is not None)
     aRotList.append(aResult)
+
+aValueType = aMultiRotation.string("AngleType")
+aValueType.setValue("SingleValue")
+
 aCenter = geomDataAPI_Point2D(aMultiRotation.attribute("MultiRotationCenter"))
 anAngle = aMultiRotation.real("MultiRotationAngle")
 aCenter.setValue(CENTER_X, CENTER_Y)
 anAngle.setValue(ANGLE)
-aNbCopies = aMultiRotation.integer("MultiRotationCopies")
-aNbCopies.setValue(1)
+aNbCopies = aMultiRotation.integer("MultiRotationObjects")
+aNbCopies.setValue(2)
 aMultiRotation.execute()
 aSession.finishOperation()
 #=========================================================================
index b421c628d5d405a20a3c4ea5dfc7865f7999fc9c..47f8fe30b871d6523bde7bb8ba2a1d5ff421fac1 100644 (file)
@@ -4,9 +4,12 @@
         
     SketchPlugin_MultiTranslation
         static const std::string MY_CONSTRAINT_TRANSLATION_ID("SketchMultiTranslation");
+        data()->addAttribute(VALUE_TYPE(), ModelAPI_AttributeString::typeId());
         data()->addAttribute(START_POINT_ID(), GeomDataAPI_Point2D::typeId());
+        data()->addAttribute(START_FULL_POINT_ID(), GeomDataAPI_Point2D::typeId());
         data()->addAttribute(END_POINT_ID(), GeomDataAPI_Point2D::typeId());
-        data()->addAttribute(NUMBER_OF_COPIES_ID(), ModelAPI_AttributeInteger::typeId());
+        data()->addAttribute(END_FULL_POINT_ID(), GeomDataAPI_Point2D::typeId());
+        data()->addAttribute(NUMBER_OF_OBJECTS_ID(), ModelAPI_AttributeInteger::typeId());
         data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefList::typeId());
         data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId());
         data()->addAttribute(TRANSLATION_LIST_ID(), ModelAPI_AttributeRefList::typeId());
@@ -33,7 +36,7 @@ def createSketch(theSketch):
     theSketch.execute()
     return allFeatures
     
-def checkTranslation(theObjects, theNbCopies, theDeltaX, theDeltaY):
+def checkTranslation(theObjects, theNbObjects, theDeltaX, theDeltaY):
     # Verify distances of the objects and the number of copies
     aFeatures = []
     aSize = theObjects.size()
@@ -45,7 +48,7 @@ def checkTranslation(theObjects, theNbCopies, theDeltaX, theDeltaY):
     anInd = 0 
     for feat, next in zip(aFeatures[:-1], aFeatures[1:]):
         anInd = anInd + 1
-        if (anInd > theNbCopies):
+        if (anInd > theNbObjects):
             anInd = 0
             continue
         assert(feat.getKind() == next.getKind())
@@ -66,7 +69,7 @@ def checkTranslation(theObjects, theNbCopies, theDeltaX, theDeltaY):
             aDiffY = aPoint2.y() - aPoint1.y() - theDeltaY
             assert(aDiffX**2 + aDiffY**2 < 1.e-15)
     # Check the number of copies is as planed
-    assert(anInd == theNbCopies)
+    assert(anInd == theNbObjects-1)
 
 
 #=========================================================================
@@ -115,12 +118,15 @@ for aFeature in aFeaturesList:
     aResult = modelAPI_ResultConstruction(aFeature.lastResult())
     assert(aResult is not None)
     aTransList.append(aResult)
+
+aValueType = aMultiTranslation.string("ValueType")
+aValueType.setValue("SingleValue")
 aStartPoint = geomDataAPI_Point2D(aMultiTranslation.attribute("MultiTranslationStartPoint"))
 aEndPoint = geomDataAPI_Point2D(aMultiTranslation.attribute("MultiTranslationEndPoint"))
 aStartPoint.setValue(START_X, START_Y)
 aEndPoint.setValue(START_X + DIR_X, START_Y + DIR_Y)
-aNbCopies = aMultiTranslation.integer("MultiTranslationCopies")
-aNbCopies.setValue(1)
+aNbCopies = aMultiTranslation.integer("MultiTranslationObjects")
+aNbCopies.setValue(2)
 aMultiTranslation.execute()
 aSession.finishOperation()
 #=========================================================================