Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintDistance.h
1 // File:    SketchPlugin_ConstraintDistance.h
2 // Created: 23 May 2014
3 // Author:  Artem ZHIDKOV
4
5 #ifndef SketchPlugin_ConstraintDistance_H_
6 #define SketchPlugin_ConstraintDistance_H_
7
8 #include "SketchPlugin.h"
9 #include "SketchPlugin_ConstraintBase.h"
10 #include "SketchPlugin_Sketch.h"
11 #include "ModelAPI_Data.h"
12
13 #include <list>
14
15 class SketchPlugin_Line;
16 class GeomDataAPI_Point2D;
17
18 #define DISTANCE_COLOR "#ff00ff"
19
20 /** \class SketchPlugin_ConstraintDistance
21  *  \ingroup DataModel
22  *  \brief Feature for creation of a new constraint which defines a distance
23  *         between a point and another feature (point, line, plane or face)
24  *
25  *  These constraint has three attributes:
26  *  SketchPlugin_Constraint::VALUE(), SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
27  */
28 class SketchPlugin_ConstraintDistance : public SketchPlugin_ConstraintBase
29 {
30  public:
31   /// Distance constraint kind
32   inline static const std::string& ID()
33   {
34     static const std::string MY_CONSTRAINT_DISTANCE_ID("SketchConstraintDistance");
35     return MY_CONSTRAINT_DISTANCE_ID;
36   }
37
38   /// \brief Returns the kind of a feature
39   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
40   {
41     static std::string MY_KIND = SketchPlugin_ConstraintDistance::ID();
42     return MY_KIND;
43   }
44
45   /// \brief Creates a new part document if needed
46   SKETCHPLUGIN_EXPORT virtual void execute();
47
48   /// \brief Request for initialization of data model of the feature: adding all attributes
49   SKETCHPLUGIN_EXPORT virtual void initAttributes();
50
51   /// Returns the AIS preview
52   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
53
54   /// Moves the feature
55   /// \param theDeltaX the delta for X coordinate is moved
56   /// \param theDeltaY the delta for Y coordinate is moved
57   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
58
59   /// \brief Use plugin manager for features creation
60   SketchPlugin_ConstraintDistance();
61 };
62
63 /// Obtain the point object from specified constraint parameter
64 boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
65                                                        const std::string& theAttribute);
66
67 boost::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData,
68                                                     const std::string& theAttribute);
69
70 boost::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(
71     const boost::shared_ptr<SketchPlugin_Line>& theLine,
72     const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint);
73
74 #endif