+# Copyright (C) 2014-2020 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
"""
TestConstraintCoincidence.py
Unit test of SketchPlugin_ConstraintCoincidence class
from GeomDataAPI import *
from ModelAPI import *
import math
+from salome.shaper import model
+
#=========================================================================
# Initialization of the test
#=========================================================================
# add an origin
aSession.startOperation()
aFeature = aDocument.addFeature("Point")
-# aFeature.string("creation_method").setValue("by_xyz")
-aFeature.real("x").setValue(0.)
-aFeature.real("y").setValue(0.)
-aFeature.real("z").setValue(0.)
+geomDataAPI_Point(aFeature.attribute("point3d")).setValue(0., 0., 0.)
+aFeature.string("creation_method").setValue("by_xyz")
anOriginName = aFeature.name()
aSession.finishOperation()
#=========================================================================
aStartPoint2.setValue(10., 100.)
aEndPoint2.setValue(100., 25.)
aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
#=========================================================================
# Make end point of second line middle point on first line
#=========================================================================
reflistB.setObject(aLine1.lastResult())
aConstraint.execute()
aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 6)
#=========================================================================
# Check values and move one constrainted object
aStartPoint1.setValue(aStartPoint1.x() + deltaX, aStartPoint1.y() + deltaY)
aSession.finishOperation()
checkMiddlePoint(aEndPoint2, aLine1)
+assert (model.dof(aSketchFeature) == 6)
#=========================================================================
# Remove constraint and move the line
#=========================================================================
aSession.startOperation()
aDocument.removeFeature(aConstraint)
aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
aSession.startOperation()
aEndPoint1.setValue(90., 0.)
aSession.finishOperation()
assert (aEndPoint2.x() == aCurX and aEndPoint2.y() == aCurY)
+assert (model.dof(aSketchFeature) == 8)
#=========================================================================
# Set external point as a middle point
anOrigShape = anOrigRes.shape()
assert (anOrigShape)
anOrigin = aSketchFeature.addFeature("SketchPoint")
-anOriginCoord = geomDataAPI_Point2D(anOrigin.attribute("PointCoordindates"))
+anOriginCoord = geomDataAPI_Point2D(anOrigin.attribute("PointCoordinates"))
anOriginCoord.setValue(0., 0.)
anOrigin.selection("External").setValue(anOrigRes, anOrigShape)
aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
# middle point constraint
aSession.startOperation()
aConstraint = aSketchFeature.addFeature("SketchConstraintMiddle")
reflistB.setObject(anOrigin.lastResult())
aSession.finishOperation()
checkMiddlePoint(anOriginCoord, aLine2)
+assert (model.dof(aSketchFeature) == 6)
#=========================================================================
# Check origin coordinates does not changed
#=========================================================================
reflistA.setAttr(aEndPoint3)
reflistB.setObject(aLine1.lastResult())
aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 9)
#=========================================================================
# Set Middle point
#=========================================================================
aSession.finishOperation()
# check the point, and no error message
assert aSketchFeature.string("SolverError").value() == ""
+assert (model.dof(aSketchFeature) == 8)
checkMiddlePoint(aEndPoint3, aLine1)
#=========================================================================
# Remove coincidence and move one line
aEndPoint1.setValue(aEndPoint1.x() + deltaX, aEndPoint1.y() + deltaY)
aSession.finishOperation()
checkMiddlePoint(aEndPoint3, aLine1)
+assert (model.dof(aSketchFeature) == 8)
#=========================================================================
# End of test
#=========================================================================
-from salome.shaper import model
assert(model.checkPythonDump())