Salome HOME
Added test for creation arc by three points
[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 <ModelAPI_IReentrant.h>
11
12 #include "SketchPlugin.h"
13 #include <SketchPlugin_SketchEntity.h>
14 #include <SketchPlugin_Sketch.h>
15 #include <list>
16
17 class GeomAPI_Pnt2d;
18
19 /**\class SketchPlugin_Line
20  * \ingroup Plugins
21  * \brief Feature for creation of the new part in PartSet.
22  */
23 class SketchPlugin_Line : public SketchPlugin_SketchEntity,
24                           public ModelAPI_IReentrant
25 {
26  public:
27   /// Arc feature kind
28   inline static const std::string& ID()
29   {
30     static const std::string SKETCH_LINE_ID("SketchLine");
31     return SKETCH_LINE_ID;
32   }
33   /// Start 2D point of the line
34   inline static const std::string& START_ID()
35   {
36     static const std::string MY_START_ID("StartPoint");
37     return MY_START_ID;
38   }
39   /// End 2D point of the line
40   inline static const std::string& END_ID()
41   {
42     static const std::string MY_END_ID("EndPoint");
43     return MY_END_ID;
44   }
45
46   /// Line length.
47   static const std::string& LENGTH_ID()
48   {
49     static const std::string MY_LENGTH("LineLength");
50     return MY_LENGTH;
51   }
52
53   /// Returns the kind of a feature
54   SKETCHPLUGIN_EXPORT virtual const std::string& getKind();
55
56   /// Returns true is sketch element is under the rigid constraint
57   SKETCHPLUGIN_EXPORT virtual bool isFixed();
58
59   /// Request for initialization of data model of the feature: adding all attributes
60   virtual void initAttributes();
61
62   /// Creates a new part document if needed
63   SKETCHPLUGIN_EXPORT virtual void execute();
64
65   /// Moves the feature
66   /// \param theDeltaX the delta for X coordinate is moved
67   /// \param theDeltaY the delta for Y coordinate is moved
68   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
69
70   /// Apply information of the message to current object. It fills start attribute of
71   /// the currrent feature by last attribute of the message feature, build coincidence
72   /// if message has selected object
73   virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
74
75   /// Return the distance between the feature and the point
76   /// \param thePoint the point
77   double distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
78
79   /// Called on change of any argument-attribute of this object
80   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
81
82   /// Use plugin manager for features creation
83   SketchPlugin_Line();
84
85 private:
86   /// Calculates the lenght of the line and fill the lenght attribute with the value
87   void updateLenghtValue();
88
89 protected:
90   /// \brief Initializes attributes of derived class.
91   virtual void initDerivedClassAttributes();
92 };
93
94 #endif