+# Copyright (C) 2014-2023 CEA, EDF
+#
+# 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
+#
+
"""
TestConstraintParallel.py
Unit test of SketchPlugin_ConstraintParallel class
-
+
SketchPlugin_ConstraintParallel
static const std::string MY_CONSTRAINT_PARALLEL_ID("SketchConstraintParallel");
data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
"""
from GeomDataAPI import *
from ModelAPI import *
+from salome.shaper import model
+
#=========================================================================
# Initialization of the test
#=========================================================================
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()
aLineBStartPoint.setValue(0., 50)
aLineBEndPoint.setValue(80., 75)
aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
#=========================================================================
# Make a constraint to keep the length of the line constant
# to parallel perpendicular constraint collapsing line to point
assert (aLineBStartPoint.y() == 50)
assert (aLineBEndPoint.x() == 80)
assert (aLineBEndPoint.y() == 75)
+assert (model.dof(aSketchFeature) == 6)
#=========================================================================
# Link lines with parallel constraint
#=========================================================================
refattrB.setObject(aResultB)
aParallelConstraint.execute()
aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 5)
#=========================================================================
# Check values and move one constrainted object
#=========================================================================
assert (aLineBStartPointPrev != aLineBStartPointNew)
assert (aLineBEndPointPrev != aLineBEndPointNew)
+assert (model.dof(aSketchFeature) == 5)
#=========================================================================
# End of test
#=========================================================================
+
+assert(model.checkPythonDump())