Salome HOME
0ff8e6b71ec3e2a2f3069733735df538eb35ed1a
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Line.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        SketchPlugin_Line.h
4 // Created:     24 Apr 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef SketchPlugin_Line_H_
8 #define SketchPlugin_Line_H_
9
10 #include "SketchPlugin.h"
11 #include <SketchPlugin_SketchEntity.h>
12 #include <SketchPlugin_Sketch.h>
13 #include <list>
14
15 #define LINE_LENGHT_BLOCKED
16 class GeomAPI_Pnt2d;
17
18 /**\class SketchPlugin_Line
19  * \ingroup Plugins
20  * \brief Feature for creation of the new part in PartSet.
21  */
22 class SketchPlugin_Line : public SketchPlugin_SketchEntity
23 {
24  public:
25   /// Arc feature kind
26   inline static const std::string& ID()
27   {
28     static const std::string SKETCH_LINE_ID("SketchLine");
29     return SKETCH_LINE_ID;
30   }
31   /// Start 2D point of the line
32   inline static const std::string& START_ID()
33   {
34     static const std::string MY_START_ID("StartPoint");
35     return MY_START_ID;
36   }
37   /// End 2D point of the line
38   inline static const std::string& END_ID()
39   {
40     static const std::string MY_END_ID("EndPoint");
41     return MY_END_ID;
42   }
43
44   /// Line length.
45 #ifndef LINE_LENGHT_BLOCKED
46   static const std::string& LENGTH_ID()
47   {
48     static const std::string MY_LENGTH("LineLength");
49     return MY_LENGTH;
50   }
51 #endif
52   /// Returns the kind of a feature
53   SKETCHPLUGIN_EXPORT virtual const std::string& getKind();
54
55   /// Returns true is sketch element is under the rigid constraint
56   SKETCHPLUGIN_EXPORT virtual bool isFixed();
57
58   /// Creates a new part document if needed
59   SKETCHPLUGIN_EXPORT virtual void execute();
60
61   /// Moves the feature
62   /// \param theDeltaX the delta for X coordinate is moved
63   /// \param theDeltaY the delta for Y coordinate is moved
64   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
65
66   /// Return the distance between the feature and the point
67   /// \param thePoint the point
68   double distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
69
70   /// Called on change of any argument-attribute of this object
71   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
72
73   /// Use plugin manager for features creation
74   SketchPlugin_Line();
75
76 private:
77   /// Calculates the lenght of the line and fill the lenght attribute with the value
78   void updateLenghtValue();
79
80 protected:
81   /// \brief Initializes attributes of derived class.
82   virtual void initDerivedClassAttributes();
83 };
84
85 #endif