1 // File: PartSet_FeaturePrs.h
2 // Created: 04 Jun 2014
3 // Author: Natalia ERMOLAEVA
5 #include <PartSet_FeatureCirclePrs.h>
6 #include <PartSet_Tools.h>
8 #include <SketchPlugin_Feature.h>
9 #include <SketchPlugin_Sketch.h>
10 #include <SketchPlugin_Circle.h>
12 #include <GeomDataAPI_Point2D.h>
13 #include <GeomAPI_Pnt2d.h>
15 #include <ModelAPI_Data.h>
16 #include <ModelAPI_Document.h>
17 #include <ModelAPI_AttributeRefAttr.h>
18 #include <ModelAPI_AttributeRefList.h>
20 #include <Precision.hxx>
24 PartSet_FeatureCirclePrs::PartSet_FeatureCirclePrs(FeaturePtr theSketch)
25 : PartSet_FeaturePrs(theSketch)
29 PartSet_SelectionMode PartSet_FeatureCirclePrs::setPoint(double theX, double theY,
30 const PartSet_SelectionMode& theMode)
32 PartSet_SelectionMode aMode = theMode;
36 PartSet_Tools::setFeaturePoint(feature(), theX, theY, CIRCLE_ATTR_CENTER);
37 aMode = SM_SecondPoint;
40 case SM_SecondPoint: {
41 boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
42 boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
43 (aData->attribute(CIRCLE_ATTR_CENTER));
44 boost::shared_ptr<GeomAPI_Pnt2d> aCoordPoint(new GeomAPI_Pnt2d(theX, theY));
45 double aRadius = aCoordPoint->distance(aPoint->pnt());
46 PartSet_Tools::setFeatureValue(feature(), aRadius, CIRCLE_ATTR_RADIUS);
57 std::string PartSet_FeatureCirclePrs::getAttribute(const PartSet_SelectionMode& theMode) const
59 std::string aAttribute;
63 aAttribute = CIRCLE_ATTR_CENTER;
66 aAttribute = CIRCLE_ATTR_RADIUS;
74 PartSet_SelectionMode PartSet_FeatureCirclePrs::getNextMode(const std::string& theAttribute) const
76 PartSet_SelectionMode aMode;
78 if (theAttribute == CIRCLE_ATTR_CENTER)
79 aMode = SM_SecondPoint;
80 else if (theAttribute == CIRCLE_ATTR_RADIUS)
85 boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureCirclePrs::featurePoint
86 (const PartSet_SelectionMode& theMode)
88 std::string aPointArg;
92 aPointArg = CIRCLE_ATTR_CENTER;
97 boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
98 boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
99 (aData->attribute(aPointArg));