Salome HOME
d4cf88274f293485b53b9c7cd5636f489c431c3f
[modules/shaper.git] / src / FeaturesPlugin / Test / TestMeasurementPresentation.py
1 # Copyright (C) 2018-2023  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 from salome.shaper import model
21
22 from ConfigAPI import *
23 Config_PropManager().registerProp("Visualization", "dimension_value_size", "Dimension value size", Config_Prop.IntSpin, "16")
24 Config_PropManager().registerProp("Visualization", "dimension_arrow_size", "Dimension arrow size", Config_Prop.IntSpin, "16")
25 Config_PropManager().registerProp("Visualization", "dimension_font", "Dimension font", Config_Prop.String, "Times-bold")
26 Config_PropManager().registerProp("Visualization", "sketch_dimension_color", "Dimension color", Config_Prop.Color, "64,128,225")
27
28 model.begin()
29 partSet = model.moduleDocument()
30 Part_1 = model.addPart(partSet)
31 Part_1_doc = Part_1.document()
32 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
33 SketchLine_1 = Sketch_1.addLine(-15.79157881408318, 17.46869043106789, -28.20135254460625, -14.21916935022164)
34 SketchLine_2 = Sketch_1.addLine(-28.20135254460625, -14.21916935022164, 5.332188506333114, -12.56026625936245)
35 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
36 SketchArc_1 = Sketch_1.addArc(-8.886980843888518, -0.1184930779185158, 5.332188506333114, -12.56026625936245, -15.79157881408318, 17.46869043106789, False)
37 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_1.startPoint())
38 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.endPoint())
39 model.do()
40 model.end()
41
42 from ModelAPI import *
43
44 aSession = ModelAPI_Session.get()
45 aSession.startOperation()
46 aMeasurement = Part_1_doc.addFeature("Measurement")
47 aMeasurement.string("MeasureKind").setValue("Length")
48 aMeasurement.selection("edge_for_length").selectSubShape("EDGE", "Sketch_1/SketchLine_1")
49 anAIS = featureToPresentation(aMeasurement).getAISObject(None)
50 assert(anAIS is not None)
51 anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS)
52 assert(anAIS is not None)
53 aSession.finishOperation()
54
55 aSession.startOperation()
56 aMeasurement = Part_1_doc.addFeature("Measurement")
57 aMeasurement.string("MeasureKind").setValue("Distance")
58 aMeasurement.selection("distance_from").selectSubShape("VERTEX", "Sketch_1/SketchLine_1_StartVertex")
59 aMeasurement.selection("distance_to").selectSubShape("EDGE", "Sketch_1/SketchLine_2")
60 anAIS = featureToPresentation(aMeasurement).getAISObject(None)
61 assert(anAIS is not None)
62 anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS)
63 assert(anAIS is not None)
64 aSession.finishOperation()
65
66 aSession.startOperation()
67 aMeasurement = Part_1_doc.addFeature("Measurement")
68 aMeasurement.string("MeasureKind").setValue("Radius")
69 aMeasurement.selection("circular").selectSubShape("EDGE", "Sketch_1/SketchArc_1_2")
70 anAIS = featureToPresentation(aMeasurement).getAISObject(None)
71 assert(anAIS is not None)
72 anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS)
73 assert(anAIS is not None)
74 aSession.finishOperation()
75
76 aSession.startOperation()
77 aMeasurement = Part_1_doc.addFeature("Measurement")
78 aMeasurement.string("MeasureKind").setValue("Angle")
79 aMeasurement.selection("angle_from").selectSubShape("EDGE", "Sketch_1/SketchLine_1")
80 aMeasurement.selection("angle_to").selectSubShape("EDGE", "Sketch_1/SketchLine_2")
81 anAIS = featureToPresentation(aMeasurement).getAISObject(None)
82 assert(anAIS is not None)
83 anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS)
84 assert(anAIS is not None)
85 aSession.finishOperation()
86
87 aSession.startOperation()
88 aMeasurement = Part_1_doc.addFeature("Measurement")
89 aMeasurement.string("MeasureKind").setValue("AngleBy3Points")
90 aMeasurement.selection("angle_point_1").selectSubShape("VERTEX", "Sketch_1/SketchLine_1_StartVertex")
91 aMeasurement.selection("angle_point_2").selectSubShape("VERTEX", "Sketch_1/SketchLine_1_EndVertex")
92 aMeasurement.selection("angle_point_3").selectSubShape("VERTEX", "Sketch_1/SketchLine_2_EndVertex")
93 anAIS = featureToPresentation(aMeasurement).getAISObject(None)
94 assert(anAIS is not None)
95 anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS)
96 assert(anAIS is not None)
97 aSession.finishOperation()