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