1 // Copyright (C) 2019-2020 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef SketchPlugin_MacroBSpline_H_
21 #define SketchPlugin_MacroBSpline_H_
23 #include <ModelAPI_IReentrant.h>
25 #include "SketchPlugin.h"
27 #include "SketchPlugin_SketchEntity.h"
29 #include <GeomAPI_IPresentable.h>
34 /**\class SketchPlugin_MacroBSpline
36 * \brief Feature for creation of the new B-spline in Sketch.
38 class SketchPlugin_MacroBSpline : public SketchPlugin_SketchEntity,
39 public GeomAPI_IPresentable,
40 public ModelAPI_IReentrant
43 /// B-spline macro feature kind
44 inline static const std::string& ID()
46 static const std::string ID("SketchMacroBSpline");
51 /// list of B-spline poles
52 inline static const std::string& POLES_ID()
54 static const std::string ID("poles");
58 /// list of references of B-spline poles
59 inline static const std::string& REF_POLES_ID()
61 static const std::string ID("poles_ref");
65 /// list of B-spline weights
66 inline static const std::string& WEIGHTS_ID()
68 static const std::string ID("weights");
72 /// flag attribute whether control polygon is need to be created
73 inline static const std::string& CONTROL_POLYGON_ID()
75 static const std::string ID("need_control_poly");
79 /// Returns the kind of a feature
80 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
82 static std::string MY_KIND = SketchPlugin_MacroBSpline::ID();
86 /// \brief Request for initialization of data model of the feature: adding all attributes.
87 SKETCHPLUGIN_EXPORT virtual void initAttributes();
89 /// Returns the AIS preview
90 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
92 /// Creates a new part document if needed
93 SKETCHPLUGIN_EXPORT virtual void execute();
95 /// Reimplemented from ModelAPI_Feature::isMacro().
97 SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
99 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
101 /// Apply information of the message to current object. It fills reference object,
102 /// tangent type and tangent point refence in case of tangent arc
103 virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
105 /// Use plugin manager for features creation
106 SketchPlugin_MacroBSpline();
109 FeaturePtr createBSplineFeature();
111 void createControlPolygon(FeaturePtr theBSpline, std::list<FeaturePtr>& thePoles);
112 void constraintsForPoles(const std::list<FeaturePtr>& thePoles);
114 std::list<double> myKnots;
115 std::list<int> myMultiplicities;