Salome HOME
High level objects history implementation for Translation, Rotation and Scale features.
[modules/shaper.git] / src / FeaturesPlugin / Test / TestMeasurementPresentation.py
1 ## Copyright (C) 2018-20xx  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
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 from salome.shaper import model
22
23 from ConfigAPI import *
24 Config_PropManager().registerProp("Visualization", "dimension_value_size", "Dimension value size", Config_Prop.IntSpin, "16")
25 Config_PropManager().registerProp("Visualization", "dimension_arrow_size", "Dimension arrow size", Config_Prop.IntSpin, "16")
26 Config_PropManager().registerProp("Visualization", "dimension_font", "Dimension font", Config_Prop.String, "Times-bold")
27 Config_PropManager().registerProp("Visualization", "sketch_dimension_color", "Dimension color", Config_Prop.Color, "64,128,225")
28
29 model.begin()
30 partSet = model.moduleDocument()
31 Part_1 = model.addPart(partSet)
32 Part_1_doc = Part_1.document()
33 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
34 SketchLine_1 = Sketch_1.addLine(-15.79157881408318, 17.46869043106789, -28.20135254460625, -14.21916935022164)
35 SketchLine_2 = Sketch_1.addLine(-28.20135254460625, -14.21916935022164, 5.332188506333114, -12.56026625936245)
36 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
37 SketchArc_1 = Sketch_1.addArc(-8.886980843888518, -0.1184930779185158, 5.332188506333114, -12.56026625936245, -15.79157881408318, 17.46869043106789, False)
38 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_1.startPoint())
39 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.endPoint())
40 model.do()
41 model.end()
42
43 from ModelAPI import *
44
45 aSession = ModelAPI_Session.get()
46 aSession.startOperation()
47 aMeasurement = Part_1_doc.addFeature("Measurement")
48 aMeasurement.string("MeasureKind").setValue("Length")
49 aMeasurement.selection("edge_for_length").selectSubShape("EDGE", "Sketch_1/SketchLine_1")
50 anAIS = featureToPresentation(aMeasurement).getAISObject(None)
51 assert(anAIS is not None)
52 anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS)
53 assert(anAIS is not None)
54 aSession.finishOperation()
55
56 aSession.startOperation()
57 aMeasurement = Part_1_doc.addFeature("Measurement")
58 aMeasurement.string("MeasureKind").setValue("Distance")
59 aMeasurement.selection("distance_from").selectSubShape("VERTEX", "Sketch_1/SketchLine_1_StartVertex")
60 aMeasurement.selection("distance_to").selectSubShape("EDGE", "Sketch_1/SketchLine_2")
61 anAIS = featureToPresentation(aMeasurement).getAISObject(None)
62 assert(anAIS is not None)
63 anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS)
64 assert(anAIS is not None)
65 aSession.finishOperation()
66
67 aSession.startOperation()
68 aMeasurement = Part_1_doc.addFeature("Measurement")
69 aMeasurement.string("MeasureKind").setValue("Radius")
70 aMeasurement.selection("circular").selectSubShape("EDGE", "Sketch_1/SketchArc_1_2")
71 anAIS = featureToPresentation(aMeasurement).getAISObject(None)
72 assert(anAIS is not None)
73 anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS)
74 assert(anAIS is not None)
75 aSession.finishOperation()
76
77 aSession.startOperation()
78 aMeasurement = Part_1_doc.addFeature("Measurement")
79 aMeasurement.string("MeasureKind").setValue("Angle")
80 aMeasurement.selection("angle_from").selectSubShape("EDGE", "Sketch_1/SketchLine_1")
81 aMeasurement.selection("angle_to").selectSubShape("EDGE", "Sketch_1/SketchLine_2")
82 anAIS = featureToPresentation(aMeasurement).getAISObject(None)
83 assert(anAIS is not None)
84 anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS)
85 assert(anAIS is not None)
86 aSession.finishOperation()
87
88 aSession.startOperation()
89 aMeasurement = Part_1_doc.addFeature("Measurement")
90 aMeasurement.string("MeasureKind").setValue("AngleBy3Points")
91 aMeasurement.selection("angle_point_1").selectSubShape("VERTEX", "Sketch_1/SketchLine_1_StartVertex")
92 aMeasurement.selection("angle_point_2").selectSubShape("VERTEX", "Sketch_1/SketchLine_1_EndVertex")
93 aMeasurement.selection("angle_point_3").selectSubShape("VERTEX", "Sketch_1/SketchLine_2_EndVertex")
94 anAIS = featureToPresentation(aMeasurement).getAISObject(None)
95 assert(anAIS is not None)
96 anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS)
97 assert(anAIS is not None)
98 aSession.finishOperation()