Salome HOME
d965eaff5a3d7d8849ef30b51f9f6f95a8127b8f
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintFillet.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:    SketchPlugin_ConstraintFillet.h
4 // Created: 19 Mar 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchPlugin_ConstraintFillet_H_
8 #define SketchPlugin_ConstraintFillet_H_
9
10 #include "SketchPlugin.h"
11 #include <SketchPlugin_Sketch.h>
12 #include "SketchPlugin_ConstraintBase.h"
13
14 /** \class SketchPlugin_ConstraintFillet
15  *  \ingroup Plugins
16  *  \brief Feature for creation of a new constraint filleting two objects which have 
17  *  coincident point
18  *
19  *  This constraint has three attributes:
20  *  SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B() 
21  *  for the filleting objects;
22  *  SketchPlugin_Constraint::VALUE() contains radius of filleting circular arc
23  *
24  *  Also the constraint has attribute SketchPlugin_Constraint::ENTITY_C()
25  *  which contains created list objects forming the fillet
26  */
27 class SketchPlugin_ConstraintFillet : public SketchPlugin_ConstraintBase
28 {
29  public:
30    /// \struct Struct to store base edges with states, result edges and constraints.
31    struct FilletFeatures {
32      /// list of objects the fillet is based and its states
33      std::list<std::pair<FeaturePtr, bool>> baseEdgesState; 
34      std::list<FeaturePtr> resultEdges; ///< list of result edges
35      std::list<FeaturePtr> resultConstraints; ///< list of constraints provided by the fillet
36    };
37
38   /// Fillet constraint kind
39   inline static const std::string& ID()
40   {
41     static const std::string MY_CONSTRAINT_FILLET_ID("SketchConstraintFillet");
42     return MY_CONSTRAINT_FILLET_ID;
43   }
44   /// \brief Returns the kind of a feature
45   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
46   {
47     static std::string MY_KIND = SketchPlugin_ConstraintFillet::ID();
48     return MY_KIND;
49   }
50
51   /// \brief Creates a new part document if needed
52   SKETCHPLUGIN_EXPORT virtual void execute();
53
54   /// \brief Request for initialization of data model of the feature: adding all attributes
55   SKETCHPLUGIN_EXPORT virtual void initAttributes();
56
57   /// Called on change of any argument-attribute of this object
58   /// \param theID identifier of changed attribute
59   SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
60
61   /// Returns the AIS preview
62   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
63
64   /// Reimplemented from ModelAPI_Feature::isMacro().
65   /// \returns true
66   SKETCHPLUGIN_EXPORT virtual bool isMacro() const;
67
68   /// \brief Use plugin manager for features creation
69   SketchPlugin_ConstraintFillet();
70
71   /// \return map of base points and features;
72   SKETCHPLUGIN_EXPORT const std::map<AttributePtr, FilletFeatures> pointsFeaturesMap() const {
73     return myPointFeaturesMap;
74   };
75
76 private:
77   /// \ Removes all produced features and restore base edges.
78   void clearResults();
79
80 private:
81   std::set<AttributePtr> myNewPoints; ///< set of new points
82
83   /// map of point and features for fillet
84   std::map<AttributePtr, FilletFeatures> myPointFeaturesMap; 
85   bool myListOfPointsChangedInCode; ///< flag to track that list of points changed in code
86   bool myRadiusChangedByUser; ///< flag to track that radius changed by user
87   bool myRadiusChangedInCode; ///< flag to track that radius changed in code
88   bool myRadiusInitialized; /// < flag to track that radius initialized
89 };
90
91 #endif