Salome HOME
Fix for crash in Object Browser when object was deleted but message not sent
[modules/shaper.git] / src / SketchPlugin / Test / TestConstraintConcidence.py
index da616ce62143c5b0bba43d69ce88657b0b1d66e7..580a45e3255779ea3e78c8b445990f2345e1237f 100644 (file)
@@ -12,8 +12,8 @@
         
     SketchPlugin_ConstraintCoincidence
         static const std::string MY_CONSTRAINT_COINCIDENCE_ID("SketchConstraintCoincidence");
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
 
 """
 from GeomDataAPI import *
@@ -22,7 +22,7 @@ from ModelAPI import *
 # Initialization of the test
 #=========================================================================
 
-__updated__ = "2014-07-28"
+__updated__ = "2014-10-28"
 
 aSession = ModelAPI_Session.get()
 aDocument = aSession.moduleDocument()
@@ -30,38 +30,30 @@ aDocument = aSession.moduleDocument()
 # Creation of a sketch
 #=========================================================================
 aSession.startOperation()
-aSketchFeature = aDocument.addFeature("Sketch")
-aSketchFeatureData = aSketchFeature.data()
-origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 origin.setValue(0, 0, 0)
-dirx = geomDataAPI_Dir(aSketchFeatureData.attribute("DirX"))
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
 dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeatureData.attribute("DirY"))
-diry.setValue(0, 1, 0)
-norm = geomDataAPI_Dir(aSketchFeatureData.attribute("Norm"))
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 aSession.finishOperation()
 #=========================================================================
 # Create a line and an arc
 #=========================================================================
 aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
-aSketchArc = aDocument.addFeature("SketchArc")
-aSketchReflist.append(aSketchArc)
-aSketchArcData = aSketchArc.data()
-anArcCentr = geomDataAPI_Point2D(aSketchArcData.attribute("ArcCenter"))
+aSketchArc = aSketchFeature.addFeature("SketchArc")
+anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("ArcCenter"))
 anArcStartPoint = geomDataAPI_Point2D(
-    aSketchArcData.attribute("ArcStartPoint"))
-anArcEndPoint = geomDataAPI_Point2D(aSketchArcData.attribute("ArcEndPoint"))
-aSketchFeature = aDocument.addFeature("SketchConstraintCoincidence")
+    aSketchArc.attribute("ArcStartPoint"))
+anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
 anArcCentr.setValue(10., 10.)
 anArcStartPoint.setValue(0., 50.)
 anArcEndPoint.setValue(50., 0.)
-aSketchLine = aDocument.addFeature("SketchLine")
-aSketchReflist.append(aSketchLine)
-aSketchLineData = aSketchLine.data()
-aLineStartPoint = geomDataAPI_Point2D(aSketchLineData.attribute("StartPoint"))
-aLineEndPoint = geomDataAPI_Point2D(aSketchLineData.attribute("EndPoint"))
+aSketchLine = aSketchFeature.addFeature("SketchLine")
+aLineStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint"))
+aLineEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
 # Lets initialize line start at circle's end:
 aLineStartPoint.setValue(50., 0.)
 aLineEndPoint.setValue(100., 25.)
@@ -70,13 +62,12 @@ aSession.finishOperation()
 # Link arc's end and line's start points with concidence constraint
 #=========================================================================
 aSession.startOperation()
-aConstraint = aDocument.addFeature("SketchConstraintCoincidence")
-aSketchReflist.append(aConstraint)
-aConstraintData = aConstraint.data()
-reflistA = aConstraintData.refattr("ConstraintEntityA")
-reflistB = aConstraintData.refattr("ConstraintEntityB")
+aConstraint = aSketchFeature.addFeature("SketchConstraintCoincidence")
+reflistA = aConstraint.refattr("ConstraintEntityA")
+reflistB = aConstraint.refattr("ConstraintEntityB")
 reflistA.setAttr(anArcEndPoint)
 reflistB.setAttr(aLineStartPoint)
+aConstraint.execute()
 aSession.finishOperation()
 #=========================================================================
 # Check values and move one constrainted object
@@ -88,9 +79,9 @@ assert (aLineStartPoint.y() == 0)
 deltaX = deltaY = 40.
 #  move line
 aSession.startOperation()
-aLineStartPoint.setValue(aLineStartPoint.x() + deltaX,
+anArcStartPoint.setValue(aLineStartPoint.x() + deltaX,
                          aLineStartPoint.y() + deltaY)
-aLineEndPoint.setValue(aLineEndPoint.x() + deltaX,
+anArcEndPoint.setValue(aLineEndPoint.x() + deltaX,
                        aLineEndPoint.y() + deltaY)
 aSession.finishOperation()
 # check that arc's points are moved also