Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintCoincidence.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:    SketchPlugin_ConstraintCoincidence.h
4 // Created: 08 May 2014
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchPlugin_ConstraintCoincidence_H_
8 #define SketchPlugin_ConstraintCoincidence_H_
9
10 #include "SketchPlugin.h"
11 #include "SketchPlugin_ConstraintBase.h"
12 #include <SketchPlugin_Sketch.h>
13 #include <list>
14
15 class GeomDataAPI_Point2D;
16
17 /** \class SketchPlugin_ConstraintCoincidence
18  *  \ingroup Plugins
19  *  \brief Feature for creation of a new constraint which defines equivalence of two points
20  *
21  *  This constraint has two attributes:
22  *  SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B()
23  */
24 class SketchPlugin_ConstraintCoincidence : public SketchPlugin_ConstraintBase
25 {
26  public:
27   /// Coincidence constraint kind
28   inline static const std::string& ID()
29   {
30     static const std::string MY_CONSTRAINT_COINCIDENCE_ID("SketchConstraintCoincidence");
31     return MY_CONSTRAINT_COINCIDENCE_ID;
32   }
33   /// \brief Returns the kind of a feature
34   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
35   {
36     static std::string MY_KIND = SketchPlugin_ConstraintCoincidence::ID();
37     return MY_KIND;
38   }
39
40   /// Returns the AIS preview
41   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
42
43   /// \brief Creates a new part document if needed
44   SKETCHPLUGIN_EXPORT virtual void execute();
45
46   /// \brief Request for initialization of data model of the feature: adding all attributes
47   SKETCHPLUGIN_EXPORT virtual void initAttributes();
48
49   /// Returns coincident feature if there is a coincidence built on the given features
50   /// \param theFeature1 the first feature
51   /// \param theFeature2 the second feature
52   static FeaturePtr findCoincidenceFeature(const FeaturePtr& theFeature1,
53                                            const FeaturePtr& theFeature2);
54
55   /// Creates a constraint on two points
56   /// \param theSketch a sketch feature
57   /// \param thePoint1 the first point
58   /// \param thePoint2 the second point
59   static void createCoincidenceFeature(SketchPlugin_Sketch* theSketch,
60                                 const std::shared_ptr<GeomDataAPI_Point2D>& thePoint1,
61                                 const std::shared_ptr<GeomDataAPI_Point2D>& thePoint2);
62
63   /// Returns point of coincidence feature
64   /// \param theFeature a coincidence feature
65   /// \return point 2d attribute. Coincidence always has at least one point 2d attribute
66   static std::shared_ptr<GeomDataAPI_Point2D> getPoint(const FeaturePtr& theFeature);
67
68   /// \brief Use plugin manager for features creation
69   SketchPlugin_ConstraintCoincidence();
70 };
71
72 #endif