Salome HOME
Cleanup code of SketchPlugin_Fillet feature. Move calculation of tangent circle to...
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Fillet.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:    SketchPlugin_Fillet.h
4 // Created: 19 Mar 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchPlugin_Fillet_H_
8 #define SketchPlugin_Fillet_H_
9
10 #include "SketchPlugin.h"
11
12 #include "SketchPlugin_SketchEntity.h"
13
14 #include <GeomAPI_IPresentable.h>
15 #include <GeomDataAPI_Point2D.h>
16
17 class GeomAPI_XY;
18
19 /// \class SketchPlugin_Fillet
20 /// \ingroup Plugins
21 /// \brief Feature for creation of a new arc filleting two objects which have
22 /// coincident point.
23 class SketchPlugin_Fillet: public SketchPlugin_SketchEntity, public GeomAPI_IPresentable
24 {
25  public:
26   /// Feature kind.
27   inline static const std::string& ID()
28   {
29     static const std::string MY_FEATURE_ID("SketchFillet");
30     return MY_FEATURE_ID;
31   }
32
33   /// Attribute name of fillet point.
34   inline static const std::string& FILLET_POINT_ID()
35   {
36     static const std::string ID("fillet_point");
37     return ID;
38   }
39
40   /// \return the kind of a feature.
41   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
42   {
43     static std::string MY_KIND = SketchPlugin_Fillet::ID();
44     return MY_KIND;
45   }
46
47   /// \brief Creates a new part document if needed.
48   SKETCHPLUGIN_EXPORT virtual void execute();
49
50   /// \brief Request for initialization of data model of the feature: adding all attributes.
51   SKETCHPLUGIN_EXPORT virtual void initAttributes();
52
53   /// Returns the AIS preview
54   SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
55
56   /// Reimplemented from ModelAPI_Feature::isMacro().
57   /// \returns true
58   SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;}
59
60   SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;}
61
62   /// Reimplemented from SketchPlugin_Feature::move().
63   /// Do nothing.
64   SKETCHPLUGIN_EXPORT virtual void move(const double, const double) {}
65
66   /// \brief Use plugin manager for features creation
67   SketchPlugin_Fillet();
68
69 private:
70   bool calculateFilletParameters();
71
72   bool findFeaturesContainingFilletPoint(std::shared_ptr<GeomDataAPI_Point2D> theFilletPoint);
73
74 private:
75     FeaturePtr myBaseFeatures[2];
76     std::string myFeatAttributes[4]; // attributes of features
77     bool myIsReversed;
78     bool myIsNotInversed[2]; // indicates which point the features share
79     bool myFilletCreated;
80     std::shared_ptr<GeomAPI_XY> myCenterXY;
81     std::shared_ptr<GeomAPI_XY> myTangentXY1;
82     std::shared_ptr<GeomAPI_XY> myTangentXY2;
83 };
84
85 #endif