Salome HOME
Simplified calculation of fly out distance and creation of constraints limited only...
[modules/shaper.git] / src / SketchPlugin / Test / TestConstraintLength.py
index 28f032e4ad309da415c1e6b4fd1ed1e5e25530cc..87a388a65021fb5eaf48bd593810e67ceafbe5ab 100644 (file)
@@ -4,9 +4,9 @@
         
     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 *
@@ -15,7 +15,7 @@ from ModelAPI import *
 # Initialization of the test
 #=========================================================================
 
-__updated__ = "2014-09-26"
+__updated__ = "2014-10-28"
 
 aSession = ModelAPI_Session.get()
 aDocument = aSession.moduleDocument()
@@ -23,27 +23,22 @@ 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 with length 100
 #=========================================================================
 aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
-aSketchLineA = aDocument.addFeature("SketchLine")
-aSketchReflist.append(aSketchLineA)
-aLineAStartPoint = geomDataAPI_Point2D(
-    aSketchLineA.data().attribute("StartPoint"))
-aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.data().attribute("EndPoint"))
+aSketchLineA = aSketchFeature.addFeature("SketchLine")
+aLineAStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint"))
+aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint"))
 aLineAStartPoint.setValue(0., 25.)
 aLineAEndPoint.setValue(100., 25.)
 aSession.finishOperation()
@@ -51,11 +46,9 @@ aSession.finishOperation()
 # Make a constraint to keep the length
 #=========================================================================
 aSession.startOperation()
-aLengthConstraint = aDocument.addFeature("SketchConstraintLength")
-aSketchReflist.append(aLengthConstraint)
-aConstraintData = aLengthConstraint.data()
-refattrA = aConstraintData.refattr("ConstraintEntityA")
-aLength = aConstraintData.real("ConstraintValue")
+aLengthConstraint = aSketchFeature.addFeature("SketchConstraintLength")
+refattrA = aLengthConstraint.refattr("ConstraintEntityA")
+aLength = aLengthConstraint.real("ConstraintValue")
 assert (not refattrA.isInitialized())
 assert (not aLength.isInitialized())