Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
[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 Handle_V3d_View;
17
18 /*!
19  \class PartSet_FeatureLinePrs
20  * \brief The class to define the line feature manipulation. It is created for
21  * the feature create operation to move out the feature properties set and use one operation
22  * for any type of features.
23 */
24 class PARTSET_EXPORT PartSet_FeatureLinePrs : public PartSet_FeaturePrs
25 {
26 public:
27   /// Returns the feature type processed by this presentation
28   /// \return the feature kind
29   static std::string getKind();
30
31   /// Constructor
32   /// \param theSketch the sketch feature
33   PartSet_FeatureLinePrs(FeaturePtr theSketch);
34   /// Destructor
35   virtual ~PartSet_FeatureLinePrs() {};
36
37   /// Sets the point to the feature in an attribute depending on the selection mode
38   /// \param theX the 2D point horizontal coordinate
39   /// \param theY the 2D point vertical coordinate
40   /// \param theMode the selection mode
41   /// \return the new selection mode
42   virtual PartSet_SelectionMode setPoint(double theX, double theY,
43                                          const PartSet_SelectionMode& theMode);
44
45   /// Returns the feature attribute name for the selection mode
46   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
47   virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
48
49   /// Returns the next selection mode after the attribute
50   /// \param theAttribute the feature attribute name
51   /// \return next attribute selection mode
52   virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
53
54
55   /// Project the point on a feature
56   /// \param theFeature the feature to be projected on
57   /// \param theMode the selection mode
58   /// \param thePoint the clicked point
59   /// \param theView the viewer
60   /// \param theX the output horizontal coordinate
61   /// \param theY the output vertical coordinate
62   void projectPointOnLine(FeaturePtr theFeature, const PartSet_SelectionMode& theMode,
63                           const gp_Pnt& thePoint, Handle_V3d_View theView,
64                           double& theX, double& theY);
65
66   /// Return the distance between the feature and the point
67   /// \param theFeature feature object
68   /// \param theX the horizontal coordinate of the point
69   /// \param theX the vertical coordinate of the point
70   static double distanceToPoint(FeaturePtr theFeature, double theX, double theY);
71
72   /// Find a point in the line with given coordinates
73   /// \param theFeature the line feature
74   /// \param theX the horizontal point coordinate
75   /// \param theY the vertical point coordinate
76   static boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
77                                                           double theY);
78
79 protected:
80   /// Initializes current feature by the given
81   /// \param theSourceFeature the feature, which attributes are used to initialize the current feature
82   virtual void initFeature(FeaturePtr theSourceFeature);
83
84   /// Returns the feature point in the selection mode position.
85   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
86   virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
87
88   /// \brief Get the line point 2d coordinates.
89   /// \param theFeature the line feature
90   /// \param theAttribute the start or end attribute of the line
91   /// \param theX the horizontal coordinate
92   /// \param theY the vertical coordinate
93   static void getLinePoint(FeaturePtr theFeature, const std::string& theAttribute,
94                            double& theX, double& theY);
95 };
96
97 #endif