X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FTest%2FTestConstraintLength.py;h=ac1345d4dfb1c7a381ce3f4cf23e027bc8d4d695;hb=cfe4bcc5b3ebf08f0f4f36a0df4067728f1a080a;hp=48acf2c6b612bc12b12749f1bd089b5c8025f7ca;hpb=758a57d77b6fa3a0485fa3378a1280c7e87a74aa;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/Test/TestConstraintLength.py b/src/SketchPlugin/Test/TestConstraintLength.py index 48acf2c6b..ac1345d4d 100644 --- a/src/SketchPlugin/Test/TestConstraintLength.py +++ b/src/SketchPlugin/Test/TestConstraintLength.py @@ -4,13 +4,16 @@ SketchPlugin_ConstraintLength static const std::string MY_CONSTRAINT_LENGTH_ID("SketchConstraintLength"); - data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type()); - data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type()); - data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type()); + data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId()); + data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId()); """ from GeomDataAPI import * from ModelAPI import * +import math +from salome.shaper import model + #========================================================================= # Initialization of the test #========================================================================= @@ -24,13 +27,11 @@ aDocument = aSession.moduleDocument() #========================================================================= aSession.startOperation() aSketchCommonFeature = aDocument.addFeature("Sketch") -aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature) +aSketchFeature = featureToCompositeFeature(aSketchCommonFeature) origin = geomDataAPI_Point(aSketchFeature.attribute("Origin")) origin.setValue(0, 0, 0) dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX")) dirx.setValue(1, 0, 0) -diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY")) -diry.setValue(0, 1, 0) norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm")) norm.setValue(0, 0, 1) aSession.finishOperation() @@ -44,6 +45,7 @@ aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint")) aLineAStartPoint.setValue(0., 25.) aLineAEndPoint.setValue(100., 25.) aSession.finishOperation() +assert (model.dof(aSketchFeature) == 4) #========================================================================= # Make a constraint to keep the length #========================================================================= @@ -62,6 +64,7 @@ aLengthConstraint.execute() aSession.finishOperation() assert (aLength.isInitialized()) assert (refattrA.isInitialized()) +assert (model.dof(aSketchFeature) == 3) #========================================================================= # Check values and move one constrainted object #========================================================================= @@ -75,10 +78,11 @@ aSession.startOperation() aLineAStartPoint.setValue(aLineAStartPoint.x() + deltaX, aLineAStartPoint.y()) aSession.finishOperation() +assert (model.dof(aSketchFeature) == 3) assert (aLineAStartPoint.y() == 25) assert (aLineAEndPoint.y() == 25) # length of the line is the same -assert (aLineAEndPoint.x() - aLineAStartPoint.x() == 100) +assert (math.fabs(aLineAEndPoint.x() - aLineAStartPoint.x() - 100) < 1.e-10) #========================================================================= # Change the length value of the constraint #========================================================================= @@ -86,7 +90,8 @@ aSession.startOperation() aLength.setValue(140.) aLengthConstraint.execute() aSession.finishOperation() -assert (aLineAEndPoint.x() - aLineAStartPoint.x() == 140) +assert (math.fabs(aLineAEndPoint.x() - aLineAStartPoint.x() - 140) < 1.e-10) +assert (model.dof(aSketchFeature) == 3) #========================================================================= # TODO: improve test # 1. remove constraint, move line's start point to @@ -95,3 +100,5 @@ assert (aLineAEndPoint.x() - aLineAStartPoint.x() == 140) #========================================================================= # End of test #========================================================================= + +assert(model.checkPythonDump())