]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_FeaturePointPrs.cpp
Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / PartSet / PartSet_FeaturePointPrs.cpp
1 // File:        PartSet_FeaturePrs.h
2 // Created:     04 Jun 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #include <PartSet_FeaturePointPrs.h>
6 #include <PartSet_Tools.h>
7
8 #include <SketchPlugin_Feature.h>
9 #include <SketchPlugin_Sketch.h>
10 #include <SketchPlugin_Point.h>
11
12 #include <GeomDataAPI_Point2D.h>
13
14 #include <ModelAPI_Data.h>
15 #include <ModelAPI_Document.h>
16 #include <ModelAPI_AttributeRefAttr.h>
17 #include <ModelAPI_AttributeRefList.h>
18
19 #include <Precision.hxx>
20
21 using namespace std;
22
23 PartSet_FeaturePointPrs::PartSet_FeaturePointPrs(FeaturePtr theSketch)
24 : PartSet_FeaturePrs(theSketch)
25 {
26 }
27
28 void PartSet_FeaturePointPrs::initFeature(FeaturePtr theFeature)
29 {
30 }
31
32 PartSet_SelectionMode PartSet_FeaturePointPrs::setPoint(double theX, double theY,
33                                                        const PartSet_SelectionMode& theMode)
34 {
35   PartSet_SelectionMode aMode = theMode;
36   switch (theMode)
37   {
38     case SM_FirstPoint: {
39       PartSet_Tools::setFeaturePoint(feature(), theX, theY, POINT_ATTR_COORD);
40       aMode = SM_DonePoint;
41     }
42     break;
43     default:
44       break;
45   }
46   return aMode;
47 }
48
49 std::string PartSet_FeaturePointPrs::getAttribute(const PartSet_SelectionMode& theMode) const
50 {
51   std::string aAttribute;
52   switch (theMode)
53   {
54     case SM_FirstPoint:
55       aAttribute = POINT_ATTR_COORD;
56     break;
57     default:
58     break;
59   }
60   return aAttribute;
61 }
62
63 PartSet_SelectionMode PartSet_FeaturePointPrs::getNextMode(const std::string& theAttribute) const
64 {
65   PartSet_SelectionMode aMode;
66
67   if (theAttribute == POINT_ATTR_COORD)
68     aMode = SM_DonePoint;
69   return aMode;
70 }
71
72 boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeaturePointPrs::featurePoint
73                                                      (const PartSet_SelectionMode& theMode)
74 {
75   std::string aPointArg;
76   switch (theMode)
77   {
78     case SM_FirstPoint:
79       aPointArg = POINT_ATTR_COORD;
80       break;
81     default:
82       break;
83   }
84   boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
85   boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
86                                                               (aData->attribute(aPointArg));
87   return aPoint;
88 }