Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
[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   virtual 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   PartSet_SelectionMode setPoint(double theX, double theY, const PartSet_SelectionMode& theMode);
45
46   /// Creates constrains of the current 
47   /// \param theX the horizontal coordnate of the point
48   /// \param theY the vertical coordnate of the point
49   /// \param theMode the current operation selection mode. The feature attribute depends on the mode
50   void setConstraints(double theX, double theY, 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   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   PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
60
61   /// \brief Save the point to the line.
62   /// \param theFeature the line feature
63   /// \param theX the horizontal coordinate
64   /// \param theY the vertical coordinate
65   /// \param theAttribute the start or end attribute of the line
66   static void setLinePoint(FeaturePtr, double theX, double theY,
67                            const std::string& theAttribute);
68
69 protected:
70   /// Returns pointer to the root document.
71   boost::shared_ptr<ModelAPI_Document> document() const;
72
73     /// Returns the operation feature
74   /// \return the feature
75   FeaturePtr feature() const;
76
77   /// Creates a constraint on two points
78   /// \param thePoint1 the first point
79   /// \param thePoint1 the second point
80   void createConstraint(boost::shared_ptr<GeomDataAPI_Point2D> thePoint1,
81                         boost::shared_ptr<GeomDataAPI_Point2D> thePoint2);
82
83   /// \brief Get the line point 2d coordinates.
84   /// \param theFeature the line feature
85   /// \param theAttribute the start or end attribute of the line
86   /// \param theX the horizontal coordinate
87   /// \param theY the vertical coordinate
88   void getLinePoint(FeaturePtr theFeature, const std::string& theAttribute,
89                     double& theX, double& theY);
90   /// Find a point in the line with given coordinates
91   /// \param theFeature the line feature
92   /// \param theX the horizontal point coordinate
93   /// \param theY the vertical point coordinate
94   boost::shared_ptr<GeomDataAPI_Point2D> findLinePoint(FeaturePtr theFeature,
95                                                        double theX, double theY);
96
97 private:
98   FeaturePtr mySketch; ///< the sketch of the feature
99   FeaturePtr myFeature; ///< the feature
100 };
101
102 #endif