1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: SketchPlugin_Line.h
4 // Created: 24 Apr 2014
5 // Author: Mikhail PONIKAROV
7 #ifndef SketchPlugin_Line_H_
8 #define SketchPlugin_Line_H_
10 #include <ModelAPI_IReentrant.h>
12 #include "SketchPlugin.h"
13 #include <SketchPlugin_SketchEntity.h>
14 #include <SketchPlugin_Sketch.h>
19 /**\class SketchPlugin_Line
21 * \brief Feature for creation of the new part in PartSet.
23 class SketchPlugin_Line : public SketchPlugin_SketchEntity,
24 public ModelAPI_IReentrant
28 inline static const std::string& ID()
30 static const std::string SKETCH_LINE_ID("SketchLine");
31 return SKETCH_LINE_ID;
33 /// Start 2D point of the line
34 inline static const std::string& START_ID()
36 static const std::string MY_START_ID("StartPoint");
39 /// End 2D point of the line
40 inline static const std::string& END_ID()
42 static const std::string MY_END_ID("EndPoint");
47 static const std::string& LENGTH_ID()
49 static const std::string MY_LENGTH("LineLength");
53 /// Returns the kind of a feature
54 SKETCHPLUGIN_EXPORT virtual const std::string& getKind();
56 /// Returns true is sketch element is under the rigid constraint
57 SKETCHPLUGIN_EXPORT virtual bool isFixed();
59 /// Request for initialization of data model of the feature: adding all attributes
60 virtual void initAttributes();
62 /// Creates a new part document if needed
63 SKETCHPLUGIN_EXPORT virtual void execute();
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);
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);
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);
79 /// Called on change of any argument-attribute of this object
80 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
82 /// Use plugin manager for features creation
86 /// Calculates the lenght of the line and fill the lenght attribute with the value
87 void updateLenghtValue();
90 /// \brief Initializes attributes of derived class.
91 virtual void initDerivedClassAttributes();