1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: SketchPlugin_MacroArc.h
4 // Created: 26 May 2014
5 // Author: Artem ZHIDKOV
7 #ifndef SketchPlugin_MacroArc_H_
8 #define SketchPlugin_MacroArc_H_
10 #include "SketchPlugin.h"
12 #include "SketchPlugin_SketchEntity.h"
14 #include <GeomAPI_IPresentable.h>
19 /**\class SketchPlugin_MacroArc
21 * \brief Feature for creation of the new arc of circle in PartSet.
22 * The visualization of this object is separated in two parts. The first one is an AIS object
23 * calculated when there is non-initialized attributes of the arc. The second is a result and
24 * it is calculated if all attributes are initialized.
26 class SketchPlugin_MacroArc: public SketchPlugin_SketchEntity,
27 public GeomAPI_IPresentable
31 inline static const std::string& ID()
33 static const std::string ID("SketchMacroArc");
37 inline static const std::string& ARC_TYPE()
39 static const std::string ID("arc_type");
43 static const std::string& ARC_TYPE_BY_CENTER_AND_POINTS()
45 static const std::string ID("by_center_and_points");
48 static const std::string& ARC_TYPE_BY_THREE_POINTS()
50 static const std::string ID("by_three_points");
54 inline static const std::string& ARC_TYPE_BY_TANGENT_EDGE()
56 static const std::string ID("by_tangent_edge");
60 /// Central 2D point of the circle which contains the arc
61 inline static const std::string& CENTER_POINT_ID()
63 static const std::string ID = "center_point";
67 inline static const std::string& CENTER_POINT_REF_ID()
69 static const std::string ID = "center_point_ref";
73 /// Start 2D point of the arc
74 inline static const std::string& START_POINT_1_ID()
76 static const std::string ID = "start_point_1";
80 /// Start 2D point of the arc
81 inline static const std::string& START_POINT_2_ID()
83 static const std::string ID = "start_point_2";
87 inline static const std::string& START_POINT_REF_ID()
89 static const std::string ID = "start_point_ref";
93 /// End 2D point of the arc
94 inline static const std::string& END_POINT_1_ID()
96 static const std::string ID = "end_point_1";
100 /// End 2D point of the arc
101 inline static const std::string& END_POINT_2_ID()
103 static const std::string ID = "end_point_2";
107 /// End 2D point of the arc
108 inline static const std::string& END_POINT_3_ID()
110 static const std::string ID = "end_point_3";
114 inline static const std::string& END_POINT_REF_ID()
116 static const std::string ID = "end_point_ref";
120 /// Passed point of the arc.
121 static const std::string& PASSED_POINT_ID()
123 static const std::string ID("passed_point");
127 static const std::string& PASSED_POINT_REF_ID()
129 static const std::string ID("passed_point_ref");
133 static const std::string& TANGENT_POINT_ID()
135 static const std::string ID("tangent_point");
140 inline static const std::string& REVERSED_ID()
142 static const std::string ID("reversed");
147 static const std::string& RADIUS_ID()
149 static const std::string ID("radius");
154 static const std::string& ANGLE_ID()
156 static const std::string ID("angle");
160 /// Returns the kind of a feature
161 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
163 static std::string MY_KIND = SketchPlugin_MacroArc::ID();
167 /// \brief Request for initialization of data model of the feature: adding all attributes.
168 SKETCHPLUGIN_EXPORT virtual void initAttributes();
170 /// Called on change of any argument-attribute of this object
171 /// \param theID identifier of changed attribute
172 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
174 /// Returns the AIS preview
175 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
177 /// Creates an arc-shape
178 SKETCHPLUGIN_EXPORT virtual void execute();
180 /// Moves the feature
181 /// \param theDeltaX the delta for X coordinate is moved
182 /// \param theDeltaY the delta for Y coordinate is moved
183 SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY)
187 /// Reimplemented from ModelAPI_Feature::isMacro().
188 SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
190 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
192 /// Use plugin manager for features creation.
193 SketchPlugin_MacroArc();
195 /// Returns shape of arc.
196 GeomShapePtr getArcShape();
199 /// Set fields for center, start and end points
200 void fillByCenterAndTwoPassed();
201 /// Set fields for center, start and end points by selected passed points
202 void fillByThreePassedPoints();
203 /// Set fields for center, start and end points by selected tangent edge
204 void fillByTangentEdge();
206 FeaturePtr createArcFeature();
208 void recalculateReversedFlagByEnd(const GeomAPI_Circ2d& theCurrentCircular);
209 void recalculateReversedFlagByPassed(const GeomAPI_Circ2d& theCurrentCircular);
212 std::shared_ptr<GeomAPI_Pnt2d> myCenter;
213 std::shared_ptr<GeomAPI_Pnt2d> myStart;
214 std::shared_ptr<GeomAPI_Pnt2d> myEnd;
216 /// To define in which direction draw arc.
217 double myParamBefore;