]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchPlugin/SketchPlugin_MacroBSpline.h
Salome HOME
Issue #17347: B-Splines in Sketcher
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_MacroBSpline.h
1 // Copyright (C) 2019-2020  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef SketchPlugin_MacroBSpline_H_
21 #define SketchPlugin_MacroBSpline_H_
22
23 #include <ModelAPI_IReentrant.h>
24
25 #include "SketchPlugin.h"
26
27 #include "SketchPlugin_SketchEntity.h"
28
29 #include <GeomAPI_IPresentable.h>
30
31 class GeomAPI_Circ2d;
32 class GeomAPI_Pnt2d;
33
34 /**\class SketchPlugin_MacroBSpline
35  * \ingroup Plugins
36  * \brief Feature for creation of the new B-spline in Sketch.
37  */
38 class SketchPlugin_MacroBSpline : public SketchPlugin_SketchEntity,
39                                   public GeomAPI_IPresentable,
40                                   public ModelAPI_IReentrant
41 {
42 public:
43   /// B-spline macro feature kind
44   inline static const std::string& ID()
45   {
46     static const std::string ID("SketchMacroBSpline");
47     return ID;
48   }
49
50
51   /// list of B-spline poles
52   inline static const std::string& POLES_ID()
53   {
54     static const std::string ID("poles");
55     return ID;
56   }
57
58   /// list of references of B-spline poles
59   inline static const std::string& REF_POLES_ID()
60   {
61     static const std::string ID("poles_ref");
62     return ID;
63   }
64
65   /// list of B-spline weights
66   inline static const std::string& WEIGHTS_ID()
67   {
68     static const std::string ID("weights");
69     return ID;
70   }
71
72   /// Returns the kind of a feature
73   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
74   {
75     static std::string MY_KIND = SketchPlugin_MacroBSpline::ID();
76     return MY_KIND;
77   }
78
79   /// \brief Request for initialization of data model of the feature: adding all attributes.
80   SKETCHPLUGIN_EXPORT virtual void initAttributes();
81
82   /// Returns the AIS preview
83   virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
84
85   /// Creates a new part document if needed
86   SKETCHPLUGIN_EXPORT virtual void execute();
87
88   /// Reimplemented from ModelAPI_Feature::isMacro().
89   /// \returns true
90   SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
91
92   SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
93
94   /// Apply information of the message to current object. It fills reference object,
95   /// tangent type and tangent point refence in case of tangent arc
96   virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
97
98   /// Use plugin manager for features creation
99   SketchPlugin_MacroBSpline();
100
101 private:
102   FeaturePtr createBSplineFeature();
103
104   void createControlPolygon(FeaturePtr theBSpline, std::list<FeaturePtr>& thePoles);
105   void constraintsForPoles(const std::list<FeaturePtr>& thePoles);
106
107   int myDegree;
108   bool myIsPeriodic;
109 };
110
111 #endif