Salome HOME
d6be6744de7bd96ae6d6bbc202520c2f5949a114
[modules/shaper.git] / src / SketchAPI / SketchAPI_Line.cpp
1 // Name   : SketchAPI_Line.cpp
2 // Purpose: 
3 //
4 // History:
5 // 07/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "SketchAPI_Line.h"
9 //--------------------------------------------------------------------------------------
10 #include <GeomAPI_Pnt2d.h>
11 //--------------------------------------------------------------------------------------
12 #include <ModelHighAPI_Selection.h>
13 #include <ModelHighAPI_Tools.h>
14 //--------------------------------------------------------------------------------------
15 SketchAPI_Line::SketchAPI_Line(
16     const std::shared_ptr<ModelAPI_Feature> & theFeature)
17 : SketchAPI_SketchEntity(theFeature)
18 {
19   initialize();
20 }
21
22 SketchAPI_Line::SketchAPI_Line(
23     const std::shared_ptr<ModelAPI_Feature> & theFeature,
24     double theX1, double theY1, double theX2, double theY2)
25 : SketchAPI_SketchEntity(theFeature)
26 {
27   if (initialize()) {
28     setByCoordinates(theX1, theY1, theX2, theY2);
29   }
30 }
31
32 SketchAPI_Line::SketchAPI_Line(
33     const std::shared_ptr<ModelAPI_Feature> & theFeature,
34     const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
35     const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
36 : SketchAPI_SketchEntity(theFeature)
37 {
38   if (initialize()) {
39     setByPoints(theStartPoint, theEndPoint);
40   }
41 }
42
43 SketchAPI_Line::SketchAPI_Line(
44     const std::shared_ptr<ModelAPI_Feature> & theFeature,
45     const ModelHighAPI_Selection & theExternal )
46 : SketchAPI_SketchEntity(theFeature)
47 {
48   if (initialize()) {
49     setByExternal(theExternal);
50   }
51 }
52
53 SketchAPI_Line::SketchAPI_Line(
54     const std::shared_ptr<ModelAPI_Feature> & theFeature,
55     const std::string & theExternalName )
56 : SketchAPI_SketchEntity(theFeature)
57 {
58   if (initialize()) {
59     setByExternalName(theExternalName);
60   }
61 }
62
63 SketchAPI_Line::~SketchAPI_Line()
64 {
65
66 }
67
68 //--------------------------------------------------------------------------------------
69 void SketchAPI_Line::setByCoordinates(
70     double theX1, double theY1, double theX2, double theY2)
71 {
72   fillAttribute(startPoint(), theX1, theY1);
73   fillAttribute(endPoint(), theX2, theY2);
74
75   execute();
76 }
77
78 void SketchAPI_Line::setByPoints(
79     const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
80     const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
81 {
82   fillAttribute(theStartPoint, startPoint());
83   fillAttribute(theEndPoint, endPoint());
84
85   execute();
86 }
87
88 void SketchAPI_Line::setByExternal(const ModelHighAPI_Selection & theExternal)
89 {
90   fillAttribute(theExternal, external());
91
92   execute();
93 }
94
95 void SketchAPI_Line::setByExternalName(const std::string & theExternalName)
96 {
97   fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
98
99   execute();
100 }
101
102 //--------------------------------------------------------------------------------------
103 void SketchAPI_Line::setStartPoint(double theX, double theY)
104 {
105   fillAttribute(startPoint(), theX, theY);
106
107   execute();
108 }
109 void SketchAPI_Line::setStartPoint(const std::shared_ptr<GeomAPI_Pnt2d> & thePoint)
110 {
111   fillAttribute(thePoint, startPoint());
112
113   execute();
114 }
115 void SketchAPI_Line::setEndPoint(double theX, double theY)
116 {
117   fillAttribute(endPoint(), theX, theY);
118
119   execute();
120 }
121 void SketchAPI_Line::setEndPoint(const std::shared_ptr<GeomAPI_Pnt2d> & thePoint)
122 {
123   fillAttribute(thePoint, endPoint());
124
125   execute();
126 }
127
128 //--------------------------------------------------------------------------------------
129