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