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