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 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   /// Sets the feature to to a feature attribute depending on the selection mode
47   /// \param theFeature a feature instance
48   /// \param theMode the selection mode
49   /// \return whether the feature is set
50   virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode);
51
52   /// Returns the feature attribute name for the selection mode
53   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
54   virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const;
55
56   /// Returns the next selection mode after the attribute
57   /// \param theAttribute the feature attribute name
58   /// \return next attribute selection mode
59   virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
60
61   /// \brief Move the full feature.
62   /// \param theDeltaX the delta for X coordinate is moved
63   /// \param theDeltaY the delta for Y coordinate is moved
64   virtual void move(double theDeltaX, double theDeltaY);
65
66   /// Project the point on a feature
67   /// \param theFeature the feature to be projected on
68   /// \param theMode the selection mode
69   /// \param thePoint the clicked point
70   /// \param theView the viewer
71   /// \param theX the output horizontal coordinate
72   /// \param theY the output vertical coordinate
73   void projectPointOnLine(FeaturePtr theFeature, const PartSet_SelectionMode& theMode,
74                           const gp_Pnt& thePoint, Handle_V3d_View theView,
75                           double& theX, double& theY);
76
77   /// Return the distance between the feature and the point
78   /// \param theFeature feature object
79   /// \param theX the horizontal coordinate of the point
80   /// \param theX the vertical coordinate of the point
81   virtual double distanceToPoint(FeaturePtr theFeature, double theX, double theY);
82
83   /// Find a point in the line with given coordinates
84   /// \param theFeature the line feature
85   /// \param theX the horizontal point coordinate
86   /// \param theY the vertical point coordinate
87   virtual boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
88                                                            double theY);
89
90   /// Creates a lin 2d object on a base of the line feature
91   /// \param theFeature the line feature
92   static boost::shared_ptr<GeomAPI_Lin2d> createLin2d(FeaturePtr theFeature);
93   /// \brief Get the line point 2d coordinates.
94   /// \param theFeature the line feature
95   /// \param theAttribute the start or end attribute of the line
96   /// \param theX the horizontal coordinate
97   /// \param theY the vertical coordinate
98   static void getLinePoint(FeaturePtr theFeature, const std::string& theAttribute,
99                            double& theX, double& theY);
100
101 protected:
102   /// Returns the feature point in the selection mode position.
103   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
104   virtual boost::shared_ptr<GeomDataAPI_Point2D> featurePoint(const PartSet_SelectionMode& theMode);
105 };
106
107 #endif