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 <ModelAPI_IReentrant.h>
12 #include "SketchPlugin.h"
13 #include "SketchPlugin_SketchEntity.h"
15 #include <GeomAPI_IPresentable.h>
20 /**\class SketchPlugin_MacroArc
22 * \brief Feature for creation of the new arc of circle in PartSet.
23 * The visualization of this object is separated in two parts. The first one is an AIS object
24 * calculated when there is non-initialized attributes of the arc. The second is a result and
25 * it is calculated if all attributes are initialized.
27 class SketchPlugin_MacroArc: public SketchPlugin_SketchEntity,
28 public GeomAPI_IPresentable,
29 public ModelAPI_IReentrant
33 inline static const std::string& ID()
35 static const std::string ID("SketchMacroArc");
39 inline static const std::string& ARC_TYPE()
41 static const std::string ID("arc_type");
45 static const std::string& ARC_TYPE_BY_CENTER_AND_POINTS()
47 static const std::string ID("by_center_and_points");
50 static const std::string& ARC_TYPE_BY_THREE_POINTS()
52 static const std::string ID("by_three_points");
56 inline static const std::string& ARC_TYPE_BY_TANGENT_EDGE()
58 static const std::string ID("by_tangent_edge");
62 /// Central 2D point of the circle which contains the arc
63 inline static const std::string& CENTER_POINT_ID()
65 static const std::string ID = "center_point";
69 inline static const std::string& CENTER_POINT_REF_ID()
71 static const std::string ID = "center_point_ref";
75 /// Start 2D point of the arc
76 inline static const std::string& START_POINT_1_ID()
78 static const std::string ID = "start_point_1";
82 /// Start 2D point of the arc
83 inline static const std::string& START_POINT_2_ID()
85 static const std::string ID = "start_point_2";
89 inline static const std::string& START_POINT_REF_ID()
91 static const std::string ID = "start_point_ref";
95 /// End 2D point of the arc
96 inline static const std::string& END_POINT_1_ID()
98 static const std::string ID = "end_point_1";
102 /// End 2D point of the arc
103 inline static const std::string& END_POINT_2_ID()
105 static const std::string ID = "end_point_2";
109 /// End 2D point of the arc
110 inline static const std::string& END_POINT_3_ID()
112 static const std::string ID = "end_point_3";
116 inline static const std::string& END_POINT_REF_ID()
118 static const std::string ID = "end_point_ref";
122 /// Passed point of the arc.
123 static const std::string& PASSED_POINT_ID()
125 static const std::string ID("passed_point");
129 static const std::string& PASSED_POINT_REF_ID()
131 static const std::string ID("passed_point_ref");
135 static const std::string& TANGENT_POINT_ID()
137 static const std::string ID("tangent_point");
142 inline static const std::string& REVERSED_ID()
144 static const std::string ID("reversed");
149 static const std::string& RADIUS_ID()
151 static const std::string ID("radius");
156 static const std::string& ANGLE_ID()
158 static const std::string ID("angle");
163 static const std::string& EDIT_ARC_TYPE_ID()
165 static const std::string ID("edit_arc_type");
169 /// Returns the kind of a feature
170 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
172 static std::string MY_KIND = SketchPlugin_MacroArc::ID();
176 /// \brief Request for initialization of data model of the feature: adding all attributes.
177 SKETCHPLUGIN_EXPORT virtual void initAttributes();
179 /// Called on change of any argument-attribute of this object
180 /// \param theID identifier of changed attribute
181 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
183 /// Returns the AIS preview
184 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
186 /// Creates an arc-shape
187 SKETCHPLUGIN_EXPORT virtual void execute();
189 /// Moves the feature
190 /// \param theDeltaX the delta for X coordinate is moved
191 /// \param theDeltaY the delta for Y coordinate is moved
192 SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY)
196 /// Reimplemented from ModelAPI_Feature::isMacro().
197 SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
199 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
201 /// Apply information of the message to current object. It fills reference object,
202 /// tangent type and tangent point refence in case of tangent arc
203 virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
205 /// Use plugin manager for features creation.
206 SketchPlugin_MacroArc();
208 /// Returns shape of arc.
209 /// \param isBound if true prepare arc, otherwice create circle containing this arc
210 GeomShapePtr getArcShape(bool isBound = true);
213 /// Set fields for center, start and end points
214 void fillByCenterAndTwoPassed();
215 /// Set fields for center, start and end points by selected passed points
216 void fillByThreePassedPoints();
217 /// Set fields for center, start and end points by selected tangent edge
218 void fillByTangentEdge();
220 FeaturePtr createArcFeature();
222 void recalculateReversedFlagByEnd(const GeomAPI_Circ2d& theCurrentCircular);
223 void recalculateReversedFlagByPassed(const GeomAPI_Circ2d& theCurrentCircular);
226 std::shared_ptr<GeomAPI_Pnt2d> myCenter;
227 std::shared_ptr<GeomAPI_Pnt2d> myStart;
228 std::shared_ptr<GeomAPI_Pnt2d> myEnd;
230 /// To define in which direction draw arc.
231 double myParamBefore;