1 // File: PartSet_FeaturePrs.h
2 // Created: 04 Jun 2014
3 // Author: Natalia ERMOLAEVA
5 #include <PartSet_FeatureArcPrs.h>
6 #include <PartSet_Tools.h>
8 #include <SketchPlugin_Feature.h>
9 #include <SketchPlugin_Sketch.h>
10 #include <SketchPlugin_ConstraintCoincidence.h>
11 #include <SketchPlugin_Line.h>
12 #include <SketchPlugin_Constraint.h>
14 #include <GeomDataAPI_Point2D.h>
16 #include <ModelAPI_Data.h>
17 #include <ModelAPI_Document.h>
18 #include <ModelAPI_AttributeRefAttr.h>
19 #include <ModelAPI_AttributeRefList.h>
21 #include <Precision.hxx>
25 PartSet_FeatureArcPrs::PartSet_FeatureArcPrs(FeaturePtr theSketch)
26 : PartSet_FeaturePrs(theSketch)
30 void PartSet_FeatureArcPrs::initFeature(FeaturePtr theFeature)
32 if (feature() && theFeature)
34 // use the last point of the previous feature as the first of the new one
35 boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
36 boost::shared_ptr<GeomDataAPI_Point2D> anInitPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
37 (aData->attribute(LINE_ATTR_END));
38 PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_START);
39 PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_END);
41 aData = feature()->data();
42 boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
43 (aData->attribute(LINE_ATTR_START));
44 PartSet_Tools::createConstraint(sketch(), anInitPoint, aPoint);
48 PartSet_SelectionMode PartSet_FeatureArcPrs::setPoint(double theX, double theY,
49 const PartSet_SelectionMode& theMode)
51 PartSet_SelectionMode aMode = theMode;
55 PartSet_Tools::setFeaturePoint(feature(), theX, theY, LINE_ATTR_START);
56 PartSet_Tools::setFeaturePoint(feature(), theX, theY, LINE_ATTR_END);
57 aMode = SM_SecondPoint;
60 case SM_SecondPoint: {
61 PartSet_Tools::setFeaturePoint(feature(), theX, theY, LINE_ATTR_END);
71 std::string PartSet_FeatureArcPrs::getAttribute(const PartSet_SelectionMode& theMode) const
73 std::string aAttribute;
77 aAttribute = LINE_ATTR_START;
80 aAttribute = LINE_ATTR_END;
88 PartSet_SelectionMode PartSet_FeatureArcPrs::getNextMode(const std::string& theAttribute) const
90 PartSet_SelectionMode aMode;
92 if (theAttribute == LINE_ATTR_START)
93 aMode = SM_SecondPoint;
94 else if (theAttribute == LINE_ATTR_END)
99 boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeatureArcPrs::featurePoint
100 (const PartSet_SelectionMode& theMode)
102 std::string aPointArg;
106 aPointArg = LINE_ATTR_START;
109 aPointArg = LINE_ATTR_END;
114 boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
115 boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
116 (aData->attribute(aPointArg));