From 06728dfdef7d2bcfb29da0d6f0dadb93f749a496 Mon Sep 17 00:00:00 2001 From: Renaud NEDELEC Date: Fri, 6 Nov 2015 10:28:48 +0100 Subject: [PATCH] [PythonAPI / sketcher] update getter names as discussed with DBC --- src/PythonAPI/Test/TestSketcherAddArc.py | 20 ++++---- src/PythonAPI/Test/TestSketcherSetTangent.py | 2 +- src/PythonAPI/model/sketcher/arc.py | 49 ++++++++++---------- src/PythonAPI/model/sketcher/sketch.py | 2 +- 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/PythonAPI/Test/TestSketcherAddArc.py b/src/PythonAPI/Test/TestSketcherAddArc.py index 9b433f0fd..1f83a1153 100644 --- a/src/PythonAPI/Test/TestSketcherAddArc.py +++ b/src/PythonAPI/Test/TestSketcherAddArc.py @@ -10,8 +10,8 @@ class SketcherAddArc(SketcherTestCase): def test_arc_by_coords(self): arc = self.sketch.addArc(0, 1, 0, 0, 1, 1) model.do() - self.assertEqual(arc.startPointData().x(), 0) - self.assertEqual(arc.startPointData().y(), 0) + self.assertEqual(arc.startPoint().x(), 0) + self.assertEqual(arc.startPoint().y(), 0) def test_arc_by_points(self): center = geom.Pnt2d(0, 1) @@ -19,8 +19,8 @@ class SketcherAddArc(SketcherTestCase): end = geom.Pnt2d(1, 1) arc = self.sketch.addArc(center, start, end) model.do() - self.assertEqual(arc.startPointData().x(), 0) - self.assertEqual(arc.startPointData().y(), 0) + self.assertEqual(arc.startPoint().x(), 0) + self.assertEqual(arc.startPoint().y(), 0) def test_number_of_args(self): with self.assertRaises(WrongNumberOfArguments): @@ -34,12 +34,12 @@ class SketcherAddArc(SketcherTestCase): arc.setStartPoint(-1.0, 0) arc.setEndPoint(0, 1.0) model.do() - self.assertEqual(arc.centerData().x(), 0) - self.assertEqual(arc.centerData().y(), 0) - self.assertEqual(arc.startPointData().x(), -1) - self.assertEqual(arc.startPointData().y(), 0) - self.assertEqual(arc.endPointData().x(), 0) - self.assertEqual(arc.endPointData().y(), 1) + self.assertEqual(arc.center().x(), 0) + self.assertEqual(arc.center().y(), 0) + self.assertEqual(arc.startPoint().x(), -1) + self.assertEqual(arc.startPoint().y(), 0) + self.assertEqual(arc.endPoint().x(), 0) + self.assertEqual(arc.endPoint().y(), 1) if __name__ == "__main__": diff --git a/src/PythonAPI/Test/TestSketcherSetTangent.py b/src/PythonAPI/Test/TestSketcherSetTangent.py index 5b0959fd2..2e782649c 100644 --- a/src/PythonAPI/Test/TestSketcherSetTangent.py +++ b/src/PythonAPI/Test/TestSketcherSetTangent.py @@ -8,7 +8,7 @@ class SketcherSetTangent(SketcherTestCase): self.line = self.sketch.addLine(0, 0, 0, 1) self.arc = self.sketch.addArc(0, 1, 0, 0, 1, 1) self.sketch.setCoincident( - self.line.endPointData(), self.arc.startPointData() + self.line.endPointData(), self.arc.startPoint() ) def test_set_tangent(self): diff --git a/src/PythonAPI/model/sketcher/arc.py b/src/PythonAPI/model/sketcher/arc.py index 0a7ae432d..212666af8 100644 --- a/src/PythonAPI/model/sketcher/arc.py +++ b/src/PythonAPI/model/sketcher/arc.py @@ -29,25 +29,7 @@ class Arc(Interface): ) self.execute() - ######## - # - # Set methods - # - ######## - - def setCenter(self, x, y): - """Set arc center.""" - self._center.setValue(x, y) - def setStartPoint(self, x, y): - """Set start point.""" - self._start_point.setValue(x, y) - - def setEndPoint(self, x, y): - """Set end point value.""" - self._end_point.setValue(x, y) - - ######## # # Getters @@ -55,21 +37,40 @@ class Arc(Interface): ######## - def centerData(self): - """Return the center point data.""" + def center(self): + """Return the center point.""" return self._center - def startPointData(self): - """Return the start point data.""" + def startPoint(self): + """Return the start point.""" return self._start_point - def endPointData(self): - """Return the end point data.""" + def endPoint(self): + """Return the end point.""" return self._end_point def result(self): """Return the arc circular line attribute.""" return self._feature.lastResult() + + + ######## + # + # Set methods + # + ######## + + def setCenter(self, x, y): + """Set arc center.""" + self._center.setValue(x, y) + + def setStartPoint(self, x, y): + """Set start point.""" + self._start_point.setValue(x, y) + + def setEndPoint(self, x, y): + """Set end point value.""" + self._end_point.setValue(x, y) ######## diff --git a/src/PythonAPI/model/sketcher/sketch.py b/src/PythonAPI/model/sketcher/sketch.py index 828284530..24268b4c5 100644 --- a/src/PythonAPI/model/sketcher/sketch.py +++ b/src/PythonAPI/model/sketcher/sketch.py @@ -45,7 +45,7 @@ def addSketch(document, plane): Returns: Sketch: sketch object """ - feature = featureToCompositeFeature(doc.addFeature("Sketch")) + feature = featureToCompositeFeature(document.addFeature("Sketch")) return Sketch(feature, plane) class Sketch(Interface): -- 2.39.2