Salome HOME
6ba12c6d8630a711424c1286f55f501f056da41b
[modules/shaper.git] / src / PartSet / PartSet_FeaturePrs.h
1 // File:        PartSet_FeaturePrs.h
2 // Created:     04 Jun 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef PartSet_FeaturePrs_H
6 #define PartSet_FeaturePrs_H
7
8 #include "PartSet.h"
9
10 #include "PartSet_Constants.h"
11
12 class GeomDataAPI_Point2D;
13
14 /*!
15  \class PartSet_FeaturePrs
16  * \brief The abstract class to define the specific feature manipulation. It is created for
17  * the feature create operation to move out the feature properties set and use one operation
18  * for any type of features.
19 */
20 class PARTSET_EXPORT PartSet_FeaturePrs
21 {
22 public:
23   /// Constructor
24   /// \param theSketch the sketch feature
25   PartSet_FeaturePrs(FeaturePtr theSketch);
26   /// Destructor
27   virtual ~PartSet_FeaturePrs();
28
29   /// Initializes some fields of feature accorging to the source feature
30   /// Saves the fiature as the presentation internal feature
31   /// \param theFeature the presentation feature
32   /// \param theSourceFeature the feature, which attributes are used to initialize the feature
33   void init(FeaturePtr theFeature, FeaturePtr theSourceFeature);
34
35   /// Returns the operation sketch feature
36   /// \returns the sketch instance
37   FeaturePtr sketch() const;
38
39   /// Sets the point to the feature in an attribute depending on the selection mode
40   /// \param theX the 2D point horizontal coordinate
41   /// \param theY the 2D point vertical coordinate
42   /// \param theMode the selection mode
43   /// \return the new selection mode
44   virtual PartSet_SelectionMode setPoint(double theX, double theY,
45                                          const PartSet_SelectionMode& theMode) = 0;
46
47   /// Returns the feature attribute name for the selection mode
48   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
49   virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const = 0;
50
51   /// Returns the next selection mode after the attribute
52   /// \param theAttribute the feature attribute name
53   /// \return next attribute selection mode
54   virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const = 0;
55
56   /// \brief Move the full feature.
57   /// \param theDeltaX the delta for X coordinate is moved
58   /// \param theDeltaY the delta for Y coordinate is moved
59   virtual void move(double theDeltaX, double theDeltaY) = 0;
60
61   /// Return the distance between the feature and the point
62   /// \param theFeature feature object
63   /// \param theX the horizontal coordinate of the point
64   /// \param theX the vertical coordinate of the point
65   virtual double distanceToPoint(FeaturePtr theFeature, double theX, double theY) = 0;
66
67   /// Find a point in the line with given coordinates
68   /// \param theFeature the line feature
69   /// \param theX the horizontal point coordinate
70   /// \param theY the vertical point coordinate
71   virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
72                                                            double theY) = 0;
73
74   /// Creates constrains of the current 
75   /// \param theX the horizontal coordnate of the point
76   /// \param theY the vertical coordnate of the point
77   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
78   void setConstraints(double theX, double theY, const PartSet_SelectionMode& theMode);
79
80 protected:
81   /// Returns the operation feature
82   /// \return the feature
83   FeaturePtr feature() const;
84
85   /// Initializes current feature by the given
86   /// \param theSourceFeature the feature, which attributes are used to initialize the current feature
87   virtual void initFeature(FeaturePtr theSourceFeature) {};
88
89   /// Returns the feature point in the selection mode position.
90   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
91   virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode) = 0;
92
93 private:
94   FeaturePtr mySketch; ///< the sketch of the feature
95   FeaturePtr myFeature; ///< the feature
96 };
97
98 #endif