Salome HOME
Create validator for distance constraint
[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_HeaderFile
6 #define SketchPlugin_ConstraintDistance_HeaderFile
7
8 #include "SketchPlugin.h"
9 #include "SketchPlugin_Constraint.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 /** \class SketchPlugin_ConstraintDistance
19  *  \ingroup DataModel
20  *  \brief Feature for creation of a new constraint which defines a distance
21  *         between a point and another feature (point, line, plane or face)
22  *
23  *  These constraint has three attributes:
24  *  SketchPlugin_Constraint::VALUE(), SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
25  */
26 class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint
27 {
28 public:
29   /// Distance constraint kind
30   inline static const std::string& ID()
31   {
32     static const std::string MY_CONSTRAINT_DISTANCE_ID("SketchConstraintDistance");
33     return MY_CONSTRAINT_DISTANCE_ID;
34   }
35
36   /// \brief Returns the kind of a feature
37   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
38   {static std::string MY_KIND = SketchPlugin_ConstraintDistance::ID(); return MY_KIND;}
39
40   /// \brief Creates a new part document if needed
41   SKETCHPLUGIN_EXPORT virtual void execute();
42
43   /// \brief Request for initialization of data model of the feature: adding all attributes
44   SKETCHPLUGIN_EXPORT virtual void initAttributes();
45
46   /// Returns the AIS preview
47   SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
48                                 boost::shared_ptr<GeomAPI_AISObject> thePrevious);
49
50   /// Moves the feature
51   /// \param theDeltaX the delta for X coordinate is moved
52   /// \param theDeltaY the delta for Y coordinate is moved
53   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
54
55   /// \brief Use plugin manager for features creation
56   SketchPlugin_ConstraintDistance();
57 };
58
59
60 /// Obtain the point object from specified constraint parameter
61 boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
62                                                        const std::string&  theAttribute);
63
64 boost::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData, const std::string& theAttribute);
65
66 boost::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(const boost::shared_ptr<SketchPlugin_Line>& theLine, 
67                                                     const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint);
68
69
70 #endif