Salome HOME
Merge branch 'CPPHighAPI'
[modules/shaper.git] / src / SketchAPI / SketchAPI_Point.cpp
1 // Name   : SketchAPI_Point.cpp
2 // Purpose: 
3 //
4 // History:
5 // 15/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "SketchAPI_Point.h"
9 //--------------------------------------------------------------------------------------
10 #include <GeomAPI_Pnt2d.h>
11 //--------------------------------------------------------------------------------------
12 #include <ModelHighAPI_Selection.h>
13 #include <ModelHighAPI_Tools.h>
14 //--------------------------------------------------------------------------------------
15 SketchAPI_Point::SketchAPI_Point(
16     const std::shared_ptr<ModelAPI_Feature> & theFeature)
17 : SketchAPI_SketchEntity(theFeature)
18 {
19   initialize();
20 }
21
22 SketchAPI_Point::SketchAPI_Point(
23     const std::shared_ptr<ModelAPI_Feature> & theFeature,
24     double theX, double theY)
25 : SketchAPI_SketchEntity(theFeature)
26 {
27   if (initialize()) {
28     setCoordinates(theX, theY);
29   }
30 }
31
32 SketchAPI_Point::SketchAPI_Point(
33     const std::shared_ptr<ModelAPI_Feature> & theFeature,
34     const std::shared_ptr<GeomAPI_Pnt2d> & thePoint)
35 : SketchAPI_SketchEntity(theFeature)
36 {
37   if (initialize()) {
38     setCoordinates(thePoint);
39   }
40 }
41
42 SketchAPI_Point::SketchAPI_Point(
43     const std::shared_ptr<ModelAPI_Feature> & theFeature,
44     const ModelHighAPI_Selection & theExternal )
45 : SketchAPI_SketchEntity(theFeature)
46 {
47   if (initialize()) {
48     setByExternal(theExternal);
49   }
50 }
51
52 SketchAPI_Point::SketchAPI_Point(
53     const std::shared_ptr<ModelAPI_Feature> & theFeature,
54     const std::string & theExternalName )
55 : SketchAPI_SketchEntity(theFeature)
56 {
57   if (initialize()) {
58     setByExternalName(theExternalName);
59   }
60 }
61
62 SketchAPI_Point::~SketchAPI_Point()
63 {
64
65 }
66
67 //--------------------------------------------------------------------------------------
68 void SketchAPI_Point::setCoordinates(
69     double theX, double theY)
70 {
71   fillAttribute(coordinates(), theX, theY);
72
73   execute();
74 }
75
76 void SketchAPI_Point::setCoordinates(
77     const std::shared_ptr<GeomAPI_Pnt2d> & thePoint)
78 {
79   fillAttribute(thePoint, coordinates());
80
81   execute();
82 }
83
84 void SketchAPI_Point::setByExternal(const ModelHighAPI_Selection & theExternal)
85 {
86   fillAttribute(theExternal, external());
87
88   execute();
89 }
90
91 void SketchAPI_Point::setByExternalName(const std::string & theExternalName)
92 {
93   fillAttribute(ModelHighAPI_Selection("VERTEX", theExternalName), external());
94
95   execute();
96 }
97
98 //--------------------------------------------------------------------------------------