Salome HOME
Task 2.1. To be able to put an orthogonality constraint between an arc and a line
[modules/shaper.git] / src / SketchPlugin / Test / TestSketchPointLine.py
index 20a85e3dad8b73ef4496d2a628bbc7b6c63873e7..99db02246d764af75b6deb2dba8d8859c4475217 100644 (file)
@@ -1,3 +1,22 @@
+# Copyright (C) 2014-2019  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
+#
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -13,32 +32,25 @@ aDocument = aSession.moduleDocument()
 #=========================================================================
 aSession.startOperation()
 aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
 assert (aSketchFeature.getKind() == "Sketch")
-aSketchFeatureData = aSketchFeature.data()
-origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
+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()
 # check that values have been changed
-origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
 assert (origin.x() == 0)
 assert (origin.y() == 0)
 assert (origin.z() == 0)
-dirx = geomDataAPI_Dir(aSketchFeatureData.attribute("DirX"))
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
 assert (dirx.x() == 1)
 assert (dirx.y() == 0)
 assert (dirx.z() == 0)
-diry = geomDataAPI_Dir(aSketchFeatureData.attribute("DirY"))
-assert (diry.x() == 0)
-assert (diry.y() == 1)
-assert (diry.z() == 0)
-norm = geomDataAPI_Dir(aSketchFeatureData.attribute("Norm"))
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
 assert (norm.x() == 0)
 assert (norm.y() == 0)
 assert (norm.z() == 1)
@@ -46,28 +58,24 @@ assert (norm.z() == 1)
 # Creation of a point
 #=========================================================================
 aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
+aSketchReflist = aSketchFeature.reflist("Features")
 assert (not aSketchReflist.isInitialized())
 assert(aSketchReflist.size() == 0)
 assert (len(aSketchReflist.list()) == 0)
 # aSketchPoint = aDocument.addFeature("SketchPoint")
 aSketchPoint = aSketchFeature.addFeature("SketchPoint")
 assert (aSketchPoint.getKind() == "SketchPoint")
-aSketchPointData = aSketchPoint.data()
-coords = geomDataAPI_Point2D(aSketchPointData.attribute("PointCoordindates"))
-assert (coords.x() == 0)
-assert (coords.y() == 0)
+coords = geomDataAPI_Point2D(aSketchPoint.attribute("PointCoordinates"))
 assert (not coords.isInitialized())
 # Simulate SketchPlugin_Point::move(...)
 coords.setValue(10., 10.)
 assert (coords.isInitialized())
 aSession.finishOperation()
 # check that values have been changed
-aSketchReflist = aSketchFeatureData.reflist("Features")
+aSketchReflist = aSketchFeature.reflist("Features")
 assert (aSketchReflist.size() == 1)
 assert (len(aSketchReflist.list()) == 1)
-aSketchPointData = aSketchPoint.data()
-coords = geomDataAPI_Point2D(aSketchPointData.attribute("PointCoordindates"))
+coords = geomDataAPI_Point2D(aSketchPoint.attribute("PointCoordinates"))
 assert (coords.x() == 10.0)
 assert (coords.y() == 10.0)
 #=========================================================================
@@ -79,14 +87,9 @@ aSketchLine = aSketchFeature.addFeature("SketchLine")
 assert (aSketchLine.getKind() == "SketchLine")
 assert (aSketchReflist.size() == 2)
 assert (len(aSketchReflist.list()) == 2)
-aSketchLineData = aSketchLine.data()
-aLineStartPoint = geomDataAPI_Point2D(aSketchLineData.attribute("StartPoint"))
-aLineEndPoint = geomDataAPI_Point2D(aSketchLineData.attribute("EndPoint"))
-assert (aLineStartPoint.x() == 0)
-assert (aLineStartPoint.y() == 0)
+aLineStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint"))
+aLineEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
 assert (not aLineStartPoint.isInitialized())
-assert (aLineEndPoint.x() == 0)
-assert (aLineEndPoint.y() == 0)
 assert (not aLineEndPoint.isInitialized())
 # Simulate SketchPlugin_Line::move(...)
 aLineStartPoint.setValue(50., 50.)
@@ -95,9 +98,8 @@ assert (aLineStartPoint.isInitialized())
 assert (aLineEndPoint.isInitialized())
 aSession.finishOperation()
 # check that values have been changed
-aSketchLineData = aSketchLine.data()
-aLineStartPoint = geomDataAPI_Point2D(aSketchLineData.attribute("StartPoint"))
-aLineEndPoint = geomDataAPI_Point2D(aSketchLineData.attribute("EndPoint"))
+aLineStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint"))
+aLineEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
 assert (aLineStartPoint.x() == 50.0)
 assert (aLineStartPoint.y() == 50.0)
 assert (aLineEndPoint.x() == 60.0)
@@ -111,3 +113,6 @@ aResultConstruction = modelAPI_ResultConstruction(aResult)
 aShape = aResultConstruction.shape()
 assert (aShape is not None)
 assert (not aShape.isNull())
+
+from salome.shaper import model
+assert(model.checkPythonDump())