1 // Name : SketchAPI_Point.cpp
5 // 15/06/16 - Sergey POKHODENKO - Creation of the file
7 //--------------------------------------------------------------------------------------
8 #include "SketchAPI_Point.h"
9 //--------------------------------------------------------------------------------------
10 #include <GeomAPI_Pnt2d.h>
11 //--------------------------------------------------------------------------------------
12 #include <ModelHighAPI_Dumper.h>
13 #include <ModelHighAPI_Selection.h>
14 #include <ModelHighAPI_Tools.h>
15 //--------------------------------------------------------------------------------------
16 SketchAPI_Point::SketchAPI_Point(
17 const std::shared_ptr<ModelAPI_Feature> & theFeature)
18 : SketchAPI_SketchEntity(theFeature)
23 SketchAPI_Point::SketchAPI_Point(
24 const std::shared_ptr<ModelAPI_Feature> & theFeature,
25 double theX, double theY)
26 : SketchAPI_SketchEntity(theFeature)
29 setCoordinates(theX, theY);
33 SketchAPI_Point::SketchAPI_Point(
34 const std::shared_ptr<ModelAPI_Feature> & theFeature,
35 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint)
36 : SketchAPI_SketchEntity(theFeature)
39 setCoordinates(thePoint);
43 SketchAPI_Point::SketchAPI_Point(
44 const std::shared_ptr<ModelAPI_Feature> & theFeature,
45 const ModelHighAPI_Selection & theExternal )
46 : SketchAPI_SketchEntity(theFeature)
49 setByExternal(theExternal);
53 SketchAPI_Point::SketchAPI_Point(
54 const std::shared_ptr<ModelAPI_Feature> & theFeature,
55 const std::string & theExternalName )
56 : SketchAPI_SketchEntity(theFeature)
59 setByExternalName(theExternalName);
63 SketchAPI_Point::~SketchAPI_Point()
68 //--------------------------------------------------------------------------------------
69 void SketchAPI_Point::setCoordinates(
70 double theX, double theY)
72 fillAttribute(coordinates(), theX, theY);
77 void SketchAPI_Point::setCoordinates(
78 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint)
80 fillAttribute(thePoint, coordinates());
85 void SketchAPI_Point::setByExternal(const ModelHighAPI_Selection & theExternal)
87 fillAttribute(theExternal, external());
92 void SketchAPI_Point::setByExternalName(const std::string & theExternalName)
94 fillAttribute(ModelHighAPI_Selection("VERTEX", theExternalName), external());
99 //--------------------------------------------------------------------------------------
101 void SketchAPI_Point::dump(ModelHighAPI_Dumper& theDumper) const
103 FeaturePtr aBase = feature();
104 const std::string& aSketchName = theDumper.parentName(aBase);
106 AttributeSelectionPtr anExternal = aBase->selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
107 if (anExternal->value()) {
109 theDumper << aBase << " = " << aSketchName << ".addPoint(" << anExternal << ")" << std::endl;
111 // point given by coordinates
112 std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
113 aBase->attribute(SketchPlugin_Point::COORD_ID()));
114 theDumper << aBase << " = " << aSketchName << ".addPoint(" << aPoint << ")" << std::endl;